:root[data-theme="cool"] {
  --primary-color: #1762bb;
  --primary-dark: #124f99;
  --ink-color: #173b67;
  --text-color: #273e57;
  --muted-color: #536b83;
  --background-color: #f5f9ff;
  --light-gray: #edf5ff;
  --border-color: #cbdced;
  --line-color: #dfebf7;
  --input-border: #b8cee5;
  --footer-bg: #163e6c;
  --footer-text: #e4effb;
  --focus-ring: 0 0 0 3px rgba(23, 98, 187, .19);
}
:root[data-theme="warm"] {
  --primary-color: #c1483e;
  --primary-dark: #a33b32;
  --ink-color: #4a302b;
  --text-color: #493c36;
  --muted-color: #746056;
  --background-color: #fffaf5;
  --light-gray: #fff1e8;
  --border-color: #e7cfc3;
  --line-color: #f0e2d9;
  --input-border: #d9b9a8;
  --footer-bg: #65382f;
  --footer-text: #fff1e8;
  --focus-ring: 0 0 0 3px rgba(193, 72, 62, .18);
}
* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  scroll-padding: 24px;
}
body {
  margin: 0;
  color: var(--text-color);
  background: var(--background-color);
  font: 16px/1.65 Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a {
  touch-action: manipulation;
}
button {
  cursor: pointer;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.65;
  cursor: wait;
}
button {
  color: inherit;
}
[hidden] {
  display: none !important;
}
.wrap {
  width: min(1080px, calc(100% - 76px));
  margin-inline: auto;
}
.mast {
  background: #fff;
  border-bottom: 1px solid var(--line-color);
}
.mast-inner,
.brand,
.panel-head,
.foot-inner,
.actions,
.report-head,
.report-actions,
.preview-head,
.dialog-head {
  display: flex;
  align-items: center;
}
.mast-inner,
.panel-head,
.foot-inner,
.report-head,
.dialog-head {
  justify-content: space-between;
}
.quiet,
.example,
.preview-link,
.back {
  background: none;
  border: 0;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.quiet,
.example,
.preview-link {
  min-height: 40px;
  padding: 6px 10px;
}
.quiet:hover,
.example:hover,
.preview-link:hover,
.back:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
.content {
  padding-block: 30px 28px;
}
.work {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}
.entry {
  border: 1px solid var(--border-color);
  background: #fff;
  border-radius: 8px;
  padding: 22px 26px 25px;
  min-width: 0;
}
.panel-head {
  margin-bottom: 19px;
  border-bottom: 1px solid var(--line-color);
  padding-bottom: 12px;
}
.panel-head h2,
.preview h2,
.dialog-head h2 {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0.03em;
}
.example {
  padding: 4px 0 4px 8px;
  font-size: 13px;
}
.example span {
  margin-left: 3px;
}

.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field.full,
.field.check,
.group-title {
  grid-column: 1/-1;
}
.field label {
  font-size: 14px;
  font-weight: 600;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  border: 1px solid var(--input-border);
  border-radius: 9px;
  padding: 8px 10px;
  color: var(--text-color);
  background: #fff;
  font-size: 15px;
}
.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--ink);
}
.field input[aria-invalid='true'],
.field textarea[aria-invalid='true'] {
  border-color: #95352d;
}
.field textarea {
  min-height: 76px;
  resize: vertical;
}
.field small {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted-color);
}
.field.check label {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  min-height: 32px;
}
.field.check input {
  width: 17px;
  min-height: 17px;
  height: 17px;
  accent-color: var(--ink);
}
.group-title {
  font-size: 14px;
  color: var(--ink);
  border-bottom: 1px solid var(--line-color);
  padding-bottom: 5px;
}
.actions {
  gap: 12px;
  margin-top: 22px;
}
.primary,
.download-btn {
  background: var(--primary-color);
  color: #fff;
  border: 1px solid var(--primary-color);
  border-radius: 5px;
  text-decoration: none;
  font-weight: 650;
  padding: 10px 20px;
  min-height: 50px;
}
.primary:after {
  content: '→';
  margin-left: 14px;
}
.primary:hover,
.download-btn:hover {
  background: var(--primary-dark);
}
#clear {
  font-size: 13px;
}

