/* Winneth — ink, rice paper, jade, a touch of gold and cinnabar. */
:root {
  --paper: #f4efe4;
  --paper-2: #ebe3d3;
  --card: #fbf8f1;
  --ink: #1c1a17;
  --ink-2: #47423a;
  --muted: #857c6e;
  --line: rgba(28, 26, 23, 0.12);
  --line-2: rgba(28, 26, 23, 0.22);
  --jade: #2d6a57;
  --jade-2: #3f8a72;
  --jade-soft: #dde8e1;
  --gold: #a8874a;
  --gold-soft: #efe4cc;
  --cinnabar: #b23a2b;
  --cinnabar-soft: #f3dcd5;
  --good: #2d6a57;
  --bad: #a33a2c;
  --mixed: #9a7a3c;
  --shadow: 0 1px 2px rgba(40, 30, 10, 0.05), 0 8px 28px -12px rgba(40, 30, 10, 0.18);
  --radius: 6px;
  --f-display: 'Cormorant Garamond', 'Noto Serif TC', Georgia, serif;
  --f-body: 'Jost', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-zh: 'Noto Serif TC', 'Songti TC', 'PMingLiU', serif;
  --f-brush: 'Ma Shan Zheng', 'Noto Serif TC', serif;
  --mist: rgba(244, 239, 228, 0.0);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15140f; --paper-2: #1d1b15; --card: #1f1d17; --ink: #efe8da; --ink-2: #cfc6b4; --muted: #968c7a;
    --line: rgba(239, 232, 218, 0.12); --line-2: rgba(239, 232, 218, 0.22);
    --jade: #6fb59b; --jade-2: #8ccab2; --jade-soft: #1f3a31; --gold: #c9a865; --gold-soft: #3a3020;
    --cinnabar: #d65a48; --cinnabar-soft: #3d1f1a; --good: #6fb59b; --bad: #e07462; --mixed: #d0aa5c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -12px rgba(0,0,0,.6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #15140f; --paper-2: #1d1b15; --card: #1f1d17; --ink: #efe8da; --ink-2: #cfc6b4; --muted: #968c7a;
  --line: rgba(239, 232, 218, 0.12); --line-2: rgba(239, 232, 218, 0.22);
  --jade: #6fb59b; --jade-2: #8ccab2; --jade-soft: #1f3a31; --gold: #c9a865; --gold-soft: #3a3020;
  --cinnabar: #d65a48; --cinnabar-soft: #3d1f1a; --good: #6fb59b; --bad: #e07462; --mixed: #d0aa5c;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -12px rgba(0,0,0,.6); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.6 var(--f-body);
  background-image: radial-gradient(1200px 600px at 85% -10%, var(--gold-soft), transparent 60%),
                    radial-gradient(900px 500px at -10% 20%, var(--jade-soft), transparent 55%);
  background-attachment: fixed; min-height: 100vh; overflow-x: hidden;
}
body::before { /* paper grain */
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .35; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .38  0 0 0 0 .28  0 0 0 .08 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body::before { mix-blend-mode: screen; opacity: .12; } }
:root[data-theme="dark"] body::before { mix-blend-mode: screen; opacity: .12; }

