:root {
  --ink: #241a17;
  --muted: #766963;
  --paper: #fffdf7;
  --paper-2: #f8f1e5;
  --red: #9b2f2f;
  --red-dark: #702020;
  --gold: #c6a65b;
  --line: #d8cbbb;
  --shadow: 0 18px 50px rgba(58, 34, 23, .12);
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); font-family: "Noto Serif SC", "Songti SC", SimSun, serif; background:
  radial-gradient(circle at 15% 0, rgba(198,166,91,.16), transparent 28rem),
  linear-gradient(135deg, #efe7da, #faf7ef 50%, #eee4d6); min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { max-width: 1180px; margin: auto; padding: 28px 22px 48px; }
.app-view[hidden] { display:none !important; }
.input-view { max-width:760px; margin:0 auto; }
.input-masthead { justify-content:center; padding-top:7vh; text-align:left; }
.input-view .controls { grid-template-columns:repeat(4,minmax(0,1fr)); }
.input-view .datetime-field { grid-column:1 / 3; }
.input-view .chart-type-field { grid-column:3; }
.input-view .gender-field { grid-column:4; }
.input-view .name-field { grid-column:1 / 3; }
.input-view .sample-field { grid-column:3 / 5; }
.input-view .start-chart { grid-column:1 / 4; }
.input-view .reset-chart { grid-column:4; }


/* 公历／农历／四柱时间录入 */
.input-view .datetime-field { grid-column:1 / -1; }
.input-view .chart-type-field { grid-column:1; }
.input-view .gender-field { grid-column:2; }
.input-view .name-field { grid-column:3 / 5; }
.input-view .sample-field { grid-column:1 / 3; }
.input-view .start-chart { grid-column:3; }
.input-view .reset-chart { grid-column:4; }
.datetime-field { min-width:0; margin:0; padding:0; border:0; }
.datetime-field > legend { margin:0 0 7px; padding:0; color:var(--muted); font-size:13px; }
.datetime-mode-tabs { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); margin-bottom:12px; padding:3px; background:#f1e7d7; border:1px solid var(--line); border-radius:7px; }
.datetime-mode-tab { min-height:42px; padding:8px 12px; color:var(--red-dark); background:transparent; border:0; border-radius:5px; font-weight:800; letter-spacing:.08em; }
.datetime-mode-tab.active { color:#fff; background:var(--red); box-shadow:0 3px 10px rgba(112,32,32,.2); }
.datetime-mode-tab:focus-visible { outline:2px solid var(--gold); outline-offset:2px; }
.datetime-mode-panel[hidden] { display:none !important; }
.date-select-grid { display:grid; grid-template-columns:1.25fr repeat(4,minmax(0,1fr)); gap:8px; }
.bazi-select-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; }
.date-select-grid label, .bazi-select-grid label { color:var(--muted); font-size:12px; text-align:center; }
.date-select-grid select, .bazi-select-grid select { min-height:46px; padding:9px 7px; color:var(--ink); background:#fffefa; font-size:16px; font-weight:700; text-align:center; text-align-last:center; }
.datetime-help { margin:9px 2px 0; color:var(--muted); font-size:12px; line-height:1.55; }
.bazi-search { width:100%; min-height:44px; margin-top:10px; }
.datetime-feedback { display:grid; grid-template-columns:auto minmax(0,1fr); gap:3px 10px; align-items:center; margin-top:12px; padding:10px 12px; background:#fff8e9; border-left:4px solid var(--gold); }
.datetime-feedback small { grid-row:1 / 3; color:var(--muted); white-space:nowrap; }
.datetime-feedback strong { color:var(--red-dark); font-size:16px; line-height:1.35; }
.datetime-feedback span { color:var(--muted); font-size:12px; line-height:1.45; }
.datetime-feedback.error { background:#fff0ed; border-left-color:#c1392b; }
.datetime-feedback.error span { color:#a1241c; }
.datetime-feedback.pending { background:#f6f0e3; }
.bazi-candidates { margin-top:10px; }
.candidate-summary, .candidate-empty { margin:0 0 7px; color:var(--muted); font-size:12px; }
.candidate-empty { padding:10px; color:#a1241c; background:#fff0ed; border:1px solid rgba(193,57,43,.25); }
.candidate-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; max-height:210px; overflow:auto; }
.candidate-button { display:grid; grid-template-columns:24px minmax(0,1fr); gap:7px; align-items:center; min-height:46px; padding:8px; text-align:left; color:var(--ink); background:#fffefa; border:1px solid var(--line); border-radius:4px; }
.candidate-button small { display:grid; place-items:center; width:22px; height:22px; color:var(--red-dark); background:#f1e7d7; border-radius:50%; }
.candidate-button strong { min-width:0; font-size:13px; }
.candidate-button.selected { color:var(--red-dark); background:#fff4df; border-color:var(--red); box-shadow:inset 0 0 0 1px var(--red); }

.result-header { display:flex; align-items:center; justify-content:space-between; gap:18px; padding:13px 16px; }
.result-heading { display:flex; align-items:center; gap:14px; min-width:0; }
.result-heading > div { min-width:0; }
.result-heading small { display:block; color:var(--muted); font-size:11px; letter-spacing:.08em; }
.result-heading h2 { margin:2px 0 0; color:var(--red-dark); font-size:22px; line-height:1.1; }
.back-to-input { white-space:nowrap; }
.result-toolbar { flex-wrap:wrap; justify-content:flex-end; }
.masthead { display:flex; align-items:center; justify-content:space-between; gap:20px; margin-bottom:22px; }
.brand { display:flex; align-items:center; gap:15px; }
.seal { width:58px; height:58px; border:2px solid var(--red); color:var(--red); display:grid; place-items:center; font-weight:800; line-height:1; letter-spacing:2px; transform:rotate(-3deg); box-shadow:inset 0 0 0 4px #f4e9dc; }
h1 { margin:0; font-size:clamp(25px,4vw,42px); letter-spacing:.12em; }
.subtitle { margin:.3rem 0 0; color:var(--muted); letter-spacing:.18em; }
.toolbar { display:flex; gap:10px; }
.primary, .ghost { border-radius:4px; padding:11px 18px; border:1px solid var(--red); }
.primary { color:white; background:var(--red); }
.ghost { color:var(--red); background:transparent; }
.panel { background:rgba(255,253,247,.9); border:1px solid rgba(155,47,47,.18); box-shadow:var(--shadow); }
.controls { padding:18px; display:grid; grid-template-columns:1.15fr .8fr .65fr .55fr 1.25fr auto auto; gap:12px; align-items:end; }
label { display:grid; gap:6px; color:var(--muted); font-size:13px; }
input, select { min-width:0; width:100%; color:var(--ink); background:#fffefa; border:1px solid var(--line); padding:11px 12px; border-radius:3px; }
.chart-navigation { margin-top:12px; padding:10px 12px; display:grid; grid-template-columns:auto auto minmax(180px,1fr) auto auto; gap:9px; align-items:center; }
.chart-navigation button { min-width:102px; padding:9px 12px; }
.chart-navigation button small { display:block; margin-top:2px; font-size:10px; opacity:.72; }
.navigation-current { min-width:0; text-align:center; }
.navigation-current small { display:block; color:var(--muted); font-size:11px; }
.navigation-current strong { display:block; margin-top:3px; color:var(--red-dark); font-size:18px; letter-spacing:.04em; }
.chart { margin-top:18px; padding:22px; }
.chart-meta { display:grid; grid-template-columns:1.35fr .65fr; gap:18px; padding-bottom:18px; border-bottom:1px solid var(--line); }
.calendar h2 { margin:0 0 8px; font-size:24px; }
.calendar p { margin:6px 0; color:var(--muted); }
.pillars { display:grid; grid-template-columns:repeat(4,1fr); border:1px solid var(--line); }
.pillars div { padding:9px; text-align:center; border-right:1px solid var(--line); }
.pillars div:last-child { border-right:0; }
.pillars small { display:block; color:var(--muted); margin-bottom:5px; }
.pillars strong { color:var(--red-dark); font-size:22px; }
.tags { display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; }
.tags span { padding:5px 9px; background:var(--paper-2); border-left:3px solid var(--gold); font-size:14px; }
.main-grid { display:grid; grid-template-columns:minmax(520px, 1fr) 280px; gap:22px; margin-top:22px; align-items:start; min-width:0; }
.board-column { min-width:0; }
.board-wrap {
  position:relative;
  display:grid;
  grid-template-columns:96px minmax(0, 1fr) 96px;
  grid-template-rows:82px minmax(0, 1fr) 82px;
  grid-template-areas:
    ". top ."
    "left board right"
    ". bottom .";
  align-items:stretch;
  width:100%;
  min-width:0;
  align-self:start;
}
.board { grid-area:board; width:100%; min-width:0; aspect-ratio:1; display:grid; grid-template-columns:repeat(3,1fr); border:2px solid var(--ink); background:#fffef9; }
.direction-label { position:absolute; z-index:3; display:grid; place-items:center; width:28px; height:28px; color:var(--red-dark); background:var(--paper); border:1px solid rgba(155,47,47,.28); border-radius:50%; font-size:16px; font-weight:800; line-height:1; box-shadow:0 2px 8px rgba(58,34,23,.08); pointer-events:none; }
.direction-south { top:0; left:50%; transform:translateX(-50%); }
.direction-north { bottom:0; left:50%; transform:translateX(-50%); }
.direction-east { top:50%; left:0; transform:translateY(-50%); }
.direction-west { top:50%; right:0; transform:translateY(-50%); }
.outer-ring { color:var(--ink); min-width:0; min-height:0; }
.outer-top, .outer-bottom { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); }
.outer-top { grid-area:top; padding-top:30px; }
.outer-bottom { grid-area:bottom; padding-bottom:30px; }
.outer-left, .outer-right { display:grid; grid-template-rows:repeat(3,minmax(0,1fr)); }
.outer-left { grid-area:left; padding-left:32px; }
.outer-right { grid-area:right; padding-right:32px; }
.outer-slot { display:flex; align-items:center; justify-content:center; gap:7px; min-width:0; min-height:0; }
.outer-top .outer-slot, .outer-bottom .outer-slot { flex-direction:column; gap:3px; }
.outer-left .outer-slot { flex-direction:row-reverse; }
.outer-right .outer-slot { flex-direction:row; }
.outer-branch { flex:0 0 auto; color:#bd2d2d; font-size:18px; font-weight:800; line-height:1; }
.outer-hidden { min-width:0; font-size:21px; font-weight:700; letter-spacing:.03em; line-height:1; white-space:nowrap; }
.outer-hidden.empty { color:#c9bfb1; font-size:17px; }
.palace { position:relative; min-width:0; width:100%; text-align:left; color:var(--ink); background:transparent; border:0; border-right:1px solid var(--ink); border-bottom:1px solid var(--ink); padding:12px; min-height:155px; transition:.18s ease; overflow:hidden; }
.palace:nth-child(3n) { border-right:0; }
.palace:nth-child(n+7) { border-bottom:0; }
.palace:hover, .palace:focus-visible { z-index:2; background:#f9efdd; outline:2px solid var(--gold); }
.palace-head { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; align-items:start; min-height:45px; }
.palace-god, .star-door { font-size:20px; line-height:1.4; }
.palace-god { font-weight:600; white-space:nowrap; }
.palace-corner { display:flex; min-width:0; flex-direction:column; align-items:flex-end; gap:5px; }
.palace-head small { color:var(--muted); font-size:12px; line-height:1.2; white-space:nowrap; }
.palace-core { display:flex; justify-content:space-between; align-items:flex-end; gap:10px; margin-top:5px; }
.stems { display:flex; flex-direction:column; align-items:flex-start; gap:1px; font-size:23px; line-height:1.2; }
.stem-stack { display:inline-grid; grid-template-columns:auto auto; align-items:baseline; column-gap:4px; min-height:1.2em; }
.changsheng-state { display:none; color:var(--muted); font-size:11px; font-weight:400; line-height:1; letter-spacing:.06em; white-space:nowrap; }
.show-changsheng .changsheng-state { display:inline; }
.stem.s1 { color:#3153a6; }
.stem.s2 { color:#7d281f; }
.star-door { display:flex; flex-direction:column; justify-content:flex-end; align-items:flex-end; flex:0 0 auto; }
.star-door strong { font-weight:600; }
.star-door span { color:var(--ink); font-weight:700; }
.marks { position:static; display:flex; flex-wrap:wrap; justify-content:flex-end; gap:4px; max-width:72px; }
.mark { flex:0 0 auto; font-style:normal; font-size:11px; line-height:1.25; padding:2px 4px; border-radius:2px; white-space:nowrap; }
.mark.void { color:white; background:#343434; }
.mark.horse { color:white; background:var(--red); }
.center { display:flex; flex-direction:column; justify-content:center; align-items:center; background:radial-gradient(circle, #fff 0, #f7efdf 75%); }
.taiji { font-size:74px; line-height:1; }
.center small { color:var(--muted); margin-top:8px; }
.sidebar { display:grid; min-width:0; align-content:start; gap:14px; }
.side-card { border-top:4px solid var(--red); background:var(--paper-2); padding:16px; }
.side-card h3 { margin:0 0 12px; }
.facts { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.facts div { background:#fffdf7; border:1px solid var(--line); padding:9px; }
.facts small { display:block; color:var(--muted); }
.facts strong { font-size:18px; color:var(--red-dark); }
dl { margin:0; } dl div { display:flex; justify-content:space-between; gap:10px; padding:7px 0; border-bottom:1px dashed var(--line); } dt { color:var(--muted); } dd { margin:0; text-align:right; }
.status { margin-top:18px; padding:12px 14px; border-left:4px solid; }
.status.success { background:#edf5eb; border-color:#53854a; }
.status.warning { background:#fff1d9; border-color:#c07a15; }
.notes { margin-top:18px; padding:18px 22px; }
.notes h3 { margin-top:0; } .notes li { margin:8px 0; color:var(--muted); }
@media (max-width: 850px) {
  .masthead { align-items:flex-start; } .toolbar { flex-direction:column; }
  .controls { grid-template-columns:1fr 1fr; } .controls label:first-child, .controls .datetime-field { grid-column:1/-1; }
  .chart-navigation { grid-template-columns:repeat(4,1fr); } .navigation-current { grid-column:1/-1; grid-row:1; } .chart-navigation button { min-width:0; }
  .chart-meta, .main-grid { grid-template-columns:1fr; }
  .sidebar { grid-template-columns:1fr 1fr; }
}
@media (max-width: 590px) {
  .app-shell { padding:14px 8px 30px; } .masthead { flex-direction:column; }
  .toolbar { width:100%; flex-direction:row; } .toolbar button { flex:1; }
  .controls { grid-template-columns:1fr 1fr; } .controls label:first-child, .controls .datetime-field { grid-column:1/-1; }
  .chart-navigation { grid-template-columns:1fr 1fr; padding:9px; } .navigation-current { grid-column:1/-1; } .chart-navigation button { font-size:13px; }
  .chart { padding:10px; } .calendar h2 { font-size:19px; }
  .main-grid { display:block; } .sidebar { margin-top:14px; grid-template-columns:1fr; }
  .board-wrap { grid-template-columns:64px minmax(0, 1fr) 64px; grid-template-rows:64px minmax(0, 1fr) 64px; }
  .direction-label { width:24px; height:24px; font-size:14px; }
  .outer-top { padding-top:26px; } .outer-bottom { padding-bottom:26px; } .outer-left { padding-left:26px; } .outer-right { padding-right:26px; }
  .outer-slot { gap:3px; } .outer-top .outer-slot, .outer-bottom .outer-slot { gap:2px; } .outer-branch { font-size:14px; } .outer-hidden { font-size:16px; }
  .palace { min-height:112px; padding:6px; } .palace-head { min-height:37px; gap:3px; } .palace-head small { display:none; }
  .palace-god, .star-door { font-size:17px; } .stems { font-size:17px; } .stem-stack { column-gap:2px; } .changsheng-state { font-size:9px; } .palace-core { gap:4px; margin-top:2px; } .marks { max-width:54px; gap:2px; } .mark { font-size:9px; padding:1px 3px; } .taiji { font-size:53px; }
}
@media print {
  body { background:white; } .app-shell { padding:0; } .controls, .toolbar, .chart-navigation, .notes { display:none; } .panel { box-shadow:none; } .chart { border:0; margin:0; }
}

/* 闃寸洏鍒戝杩鑹茶鍒?*/
.effect-tomb { color:#16883b !important; }
.effect-strike { color:#1857d8 !important; }
.effect-both { color:#d51fb8 !important; }
.effect-pressure { color:#d01818 !important; }
.stem-char { display:inline; }
.door { font-weight:700; }
.host-badge { position:absolute; left:8px; bottom:7px; color:#78552b; background:#f2dfaf; border:1px solid #c7a75b; padding:2px 5px; border-radius:2px; font-size:10px; font-style:normal; }
.center-host { margin-top:6px; color:#78552b; font-size:14px; }
.color-legend { display:flex; flex-wrap:wrap; gap:8px; list-style:none; margin-left:-20px !important; }
.legend { padding:5px 9px; background:#fffdf7; border:1px solid var(--line); font-weight:700; }
.legend.tomb { color:#16883b; }
.legend.strike { color:#1857d8; }
.legend.both { color:#d51fb8; }
.legend.pressure { color:#d01818; }
.ju-card p { margin:0 0 9px; color:var(--muted); line-height:1.6; }
.ju-card > strong { display:block; color:var(--red-dark); background:#fffdf7; border:1px solid var(--line); padding:10px; font-size:16px; }
.ju-card > small { display:block; margin-top:9px; color:var(--muted); line-height:1.55; }









/* 终身盘大运 */
.dayun-section { margin-top:20px; border-top:1px solid var(--line); padding-top:18px; }
.dayun-section[hidden] { display:none; }
.dayun-heading { display:flex; align-items:flex-end; justify-content:space-between; gap:18px; margin-bottom:12px; }
.dayun-heading h3 { margin:2px 0 0; font-size:22px; color:var(--red-dark); }
.dayun-heading small { color:var(--muted); letter-spacing:.12em; }
.dayun-heading p { margin:0; color:var(--muted); text-align:right; line-height:1.55; }
.dayun-table-wrap { overflow-x:auto; max-width:100%; border:1px solid var(--line); background:#fffdf7; scrollbar-gutter:stable; }
.dayun-table { width:100%; min-width:760px; border-collapse:collapse; table-layout:fixed; text-align:center; }
.dayun-table th, .dayun-table td { border-right:1px solid var(--line); border-bottom:1px solid var(--line); padding:12px 9px; white-space:nowrap; }
.dayun-table tr:last-child th, .dayun-table tr:last-child td { border-bottom:0; }
.dayun-table th { position:sticky; left:0; z-index:1; width:76px; color:var(--red-dark); background:#f5e8cf; font-size:14px; }
.dayun-table td { min-width:82px; font-size:17px; font-weight:700; }
.dayun-table #dayun-ganzhi td { color:var(--red-dark); font-size:20px; }
.dayun-table td.current-dayun { background:#fff0c7; box-shadow:inset 0 -4px 0 #c07a15; }
.dayun-table td[data-dayun-index] { cursor:pointer; transition:background .15s ease, box-shadow .15s ease; }
.dayun-table td[data-dayun-index]:hover { background:#fff7df; }
.dayun-table td.selected-dayun { background:#f8e5bc; box-shadow:inset 0 0 0 2px var(--red-dark); }
.dayun-table td.current-dayun.selected-dayun { background:#ffe3a2; box-shadow:inset 0 0 0 2px var(--red-dark), inset 0 -4px 0 #c07a15; }
.liunian-heading { display:flex; align-items:flex-end; justify-content:space-between; gap:18px; margin:20px 0 10px; }
.liunian-heading h4 { margin:2px 0 0; font-size:19px; color:var(--red-dark); }
.liunian-heading small, .liunian-heading p { color:var(--muted); }
.liunian-heading p { margin:0; text-align:right; line-height:1.55; }
.liunian-table-wrap { overflow-x:auto; max-width:100%; border:1px solid var(--line); background:#fffdf7; scrollbar-gutter:stable; }
.liunian-table { width:100%; min-width:900px; border-collapse:collapse; table-layout:fixed; text-align:center; }
.liunian-table th, .liunian-table td { border-right:1px solid var(--line); border-bottom:1px solid var(--line); padding:10px 7px; white-space:nowrap; }
.liunian-table tr:last-child th, .liunian-table tr:last-child td { border-bottom:0; }
.liunian-table th { position:sticky; left:0; z-index:1; width:76px; color:var(--red-dark); background:#f5e8cf; font-size:14px; }
.liunian-table td { min-width:76px; font-size:16px; font-weight:700; }
.liunian-table #liunian-ganzhi td { color:var(--red-dark); font-size:19px; }
.liunian-table td.current-liunian { background:#fff0c7; box-shadow:inset 0 -4px 0 #c07a15; }
@media (max-width:590px) {
  .dayun-heading, .liunian-heading { align-items:flex-start; flex-direction:column; gap:6px; }
  .dayun-heading p, .liunian-heading p { text-align:left; font-size:13px; }
  .dayun-table { min-width:700px; }
  .liunian-table { min-width:850px; }
  .dayun-table th, .dayun-table td, .liunian-table th, .liunian-table td { padding:10px 7px; }
}


/* 可折叠信息卡 */
.mobile-detail { overflow:hidden; }
.mobile-detail > summary, .notes > summary {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  color:var(--red-dark);
  font-weight:800;
  cursor:pointer;
  list-style:none;
}
.mobile-detail > summary::-webkit-details-marker, .notes > summary::-webkit-details-marker { display:none; }
.mobile-detail > summary::after, .notes > summary::after {
  content:"＋";
  flex:0 0 auto;
  font-size:20px;
  font-weight:400;
  line-height:1;
}
.mobile-detail[open] > summary::after, .notes[open] > summary::after { content:"－"; }
.mobile-detail[open] > summary { margin-bottom:12px; }
.detail-content h3 { margin:0 0 12px; }
.notes > summary { font-size:18px; }
.notes[open] > summary { margin-bottom:10px; }

/* 手机优先布局：核心排盘占满屏幕，次要信息折叠 */
@media screen and (max-width:700px) {
  body { background:#f3ede3; }
  .app-shell { width:100%; max-width:none; padding:10px 6px 28px; overflow:hidden; }
  .panel { box-shadow:0 8px 24px rgba(58,34,23,.08); }
  .app-view { width:100%; }
  .input-view { min-height:calc(100vh - 38px); display:flex; flex-direction:column; justify-content:center; }
  .input-masthead { justify-content:flex-start; padding:0 6px; }
  .input-view .controls { width:100%; }
  .input-view .notes { margin-top:10px; }
  .result-header { position:sticky; top:0; z-index:20; margin:0 -2px 8px; padding:8px; flex-direction:column; align-items:stretch; gap:8px; background:rgba(255,253,247,.97); backdrop-filter:blur(8px); }
  .result-heading { justify-content:space-between; gap:8px; }
  .result-heading > div { order:-1; }
  .result-heading small { font-size:9px; }
  .result-heading h2 { font-size:18px; }
  .back-to-input { min-height:44px; padding:8px 12px; }
  .result-toolbar { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); width:100%; gap:6px; }
  .result-toolbar button { min-width:0; min-height:44px; padding:8px 4px; font-size:12px; line-height:1.2; }

  .masthead { flex-direction:column; gap:10px; margin-bottom:12px; }
  .brand { width:100%; gap:10px; }
  .seal { width:44px; height:44px; font-size:14px; box-shadow:inset 0 0 0 3px #f4e9dc; }
  h1 { font-size:22px; letter-spacing:.08em; white-space:nowrap; }
  .subtitle { margin-top:2px; font-size:11px; letter-spacing:.1em; }
  .toolbar { width:100%; display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; }
  .toolbar button { min-width:0; min-height:44px; padding:8px 4px; font-size:12px; line-height:1.2; }

  .controls, .input-view .controls { padding:12px; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px 8px; align-items:end; }
  .datetime-field > legend { font-size:12px; }
  .datetime-mode-tabs { position:sticky; top:8px; z-index:4; margin-bottom:10px; }
  .datetime-mode-tab { min-height:44px; padding:8px 4px; font-size:15px; }
  .date-select-grid { grid-template-columns:repeat(6,minmax(0,1fr)); gap:7px 5px; }
  .date-select-grid label:nth-child(1) { grid-column:span 2; }
  .date-select-grid label:nth-child(2), .date-select-grid label:nth-child(3) { grid-column:span 2; }
  .date-select-grid label:nth-child(4), .date-select-grid label:nth-child(5) { grid-column:span 3; }
  .bazi-select-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; }
  .date-select-grid select, .bazi-select-grid select { min-height:48px; padding:8px 3px; font-size:16px; }
  .datetime-feedback { grid-template-columns:1fr; gap:3px; padding:9px 10px; }
  .datetime-feedback small { grid-row:auto; }
  .datetime-feedback strong { font-size:15px; }
  .candidate-list { grid-template-columns:1fr; max-height:240px; }
  .candidate-button { min-height:48px; }
  .controls .datetime-field, .controls .name-field, .controls .sample-field,
  .input-view .datetime-field, .input-view .name-field, .input-view .sample-field { grid-column:1/-1; }
  .controls .datetime-field { grid-row:1; }
  .controls .chart-type-field { grid-row:2; grid-column:1; }
  .controls .gender-field { grid-row:2; grid-column:2; }
  .controls .name-field { grid-row:3; }
  .controls .sample-field { grid-row:4; }
  .controls .start-chart, .input-view .start-chart { grid-row:5; grid-column:1; }
  .controls .reset-chart { grid-row:5; grid-column:2; }
  label { gap:5px; font-size:12px; }
  input, select, .controls button { min-height:46px; padding:10px 11px; font-size:16px; }
  .controls .start-chart { font-size:17px; font-weight:800; }

  .chart-navigation {
    margin-top:8px;
    padding:8px;
    grid-template-columns:repeat(2,minmax(0,1fr));
    grid-template-areas:"current current" "prev-ju next-ju" "prev-day next-day";
    gap:7px;
  }
  #previous-day { grid-area:prev-day; }
  #previous-ju { grid-area:prev-ju; }
  #next-ju { grid-area:next-ju; }
  #next-day { grid-area:next-day; }
  .navigation-current { grid-area:current; padding:4px 4px 7px; border-bottom:1px solid var(--line); }
  .navigation-current strong { margin-top:2px; font-size:17px; }
  .chart-navigation button { min-width:0; min-height:44px; padding:7px 6px; font-size:14px; }
  .chart-navigation button small { display:inline; margin:0 0 0 2px; font-size:9px; }

  .chart { margin-top:10px; padding:10px 4px 14px; overflow:hidden; }
  .chart-meta { display:block; padding:0 6px 12px; }
  .calendar h2 { margin-bottom:5px; font-size:18px; line-height:1.35; }
  .calendar p { margin:4px 0; font-size:13px; line-height:1.45; }
  .tags { flex-wrap:nowrap; gap:6px; margin:8px -2px 10px; padding:0 2px 4px; overflow-x:auto; scrollbar-width:none; -webkit-overflow-scrolling:touch; }
  .tags::-webkit-scrollbar { display:none; }
  .tags span { flex:0 0 auto; padding:4px 7px; font-size:11px; white-space:nowrap; }
  .pillars { margin-top:8px; }
  .pillars div { min-width:0; padding:7px 2px; }
  .pillars small { margin-bottom:3px; font-size:10px; }
  .pillars strong { font-size:18px; }

  .main-grid { display:block; min-width:0; margin-top:12px; }
  .board-column { width:100%; min-width:0; }
  .board-wrap {
    width:100%;
    grid-template-columns:38px minmax(0,1fr) 38px;
    grid-template-rows:38px minmax(0,1fr) 38px;
  }
  .board { min-width:0; width:100%; aspect-ratio:1; }
  .direction-label { width:20px; height:20px; font-size:12px; box-shadow:none; }
  .outer-top { padding-top:20px; }
  .outer-bottom { padding-bottom:20px; }
  .outer-left { padding-left:20px; }
  .outer-right { padding-right:20px; }
  .outer-slot, .outer-top .outer-slot, .outer-bottom .outer-slot { gap:1px; }
  .outer-left .outer-slot, .outer-right .outer-slot { flex-direction:column; }
  .outer-left .outer-hidden, .outer-right .outer-hidden { writing-mode:vertical-rl; text-orientation:upright; }
  .outer-branch { font-size:12px; }
  .outer-hidden, .outer-hidden.empty { font-size:13px; letter-spacing:0; }

  .palace { min-height:0; padding:5px 4px; }
  .palace-head { min-height:27px; gap:2px; }
  .palace-head small { display:none; }
  .palace-god, .star-door { font-size:14px; line-height:1.22; }
  .palace-god { font-weight:700; }
  .palace-core { gap:3px; margin-top:2px; }
  .stems { gap:0; font-size:15px; line-height:1.08; }
  .stem-stack { column-gap:1px; }
  .changsheng-state { font-size:8px; letter-spacing:0; }
  .marks { max-width:42px; gap:1px; }
  .mark { font-size:8px; padding:1px 2px; }
  .host-badge { left:3px; bottom:3px; padding:1px 2px; font-size:7px; }
  .taiji { font-size:39px; }
  .center small { margin-top:3px; }
  .center-host { margin-top:3px; font-size:10px; }

  .sidebar { margin-top:12px; display:grid; grid-template-columns:1fr; gap:8px; }
  .side-card { padding:12px; border-top-width:3px; }
  .mobile-detail > summary { min-height:24px; font-size:16px; }
  .mobile-detail > summary::after { font-size:18px; }
  .mobile-detail[open] > summary { margin-bottom:9px; }
  .facts { grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
  .facts div { min-width:0; padding:7px; }
  .facts small { font-size:10px; }
  .facts strong { display:block; overflow-wrap:anywhere; font-size:14px; }
  dl div { padding:7px 0; font-size:13px; }
  dd { max-width:68%; overflow-wrap:anywhere; }
  .detail-content h3 { margin-bottom:7px; font-size:16px; }
  .detail-content p { margin:0; color:var(--muted); font-size:13px; line-height:1.6; }
  .ju-card p, .ju-card > small { font-size:12px; }
  .ju-card > strong { padding:8px; font-size:14px; overflow-wrap:anywhere; }

  .dayun-section { margin-top:12px; padding:12px 4px 0; }
  .dayun-heading, .liunian-heading { align-items:flex-start; flex-direction:column; gap:3px; margin-bottom:8px; }
  .dayun-heading h3 { font-size:19px; }
  .liunian-heading { margin-top:15px; }
  .liunian-heading h4 { font-size:17px; }
  .dayun-heading p, .liunian-heading p { text-align:left; font-size:11px; }
  .dayun-table-wrap, .liunian-table-wrap { position:relative; max-width:100%; overflow-x:auto; scrollbar-gutter:auto; -webkit-overflow-scrolling:touch; }
  .dayun-table-wrap::before, .liunian-table-wrap::before {
    content:"左右滑动查看更多 →";
    display:block;
    position:sticky;
    left:0;
    width:max-content;
    padding:4px 7px;
    color:var(--muted);
    background:#f5e8cf;
    font-size:10px;
    z-index:3;
  }
  .dayun-table { min-width:620px; }
  .liunian-table { min-width:690px; }
  .dayun-table th, .dayun-table td, .liunian-table th, .liunian-table td { padding:8px 4px; }
  .dayun-table th, .liunian-table th { width:52px; font-size:11px; }
  .dayun-table td { min-width:60px; font-size:14px; }
  .dayun-table #dayun-ganzhi td { font-size:16px; }
  .liunian-table td { min-width:61px; font-size:13px; }
  .liunian-table #liunian-ganzhi td { font-size:15px; }

  .status { margin:12px 4px 0; padding:10px; font-size:12px; line-height:1.55; }
  .notes { margin-top:10px; padding:13px; }
  .notes > summary { min-height:30px; font-size:15px; }
  .notes ul { margin:0; padding-left:20px; }
  .notes li { margin:7px 0; font-size:12px; line-height:1.55; }
  .color-legend { margin-left:-20px !important; gap:4px; }
  .legend { padding:4px 6px; font-size:11px; }
}

@media screen and (max-width:360px) {
  .app-shell { padding-left:4px; padding-right:4px; }
  .chart { padding-left:2px; padding-right:2px; }
  .board-wrap { grid-template-columns:32px minmax(0,1fr) 32px; grid-template-rows:34px minmax(0,1fr) 34px; }
  .outer-top { padding-top:18px; } .outer-bottom { padding-bottom:18px; } .outer-left { padding-left:17px; } .outer-right { padding-right:17px; }
  .palace { padding:4px 3px; }
  .palace-god, .star-door { font-size:13px; }
  .stems { font-size:14px; }
  .marks { max-width:34px; }
  .taiji { font-size:34px; }
  .center-host { font-size:9px; }
}

@media print {
  .dayun-table-wrap, .liunian-table-wrap { overflow:visible; }
  .dayun-table, .liunian-table { min-width:0; }
  .dayun-table th, .dayun-table td, .liunian-table th, .liunian-table td { padding:8px 4px; font-size:12px; }
  .dayun-table #dayun-ganzhi td, .liunian-table #liunian-ganzhi td { font-size:14px; }
}


/* 手机优先时间选择器：主页面保持简洁，点击后从底部弹出滚轮 */
.datetime-trigger {
  width:100%; min-height:82px; display:grid; grid-template-columns:44px minmax(0,1fr) 20px;
  align-items:center; gap:12px; padding:13px 14px; color:var(--ink); text-align:left;
  background:linear-gradient(135deg,#fffefa,#fff8ec); border:1px solid #d9c8b3; border-radius:14px;
  box-shadow:0 7px 18px rgba(82,48,31,.08); -webkit-tap-highlight-color:transparent;
}
.datetime-trigger:active { transform:scale(.995); background:#fff7e8; }
.datetime-trigger:focus-visible { outline:3px solid rgba(155,47,47,.2); outline-offset:2px; }
.datetime-trigger-icon { display:grid; place-items:center; width:44px; height:44px; color:#fff; background:var(--red); border-radius:13px; font-size:19px; font-weight:900; box-shadow:inset 0 0 0 2px rgba(255,255,255,.2); }
.datetime-trigger-copy { display:grid; min-width:0; gap:3px; }
.datetime-trigger-copy small { color:var(--red); font-size:12px; font-weight:800; letter-spacing:.05em; }
.datetime-trigger-copy strong { overflow:hidden; color:var(--ink); font-size:18px; line-height:1.35; text-overflow:ellipsis; white-space:nowrap; }
.datetime-trigger-copy > span { overflow:hidden; color:var(--muted); font-size:12px; line-height:1.4; text-overflow:ellipsis; white-space:nowrap; }
.datetime-trigger-arrow { color:#b49b83; font-family:Arial,sans-serif; font-size:31px; font-weight:300; }
.datetime-feedback { display:none; margin:7px 2px 0; padding:8px 10px; border:0; border-radius:8px; font-size:12px; line-height:1.45; }
.datetime-feedback.error, .datetime-feedback.pending { display:block; }
.datetime-feedback.error { color:#a1241c; background:#fff0ed; }
.datetime-feedback.pending { color:#78552b; background:#fff7df; }

.datetime-sheet[hidden] { display:none !important; }
.datetime-sheet { position:fixed; inset:0; z-index:1000; display:flex; align-items:flex-end; justify-content:center; font-family:"Noto Sans SC","Microsoft YaHei",sans-serif; }
.datetime-backdrop { position:absolute; inset:0; width:100%; height:100%; padding:0; background:rgba(25,18,15,.48); border:0; opacity:0; transition:opacity .22s ease; -webkit-tap-highlight-color:transparent; }
.datetime-sheet-panel { position:relative; width:min(100%,560px); max-height:min(88vh,720px); padding:0 14px calc(14px + env(safe-area-inset-bottom)); overflow-y:auto; overscroll-behavior:contain; color:#26201d; background:#fff; border-radius:22px 22px 0 0; box-shadow:0 -16px 45px rgba(31,20,15,.22); transform:translateY(102%); transition:transform .24s cubic-bezier(.2,.75,.25,1); }
.datetime-sheet.open .datetime-backdrop { opacity:1; }
.datetime-sheet.open .datetime-sheet-panel { transform:translateY(0); }
.datetime-sheet-open { overflow:hidden; touch-action:none; }
.sheet-grabber { width:38px; height:4px; margin:8px auto 3px; background:#d8d3cf; border-radius:999px; }
.datetime-sheet-header { display:grid; grid-template-columns:64px minmax(0,1fr) 64px; align-items:center; min-height:48px; border-bottom:1px solid #eee9e5; }
.datetime-sheet-header h2 { margin:0; font-size:16px; text-align:center; letter-spacing:.03em; }
.sheet-action { min-height:44px; padding:5px 4px; background:transparent; border:0; font-size:15px; }
.sheet-cancel { color:#777; text-align:left; }
.sheet-confirm { color:var(--red); text-align:right; font-weight:800; }
.datetime-sheet .datetime-mode-tabs { width:min(100%,270px); margin:12px auto 4px; padding:2px; background:#fff; border:1px solid #d9b2b2; border-radius:999px; }
.datetime-sheet .datetime-mode-tab { min-height:34px; padding:5px 12px; color:#554b47; border-radius:999px; font-size:14px; letter-spacing:.03em; }
.datetime-sheet .datetime-mode-tab.active { color:#fff; background:#d73535; box-shadow:none; }
.picker-preview { display:grid; gap:2px; min-height:54px; padding:8px 4px 4px; text-align:center; }
.picker-preview strong { color:#2e2825; font-size:15px; line-height:1.4; }
.picker-preview span { color:#9a8f89; font-size:11px; line-height:1.35; }
.datetime-sheet .datetime-mode-panel { padding-top:2px; }
.wheel-picker { --wheel-row:46px; position:relative; display:grid; height:calc(var(--wheel-row) * 5); overflow:hidden; border-top:1px solid #f0ece9; border-bottom:1px solid #f0ece9; }
.wheel-picker-five { grid-template-columns:1.18fr .82fr .82fr .82fr .82fr; }
.wheel-picker-bazi { grid-template-columns:repeat(4,minmax(0,1fr)); }
.wheel-picker::before { content:""; position:absolute; z-index:0; left:0; right:0; top:calc(var(--wheel-row) * 2); height:var(--wheel-row); background:linear-gradient(90deg,rgba(155,47,47,.06),rgba(155,47,47,.105),rgba(155,47,47,.06)); border-top:1px solid rgba(155,47,47,.17); border-bottom:1px solid rgba(155,47,47,.17); pointer-events:none; }
.wheel-picker::after { content:""; position:absolute; z-index:3; inset:0; background:linear-gradient(to bottom,#fff 0,rgba(255,255,255,.82) 15%,transparent 39%,transparent 61%,rgba(255,255,255,.82) 85%,#fff 100%); pointer-events:none; }
.wheel-column { position:relative; z-index:1; min-width:0; }
.wheel-heading { position:absolute; z-index:4; top:50%; right:2px; transform:translateY(-50%); color:#9f948d; font-size:10px; pointer-events:none; }
.wheel-scroll { height:100%; overflow-y:auto; overscroll-behavior:contain; scroll-snap-type:y mandatory; scrollbar-width:none; -webkit-overflow-scrolling:touch; touch-action:pan-y; }
.wheel-scroll::-webkit-scrollbar { display:none; }
.wheel-spacer { height:calc(var(--wheel-row) * 2); }
.wheel-option { display:block; width:100%; height:var(--wheel-row); padding:0 12px 0 2px; overflow:hidden; color:#aaa09b; background:transparent; border:0; scroll-snap-align:center; scroll-snap-stop:always; font-size:15px; text-align:center; text-overflow:ellipsis; white-space:nowrap; }
.wheel-option.selected { color:#241f1c; font-size:18px; font-weight:800; }
.wheel-picker-bazi .wheel-option { padding-right:2px; font-size:18px; }
.wheel-picker-bazi .wheel-option.selected { color:var(--red); font-size:22px; }
.datetime-sheet .datetime-help { margin:9px 4px 0; text-align:center; font-size:11px; }
.datetime-sheet .bazi-search { min-height:46px; margin-top:12px; color:#fff; background:var(--red); border:0; border-radius:999px; font-size:15px; font-weight:800; }
.datetime-sheet .bazi-candidates { margin:10px 0 2px; }
.datetime-sheet .candidate-list { max-height:150px; }
.datetime-sheet .candidate-button { min-height:48px; border-radius:10px; }
.datetime-state-controls { position:absolute !important; width:1px !important; height:1px !important; overflow:hidden !important; clip-path:inset(50%) !important; white-space:nowrap !important; }

@media screen and (max-width:700px) {
  .input-masthead { padding-top:12px; }
  .input-view .controls { padding:12px; border-radius:14px; }
  .datetime-field > legend { margin-bottom:7px; }
  .datetime-trigger { min-height:84px; padding:13px 12px; border-radius:13px; }
  .datetime-trigger-copy strong { font-size:17px; }
  .datetime-sheet-panel { width:100%; max-height:91dvh; border-radius:20px 20px 0 0; }
  .wheel-picker { --wheel-row:44px; }
  .wheel-option { font-size:14px; }
  .wheel-option.selected { font-size:17px; }
  .candidate-list { grid-template-columns:1fr; }
}

@media screen and (min-width:701px) {
  .datetime-sheet { align-items:center; padding:24px; }
  .datetime-sheet-panel { border-radius:22px; transform:translateY(30px) scale(.98); opacity:0; transition:transform .22s ease,opacity .22s ease; }
  .datetime-sheet.open .datetime-sheet-panel { transform:translateY(0) scale(1); opacity:1; }
}

/* 滚轮必须在固定高度内滚动，不能被长年份列表撑高 */
.wheel-picker { min-height:calc(var(--wheel-row) * 5); }
.wheel-column { min-height:0; height:100%; overflow:hidden; }
.wheel-scroll { position:absolute; inset:0; height:auto; }

/* 手机端四柱：每次只操作一柱，天干与地支分别滚动选择 */
.bazi-mode-panel { padding-top:8px !important; }
.bazi-pillar-tabs { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:7px; margin:0 2px 10px; }
.bazi-pillar-tab { min-width:0; min-height:58px; padding:7px 2px 6px; color:#756a64; background:#f7f3f0; border:1px solid #e8dfda; border-radius:12px; text-align:center; }
.bazi-pillar-tab small { display:block; margin-bottom:3px; color:#9b8e87; font-size:11px; line-height:1.2; }
.bazi-pillar-tab strong { display:block; color:#332b27; font-family:"Noto Serif SC","Songti SC",serif; font-size:19px; line-height:1.15; letter-spacing:.08em; }
.bazi-pillar-tab.active { background:#fff8f5; border-color:rgba(155,47,47,.52); box-shadow:0 3px 12px rgba(115,42,42,.09); }
.bazi-pillar-tab.active small,.bazi-pillar-tab.active strong { color:var(--red); }
.bazi-current-label { display:flex; align-items:center; justify-content:space-between; min-height:34px; padding:0 7px; }
.bazi-current-label span { color:var(--red); font-size:14px; font-weight:800; }
.bazi-current-label strong { color:#9b8e87; font-size:12px; font-weight:600; }
.bazi-pillar-wheel[hidden] { display:none !important; }
.wheel-picker-bazi-pair { grid-template-columns:repeat(2,minmax(0,1fr)); border-radius:12px; }
.wheel-picker-bazi-pair .wheel-column:first-child { border-right:1px solid #eee8e4; }
.wheel-picker-bazi-pair .wheel-heading { right:10px; color:#9f948d; font-size:11px; }
.wheel-picker-bazi-pair .wheel-option { padding:0 32px 0 10px; font-family:"Noto Serif SC","Songti SC",serif; font-size:21px; }
.wheel-picker-bazi-pair .wheel-option.selected { color:var(--red); font-size:28px; font-weight:900; }
.bazi-parity-note { display:flex; justify-content:center; gap:22px; margin:8px 0 0; color:#9b8e87; font-size:11px; }
.bazi-parity-note span::before { content:""; display:inline-block; width:5px; height:5px; margin:0 5px 2px 0; background:var(--red); border-radius:50%; opacity:.55; }

@media screen and (max-width:700px) {
  .datetime-sheet-header { position:sticky; top:0; z-index:20; background:#fff; }
  #bazi-picker .bazi-pillar-tabs { margin-bottom:5px; }
  #bazi-picker .bazi-current-label { min-height:28px; }
  #bazi-picker .wheel-picker-bazi-pair { --wheel-row:40px; height:calc(var(--wheel-row) * 3); min-height:calc(var(--wheel-row) * 3); }
  #bazi-picker .wheel-picker-bazi-pair::before { top:var(--wheel-row); }
  #bazi-picker .wheel-picker-bazi-pair::after { background:linear-gradient(to bottom,#fff 0,rgba(255,255,255,.72) 20%,transparent 36%,transparent 64%,rgba(255,255,255,.72) 80%,#fff 100%); }
  #bazi-picker .wheel-picker-bazi-pair .wheel-spacer { height:var(--wheel-row); }
  #bazi-picker .bazi-parity-note { margin-top:5px; }
  #bazi-picker .bazi-search { min-height:44px; margin-top:6px; }
}

@media screen and (max-width:380px) {
  .bazi-pillar-tabs { gap:5px; }
  .bazi-pillar-tab { min-height:55px; border-radius:10px; }
  .bazi-pillar-tab strong { font-size:18px; }
  .wheel-picker-bazi-pair .wheel-option.selected { font-size:26px; }
}
/* PWA installation and standalone-mode polish */
.pwa-install-card {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding: 10px 42px 10px 10px;
  border: 1px solid rgba(155, 47, 47, .22);
  background: linear-gradient(135deg, rgba(255, 250, 240, .98), rgba(252, 238, 222, .96));
}
.pwa-install-card[hidden] { display: none !important; }
.pwa-install-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--red);
  color: #fff7df;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.05;
  text-align: center;
}
.pwa-install-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pwa-install-copy strong { color: var(--ink); font-size: 15px; }
.pwa-install-copy span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.pwa-install-button { min-width: 68px; min-height: 40px; padding: 7px 12px; }
.pwa-install-dismiss {
  position: absolute;
  top: 4px;
  right: 5px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}
html.pwa-standalone body { padding-top: env(safe-area-inset-top); }
html.pwa-standalone .result-header { top: env(safe-area-inset-top); }

@media screen and (max-width: 700px) {
  body { padding-bottom: env(safe-area-inset-bottom); }
  .pwa-install-card {
    grid-template-columns: 42px minmax(0, 1fr);
    padding: 10px 42px 10px 10px;
  }
  .pwa-install-button {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 44px;
  }
}

@media print {
  .pwa-install-card { display: none !important; }
}


/* Case library, chart basis, and mobile case editor */
button, input, select, textarea { font: inherit; }
.case-center { margin-top:14px; overflow:hidden; }
.case-center > summary {
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  min-height:52px; padding:12px 16px; color:var(--red-dark); cursor:pointer;
  font-weight:800; list-style:none; -webkit-tap-highlight-color:transparent;
}
.case-center > summary::-webkit-details-marker { display:none; }
.case-center > summary::after { content:"＋"; flex:0 0 auto; font-size:20px; font-weight:400; line-height:1; }
.case-center[open] > summary::after { content:"－"; }
.case-center > summary small { margin-left:auto; color:var(--muted); font-size:12px; font-weight:400; }
.case-center-body { padding:0 16px 16px; border-top:1px solid rgba(155,47,47,.12); }
.case-search-row { display:grid; gap:6px; padding-top:14px; }
.case-search-row > label { color:var(--muted); font-size:12px; }
.case-search-row > div { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; }
.case-search-row input { min-height:46px; }
.case-search-row button { min-width:72px; min-height:46px; padding:8px 12px; }
.case-list { display:grid; gap:10px; max-height:430px; margin-top:12px; overflow-y:auto; overscroll-behavior:contain; scrollbar-gutter:stable; }
.case-empty { padding:24px 14px; color:var(--muted); background:rgba(248,241,229,.72); border:1px dashed var(--line); border-radius:9px; font-size:13px; line-height:1.65; text-align:center; }
.case-item { padding:10px; background:#fffefa; border:1px solid var(--line); border-radius:10px; box-shadow:0 4px 12px rgba(58,34,23,.05); }
.case-item.active { background:#fff7e8; border-color:var(--red); box-shadow:inset 3px 0 0 var(--red),0 4px 12px rgba(58,34,23,.06); }
.case-open { width:100%; min-height:48px; display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:10px; padding:5px 4px; color:var(--ink); text-align:left; background:transparent; border:0; }
.case-open span { min-width:0; display:grid; gap:4px; }
.case-open strong { overflow:hidden; color:var(--red-dark); font-size:15px; line-height:1.35; text-overflow:ellipsis; white-space:nowrap; }
.case-open small { overflow:hidden; color:var(--muted); font-size:11px; line-height:1.45; text-overflow:ellipsis; white-space:nowrap; }
.case-open em { color:var(--red); font-size:12px; font-style:normal; font-weight:800; white-space:nowrap; }
.case-item > p { max-height:4.6em; margin:7px 4px 9px; overflow:hidden; color:#5f534d; font-size:12px; line-height:1.55; white-space:pre-wrap; }
.case-item-actions { display:grid; grid-template-columns:minmax(0,1fr) 74px; gap:8px; padding-top:8px; border-top:1px solid rgba(216,203,187,.72); }
.case-item-actions button { min-height:44px; padding:7px 10px; border-radius:5px; font-size:12px; }
.danger-link { color:#a1241c; background:#fff; border:1px solid rgba(193,57,43,.35); }
.backup-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin-top:12px; }
.backup-actions button { min-height:46px; padding:9px 8px; }
.case-storage-status { margin:10px 2px 0; color:var(--muted); font-size:12px; line-height:1.55; }
.case-storage-status.success { color:#176b35; }
.case-storage-status.error { color:#a1241c; }

.basis-card { border-left:3px solid var(--gold); }
.chart-basis { display:grid; gap:0; }
.chart-basis div { display:grid; grid-template-columns:76px minmax(0,1fr); gap:8px; padding:8px 0; border-bottom:1px solid rgba(216,203,187,.72); }
.chart-basis div:last-child { border-bottom:0; }
.chart-basis small { color:var(--muted); font-size:11px; line-height:1.45; }
.chart-basis strong { min-width:0; color:var(--ink); font-size:12px; line-height:1.55; overflow-wrap:anywhere; }

.case-sheet[hidden] { display:none !important; }
.case-sheet { position:fixed; inset:0; z-index:1100; display:flex; align-items:flex-end; justify-content:center; font-family:"Noto Sans SC","Microsoft YaHei",sans-serif; }
.case-sheet-backdrop { position:absolute; inset:0; width:100%; height:100%; padding:0; background:rgba(25,18,15,.5); border:0; opacity:0; transition:opacity .2s ease; -webkit-tap-highlight-color:transparent; }
.case-sheet-panel { position:relative; width:min(100%,600px); max-height:min(88dvh,760px); padding:0 14px calc(16px + env(safe-area-inset-bottom)); overflow-y:auto; overscroll-behavior:contain; color:var(--ink); background:#fff; border-radius:22px 22px 0 0; box-shadow:0 -16px 45px rgba(31,20,15,.24); transform:translateY(102%); transition:transform .22s cubic-bezier(.2,.75,.25,1); }
.case-sheet.open .case-sheet-backdrop { opacity:1; }
.case-sheet.open .case-sheet-panel { transform:translateY(0); }
.case-sheet-open { overflow:hidden; touch-action:none; }
.case-sheet-header { position:sticky; top:0; z-index:2; display:grid; grid-template-columns:64px minmax(0,1fr) 64px; align-items:center; min-height:50px; background:#fff; border-bottom:1px solid #eee9e5; }
.case-sheet-header h2 { margin:0; font-size:16px; text-align:center; letter-spacing:.03em; }
.case-editor { display:grid; gap:15px; padding:14px 0 2px; }
.case-editor-meta { margin:0; padding:9px 11px; color:var(--muted); background:#f8f1e5; border-radius:8px; font-size:12px; line-height:1.55; }
.case-editor label { display:grid; gap:7px; color:var(--red-dark); font-size:13px; font-weight:800; }
.case-editor input, .case-editor textarea { width:100%; min-width:0; padding:11px 12px; color:var(--ink); background:#fffefa; border:1px solid var(--line); border-radius:8px; font-size:16px; font-weight:400; line-height:1.55; }
.case-editor input { min-height:48px; }
.case-editor textarea { min-height:190px; resize:vertical; }
.case-editor-actions { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.case-editor-actions small { color:var(--muted); font-size:11px; line-height:1.45; text-align:right; }
.danger { min-height:44px; padding:8px 14px; color:#a1241c; background:#fff2ef; border:1px solid rgba(193,57,43,.4); border-radius:6px; white-space:nowrap; }

@media screen and (max-width:700px) {
  .result-toolbar { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .case-center { margin:10px 0 0; }
  .case-center > summary { min-height:50px; padding:11px 13px; }
  .case-center-body { padding:0 10px 12px; }
  .case-search-row { padding-top:10px; }
  .case-search-row > div { gap:6px; }
  .case-search-row button { min-width:64px; }
  .case-list { max-height:48dvh; margin-top:10px; padding-right:1px; }
  .case-item { padding:8px; border-radius:9px; }
  .case-open { min-height:50px; }
  .case-open strong { font-size:14px; }
  .case-item-actions { grid-template-columns:minmax(0,1fr) 68px; gap:6px; }
  .backup-actions { gap:6px; }
  .backup-actions button { min-width:0; font-size:12px; }
  .chart-basis div { grid-template-columns:84px minmax(0,1fr); padding:7px 0; }
  .chart-basis small { font-size:10px; }
  .chart-basis strong { font-size:11px; }
  .case-sheet-panel { max-height:88dvh; padding-left:12px; padding-right:12px; }
  .case-editor { padding-top:11px; }
  .case-editor textarea { min-height:210px; }
  .case-editor-actions { align-items:flex-end; }
}

@media screen and (max-width:360px) {
  .case-open small { white-space:normal; }
  .case-editor-actions { align-items:stretch; flex-direction:column-reverse; }
  .case-editor-actions small { text-align:left; }
  .danger { width:100%; }
}

@media print {
  .case-center, .case-sheet, #save-case { display:none !important; }
}

/* 结果页标签、模式与分享 */
.result-tabs { position:sticky; top:0; z-index:18; display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:5px; margin-top:12px; padding:5px; background:rgba(255,253,247,.96); backdrop-filter:blur(8px); }
.result-tab { min-height:44px; padding:8px 10px; color:var(--muted); background:transparent; border:0; border-radius:4px; font-size:14px; font-weight:800; }
.result-tab.active { color:#fff; background:var(--red); box-shadow:0 3px 9px rgba(155,47,47,.18); }
.view-mode { display:flex; align-items:center; gap:4px; padding:4px; color:var(--muted); background:#f6efe4; border:1px solid var(--line); border-radius:5px; white-space:nowrap; }
.view-mode > span { padding:0 4px; font-size:11px; }
.view-mode-button { min-height:32px; padding:5px 9px; color:var(--muted); background:transparent; border:0; border-radius:3px; font-size:12px; font-weight:800; }
.view-mode-button.active { color:var(--red-dark); background:#fffdf7; box-shadow:0 1px 4px rgba(70,40,20,.12); }
.result-panel[hidden] { display:none !important; }
.result-panel { min-width:0; }
.result-panel > .chart-meta { margin-bottom:20px; }
.details-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; align-items:start; }
.details-grid .facts-card { grid-column:1 / -1; }
.basis-grid { grid-template-columns:minmax(0,1.4fr) minmax(260px,.6fr); }
.fortune-empty { padding:30px 18px; color:var(--muted); text-align:center; background:#fffdf7; border:1px dashed var(--line); border-radius:6px; }
.fortune-link-summary { margin:10px 0 12px; padding:10px 12px; color:var(--red-dark); background:#fff4de; border-left:3px solid var(--gold); line-height:1.5; }
.fortune-link-summary strong { margin-right:5px; }
.dayun-table td.selected-dayun, .liunian-table td.selected-liunian { position:relative; z-index:1; }
.selected-palace { background:#fff4d7 !important; outline:2px solid var(--red) !important; outline-offset:-2px; }
body[data-display-mode="simple"] .technical-tag,
body[data-display-mode="simple"] .outer-hidden,
body[data-display-mode="simple"] .marks,
body[data-display-mode="simple"] .host-badge,
body[data-display-mode="simple"] .changsheng-state,
body[data-display-mode="simple"] .detail-content dl div:nth-child(n+5) { display:none !important; }
body[data-display-mode="simple"] .board-wrap { grid-template-rows:56px minmax(0,1fr) 56px; grid-template-columns:58px minmax(0,1fr) 58px; }
body[data-display-mode="simple"] .palace { padding:9px; min-height:130px; }
body[data-display-mode="simple"] .palace-god, body[data-display-mode="simple"] .star-door { font-size:18px; }
body[data-display-mode="simple"] .stems { font-size:21px; }
body[data-display-mode="simple"] .calendar h2 { font-size:21px; }
body[data-display-mode="simple"] .pillars strong { font-size:20px; }
.palace-sheet[hidden] { display:none !important; }
.palace-sheet { position:fixed; inset:0; z-index:1200; display:flex; align-items:flex-end; justify-content:center; }
.palace-sheet .datetime-backdrop { position:absolute; inset:0; width:100%; height:100%; padding:0; background:rgba(25,18,15,.52); border:0; }
.palace-sheet-panel { position:relative; width:min(100%,600px); max-height:min(82dvh,720px); padding:0 16px calc(18px + env(safe-area-inset-bottom)); overflow:auto; color:var(--ink); background:#fffdf9; border-radius:20px 20px 0 0; box-shadow:0 -14px 40px rgba(31,20,15,.28); }
.palace-sheet-header { position:sticky; top:0; z-index:2; display:flex; align-items:center; justify-content:space-between; min-height:54px; background:#fffdf9; border-bottom:1px solid var(--line); }
.palace-sheet-header h2 { margin:0; color:var(--red-dark); font-size:18px; }
.palace-sheet-header .sheet-action { min-height:40px; }
body.sheet-open { overflow:hidden; }
.share-stage .result-panel[hidden] { display:block !important; }
.share-stage .chart { margin:0; box-shadow:none; }
.share-stage .result-panel { padding:0; }
.share-stage .dayun-section { display:block !important; }
.share-image-root { width:390px !important; padding:16px !important; background:#fffdf7 !important; }
.share-image-root .board-wrap { margin-top:14px; }
.share-image-root .details-grid { grid-template-columns:1fr; }
.share-image-root .facts-card { grid-column:auto; }
.share-image-root .palace-sheet, .share-image-root .share-stage { display:none !important; }
.share-image-root .share-privacy-pillars { opacity:.72; }

@media screen and (max-width:850px) {
  .result-header { gap:7px; }
  .view-mode { align-self:flex-start; }
  .result-tabs { margin-top:6px; }
  .chart { padding:14px; }
  .details-grid, .basis-grid { grid-template-columns:1fr; gap:10px; }
  .details-grid .facts-card { grid-column:auto; }
}
@media screen and (max-width:590px) {
  .result-tabs { top:0; margin-left:-2px; margin-right:-2px; }
  .result-tab { min-height:42px; padding:7px 4px; font-size:12px; }
  .view-mode { width:max-content; }
  .view-mode-button { min-height:30px; }
  .result-toolbar { grid-template-columns:repeat(3,minmax(0,1fr)) !important; }
  .result-toolbar button { font-size:11px; }
  .fortune-link-summary { font-size:12px; }
  .palace-sheet-panel { width:100%; }
}
@media print {
  .result-tabs, .view-mode, #save-long-image, #privacy-share, .palace-sheet { display:none !important; }
  .result-panel[hidden] { display:block !important; }
  #share-capture { margin:0; padding:0; border:0; box-shadow:none; }
}

/* Stable 900px long-image layout: independent from the device viewport. */
.share-stage { width:900px !important; }
.share-image-root { width:900px !important; max-width:none !important; overflow:visible !important; }
.share-image-root .chart-meta { grid-template-columns:minmax(0,1.35fr) minmax(300px,.65fr) !important; }
.share-image-root .board-wrap {
  grid-template-columns:84px minmax(0,1fr) 84px !important;
  grid-template-rows:76px minmax(0,1fr) 76px !important;
}
.share-image-root .board { min-width:0 !important; }
.share-image-root .details-grid { grid-template-columns:repeat(2,minmax(0,1fr)) !important; }
.share-image-root .details-grid .facts-card { grid-column:1 / -1 !important; }
.share-image-root .basis-grid { grid-template-columns:minmax(0,1.4fr) minmax(260px,.6fr) !important; }
.share-image-root .dayun-heading,
.share-image-root .liunian-heading { flex-direction:row !important; align-items:flex-end !important; }
.share-image-root .dayun-table-wrap,
.share-image-root .liunian-table-wrap { overflow:visible !important; scrollbar-gutter:auto !important; }
.share-image-root .dayun-table,
.share-image-root .liunian-table { width:100% !important; min-width:0 !important; table-layout:fixed !important; }
.share-image-root .dayun-table th,
.share-image-root .liunian-table th { position:static !important; width:68px !important; }
.share-image-root .dayun-table th,
.share-image-root .dayun-table td,
.share-image-root .liunian-table th,
.share-image-root .liunian-table td { min-width:0 !important; padding:8px 4px !important; font-size:14px !important; }
.share-image-root .dayun-table #dayun-ganzhi td,
.share-image-root .liunian-table #liunian-ganzhi td { font-size:17px !important; }