.preview {
  padding: 22px 24px 17px;
  border-radius: 6px;
  background: var(--tint);
  position: relative;
  border: 1px solid var(--border-color);
  overflow: hidden;
  min-width: 0;
}
.preview-head {
  gap: 9px;
  margin-bottom: 14px;
}
.preview-head h2 {
  font-size: 14px;
  color: var(--ink);
}
.line-mark {
  width: 21px;
  height: 2px;
  background: var(--ink);
  display: block;
}
.peek-title {
  font:
    650 25px/1.42 var(--display);
  color: var(--ink);
  overflow-wrap: anywhere;
}
.peek-summary {
  margin: 9px 0 12px;
  color: var(--text-color);
  font-size: 14px;
}
.peek-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid var(--line-color);
  font-variant-numeric: tabular-nums;
}
.peek-row b {
  font-size: 13px;
  flex: 0 0 auto;
  max-width: 45%;
  font-weight: 550;
}
.peek-row span {
  font-size: 13px;
  text-align: right;
  overflow-wrap: anywhere;
}
.preview-link {
  font-size: 13px;
  margin-top: 8px;
  padding-left: 0;
}

#result {
  margin-top: 34px;
  padding: 25px 28px 22px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  scroll-margin-top: 12px;
  outline: none;
}
#report-kind {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.report-head {
  gap: 16px;
  align-items: end;
}
#report-title {
  font:
    600 clamp(27px, 3vw, 38px)/1.35 var(--display);
  letter-spacing: -.035em;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.report-actions {
  gap: 8px;
}
.report-actions button,
#close {
  min-height: 39px;
  background: #fff;
  border: 1px solid var(--input-border);
  border-radius: 9px;
  padding: 6px 12px;
  color: var(--ink);
  white-space: nowrap;
}
.report-actions button:hover,
#close:hover {
  background: var(--tint);
}
#summary {
  margin: 10px 0 18px;
  font-size: 15px;
}
.result-section {
  margin: 30px 0;
}
.result-section h3 {
  font-size: 18px;
  margin-bottom: 8px;
}
.result-section p,
.result-section li {
  max-width: 82ch;
}
.result-section ul,
dialog ol {
  padding-left: 1.45em;
}
.result-section ul {
  margin: 8px 0;
}
.result-section li {
  margin: 5px 0;
}
.result-section p {
  margin: 7px 0;
  color: var(--text-color);
}
.result-section p.result-meta { color: var(--muted-color); font-size: 14px; }
.pillar-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 16px 0;
  padding: 12px 0;
  border: 1px solid var(--line-color);
  border-radius: 12px;
  background: linear-gradient(125deg, #fff, var(--tint));
}
.pillar-strip > div { text-align: center; border-inline-start: 1px solid var(--line-color); }
.pillar-strip > div:first-child { border: 0; }
.pillar-strip dt { color: var(--muted-color); font-size: 12px; }
.pillar-strip dd { display: grid; margin: 4px 0 0; font: 600 clamp(23px, 2vw, 30px)/1.13 var(--display); }
.pillar-strip [data-element="木"] { color: #2e7138; }
.pillar-strip [data-element="火"] { color: #ac342d; }
.pillar-strip [data-element="土"] { color: #75594b; }
.pillar-strip [data-element="金"] { color: #805e14; }
.pillar-strip [data-element="水"] { color: #175ba0; }
.pillar-evidence summary {
  color: var(--primary-dark); font-weight: 600; font-size: 14px; cursor: pointer;
  align-content: center; min-height: 44px; padding: 8px 0;
}
.table-scroll {
  max-width: 100%;
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  margin: 7px 0;
  font-size: 14px;
  line-height: 1.55;
}
th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line-color);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}
th {
  background: var(--tint);
  color: var(--ink);
  font-weight: 600;
}
td:first-child {
  font-weight: 600;
  color: var(--text-color);
}
.table-scroll table thead th:first-child {
  border-radius: 3px 0 0 3px;
}
.swatches {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}
.chip {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
}
.chip i {
  width: 25px;
  height: 25px;
  border: 1px solid #0002;
  border-radius: 50%;
}

#download:not(:empty) {
  margin: 18px 0;
}
.back {
  display: inline-block;
  font-size: 13px;
  padding: 8px 0;
}
#error {
  margin-top: 12px;
  color: #932f2a;
  background: #fff2ed;
  padding: 8px 10px;
  border-left: 3px solid #a34339;
}
#notice:not(:empty) {
  padding: 10px 12px;
  margin-top: 16px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--ink);
  background: white;
}
.foot-inner {
  color: var(--footer-text);
  font-size: 12px;
  padding: 16px 0 22px;
}
.foot-inner i {
  display: inline-block;
  height: 11px;
  border-left: 1px solid var(--border-color);
  margin: 0 6px;
}
.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  position: fixed;
  left: 4px;
  top: 4px;
  z-index: 6;
  background: white;
  padding: 8px;
}
dialog {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 24px;
  max-width: min(450px, 90vw);
  color: var(--text-color);
}
dialog::backdrop {
  background: color-mix(in srgb, var(--ink) 45%, transparent);
}
dialog p,
dialog ol {
  margin-top: 15px;
}
.guide-note {
  font-size: 13px;
  color: var(--muted-color);
}
#close {
  font-size: 22px;
  line-height: 1;
}
.element-line {
  height: 6px;
  background: var(--line-color);
  border-radius: 5px;
  margin-top: 5px;
  overflow: hidden;
}
.element-line i {
  display: block;
  height: 100%;
  background: var(--ink);
}
.copybox {
  width: 100%;
  min-height: 120px;
}
.element-line[data-element='木'] i {
  background: #2e7d32;
}
.element-line[data-element='火'] i {
  background: #d32f2f;
}
.element-line[data-element='土'] i {
  background: #8d6e63;
}
.element-line[data-element='金'] i {
  background: #d4af37;
}
.element-line[data-element='水'] i {
  background: #1565c0;
}