a { color: var(--jade); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--f-display); font-weight: 600; letter-spacing: .005em; line-height: 1.12; margin: 0 0 .4em; }
h1 { font-size: clamp(2.3rem, 5.4vw, 4.2rem); font-weight: 500; }
h2 { font-size: clamp(1.7rem, 3.2vw, 2.4rem); font-weight: 500; }
h3 { font-size: 1.35rem; }
p { margin: 0 0 1em; }
.zh { font-family: var(--f-zh); }
.brush { font-family: var(--f-brush); font-weight: 400; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.tiny { font-size: .76rem; letter-spacing: .02em; }
.caps { text-transform: uppercase; letter-spacing: .18em; font-size: .72rem; font-weight: 500; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 1; }
@media (max-width: 640px) { .wrap { padding: 0 16px; } }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--jade); outline-offset: 2px; border-radius: 3px; }

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 50; backdrop-filter: saturate(1.2) blur(12px); -webkit-backdrop-filter: saturate(1.2) blur(12px);
  background: color-mix(in srgb, var(--paper) 82%, transparent); border-bottom: 1px solid var(--line);
}
.top::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); opacity: .45; }
.top .wrap { display: flex; align-items: center; gap: 22px; height: 64px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.seal {
  width: 36px; height: 36px; background: var(--cinnabar); color: #fbefe6; display: grid; place-items: center;
  font-family: var(--f-brush); font-size: 26px; line-height: 1; border-radius: 3px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.18), inset 0 0 0 3px var(--cinnabar);
  transform: rotate(-3deg); flex: none;
}
.wordmark { font-family: var(--f-display); font-size: 1.45rem; letter-spacing: .32em; font-weight: 600; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a { color: var(--ink-2); padding: 8px 12px; border-radius: 999px; font-size: .92rem; display: flex; gap: 6px; align-items: baseline; }
.nav a .zh { font-size: .82rem; color: var(--gold); }
.nav a:hover { background: var(--paper-2); text-decoration: none; }
.nav a.on { background: var(--ink); color: var(--paper); }
.nav a.on .zh { color: var(--gold-soft); }
.codechip { font-size: .8rem; border: 1px solid var(--line-2); padding: 6px 12px; border-radius: 999px; color: var(--ink-2); background: var(--card); cursor: pointer; white-space: nowrap; font-family: var(--f-body); }
.codechip b { font-variant-numeric: tabular-nums; letter-spacing: .06em; color: var(--jade); }
.iconbtn { background: none; border: 1px solid transparent; color: var(--ink-2); width: 38px; height: 38px; border-radius: 999px; cursor: pointer; display: grid; place-items: center; }
.iconbtn:hover { background: var(--paper-2); }
@media (max-width: 960px) { .nav a .zh { display: none; } .nav a { padding: 8px 9px; } }
@media (max-width: 820px) { .nav { display: none; } .top .wrap { justify-content: space-between; } .wordmark { font-size: 1.2rem; } }

/* Mobile bottom bar */
.tabbar { display: none; }
@media (max-width: 820px) {
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 1px; color: var(--muted); font-size: .68rem; padding: 4px 0; background: none; border: 0; font-family: inherit; cursor: pointer; }
  .tabbar .zh { font-size: 1.25rem; line-height: 1.1; color: var(--ink-2); }
  .tabbar .on, .tabbar .on .zh { color: var(--jade); }
  .tabbar a:hover { text-decoration: none; }
  main { padding-bottom: 86px; }
}
.sheet { position: fixed; inset: 0; z-index: 70; background: rgba(20, 16, 10, .35); display: flex; align-items: flex-end; }
.sheet .panel { background: var(--card); width: 100%; border-radius: 16px 16px 0 0; padding: 18px 18px calc(22px + env(safe-area-inset-bottom)); box-shadow: var(--shadow); animation: rise .25s ease-out; }
.sheet .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sheet .grid a { display: flex; flex-direction: column; align-items: center; padding: 14px 6px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); }
.sheet .grid a .zh { font-size: 1.6rem; }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }

/* ---------- Generic blocks ---------- */
main { position: relative; z-index: 1; min-height: 70vh; }
.view { animation: viewin .5s cubic-bezier(.2,.7,.2,1); }
@keyframes viewin { from { opacity: 0; transform: translateY(10px); } }
.section { padding: 46px 0 10px; }
.sec-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.sec-head .glyph { font-family: var(--f-zh); font-size: 1.5rem; width: 46px; height: 46px; display: grid; place-items: center; border: 1px solid var(--gold); color: var(--gold); border-radius: 2px; flex: none; position: relative; }
.sec-head .glyph::after { content: ''; position: absolute; inset: 3px; border: 1px solid var(--gold); opacity: .35; }
.sec-head h2 { margin: 0; }
.sec-head p { margin: 4px 0 0; color: var(--muted); max-width: 640px; }
.sec-head .grow { flex: 1; min-width: 200px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; position: relative; }
.card.flat { box-shadow: none; }
.card h3 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.card h3 .zh { color: var(--gold); font-size: 1rem; font-weight: 500; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 980px) { .grid3, .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); } .card { padding: 18px 16px; } }
.stack > * + * { margin-top: 18px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
hr.rule { border: 0; height: 1px; background: linear-gradient(90deg, var(--line-2), transparent); margin: 22px 0; }

/* ---------- Forms ---------- */
label.f { display: block; }
label.f > span { display: block; font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line-2); border-radius: 6px;
  padding: 11px 12px; transition: border-color .15s, box-shadow .15s; min-height: 46px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--jade); box-shadow: 0 0 0 3px color-mix(in srgb, var(--jade) 18%, transparent); }
