/* V0.4 structural rules. The screen-only V0.2 theme below preserves mobile metrics and print. */
:root{--paper:#f7f7f7;--surface:#fff;--ink:#222;--muted:#555;--line:#ccc}
*{box-sizing:border-box}body{margin:0;background:var(--paper);color:var(--ink);font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;line-height:1.6}
[hidden]{display:none!important}button,input,select,textarea{font:inherit;min-width:0}button,a,input,select,summary{touch-action:manipulation}
button,.button{min-height:44px;border:1px solid #999;border-radius:3px;padding:8px 12px;background:var(--surface);color:var(--ink);cursor:pointer;display:inline-flex;justify-content:center;align-items:center;text-decoration:none}
button:disabled{opacity:.5;cursor:not-allowed}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible,.scroll-table:focus-visible{outline:2px solid #222;outline-offset:2px}
.page-header{max-width:1440px;margin:auto;padding:16px;display:flex;align-items:baseline;gap:16px;flex-wrap:wrap;border-bottom:1px solid var(--line)}h1{font-size:24px;margin:0}h2{font-size:20px;margin:0 0 16px}h3{font-size:16px;margin:16px 0 8px}h3 small{font-size:12px;font-weight:400;color:var(--muted)}
.input-page{max-width:620px;margin:20px auto;padding:0 16px}.result-page{max-width:1440px;margin:20px auto;padding:0 16px}.panel{min-width:0;background:var(--surface);border:1px solid var(--line);padding:20px;margin-bottom:20px}
.fields label,.field-label{display:block;margin:12px 0 6px}.fields input:not([type=checkbox]),.fields select,.date-controls input{width:100%;height:48px;border:1px solid #999;padding:8px;background:white;font-size:16px}
.two,.three{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.three{grid-template-columns:repeat(3,minmax(0,1fr))}.fields .check{display:flex;align-items:center;gap:8px;min-height:44px}.check input{width:20px;height:20px;margin:0}.primary{width:100%;min-height:52px;font-weight:700;margin-top:12px;background:#eee}
.status,.note{font-size:13px;overflow-wrap:anywhere}.status{min-height:22px}.status[data-kind=error]{font-weight:700}.note{color:var(--muted)}.toolbar{display:flex;flex-wrap:wrap;gap:8px}.result-actions{margin-bottom:12px}
.profile-text{font-size:14px}.basic-row{display:grid;grid-template-columns:112px minmax(0,1fr);gap:12px;padding:8px 0;border-bottom:1px solid #ddd}.basic-row b{font-weight:600}.basic-row span{overflow-wrap:anywhere}
.chenggu-content{min-width:0;margin:8px 0 12px;padding:11px 13px;border-left:2px solid #a33d32;background:#fbf6ef;overflow-wrap:anywhere;word-break:break-word}
.chenggu-content>*{max-width:100%}.chenggu-content p{margin:5px 0}.chenggu-content-title{margin:0 0 7px;font:700 16px/1.5 "Songti SC","Noto Serif CJK SC",serif;color:#a33d32}
.chenggu-content-reading,.chenggu-content-explanation{line-height:1.75}.chenggu-content-status,.chenggu-content-notice{font-size:12px;color:#686055}
.chenggu-preview-warning{font-size:12px;font-weight:700;color:#a33d32}
.pc-shensha-name,.pc-pillar-relationship{display:block;overflow-wrap:anywhere}.pc-pillar-relationship{text-align:left}
.scroll-table{max-width:100%;overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:thin}table{width:100%;border-collapse:separate;border-spacing:0;table-layout:fixed;font-size:14px}th,td{border-right:1px solid var(--line);border-bottom:1px solid var(--line);padding:10px 6px;text-align:center;vertical-align:middle;overflow-wrap:anywhere;background:white}tr>*:first-child{border-left:1px solid var(--line)}thead th{border-top:1px solid var(--line);background:#eee}tbody th{background:#f3f3f3}th:first-child{width:100px}.stem,.branch{font-size:26px;font-weight:700}.hidden-line{display:block;line-height:1.8}.hidden-line b{margin-right:4px}.compare{min-width:900px}.compare th:first-child{width:100px}.comprehensive{min-width:1380px}.comprehensive th:first-child{width:120px}
.compare th:first-child,.comprehensive th:first-child{position:sticky;left:0;z-index:1}.selected-column{background:#e5e5e5;box-shadow:inset 0 0 0 1px #555}.comprehensive button{width:100%;font-size:13px;padding:6px 2px}.comprehensive td{font-size:13px}.annual-choice > span{display:block}.date-controls{display:block;font-size:14px;max-width:300px}.date-controls input{display:block;margin-top:4px}.query-level{min-width:0}.scroll-strip{position:relative;display:flex;gap:8px;max-width:100%;overflow-x:auto;overscroll-behavior-x:contain;padding:4px 2px 12px;scrollbar-width:thin}.strip-item{flex:0 0 92px;min-height:72px;display:grid;gap:2px;align-content:center;border:2px solid #bbb;white-space:nowrap}.strip-item small{font-size:12px}.strip-item b{font-size:18px}.strip-item.selected{background:#ddd;border-color:#222;font-weight:700}.strip-item.selected small:first-child:before{content:"选中 "}.strip-item.selected small{font-weight:600}
.element-木{color:#238047}.element-火{color:#c9443c}.element-土{color:#9c6a33}.element-金{color:#be801f}.element-水{color:#256ab6}/* Existing five-element semantics only. */
.json-area{margin-top:16px}.json-area summary{min-height:44px;cursor:pointer;padding:10px 0}.json-area pre{font-size:12px;white-space:pre-wrap;overflow-wrap:anywhere;background:#f3f3f3;padding:12px}.json-area pre,.profile-text{min-width:0}#copy-text{width:100%;font-size:14px}#aux{font-size:14px}
.comprehensive .annual-choice{display:block}
.comprehensive .annual-choice[aria-pressed=true]{background:#ddd;border-color:#222;font-weight:700}
@media(max-width:768px){.page-header{padding:12px;gap:8px}.page-header span{font-size:12px}h1{font-size:22px}.input-page,.result-page{padding:0 12px;margin:12px auto}.panel{padding:14px 10px;margin-bottom:16px}h2{font-size:18px}.profile-text{font-size:13px}.basic-row{grid-template-columns:76px minmax(0,1fr);gap:8px}#pillar-table table{font-size:12px}#pillar-table th:first-child{width:44px}#pillar-table th,#pillar-table td{padding:8px 2px}#pillar-table .hidden-line{font-size:12px}#pillar-table .stem,#pillar-table .branch{font-size:25px}.two,.three{gap:8px}.toolbar{gap:8px}.toolbar button,.toolbar a{font-size:13px;flex:1 1 120px}.date-controls{max-width:none}.note{font-size:12px}}
@media(max-width:768px){.chenggu-content{margin:7px 0 10px;padding:9px 10px}.chenggu-content-title{font-size:15px}}
@media print{body{background:white}.page-header{padding:0 0 8px}.result-page{max-width:none;margin:0;padding:0}.result-actions,.date-controls,.scroll-strip,.query-level,#manual-copy,.json-area,#status{display:none!important}.panel{padding:8px;border-color:#999;margin-bottom:12px}.scroll-table{overflow:visible}.compare,.comprehensive{min-width:0}.compare th:first-child,.comprehensive th:first-child{position:static;width:62px}table,.comprehensive td{font-size:8px}th,td{padding:5px 2px}.comprehensive button{font-size:8px;border:0;min-height:0;padding:2px 0}.stem,.branch{font-size:16px}h2{font-size:16px}thead{display:table-header-group}tr{break-inside:avoid}.basic-row{padding:3px 0;font-size:11px}.selected-column{box-shadow:none}.annual-choice span{font-size:8px}}
@media print{.chenggu-content[data-chenggu-preview]{display:none!important}.chenggu-content{background:white;border-color:#777;break-inside:avoid}}

/* Restore verified V0.2 colors, surfaces and typography, not its obsolete page layout.
   Source: BaZi_A_Engine_V0_2.zip / BaZi_A_Engine_V0_2/src/style.css.
   Keep V0.4 control sizes, column widths, mobile spacing and all print rules above. */
@media screen {
  :root {
    --paper:#faf7f1; --surface:#fffdf9; --line:#e9dfd1; --ink:#302b27;
    --muted:#82796d; --red:#a33d32; --redlight:#f9eeeb; --gold:#ad8750;
    --green:#258046; --wood:#238047; --fire:#c9443c; --earth:#9c6a33;
    --metal:#be801f; --water:#256ab6;
    --shadow:0 8px 30px rgba(75,53,24,.045);
  }
  body {
    background:linear-gradient(180deg,#f4eee4 0,#faf7f1 260px);
    font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Noto Sans CJK SC","Microsoft YaHei",sans-serif;
  }
  .page-header {border-bottom-color:#e5dacf}
  .page-header span {color:var(--muted)}
  .panel {background:rgba(255,253,249,.95);border-radius:14px;box-shadow:var(--shadow)}
  button,.button {border-color:var(--line);background:#fffaf5;border-radius:7px;color:var(--red)}
  .fields label,.field-label {color:#524d46}
  .fields input:not([type=checkbox]),.fields select,.date-controls input {
    border-color:#e0d6ca;border-radius:8px;color:var(--ink);
  }
  .fields input:focus,.fields select:focus,.date-controls input:focus {
    border-color:#c59d80;box-shadow:0 0 0 3px #ecd9cb;
  }
  button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible,.scroll-table:focus-visible {
    outline-color:var(--red);
  }
  .primary {
    background:linear-gradient(120deg,#a53b32,#bf5e4a);color:white;border-color:#a9473b;
    border-radius:9px;box-shadow:0 5px 13px #a6433226;
  }
  .status {color:var(--green)}
  .status[data-kind=error] {color:#c22}
  .basic-row {border-bottom-color:#f2eae0}
  .basic-row b {color:#686055}
  h3 {color:#6a594a}
  th,td {border-color:#eee5da;background:var(--surface)}
  tr>*:first-child,thead th {border-color:#eee5da}
  thead th {background:#f1e9dd;color:#504840}
  tbody th {background:#f7f2e9;color:#686155}
  .selected-column {background:var(--redlight);box-shadow:inset 0 0 0 1px #bd725d}
  .strip-item {background:white;border-color:#e7dcd0;border-radius:9px;color:var(--ink)}
  .strip-item small {color:var(--muted)}
  /* The original active-tab vermilion also matches the retained Stage 3 selection treatment. */
  .strip-item.selected {background:var(--red);border-color:var(--red);color:white}
  .strip-item.selected small,.strip-item.selected [class^=element-] {color:white}
  .comprehensive .annual-choice[aria-pressed=true] {
    background:#fff0e9;border-color:#bd725d;box-shadow:inset 0 0 0 1px #e7b6a7;color:var(--red);
  }
  .element-木 {color:var(--wood)} .element-火 {color:var(--fire)}
  .element-土 {color:var(--earth)} .element-金 {color:var(--metal)} .element-水 {color:var(--water)}
  .json-area pre {background:#f7f3ed;border-radius:8px}
  .json-area summary::marker {color:var(--red)}
}

@media screen and (min-width:769px) {
  h1 {font-family:"Songti SC","Noto Serif CJK SC",serif;font-size:25px;letter-spacing:3px}
  h2 {font-family:"Songti SC","Noto Serif CJK SC",serif;font-size:19px;font-weight:750;letter-spacing:1px}
  .page-header span {font-size:12px;border:1px solid var(--line);padding:8px 12px;border-radius:24px}
  .fields label,.field-label {font-weight:650}
}
@media screen and (min-width:1024px) {
  /* Same four existing siblings; desktop presentation requested by the user, no DOM reordering. */
  #chart {display:grid;grid-template-columns:minmax(0,.86fr) minmax(0,1.14fr);gap:16px;align-items:start}
  #chart>.module {margin-bottom:0}
  #query,#details {grid-column:1 / -1}
}

/* V0.4.2: only the PC brand, first row and action placement. Phone and
   lower-module styles are intentionally unchanged; print uses the legacy DOM. */
.pc-brand-header {display:none}
@media print {.pc-print>.page-header>span{display:none}}
@media print {
  .pc-print .element-金 {color:#ff8000}
  .pc-print .element-木 {color:#008800}
  .pc-print .element-水 {color:#1800f0}
  .pc-print .element-火 {color:#f00000}
  .pc-print .element-土 {color:#995000}
}
@media screen and (min-width:1024px) {
  /* V0.4.3 user-specified element colors, consistently inherited by every PC field. */
  body.pc-result {--metal:#ff8000;--wood:#008800;--water:#1800f0;--fire:#f00000;--earth:#995000}
  .pc-result>.page-header {display:none}
  .pc-result .pc-brand-header {
    display:flex;align-items:center;justify-content:space-between;gap:24px;
    max-width:1440px;margin:auto;padding:24px 16px;border-bottom:1px solid #e5dacf;
  }
  .pc-brand {display:flex;align-items:center;gap:14px}
  .pc-brand strong {font:750 30px "Songti SC","Noto Serif CJK SC",serif;letter-spacing:3px}
  .pc-brand p,.pc-page-intro p {margin:5px 0 0;font-size:14px;color:var(--muted)}
  .pc-seal {display:grid;place-items:center;width:42px;height:42px;flex-shrink:0;border:2px solid #b9695b;border-radius:8px;color:var(--red);font:26px "Songti SC",serif}
  .pc-page-intro {text-align:right}
  .pc-page-title {font:750 25px "Songti SC","Noto Serif CJK SC",serif;letter-spacing:1px}
  .pc-result #chart {grid-template-columns:minmax(0,.45fr) minmax(0,.55fr)}
  .pc-result #basic,.pc-result #four {align-self:stretch}
  .pc-result #basic-body {font-size:15px;line-height:1.8}
  .pc-result .pc-profile-line {margin:7px 0;overflow-wrap:anywhere}
  .pc-result .pc-profile-line>b {font-weight:650;color:#686055}
  .pc-inline-field {display:inline-block;margin-right:10px}
  .pc-result #pillar-table th,.pc-result #pillar-table td {padding:8px 6px}
  .pc-result #pillar-table .stem,.pc-result #pillar-table .branch {font-size:29px;font-weight:780;line-height:1.15}
  .pc-result #pillar-table td.pc-shensha-cell {font-size:13px;line-height:1.5;vertical-align:middle}
  .pc-result .pc-shensha-name {display:block;overflow-wrap:anywhere}
  .pc-result .pc-shensha-name+.pc-shensha-name {margin-top:2px}
  .pc-result .pc-shensha-empty {color:var(--muted)}
  .pc-result #pillar-table td.pc-pillar-relationships {text-align:left;vertical-align:top;font-size:12px;line-height:1.55}
  .pc-result .pc-pillar-relationship {display:block;overflow-wrap:anywhere}
  .pc-result .pc-pillar-relationship+.pc-pillar-relationship {margin-top:3px}
  .pc-result .pc-pillar-relationship b {font-weight:650;color:#686055}
  .pc-result .pc-pillar-relationship-empty {display:block;color:var(--muted)}
  .pc-result #four>#aux,.pc-result #four>.note {display:none}
  .pc-result #pc-shensha-scope {margin:8px 0 0;font-size:12px;color:var(--muted)}
  .pc-result #pc-four-notes {margin-top:14px;border-top:1px solid var(--line);font-size:14px}
  .pc-result .pc-rule-details {margin-top:16px;border-top:1px solid var(--line)}
  .pc-result .pc-rule-details summary {min-height:44px;padding:10px 0;cursor:pointer;font-size:14px}
  .pc-result .pc-rule-details summary::marker {color:var(--red)}
  .pc-result .pc-rule-details .basic-row {font-size:13px}
  .pc-result #result-footer {margin-top:20px;padding:16px 0;border-top:1px solid #e5dacf}
  .pc-result #result-footer .result-actions {margin-bottom:0}
  .pc-result #result-footer .status {margin:0 0 12px}
  .pc-result #result-footer .pc-development-status {display:none}
  .pc-result #result-footer #manual-copy {margin-top:16px}
}

/* V0.5: compact PC query only. Legacy mobile and print layout is restored by
   the controller, while all pre-existing control IDs and handlers stay intact. */
@media screen and (min-width:1024px) {
  .pc-result .element-金 {font-weight:700;-webkit-text-stroke:.35px #784000}
  .pc-result .strip-item.selected .element-金 {-webkit-text-stroke:0}
  .pc-query .pc-query-compare {min-width:900px}
  .pc-query .pc-query-compare td {padding:7px 4px}
  .pc-query .pc-query-compare td small {display:block;font-size:13px;color:var(--ink)}
  .pc-query .pc-query-compare .stem,.pc-query .pc-query-compare .branch {font-size:26px;line-height:1.3}
  .pc-query .pc-time-table {max-width:100%;margin-top:14px}
  .pc-query .pc-time-table th {width:66px;background:#f7f3ed}
  .pc-query .pc-time-table tr:first-child>* {border-top:1px solid var(--line)}
  .pc-query .pc-time-table td {min-width:0;padding:4px 7px;text-align:left}
  .pc-query .query-level h3 {margin:0 0 2px;font-size:12px;font-weight:400;color:var(--muted)}
  .pc-query .query-level:first-child h3 small {font-size:12px}
  .pc-query .scroll-strip {gap:0;padding:0 0 4px}
  .pc-query .strip-item {flex:0 0 80px;min-height:58px;padding:3px 2px;border-width:1px;border-radius:0;gap:0}
  .pc-query .strip-item b {font-size:19px;line-height:1.35}
  .pc-query .strip-item small {font-size:12px;line-height:1.35}
  .pc-query #query-days .strip-item {flex-basis:44px;min-height:48px}
  .pc-query #query-days .strip-item b {font-size:17px}
  .pc-query .strip-item.selected {box-shadow:inset 0 0 0 1px var(--red)}
  .pc-query .strip-item.selected small:first-child:before {content:"选中";display:block;font-size:10px;line-height:1}
  .pc-query #query-notes {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px 16px;margin-top:12px}
  .pc-query #query-notes p {margin:0;font-size:14px;line-height:1.8}
  .pc-query #query-notes b {color:var(--muted);font-weight:600}
}

/* V0.5.1: only the PC third-module comparison/header. V0.5 selector rows,
   element color tokens, other modules, mobile and print styles are untouched. */
@media screen and (min-width:1024px) {
  .pc-query .pc-query-heading {display:flex;justify-content:space-between;align-items:center;gap:16px;margin-bottom:8px}
  .pc-query .pc-query-heading h2 {margin:0}
  .pc-query .pc-query-heading .date-controls {display:flex;align-items:center;gap:8px;max-width:none;font-size:13px;white-space:nowrap}
  .pc-query .pc-query-heading input {width:188px;min-height:42px;margin:0;padding:7px 9px}
  .pc-query #query-label {margin:5px 0;font-size:14px}
  .pc-query .pc-query-rules {margin-bottom:8px}
  .pc-query .pc-query-rules summary {padding:8px 0;min-height:36px;cursor:pointer;font-size:13px}
  .pc-query .pc-query-rules summary::marker {color:var(--red)}
  .pc-query .pc-query-rules p {margin:4px 0 8px}
  .pc-query .pc-query-compare {min-width:0;max-width:860px;margin:0 auto}
  .pc-query .pc-query-compare th:first-child {width:72px}
  .pc-query .pc-query-compare tbody tr:nth-child(2) td,
  .pc-query .pc-query-compare tbody tr:nth-child(3) td {height:68px;padding:8px 6px}
  .pc-query .pc-god-pair {display:inline-flex;align-items:center;justify-content:center;gap:6px;vertical-align:middle}
  .pc-query .pc-god-stack {display:flex;flex-direction:column;align-items:center;gap:2px}
  .pc-query .pc-query-compare .pc-god {font-size:13px;line-height:1.1;color:var(--ink);writing-mode:vertical-rl;text-orientation:upright}
}

/* V0.5.2: PC third-module columns only. Preserve all selector cells and
   local scroll regions; the presentation adapter restores mobile/print DOM. */
@media screen and (min-width:1024px) {
  .pc-query .pc-query-body {display:grid;grid-template-columns:minmax(0,.45fr) minmax(0,.55fr);gap:16px;align-items:start;margin-top:8px}
  .pc-query .pc-query-results {min-width:0}
  .pc-query .pc-query-results .pc-query-compare {width:100%;max-width:none;margin:0}
  .pc-query .pc-query-body>.pc-time-table {min-width:0;width:100%;margin-top:0}
  .pc-query .pc-query-results #query-notes {grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 12px}
}

/* V0.6: only the PC fourth-module overview and professional disclosure. */
@media screen and (min-width:1024px) {
  #details.pc-overview .overview-table {min-width:1240px}
  #details.pc-overview .overview-table th:first-child {width:100px;position:sticky;left:0;z-index:1}
  #details.pc-overview .overview-table th,#details.pc-overview .overview-table td {padding:7px 4px}
  #details.pc-overview .overview-luck {width:100%;min-height:34px;padding:4px 2px;font-size:24px;font-weight:700;background:transparent;border-color:transparent}
  #details.pc-overview .overview-luck[aria-pressed=true] {background:var(--redlight);border-color:var(--red)}
  #details.pc-overview .overview-table tbody tr:nth-child(3) td {font-size:24px;font-weight:700}
  #details.pc-overview .overview-table tbody tr:last-child td {vertical-align:top}
  #details.pc-overview .overview-year {display:block;width:100%;min-height:28px;padding:2px 1px;border:0;border-radius:0;background:transparent;font-size:14px;line-height:1.5;color:var(--ink);white-space:nowrap}
  #details.pc-overview .overview-year[aria-pressed=true] {background:var(--redlight);box-shadow:inset 0 0 0 1px var(--red);font-weight:700}
  #details.pc-overview .overview-year small {display:block;font-size:11px;line-height:1.2;color:var(--muted)}
  #details.pc-overview .overview-note {margin:10px 0}
  #details.pc-overview #luck-professional {margin-top:12px;border-top:1px solid var(--line)}
  #details.pc-overview #luck-professional>summary {padding:10px 0;min-height:44px;cursor:pointer;font-size:14px}
  #details.pc-overview #luck-professional>summary::marker {color:var(--red)}
}

/* JSON tools are console-only; no URL or UI switch exposes them. */
.result-page [data-debug-only]{display:none!important}

/* V0.7.1: neutral emphasis only in the PC fourth module; no mobile styles. */
@media screen and (min-width:1024px) {
  #details.pc-overview .changsheng-stage {font-weight:700;color:inherit}
}