@media (min-width: 761px) {
  body[data-tool='pillar-reverse'] .fields {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  body[data-tool='pillar-reverse'] .field:nth-child(n + 5) {
    grid-column: span 2;
  }
}
@media (max-width: 760px) {
  .wrap {
    width: calc(100% - 36px);
  }
  .content {
    padding: 16px 0 20px;
  }
  .work {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .entry,
  .preview,
  #result {
    padding: 16px;
  }
  .panel-head {
    margin-bottom: 14px;
    padding-bottom: 8px;
  }
  .panel-head h2 {
    font-size: 19px;
  }
  .fields {
    gap: 13px 12px;
  }
  .preview {
    padding: 17px 18px;
  }
  .preview .peek-title {
    font-size: 22px;
  }
  .report-head {
    align-items: start;
    flex-wrap: wrap;
  }
  .report-actions button {
    min-height: 40px;
  }
  #report-title {
    font-size: 26px;
  }
  .result-section {
    margin: 19px 0;
  }
  .result-section td,
  .result-section th {
    padding: 7px;
  }
  .table-scroll.wide thead {
    position: absolute;
    width: 1px;
    height: 1px;
    clip-path: inset(50%);
    overflow: hidden;
  }
  .table-scroll.wide tr {
    display: block;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin: 9px 0;
  }
  .table-scroll.wide td {
    display: grid;
    grid-template-columns: minmax(78px, 0.34fr) 1fr;
    gap: 9px;
    padding: 7px 9px;
  }
  .table-scroll.wide td:before {
    content: attr(data-label);
    font-size: 12px;
    color: var(--muted-color);
    font-weight: 500;
  }
  .table-scroll.wide td:first-child {
    background: var(--tint);
  }
  .table-scroll.wide td:last-child {
    border: 0;
  }
  .table-scroll.wide table,
  .table-scroll.wide tbody {
    display: block;
  }
}
@media (max-width: 420px) {
  .field label {
    font-size: 13px;
  }
  .field input,
  .field select,
  .field textarea {
    font-size: 16px;
  }
  .field select {
    padding-left: 5px;
  }
  .fields {
    column-gap: 9px;
  }
  .foot-inner {
    font-size: 11px;
  }
}