input[type="range"] { padding: 0; min-height: 30px; accent-color: var(--jade); background: none; border: 0; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--jade); }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; padding: 3px; background: var(--paper); flex-wrap: wrap; }
.seg button { border: 0; background: none; font: inherit; font-size: .86rem; padding: 7px 14px; border-radius: 999px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--ink); color: var(--paper); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 500 .95rem var(--f-body); letter-spacing: .02em;
  background: var(--jade); color: #fff; border: 1px solid var(--jade); padding: 11px 20px; border-radius: 999px; cursor: pointer;
  transition: transform .12s, background .15s, box-shadow .15s; min-height: 44px; text-decoration: none !important;
}
.btn:hover { background: var(--jade-2); box-shadow: 0 6px 18px -8px var(--jade); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--paper-2); box-shadow: none; }
.btn.ink { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.small { padding: 6px 14px; min-height: 34px; font-size: .85rem; }
.btn[disabled] { opacity: .55; cursor: progress; }
.linkbtn { background: none; border: 0; color: var(--jade); cursor: pointer; font: inherit; font-size: .86rem; padding: 0; }
.linkbtn:hover { text-decoration: underline; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-2); background: var(--paper); white-space: nowrap; }
.chip.good { border-color: color-mix(in srgb, var(--good) 45%, transparent); color: var(--good); background: color-mix(in srgb, var(--good) 8%, var(--card)); }
.chip.bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad); background: color-mix(in srgb, var(--bad) 7%, var(--card)); }
.chip.mixed { border-color: color-mix(in srgb, var(--mixed) 50%, transparent); color: var(--mixed); }
.method { display: inline-flex; gap: 8px; align-items: center; font-size: .78rem; color: var(--muted); border-top: 1px dashed var(--line-2); padding-top: 10px; margin-top: 14px; flex-wrap: wrap; }
.method b { color: var(--ink-2); font-weight: 500; }

/* Search dropdown */
.search { position: relative; }
.search .results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--card); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow); z-index: 30; max-height: 260px; overflow: auto; }
.search .results button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; font: inherit; font-size: .88rem; color: var(--ink); cursor: pointer; border-bottom: 1px solid var(--line); }
.search .results button:hover { background: var(--paper-2); }

/* ---------- Hero ---------- */
.hero { position: relative; padding: 70px 0 40px; overflow: hidden; }
.hero .wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 40px; align-items: center; }
.hero .kicker { color: var(--gold); }
.hero h1 em { font-style: italic; color: var(--jade); }
.hero .lede { font-size: 1.12rem; color: var(--ink-2); max-width: 560px; }
.hero .verse { writing-mode: vertical-rl; font-family: var(--f-brush); font-size: clamp(2.6rem, 6vw, 4.6rem); line-height: 1.05; color: var(--ink); opacity: .88; letter-spacing: .08em; display: flex; flex-direction: column; gap: 18px; }
.hero .verse span:nth-child(2) { margin-block-start: 0; margin-inline-start: 1.4em; }
.hero .verse span:nth-child(3) { margin-inline-start: .6em; }
.hero .verse small { font-family: var(--f-body); writing-mode: horizontal-tb; font-size: .7rem; letter-spacing: .14em; color: var(--muted); display: block; margin-top: 10px; text-transform: uppercase; }
.hero .verse-wrap { position: relative; }
.hero .verse-wrap .seal { position: absolute; bottom: -28px; left: -16px; width: 44px; height: 44px; font-size: 30px; }
.mountains { position: absolute; left: 0; right: 0; bottom: 0; height: 260px; pointer-events: none; z-index: 0; opacity: .9; }
.mountains svg { width: 100%; height: 100%; }
.mist { animation: drift 40s linear infinite alternate; }
@keyframes drift { to { transform: translateX(-60px); } }
@media (max-width: 820px) { .hero { padding: 36px 0 20px; } .hero .wrap { grid-template-columns: minmax(0, 1fr) auto; gap: 14px; } .hero .verse { font-size: 2.1rem; gap: 8px; } .mountains { height: 160px; } }
@media (max-width: 420px) { .hero .verse { font-size: 1.7rem; } }