:root {
  --ink: var(--ink-color);
  --tint: var(--light-gray);
  --thread: #416b96;
  --paper: #f5f9ff;
  --display: "Source Han Serif SC", "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --landscape: url("landscape-cool.webp");
}
:root[data-theme="warm"] {
  --landscape: url("landscape-warm.webp");
  --thread: #865445;
  --paper: #fff4e6;
}
body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; display: flex; flex-direction: column; }
main:has(#result[hidden]) .tool-stage { flex-grow: 1; }
html { scroll-padding-top: 92px; }
.mast { position: sticky; top: 0; z-index: 5; }
.mast-inner { width: min(1660px, calc(100% - 76px)); min-height: 76px; gap: 12px; }
.brand { gap: 10px; color: var(--ink); }
.brand img { object-fit: contain; flex: none; }
.brand strong { font: 650 25px/1.15 var(--display); white-space: nowrap; }
.brand-short { display: none; }
.brand-tagline { color: var(--muted-color); font-size: 12px; margin-left: 4px; padding-left: 12px; border-left: 1px solid var(--line-color); white-space: nowrap; }
.mast-actions, .theme-switch { display: flex; align-items: center; }
.mast-actions { gap: 16px; }
.mast .quiet { color: var(--primary-dark); font-size: 14px; white-space: nowrap; }
.theme-switch {
  border-radius: 24px;
  background: var(--tint);
  border: 1px solid var(--line-color);
  padding: 2px;
}
.theme-switch button {
  display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 50%; background: transparent;
  color: var(--muted-color);
}
.theme-switch button[aria-pressed="true"] { background: var(--primary-color); color: #fff; }
.theme-switch button:hover:not([aria-pressed="true"]) { color: var(--primary-color); background: #fff; }
.theme-switch svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.65; }
.tool-stage {
  width: 100%;
  max-width: 1660px;
  margin-inline: auto;
  padding: 0 0 clamp(42px, 5vw, 84px);
  background-color: var(--background-color);
  background-image: linear-gradient(90deg, #ffffff3d, transparent 72%), var(--landscape);
  background-position: center center;
  background-size: cover;
  border-bottom: 1px solid var(--line-color);
}
.hero-inner { display: flex; align-items: center; justify-content: space-between; position: relative; min-height: clamp(220px, 26vh, 304px); }
.hero-copy { max-width: 68%; padding: 44px 0 36px; }
.kicker {
  display: flex; align-items: center; gap: 10px; margin: 0 0 12px;
  color: var(--primary-dark); font-size: 13px; font-weight: 650; letter-spacing: .075em;
}
.kicker::before, .result-section h3::before {
  content: ""; width: 3px; height: 1.1em; border-radius: 2px; background: var(--primary-color); flex: none;
}
.kicker span { opacity: .55; }
.hero h1 { color: var(--ink); font: 600 clamp(38px, 4.1vw, 58px)/1.15 var(--display); letter-spacing: -.055em; }
.hero .intro { margin: 13px 0 0; color: var(--text-color); font-size: 17px; line-height: 1.7; }
#cover { width: min(33%, 350px); height: auto; margin-right: 3%; pointer-events: none; }
.entry, .preview {
  background: rgba(255,255,255,.97);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  box-shadow: 0 5px 20px color-mix(in srgb, var(--ink) 7%, transparent);
}
.entry { padding: 24px 28px 28px; }
.preview { padding: 24px 26px 18px; }
.panel-head h2, .dialog-head h2 { color: var(--ink); font: 700 22px/1.4 var(--display); }
.preview-head h2 { font-size: 14px; font-weight: 650; line-height: 1.4; }
.line-mark { width: 3px; height: 15px; border-radius: 2px; background: var(--primary-color); }
.preview-head h2, .example, .preview-link, .back { color: var(--primary-dark); }
.actions .primary { flex: 1; border-radius: 12px; }
.actions #clear { min-width: 56px; min-height: 46px; }
.field input:not([type="checkbox"]):focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary-color);
  box-shadow: var(--focus-ring);
}
.result-section h3 {
  display: flex; align-items: center; gap: 11px; color: var(--ink);
  font: 600 clamp(22px, 2vw, 28px)/1.4 var(--display); letter-spacing: -.03em;
}
.result-section h3::before { width: 5px; height: 19px; }
.result-section td:first-child { color: var(--ink); }
.content { padding-block: 0; }
#result { margin-block: 28px; box-shadow: 0 5px 22px color-mix(in srgb, var(--ink) 6%, transparent); }
#notice:not(:empty) { margin-block: 18px; }
dialog { border-radius: 16px; }
footer { background: var(--footer-bg); }
.foot-inner { min-height: 64px; padding-block: 14px; }
.foot-inner i { border-color: currentColor; opacity: .4; }
@media (min-width: 1200px) {
  .hero-inner, .work, .content, .foot-inner { width: min(1340px, 86%); }
}
@media (max-width: 760px) {
  html { scroll-padding-top: 68px; }
  .mast-inner { width: calc(100% - 36px); min-height: 60px; }
  .brand { gap: 7px; }
  .brand img { width: 30px; height: 30px; }
  .brand strong { font-size: 18px; }
  .brand-tagline { display: none; }
  .mast-actions { gap: 5px; }
  .mast .quiet { padding-inline: 5px; }
  .theme-switch button { width: 44px; height: 44px; }
  .tool-stage {
    background-image: linear-gradient(180deg, transparent 64%, var(--background-color) 100%), var(--landscape);
    background-size: auto 620px;
    background-position: 62% top;
    background-repeat: no-repeat;
    padding-bottom: 24px;
  }
  .hero-inner { min-height: 166px; }
  .hero-copy { max-width: 100%; padding: 24px 0 20px; }
  .kicker { margin-bottom: 9px; font-size: 12px; }
  .hero h1 { font-size: clamp(30px, 6vw, 40px); }
  .hero .intro { font-size: 15px; margin-top: 10px; }
  #cover { width: 34%; margin-right: 0; }
  .entry, .preview, #result { border-radius: 14px; }
  .entry, .preview { padding: 17px 18px; }
  .content { padding: 0; }
  #result { margin-block: 17px; }
}
@media (max-width: 540px) {
  #cover { display: none; }
  .tool-stage { background-size: 100% 408px, auto 408px; background-position: center top, 78% top; }
  .hero .intro { max-width: 32em; }
  .mast-actions { gap: 4px; }
  .brand strong { font-size: 21px; }
  .theme-switch svg { width: 18px; height: 18px; }
  .brand-full { display: none; }
  .brand-short { display: inline; }
  .field.long-choice { grid-column: 1 / -1; }
}
@media (max-width: 360px) {
  .field:has(input:is([type="date"], [type="time"], [type="month"])) { grid-column: 1 / -1; }
  .edit-row label:has(input[type="date"]) { flex-basis: 100%; }
}
@media print {
  body, main { display: block; min-height: 0; }
  .tool-stage { display: none; }
  #result { box-shadow: none; border: 0; padding: 0; margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    animation: none !important;
  }
}
@media print {
  body {
    background: #fff;
    color: #111;
    font: 11pt/1.5 serif;
  }
  .wrap {
    width: 100%;
  }
  .mast,
  .hero,
  .work,
  footer,
  #notice,
  .report-actions,
  .back,
  #download,
  .skip,
  dialog {
    display: none !important;
  }
  .content,
  #result {
    margin: 0;
    padding: 0;
    border: 0;
  }
  #result {
    display: block;
  }
  .result-section {
    margin: 12px 0;
  }
  .table-scroll {
    overflow: visible;
  }
  tr {
    break-inside: avoid;
  }
  h3 {
    break-after: avoid;
  }
  th,
  td {
    padding: 5px;
  }
  .report-head {
    display: block;
  }
}