.today { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 22px; align-items: center; }
.pillarmini { display: flex; gap: 10px; }
.pillarmini div { text-align: center; }
.pillarmini .zh { font-size: 1.7rem; line-height: 1.15; display: block; writing-mode: vertical-rl; margin: 0 auto; }
.pillarmini small { font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 720px) { .today { grid-template-columns: minmax(0, 1fr); } }

.doors { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .doors { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.door {
  display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 16px; align-items: start; padding: 22px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink);
  transition: transform .2s, box-shadow .2s, border-color .2s; position: relative; overflow: hidden;
}
.door:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--gold); }
.door .big { font-family: var(--f-brush); font-size: 3rem; line-height: 1; color: var(--ink); width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; background: var(--paper-2); }
.door h3 { margin: 4px 0 4px; font-size: 1.3rem; }
.door p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.45; }
.door::after { content: '→'; position: absolute; right: 18px; top: 18px; color: var(--gold); opacity: 0; transition: opacity .2s, transform .2s; }
.door:hover::after { opacity: 1; transform: translateX(3px); }
@media (max-width: 520px) { .doors { grid-template-columns: minmax(0, 1fr); } .door { grid-template-columns: 52px minmax(0, 1fr); padding: 16px; } .door .big { width: 52px; height: 52px; font-size: 2.4rem; } }

/* ---------- Pillars ---------- */
.pillars { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; text-align: center; }
.pillar { border: 1px solid var(--line); border-radius: 6px; padding: 12px 6px 10px; background: var(--paper); position: relative; }
.pillar.dm { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold-soft); }
.pillar .lbl { font-size: .66rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.pillar .god { font-size: .72rem; color: var(--gold); min-height: 1.2em; }
.pillar .ch { font-family: var(--f-zh); font-size: clamp(1.9rem, 4.5vw, 2.6rem); line-height: 1.15; font-weight: 600; }
.pillar .py { font-size: .72rem; color: var(--ink-2); }
.pillar .el { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.pillar .hid { font-size: .7rem; color: var(--muted); margin-top: 6px; font-family: var(--f-zh); }
.elbar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--paper-2); }
.elbar div { transition: flex-grow .8s cubic-bezier(.2,.7,.2,1); }
.ellegend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--ink-2); margin-top: 8px; }
.ellegend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }

/* ---------- Numbers ---------- */
.nums { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.num { border: 1px solid var(--line); border-radius: 6px; padding: 14px; background: var(--paper); cursor: pointer; text-align: left; font: inherit; color: inherit; transition: border-color .15s, transform .15s; }
.num:hover { border-color: var(--gold); transform: translateY(-1px); }
.num .n { font-family: var(--f-display); font-size: 2.4rem; line-height: 1; font-weight: 600; }
.num .n small { font-size: 1rem; color: var(--muted); font-weight: 500; }
.num .t { font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.num .w { font-size: .82rem; color: var(--ink-2); }
.working { font-family: ui-monospace, 'SF Mono', Consolas, monospace; font-size: .8rem; background: var(--paper-2); border-radius: 6px; padding: 10px 12px; color: var(--ink-2); white-space: pre-wrap; margin-top: 8px; line-height: 1.5; overflow-x: auto; }
table.cmp { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.cmp th, table.cmp td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.cmp th { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
table.cmp td.n { font-family: var(--f-display); font-size: 1.35rem; font-weight: 600; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.loshu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; width: min(100%, 300px); aspect-ratio: 1; border: 1.5px solid var(--ink); position: relative; }
.loshu div { border: .5px solid var(--line-2); display: grid; place-items: center; position: relative; font-family: var(--f-display); font-size: 1.5rem; font-weight: 600; }
.loshu div .home { position: absolute; top: 4px; left: 6px; font-size: .66rem; color: var(--muted); font-family: var(--f-body); font-weight: 400; }
.loshu div.empty { color: var(--line-2); }
.loshu div.empty::after { content: ''; position: absolute; inset: 30%; border: 1px dashed var(--line-2); border-radius: 50%; }
.loshu div.has { background: color-mix(in srgb, var(--jade) 7%, transparent); }
.loshu svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ---------- Palace charts ---------- */
.palaces { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border: 1.5px solid var(--ink); background: var(--card); position: relative; }
.pal { border: .5px solid var(--line-2); padding: 10px 10px 8px; min-height: 150px; position: relative; cursor: pointer; transition: background .15s; display: flex; flex-direction: column; text-align: left; font: inherit; color: inherit; background: none; }
.pal:hover { background: var(--paper-2); }
.pal.sel { background: var(--gold-soft); }
.pal.hl-self { box-shadow: inset 0 0 0 2px var(--jade); }
.pal.hl-matter { box-shadow: inset 0 0 0 2px var(--gold); }
.pal.hl-self.hl-matter { box-shadow: inset 0 0 0 2px var(--jade), inset 0 0 0 4px var(--gold); }
.pal .dir { font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; }
.pal .dir .zh { letter-spacing: 0; font-size: .8rem; color: var(--gold); }
.pal .spirit { font-family: var(--f-zh); font-size: .9rem; color: var(--ink-2); margin-top: 4px; }
.pal .star { font-family: var(--f-zh); font-size: .95rem; }
.pal .gate { font-family: var(--f-zh); font-size: 1.45rem; font-weight: 600; line-height: 1.1; margin-top: 2px; }
.pal .gate.good { color: var(--good); }
.pal .gate.bad { color: var(--bad); }
.pal .stems { display: flex; justify-content: space-between; align-items: end; margin-top: auto; font-family: var(--f-zh); font-size: 1.1rem; }
.pal .stems .h { font-weight: 700; }
.pal .stems .e { color: var(--muted); }
.pal .flags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.pal .flags span { font-size: .62rem; padding: 1px 5px; border-radius: 3px; background: var(--paper-2); color: var(--ink-2); font-family: var(--f-zh); }
.pal .flags span.bad { background: var(--cinnabar-soft); color: var(--bad); }
.pal .en { font-size: .7rem; color: var(--muted); font-family: var(--f-body); font-weight: 400; }
.pal.centre { cursor: default; background: repeating-linear-gradient(45deg, transparent 0 8px, color-mix(in srgb, var(--gold) 6%, transparent) 8px 9px); }
.pal.centre:hover { background: repeating-linear-gradient(45deg, transparent 0 8px, color-mix(in srgb, var(--gold) 6%, transparent) 8px 9px); }
.pal .tag { position: absolute; top: 6px; right: 8px; font-size: .62rem; border-radius: 3px; padding: 1px 5px; color: #fff; }
.pal .tag.you { background: var(--jade); }
.pal .tag.it { background: var(--gold); }
@media (max-width: 560px) { .pal { min-height: 118px; padding: 7px 6px 6px; } .pal .gate { font-size: 1.15rem; } .pal .en { display: none; } .pal .stems { font-size: .95rem; } .pal .dir { font-size: .56rem; } }

.fs .pal { min-height: 120px; align-items: center; justify-content: center; }
.fs .nums3 { display: grid; grid-template-columns: 1fr 1fr; width: 100%; font-family: var(--f-display); font-weight: 600; }
.fs .nums3 .m { font-size: 1.5rem; text-align: left; }
.fs .nums3 .w { font-size: 1.5rem; text-align: right; color: var(--jade); }
.fs .base { font-family: var(--f-display); font-size: 2.4rem; font-weight: 500; color: var(--muted); line-height: .9; }
.fs .ann { font-size: .74rem; color: var(--cinnabar); }
.fs .pal.prosper .nums3 span.p { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 4px; text-decoration-thickness: 2px; }

/* Detail drawer under charts */
.drawer { border-left: 2px solid var(--gold); padding: 6px 0 6px 16px; margin-top: 16px; animation: viewin .3s; }
.factor { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: .92rem; }
.factor .ic { font-weight: 700; text-align: center; }
.factor .ic.good { color: var(--good); } .factor .ic.bad { color: var(--bad); } .factor .ic.neutral { color: var(--muted); }
.factor .rid { font-family: ui-monospace, Consolas, monospace; font-size: .68rem; color: var(--muted); }

.tone { display: inline-flex; align-items: center; gap: 10px; font-family: var(--f-display); font-size: 1.6rem; font-weight: 600; }
.tone .dot { width: 14px; height: 14px; border-radius: 50%; }
.tone.favourable .dot { background: var(--good); } .tone.challenging .dot { background: var(--bad); } .tone.mixed .dot { background: var(--mixed); }

/* ---------- Luopan ---------- */
.luopan { width: 100%; max-width: 440px; margin: 0 auto; display: block; }
.luopan .spin { transform-origin: 50% 50%; animation: settle 1.6s cubic-bezier(.2,.8,.2,1); }
@keyframes settle { from { transform: rotate(-40deg); opacity: 0; } }
.lp-text { font-family: var(--f-zh); fill: var(--ink); }
.dirlist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.dirlist div { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 8px; align-items: center; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--paper); font-size: .86rem; }
.dirlist .d { font-family: var(--f-display); font-weight: 700; font-size: 1.15rem; }
.dirlist .good { border-left: 3px solid var(--good); }
.dirlist .bad { border-left: 3px solid var(--bad); }
@media (max-width: 400px) { .dirlist { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Map ---------- */
.map { height: 420px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; background: var(--paper-2); position: relative; z-index: 1; }
@media (max-width: 640px) { .map { height: 340px; } }
.leaflet-container { font-family: var(--f-body); background: var(--paper-2); }
.map-compass { position: absolute; pointer-events: none; z-index: 450; }
.map-compass .handle { pointer-events: auto; cursor: grab; touch-action: none; }
.plan svg [data-h] { touch-action: none; }
.map-tools { position: absolute; top: 10px; right: 10px; z-index: 500; display: flex; gap: 6px; }
.map-tools button { background: var(--card); border: 1px solid var(--line-2); border-radius: 6px; padding: 6px 10px; font: inherit; font-size: .8rem; cursor: pointer; color: var(--ink); }
.map-tools button.on { background: var(--ink); color: var(--paper); }

/* ---------- Floor plan ---------- */
.plan { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-2); overflow: hidden; touch-action: none; user-select: none; }
.plan img { display: block; width: 100%; height: auto; }
.plan svg.overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.plan .drop { padding: 50px 20px; text-align: center; color: var(--muted); border: 2px dashed var(--line-2); border-radius: var(--radius); cursor: pointer; }
.plan .drop .zh { font-size: 3rem; display: block; color: var(--gold); }
.layers { display: flex; gap: 14px; flex-wrap: wrap; font-size: .86rem; }
.layers label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .hd { font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); text-align: center; padding: 4px 0; }
.cal button { border: 1px solid var(--line); background: var(--paper); border-radius: 6px; min-height: 74px; padding: 5px; text-align: left; font: inherit; color: var(--ink); cursor: pointer; display: flex; flex-direction: column; gap: 2px; position: relative; transition: transform .12s, border-color .12s; }
.cal button:hover { border-color: var(--gold); }
.cal button.sel { outline: 2px solid var(--ink); outline-offset: -1px; }
.cal button.cmp { outline: 2px dashed var(--gold); outline-offset: -1px; }
.cal .dn { font-family: var(--f-display); font-size: 1.15rem; font-weight: 600; line-height: 1; }
.cal .of { font-family: var(--f-zh); font-size: .9rem; }
.cal .pz { font-family: var(--f-zh); font-size: .66rem; color: var(--muted); }
.cal .mk { position: absolute; top: 5px; right: 5px; font-size: .7rem; font-weight: 700; }
.cal button.favourable { background: color-mix(in srgb, var(--good) 11%, var(--paper)); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.cal button.unfavourable { background: color-mix(in srgb, var(--bad) 7%, var(--paper)); }
.cal button.unfavourable .of { color: var(--bad); }
.cal button.favourable .of { color: var(--good); }
.cal button.out { visibility: hidden; }
@media (max-width: 560px) { .cal button { min-height: 58px; padding: 3px; } .cal .pz { display: none; } .cal .dn { font-size: .95rem; } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--line-2); }
.legend .g::before { background: color-mix(in srgb, var(--good) 25%, var(--paper)); }
.legend .b::before { background: color-mix(in srgb, var(--bad) 18%, var(--paper)); }

.timeline { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
.timeline > * { scroll-snap-align: start; }
.mcard { border: 1px solid var(--line); border-radius: 6px; padding: 12px; background: var(--paper); }
.mcard .mo { font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.mcard .zh { font-size: 1.6rem; font-weight: 600; }
.mcard.clash { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.mcard.harm { border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.days { display: grid; gap: 6px; }
.day { display: grid; grid-template-columns: 88px 54px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); font-size: .88rem; }
.day .dt { font-weight: 500; }
.day .zh { font-size: 1.15rem; }
@media (max-width: 560px) { .day { grid-template-columns: 70px 44px minmax(0, 1fr); } .day .chips { grid-column: 1 / -1; } }

/* ---------- AI reading ---------- */
.reading { position: relative; }
.reading .headline { font-family: var(--f-display); font-size: clamp(1.5rem, 3vw, 2rem); font-style: italic; line-height: 1.2; margin-bottom: 10px; }
.reading section { padding: 14px 0; border-top: 1px solid var(--line); }
.reading section h4 { font-family: var(--f-display); font-size: 1.2rem; margin-bottom: 6px; }
.reading .basis { font-size: .74rem; color: var(--muted); }
.reading ul { padding-left: 1.1em; margin: 0; }
.reading li { margin: 4px 0; }
.ai-badge { display: inline-flex; align-items: center; gap: 6px; font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.ai-badge::before { content: '筆'; font-family: var(--f-zh); font-size: .9rem; letter-spacing: 0; }
.skeleton { height: 14px; border-radius: 4px; background: linear-gradient(90deg, var(--paper-2), var(--card), var(--paper-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; margin: 10px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }
.inkload { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--jade); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.chat { display: flex; flex-direction: column; gap: 10px; }
.chat .msgs { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; }
.chat .m { padding: 10px 14px; border-radius: 12px; max-width: 88%; font-size: .93rem; white-space: pre-wrap; }
.chat .m.u { align-self: flex-end; background: var(--ink); color: var(--paper); border-bottom-right-radius: 4px; }
.chat .m.a { align-self: flex-start; background: var(--paper-2); border-bottom-left-radius: 4px; }
.chat form { display: flex; gap: 8px; }
.chat input { flex: 1; }
.suggest { display: flex; gap: 6px; flex-wrap: wrap; }
.suggest button { font: inherit; font-size: .8rem; border: 1px solid var(--line-2); background: var(--paper); color: var(--ink-2); border-radius: 999px; padding: 5px 11px; cursor: pointer; }
.suggest button:hover { border-color: var(--jade); color: var(--jade); }

/* ---------- Detail levels ---------- */
body.lv-simple .pro, body.lv-simple .detail { display: none !important; }
body.lv-detailed .pro { display: none !important; }

/* ---------- Toast & modal ---------- */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 11px 18px; border-radius: 999px; font-size: .9rem; z-index: 100; box-shadow: var(--shadow); animation: rise .25s; max-width: calc(100vw - 32px); }
@media (min-width: 821px) { .toast { bottom: 28px; } }
.modal { position: fixed; inset: 0; z-index: 90; background: rgba(20, 16, 10, .45); display: grid; place-items: center; padding: 16px; }
.modal .card { max-width: 460px; width: 100%; animation: rise .25s; }
.bigcode { font-family: var(--f-display); font-size: 2.6rem; letter-spacing: .12em; font-weight: 600; text-align: center; padding: 12px; border: 1px dashed var(--gold); border-radius: 8px; margin: 12px 0; font-variant-numeric: tabular-nums; }

/* ---------- Footer ---------- */
footer.foot { margin-top: 70px; padding: 34px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: .84rem; position: relative; z-index: 1; }
footer.foot .wrap { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 30px; }
@media (max-width: 720px) { footer.foot .wrap { grid-template-columns: minmax(0, 1fr); } }

.notice { border: 1px solid var(--line-2); border-left: 3px solid var(--gold); padding: 12px 14px; border-radius: 4px; background: var(--paper); font-size: .9rem; }
.notice.warn { border-left-color: var(--cinnabar); }
.empty-state { text-align: center; padding: 34px 16px; }
.empty-state .zh { font-size: 3.2rem; color: var(--gold); display: block; line-height: 1; margin-bottom: 10px; font-family: var(--f-brush); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .top, .tabbar, .no-print, footer.foot .grow, .map, .chat { display: none !important; }
  body { background: #fff; } body::before { display: none; } .card { box-shadow: none; break-inside: avoid; }
}
.legend.plain span::before { display: none; }
@media (max-width: 640px) {
  .hero .wrap { grid-template-columns: minmax(0, 1fr); }
  .hero .verse-wrap { position: absolute; top: -6px; right: 12px; opacity: .16; pointer-events: none; }
  .hero .verse { font-size: 3.2rem; }
  .hero .verse-wrap .seal { display: none; }
}
.top .wrap > .row { flex-wrap: nowrap; flex: none; }
@media (max-width: 1100px) { .top .wrap { gap: 12px; } .nav a { padding: 8px 8px; font-size: .88rem; } .wordmark { letter-spacing: .22em; } }
