/* Tử Vi · Bát Tự — the tool (after sign-in). Paint: the shared Terranimus tokens (tokens.css: paper, ink, clay,
   Newsreader, IBM Plex Sans; ui-tokens.css: the sign-in card). This file adds what carries meaning in a chart (the five
   elements, the Tứ Hóa badges, the tam phương tứ chính highlight) and the tool's layout.
   Redesign of 1 Nov 2026 (redesign-skill + ui-ux-pro-max + taste-skill house rules): one head per chart with its
   actions, the birth folded into a summary card, a sticky tab bar, the palace beside the chart on wide screens, tone
   steps instead of outlines, 44px targets, 16px+ text on phones, focus rings, reduced motion. */

body {
  --i-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8.5 6.5 12 13 4.5'/%3E%3C/svg%3E");
  --i-chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 6 8 10.5 12.5 6'/%3E%3C/svg%3E");
  --i-plus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M8 3.5v9M3.5 8h9'/%3E%3C/svg%3E");
  --i-minus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3.5 8h9'/%3E%3C/svg%3E");
  --paper-2: var(--paper-sunk);
  --ink-2: var(--ink-soft);
  --ink-3: color-mix(in oklab, var(--ink) 66%, var(--paper)); /* secondary text, >= 4.5:1 on paper */
  --son: var(--clay-fill);
  --focus: var(--clay-ink);
  --on-strong: #141110;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --head-h: 64px;
  /* Ngũ hành and Tứ Hóa, each >= 4.5:1 on the night panels (tuvi-theme.css) */
  --kim: #bcc5cf;
  --moc: #8bd394;
  --thuy: #98bdf2;
  --hoa: #f4968d;
  --tho: #e6bd6c;
  --loc: #8bd394;
  --quyen: #cfa3ec;
  --khoa: #98bdf2;
  --ky: #f4968d;
  --hl: color-mix(in oklab, var(--gold) 9%, var(--paper-sunk));
  --hl-self: color-mix(in oklab, var(--gold) 20%, var(--paper-sunk));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 124px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body { margin: 0; background: transparent; color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; } /* the night and its stars are drawn by tuvi-theme.css */
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.005em; margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
button, input, select { font: inherit; color: inherit; }
/* The parts the browser draws carry the palette too: selection, caret, scrollbars, native controls. */
::selection { background: color-mix(in oklab, var(--clay) 32%, var(--paper)); color: var(--ink); }
html { accent-color: var(--son); scrollbar-color: color-mix(in oklab, var(--ink) 26%, transparent) transparent; }
input, textarea { caret-color: var(--clay-ink); }
a { text-underline-offset: 3px; text-decoration-thickness: 1px; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 14px; }

/* ── Buttons: one primary (clay), one quiet (a tone step); both 44px ── */
.btn-primary, .btn-quiet, .go, .ghost {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: var(--radius-md); border: 0; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--dur-quick) var(--ease-out), transform var(--dur-quick) var(--ease-out), color var(--dur-quick);
}
.btn-primary, .go { background: var(--son); color: var(--on-clay); }
.btn-primary:hover, .go:hover { background: color-mix(in oklab, var(--son) 90%, white); }
.btn-primary, .go { border-radius: 999px; }
.btn-quiet, .ghost { background: var(--paper-sunk); color: var(--ink); }
.btn-quiet:hover, .ghost:hover { background: var(--paper-deep); }
.btn-primary:active, .btn-quiet:active, .go:active, .ghost:active { transform: scale(0.98); }
.go[aria-busy="true"] { opacity: 0.7; cursor: progress; }

/* ── Header: the wordmark (back to the first face) and the account menu ── */
.top { position: sticky; top: 0; z-index: 30; height: var(--head-h); background: color-mix(in oklab, var(--paper) 78%, transparent); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2); box-shadow: 0 1px 0 var(--rule); }
.top-in, .top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.top .account { margin-left: auto; }
.top .chua-btn { margin-right: auto; }
.top { padding: 0 max(var(--gutter), calc((100vw - 1320px) / 2)); }
.top .mark { font-family: var(--serif); font-weight: 700; font-size: 22px; color: var(--ink); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; letter-spacing: -0.01em; }
.account { position: relative; }
.acct-btn { appearance: none; display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 10px 4px 4px; border: 0; border-radius: 999px; background: var(--paper-sunk); cursor: pointer; max-width: 260px; transition: background var(--dur-quick); }
.acct-btn:hover { background: var(--paper-deep); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--clay-soft); color: var(--clay-ink); font-weight: 600; font-size: 15px; flex: none; }
.who { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; flex: none; }
.acct-menu { position: absolute; right: 0; top: calc(100% + 8px); width: min(360px, calc(100vw - 24px)); max-height: calc(100dvh - var(--head-h) - 24px); overflow-y: auto; scrollbar-width: none; padding: 14px; background: var(--paper); border-radius: var(--radius-lg); box-shadow: 0 0 0 1px var(--rule-strong), 0 24px 48px -12px #000; display: grid; gap: 6px; }
.acct-menu::-webkit-scrollbar { display: none; }
.am-who { display: flex; align-items: center; gap: 12px; padding: 4px 4px 10px; }
.am-avatar { width: 44px; height: 44px; font-size: 18px; }
.am-name { font-weight: 600; font-size: 16px; color: var(--ink); }
.am-who .acct-email { padding: 0; }
.am-k { margin-top: 8px; padding: 0 4px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.am-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.am-list li { display: flex; align-items: center; gap: 4px; }
.am-row { appearance: none; flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 8px; border: 0; border-radius: var(--radius-md); background: none; color: var(--ink); text-align: left; cursor: pointer; transition: background var(--dur-quick); }
.am-row:hover { background: var(--paper-sunk); }
.am-row[aria-current="true"] { background: var(--paper-sunk); }
.am-ini { width: 36px; height: 36px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--paper-deep); color: var(--gold); font-family: var(--serif); font-size: 18px; }
.am-txt { min-width: 0; display: grid; }
.am-txt b { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-txt small { font-size: 13px; color: var(--ink-3); }
.am-on { margin-left: auto; flex: none; font-size: 12px; font-weight: 600; color: var(--gold); }
.am-set { appearance: none; flex: none; min-height: 44px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink-3); font-size: 13px; font-weight: 600; cursor: pointer; opacity: 0; transition: opacity var(--dur-quick), color var(--dur-quick); }
.am-list li:hover .am-set, .am-set:focus-visible { opacity: 1; }
.am-set:hover { color: var(--gold); }
@media (hover: none) { .am-set { opacity: 1; } }
.am-none, .am-empty { padding: 4px 8px; }
.am-add { display: flex; align-items: center; gap: 10px; color: var(--gold); margin-top: 4px; }
.am-add .ico { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.am-foot { display: grid; gap: 2px; margin-top: 8px; padding-top: 8px; box-shadow: 0 -1px 0 var(--rule); }
.acct-email { padding: 8px 10px; font-size: 13px; color: var(--ink-3); overflow-wrap: anywhere; }
.menu-item { appearance: none; text-align: left; min-height: 44px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); background: none; cursor: pointer; font-weight: 500; }
.menu-item:hover { background: var(--paper-sunk); }

/* ── Layout: the side (birth and saved charts) and the result ── */
/* Wide screens: the chart takes the page; the side column (form, birth card, saved charts) opens when asked for. */
.layout { max-width: 1400px; margin: 0 auto; padding: 12px var(--gutter) 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; align-items: start; }
.layout.side-open { grid-template-columns: 320px minmax(0, 1fr); }
.side { display: none; gap: 16px; align-content: start; position: sticky; top: calc(var(--head-h) + 12px); max-height: calc(100vh - var(--head-h) - 24px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.layout.side-open .side { display: grid; }
.result, .side { min-width: 0; }
.result { container-type: inline-size; container-name: result; }
.empty { min-height: 280px; display: grid; align-content: center; gap: 8px; color: var(--ink-2); background: var(--paper-sunk); border-radius: var(--radius-lg); padding: 24px; }
.empty h2 { color: var(--ink); font-size: 1.4rem; }

/* The birth on screen, folded */
.birth-card { background: var(--paper-sunk); border-radius: 18px; padding: 18px 20px; display: grid; gap: 4px; box-shadow: inset 0 0 0 1px var(--rule); }
.bc-k { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.bc-date { font-family: var(--serif); font-weight: 600; font-size: 1.7rem; line-height: 1.2; font-variant-numeric: lining-nums tabular-nums; }
.bc-line { color: var(--ink-2); font-size: 15px; }
.bc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.bc-actions .btn-quiet { background: var(--paper); }
.bc-actions .btn-quiet:hover { background: var(--paper-deep); }

/* The form */
.form { background: var(--paper-sunk); border-radius: 18px; padding: 22px; display: grid; gap: 16px; box-shadow: inset 0 0 0 1px var(--rule); }
.form h2 { font-size: 1.6rem; font-weight: 600; }
fieldset { border: 0; margin: 0; padding: 0; }
legend, .label, .field > label { display: block; font-size: 14px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field { display: grid; gap: 6px; }
.field > label { margin: 0; }
input[type="date"], input[type="time"], input[type="search"], input[type="text"], input[type="number"], input:not([type]), select, .trio input, #place-q, .num, .save-form input {
  color: var(--ink);
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); background: var(--paper); font-size: 16px;
  transition: border-color var(--dur-quick);
}
/* iPhone and iPad Safari draw date and time inputs with their own width, height and centred text; these keep them the
   size of the other fields, left-aligned, and inside their column. */
input[type="date"], input[type="time"] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; color: var(--ink); line-height: 1.5; }
input[type="date"]::-webkit-date-and-time-value, input[type="time"]::-webkit-date-and-time-value { text-align: left; min-height: 1.5em; }
input:hover, select:hover { border-color: color-mix(in oklab, var(--ink) 40%, transparent); }
input:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); box-shadow: 0 0 0 4px color-mix(in oklab, var(--gold) 18%, transparent); }
.trio { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 6px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--paper); border-radius: var(--radius-md); }
.seg legend { grid-column: 1 / -1; padding: 0; margin-bottom: 6px; }
.seg label { display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: var(--radius-sm); cursor: pointer; font-size: 15px; font-weight: 500; color: var(--ink-2); transition: background var(--dur-quick), color var(--dur-quick); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--gold); color: var(--on-clay); font-weight: 600; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-2); min-height: 36px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--son); }
.advanced summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink-2); min-height: 44px; display: flex; align-items: center; gap: 10px; list-style: none; }
.advanced summary::-webkit-details-marker { display: none; }
/* A chevron says the line opens; it turns when open. */
.advanced summary::after { content: ''; width: 7px; height: 7px; margin-top: -4px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor; transform: rotate(45deg); transition: transform var(--dur-quick) var(--ease-out, ease); }
.advanced[open] summary::after { margin-top: 4px; transform: rotate(-135deg); }
.advanced summary:hover { color: var(--ink); }
.advanced[open] { display: grid; gap: 12px; }
.form-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.form-actions .go { width: 100%; font-size: 16px; min-height: 48px; }
.form-actions .btn-quiet { background: var(--paper); min-height: 48px; }
.form-actions:has(#cancel-edit[hidden]) { grid-template-columns: 1fr; }
.error { color: var(--danger-ink); font-size: 14px; background: color-mix(in oklab, var(--danger-ink) 9%, var(--paper)); border-radius: var(--radius-sm); padding: 8px 10px; }
.privacy { font-size: 13px; color: var(--ink-3); }

/* Birthplace search */
.place-field { position: relative; }
.place-list { position: absolute; z-index: 12; top: 78px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none; background: var(--paper); border: 1px solid var(--rule-strong); border-radius: var(--radius-md); max-height: 320px; overflow-y: auto; box-shadow: 0 12px 32px color-mix(in oklab, var(--ink) 12%, transparent); }
.place-list li { display: grid; gap: 0; padding: 8px 10px; min-height: 44px; border-radius: var(--radius-sm); cursor: pointer; }
.place-list li span { font-size: 12.5px; color: var(--ink-3); }
.place-list li[aria-selected="true"], .place-list li:hover { background: var(--paper-sunk); }
.place-list li.none { cursor: default; font-size: 14px; color: var(--ink-3); }
.place-tz { font-size: 13px; color: var(--ink-3); }

/* Saved charts */
.saved { display: grid; gap: 10px; }
.saved h2 { font-size: 1.15rem; padding: 0 4px; }
.saved-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 360px; overflow-y: auto; }
.saved-list li { display: flex; align-items: stretch; gap: 4px; border-radius: var(--radius-md); }
.saved-open { flex: 1; min-width: 0; min-height: 52px; display: grid; text-align: left; gap: 1px; padding: 8px 12px; border: 0; border-radius: var(--radius-md); background: var(--paper-sunk); cursor: pointer; transition: background var(--dur-quick); }
.saved-open:hover { background: var(--paper-deep); }
.saved-list li.on .saved-open { background: var(--hl-self); }
.saved-open b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-open span { font-size: 13px; color: var(--ink-3); }
.saved-del { appearance: none; min-width: 52px; min-height: 52px; border: 0; border-radius: var(--radius-md); background: var(--paper-sunk); color: var(--danger-ink); font-size: 14px; cursor: pointer; transition: background var(--dur-quick); }
.saved-del:hover { background: color-mix(in oklab, var(--danger-ink) 12%, var(--paper)); }
#saved-empty { padding: 0 4px; }

/* ── The result: head, save field, tabs ── */
.chart-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; padding: 4px 0 14px; }
.ch-text { display: grid; gap: 4px; min-width: 0; }
.ch-title { font-size: clamp(1.7rem, 1.3rem + 1.2vw, 2.4rem); font-weight: 600; line-height: 1.05; }
.ch-sub { color: var(--ink-2); font-size: 15px; font-variant-numeric: tabular-nums; }
.sample-note { font-size: 14px; color: var(--clay-ink); display: flex; gap: 8px; align-items: baseline; }
.sample-note::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--son); flex: none; transform: translateY(-1px); }
.ch-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.save-done { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border-radius: var(--radius-md); background: color-mix(in oklab, var(--loc) 12%, var(--paper)); color: var(--loc); font-weight: 600; font-size: 14px; }
.save-done::before { content: ''; width: 14px; height: 14px; flex: none; background: currentColor; -webkit-mask: var(--i-check) center / contain no-repeat; mask: var(--i-check) center / contain no-repeat; }
.save-bar { display: grid; gap: 8px; margin-bottom: 14px; padding: 14px 16px; background: var(--paper-sunk); border-radius: var(--radius-lg); }
.save-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.save-form label { font-size: 14px; font-weight: 600; color: var(--ink-2); width: 100%; }
.save-form input { flex: 1 1 220px; width: auto; }

.tabs-bar { position: sticky; top: var(--head-h); z-index: 20; padding: 8px 0 12px; margin-bottom: 4px; pointer-events: none; }
.tabs-bar > * { pointer-events: auto; }
.tabs { position: relative; display: flex; gap: 4px; padding: 4px; width: fit-content; max-width: 100%; overflow-x: auto; scrollbar-width: none; background: color-mix(in oklab, var(--paper-sunk) 86%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-radius: 999px; }
.tabs::before { content: ""; position: absolute; top: 4px; bottom: 4px; left: 0; width: var(--tw, 0px); transform: translateX(var(--tx, 0px)); border-radius: 999px; background: var(--gold); transition: transform 380ms var(--ease-out), width 380ms var(--ease-out); }
.tabs::-webkit-scrollbar { display: none; }
.tabs.more-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); }
.tabs.more-l { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent); }
.tabs.more-l.more-r { -webkit-mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent); }
.tabs button { position: relative; z-index: 1; appearance: none; background: none; border: 0; padding: 0 18px; min-height: 42px; cursor: pointer; color: var(--ink-2); font-weight: 600; font-size: 15px; white-space: nowrap; border-radius: 999px; transition: background var(--dur-quick), color 260ms var(--ease-out); }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--on-clay); background: var(--gold); border-radius: 999px; }
.tabs:not(.ind) button[aria-selected="true"] { background: var(--gold); }

/* ── Tử Vi ── */
.ziwei-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; margin-bottom: 6px; }
.school-field { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.school-field select { width: auto; min-width: 210px; font-weight: 500; color: var(--ink); }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--ink-2); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 40px; height: 24px; border-radius: 999px; background: var(--paper-deep); position: relative; transition: background var(--dur-quick); flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--paper); box-shadow: 0 1px 2px color-mix(in oklab, var(--ink) 30%, transparent); transition: transform var(--dur-quick) var(--ease-out); }
.switch input:checked + .track { background: var(--son); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
.school-note { font-size: 14px; color: var(--ink-3); margin-bottom: 14px; max-width: 72ch; }

.ziwei-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
@container result (min-width: 1040px) {
  .ziwei-grid { grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; }
}
.palace-side { display: grid; gap: 10px; }
@container result (min-width: 1040px) {
  .palace-side { align-self: start; }
}
.hint { font-size: 14px; color: var(--ink-3); background: var(--paper-sunk); border-radius: 18px; padding: 16px 18px; box-shadow: inset 0 0 0 1px var(--rule); }

/* The lá số: twelve palaces round the centre, 1px gaps of rule colour, tone steps for the highlight */
.chart-wrap { overflow-x: auto; padding: 26px 20px; margin: -26px -20px; }
.chart { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(168px, auto)); gap: 1px; background: color-mix(in oklab, var(--gold) 34%, transparent); border: 1px solid color-mix(in oklab, var(--gold) 55%, transparent); min-width: 340px; box-shadow: 0 0 0 5px color-mix(in oklab, var(--paper-sunk) 90%, transparent), 0 0 0 6px var(--rule), 0 40px 90px -40px #000; }
.palace { container-type: inline-size; position: relative; border: 0; padding: 9px 10px 28px; font-size: 13px; line-height: 1.35; cursor: pointer; background: color-mix(in oklab, var(--paper-sunk) 55%, var(--paper)); text-align: left; display: flex; flex-direction: column; gap: 4px; min-width: 0; color: var(--ink); transition: background var(--dur-quick); }
.palace:hover { background: var(--paper-deep); }
.palace.trine { background: var(--hl); }
.palace.selected { background: var(--hl-self); box-shadow: inset 0 0 0 2px var(--gold), inset 0 0 28px -6px color-mix(in oklab, var(--gold) 45%, transparent); }
.palace:focus-visible { outline-offset: -3px; }
.p-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.p-name { font-family: var(--serif); font-weight: 700; font-size: 18px; line-height: 1.1; }
.palace.soul .p-name { color: var(--gold); }
.p-body { font-family: var(--sans); font-size: 10.5px; font-weight: 700; color: var(--on-clay); background: var(--son); border-radius: 4px; padding: 1px 5px; margin-left: 6px; vertical-align: 2px; }
.p-gz { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.p-major { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.star-major { font-weight: 600; font-size: 15px; line-height: 1.25; }
.star-major .br { font-weight: 500; font-size: 11px; color: var(--ink-3); margin-left: 4px; letter-spacing: 0.02em; }
.p-empty { font-size: 13px; color: var(--ink-3); font-style: italic; }
.mut { display: inline-block; font-size: 10.5px; font-weight: 700; color: var(--on-strong); border-radius: 4px; padding: 0 5px; margin-left: 5px; vertical-align: 1px; line-height: 1.6; }
.mut.Lộc { background: var(--loc); } .mut.Quyền { background: var(--quyen); } .mut.Khoa { background: var(--khoa); } .mut.Kỵ { background: var(--ky); }
.p-minor { display: grid; grid-template-columns: 1fr 1fr; column-gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.p-adj { font-size: 11.5px; color: var(--ink-3); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.p-han { display: flex; flex-wrap: wrap; gap: 2px 6px; font-size: 11px; color: var(--ink-3); }
.p-han .on { color: var(--clay-ink); font-weight: 700; }
.p-han .flow { flex-basis: 100%; color: var(--quyen); }
.palace.han-year { box-shadow: inset 0 0 0 2px var(--son); }
.palace.han-decade .p-decade { color: var(--clay-ink); }
.p-foot { position: absolute; left: 10px; right: 10px; bottom: 6px; display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.p-decade { font-weight: 700; color: var(--ink-2); }
.p-foot .th { font-weight: 600; color: var(--ink-2); background: var(--paper-sunk); border-radius: 4px; padding: 0 6px; }
.palace.trine .p-foot .th, .palace.selected .p-foot .th { background: var(--paper); }
@container (max-width: 200px) {
  .p-head { flex-direction: column; align-items: flex-start; gap: 0; }
  .p-minor { grid-template-columns: 1fr; }
  .p-foot .ts { display: none; }
}
.el-Kim { color: var(--kim); } .el-Mộc { color: var(--moc); } .el-Thủy { color: var(--thuy); } .el-Hỏa { color: var(--hoa); } .el-Thổ { color: var(--tho); }

.center { position: relative; isolation: isolate; grid-column: 2 / 4; grid-row: 2 / 4; padding: 18px 22px; display: flex; flex-direction: column; justify-content: center; gap: 8px; background: linear-gradient(color-mix(in oklab, var(--paper) 84%, transparent), color-mix(in oklab, var(--paper) 84%, transparent)), url('/img/suzhou-pole-640.webp') center / cover, var(--paper); }
.center > :not(svg) { position: relative; z-index: 1; }
.center h3 { font-size: 1.75rem; font-weight: 600; text-align: center; margin-bottom: 6px; color: var(--gold); }
.center dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 14px; }
.center dt { color: var(--ink-3); }
.center dd { margin: 0; font-weight: 600; }

/* Tuần / Triệt: a seal on the chart's frame, across the wall between their two palaces */
.seal-mark { position: absolute; z-index: 2; width: max-content; height: max-content; align-self: start; justify-self: start; background: var(--son-red); color: oklch(0.97 0.01 85); font-size: 11px; font-weight: 700; line-height: 1.25; padding: 2px 8px; pointer-events: none; white-space: nowrap; border-radius: 4px; box-shadow: 0 4px 14px -4px color-mix(in oklab, var(--son-red) 70%, transparent); }
/* outside the frame, so no palace text is covered */
.seal-mark.top { transform: translate(-50%, -100%); border-radius: 4px 4px 0 0; }
.seal-mark.bottom { transform: translate(-50%, 0); border-radius: 0 0 4px 4px; }
.seal-mark.left, .seal-mark.right { writing-mode: vertical-rl; padding: 8px 2px; }
.seal-mark.left { transform: translate(-100%, -50%); border-radius: 4px 0 0 4px; }
.seal-mark.right { transform: translate(0, -50%); border-radius: 0 4px 4px 0; }

/* The legend: one quiet line of keys */
.legend { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 14px; font-size: 13px; color: var(--ink-2); }
.legend p { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.lg-h { font-weight: 600; color: var(--ink); margin-right: 2px; }
.term-link { appearance: none; background: none; border: 0; padding: 4px 2px; min-height: 32px; font: inherit; color: inherit; cursor: pointer; border-radius: 4px; text-decoration: none; transition: color var(--dur-quick), background var(--dur-quick); }
.term-link:hover { color: var(--clay-ink); text-decoration: underline; text-underline-offset: 3px; }
.legend .term-link b { font-weight: 700; color: var(--ink); margin-right: 2px; }

/* The palace in depth (views.js palaceDetail) */
.palace-detail { background: var(--paper-sunk); border-radius: 18px; padding: 20px; display: grid; gap: 10px; box-shadow: inset 0 0 0 1px var(--rule); }
.palace-detail h3 { font-size: 1.65rem; font-weight: 600; color: var(--gold); }
.palace-detail .lead { font-size: 15px; color: var(--ink-2); }
.palace-detail h4 { font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--ink-3); margin: 6px 0 0; letter-spacing: 0.01em; }
.palace-detail .term-link { color: var(--clay-ink); padding: 2px 0; min-height: 28px; }
.rel-grid { display: grid; grid-template-columns: max-content 1fr; align-items: baseline; gap: 4px 14px; margin: 0; font-size: 14px; }
.rel-grid dt { color: var(--ink-3); }
.rel-grid dt .term-link { color: var(--ink-3); }
.rel-grid dd { margin: 0; }
.star-d { background: var(--paper); border-radius: var(--radius-md); }
.star-d + .star-d { margin-top: 4px; }
.star-d summary { cursor: pointer; padding: 10px 12px; min-height: 44px; display: flex; align-items: center; gap: 6px; font-weight: 600; list-style: none; }
.star-d summary::-webkit-details-marker { display: none; }
.star-d summary::after { content: ''; margin-left: auto; width: 16px; height: 16px; flex: none; background: var(--ink-3); -webkit-mask: var(--i-chev) center / contain no-repeat; mask: var(--i-chev) center / contain no-repeat; transition: transform var(--dur-quick) var(--ease-out); }
.star-d[open] summary::after { transform: rotate(180deg); }
.star-d .grade { font-weight: 500; font-size: 13px; color: var(--ink-3); }
.star-body { padding: 0 12px 12px; display: grid; gap: 6px; font-size: 14px; }
.adj-list { display: flex; flex-wrap: wrap; gap: 0 12px; font-size: 14px; }
.sub { background: var(--paper); border-radius: var(--radius-md); padding: 12px 14px; display: grid; gap: 4px; }
.sub h4 { margin-top: 0; }
.flights { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }

/* ── Vận hạn ── */
.han-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 12px; margin-bottom: 14px; }
.han-bar .field { min-width: 200px; }
.han-when { font-size: 16px; color: var(--ink-2); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.han-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 12px; }
.han-cards > .han-when { grid-column: 1 / -1; }
.han-card { background: var(--paper-sunk); border-radius: var(--radius-lg); padding: 16px 18px; display: grid; gap: 8px; align-content: start; font-size: 16px; }
.han-card h4 { font-family: var(--serif); font-size: 1.2rem; font-weight: 500; display: flex; align-items: baseline; gap: 8px; }
.han-card .gz { font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--clay-ink); background: var(--paper); border-radius: 4px; padding: 1px 7px; }
.folk { margin-top: 16px; background: var(--paper-sunk); border-radius: var(--radius-lg); padding: 18px 20px; display: grid; gap: 10px; }
.folk h3 { font-size: 1.2rem; }
.folk dl { margin: 0; display: grid; }
.folk-row { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 14px; padding: 12px 0; font-size: 16px; }
.folk-row:first-child { border-top: 0; padding-top: 4px; }
.folk-row dt { font-weight: 600; }
.folk-row dd { margin: 0; }
.folk-row.bad dt { color: var(--ky); }
.folk-row.good dt { color: var(--loc); }
.folk-row .src summary { cursor: pointer; font-size: 13px; color: var(--ink-3); min-height: 32px; display: inline-flex; align-items: center; }

/* ── Xem ngày ── */
.day-card { background: var(--paper-sunk); border-radius: var(--radius-lg); padding: 18px 20px; display: grid; gap: 12px; }
.day-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.day-solar { font-family: var(--serif); font-size: 1.45rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.day-lunar { font-size: 14px; color: var(--ink-2); }
.verdict { font-weight: 700; font-size: 15px; padding: 8px 14px; border-radius: var(--radius-md); text-align: center; white-space: nowrap; }
.verdict small { display: block; font-weight: 500; font-size: 13px; }
.v4 { background: color-mix(in oklab, var(--loc) 30%, var(--paper)); }
.v3 { background: color-mix(in oklab, var(--loc) 14%, var(--paper)); }
.v2 { background: var(--paper); }
.v1 { background: color-mix(in oklab, var(--ky) 16%, var(--paper)); }
.day-facts { display: grid; grid-template-columns: max-content 1fr; align-items: baseline; gap: 6px 16px; margin: 0; font-size: 14px; }
.day-facts dt { color: var(--ink-3); }
.day-facts dd { margin: 0; }
.personal { font-size: 14px; background: var(--paper); border-radius: var(--radius-md); padding: 10px 12px; }
.reasons { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.reasons li { display: flex; gap: 8px; align-items: baseline; }
.reasons li::before { content: ''; flex: none; width: 14px; height: 14px; transform: translateY(2px); background: var(--loc); -webkit-mask: var(--i-plus) center / contain no-repeat; mask: var(--i-plus) center / contain no-repeat; }
.reasons li.bad::before { background: var(--ky); -webkit-mask-image: var(--i-minus); mask-image: var(--i-minus); }
.day-card h4 { font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--ink-3); }
.day-notes { margin: 0; padding-left: 18px; }
.month { margin-top: 18px; }
@container result (min-width: 1040px) {
  .ngay-lower { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 32px; align-items: start; }
  .ngay-lower .best-day { display: grid; grid-template-columns: max-content minmax(0, 1fr) auto; }
  .ngay-lower .best h3 { min-height: 44px; display: flex; align-items: center; margin-bottom: 10px; }
}
.month-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.month-head h3 { font-size: 1.2rem; }
.month-head .ghost { min-width: 44px; padding: 0; }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.month-grid .mh { font-size: 12px; color: var(--ink-3); text-align: center; padding: 2px 0; font-weight: 600; }
.md { position: relative; appearance: none; border: 0; border-radius: var(--radius-sm); min-height: 56px; padding: 6px 4px; display: grid; justify-items: center; align-content: center; cursor: pointer; font: inherit; color: var(--ink); transition: transform var(--dur-quick); }
.md:hover { transform: translateY(-1px); }
.md b { font-size: 15px; font-variant-numeric: tabular-nums; }
.md .ml { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.md .hd { position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--son); }
.md.on { box-shadow: inset 0 0 0 2px var(--ink); }
.md.xung b { text-decoration: line-through; text-decoration-color: var(--ky); }
.month-key { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 4px; font-size: 13px; color: var(--ink-2); }
.month-key span { display: inline-flex; align-items: center; gap: 6px; }
.month-key i { display: inline-block; width: 16px; height: 16px; border-radius: 4px; }
.month-key i.edge { box-shadow: inset 0 0 0 1px var(--rule-strong); }
.month-key .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--son); }
.best { margin-top: 18px; }
.best h3 { font-size: 1.2rem; margin-bottom: 10px; }
.best-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.best-day { width: 100%; appearance: none; border: 0; border-radius: var(--radius-md); background: var(--paper-sunk); padding: 12px 14px; min-height: 48px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; text-align: left; font: inherit; color: inherit; cursor: pointer; transition: background var(--dur-quick); }
.best-day:hover { background: var(--paper-deep); }
.best-day b { font-variant-numeric: tabular-nums; }
.best-day span { font-size: 14px; color: var(--ink-2); }
.verdict-s { margin-left: auto; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: var(--radius-sm); }

/* ── Bát Tự ── */
.pillars { display: grid; grid-template-columns: auto repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--rule-strong); border: 1px solid var(--rule-strong); border-radius: var(--radius-md); overflow: hidden; }
.pillars > div { padding: 10px 8px; background: var(--paper); text-align: center; display: flex; flex-direction: column; justify-content: center; min-height: 48px; }
.pillars .rowh { text-align: left; font-size: 13px; color: var(--ink-3); background: var(--paper-sunk); align-items: flex-start; font-weight: 600; }
.pillars .colh { font-family: var(--serif); font-size: 1.1rem; font-weight: 500; background: var(--paper-sunk); }
.pillars .god { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.pillars .glyph { font-family: var(--serif); font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.1rem); font-weight: 500; line-height: 1.1; }
.pillars .glyph small { display: block; font-family: var(--sans); font-size: 12px; color: var(--ink-3); font-weight: 400; }
.pillars .hidden-stems { font-size: 13px; gap: 2px; }
.pillars .napam { font-size: 13px; color: var(--ink-2); }
.pillars .daymaster { background: var(--hl); }
.pillars .none { color: var(--ink-3); font-size: 13px; }
.bazi-lower { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 14px; margin-top: 14px; }
.bazi-lower > section { background: var(--paper-sunk); border-radius: var(--radius-lg); padding: 18px 20px; }
.bazi-lower h3 { font-size: 1.15rem; margin-bottom: 10px; }
.bar { display: grid; grid-template-columns: 52px 1fr 24px; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 6px; }
.bar .track { height: 10px; background: var(--paper); border-radius: 6px; overflow: hidden; }
.bar .fill { display: block; height: 100%; border-radius: 6px; background: currentColor; }
.luck { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.luck li { background: var(--paper); padding: 10px; font-size: 13px; display: grid; gap: 2px; border-radius: var(--radius-sm); }
.luck li.now { background: var(--son); color: var(--on-clay); }
.luck li.now .yrs, .luck li.now * { color: var(--on-clay); }
.luck .gz { font-family: var(--serif); font-size: 1.15rem; }
.luck .yrs { color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ── Cách tính, Giải nghĩa ── */
.calc { background: var(--paper-sunk); border-radius: var(--radius-lg); padding: 20px; }
.calc dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.calc dt { color: var(--ink-3); }
.calc dd { margin: 0; }
.calc h3 { font-size: 1.15rem; margin: 18px 0 8px; }
.calc h3:first-child { margin-top: 0; }
.calc ul { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
.gloss-search { max-width: 440px; margin-bottom: 14px; }
.gloss { display: grid; gap: 18px; }
.gloss h3 { font-size: 1.2rem; margin-bottom: 8px; }
.gl { background: var(--paper-sunk); border-radius: var(--radius-md); }
.gl + .gl { margin-top: 4px; }
.gl summary { cursor: pointer; padding: 12px 14px; min-height: 48px; display: flex; align-items: center; gap: 6px; font-weight: 600; list-style: none; }
.gl summary::-webkit-details-marker { display: none; }
.gl summary::after { content: ''; margin-left: auto; width: 16px; height: 16px; flex: none; background: var(--ink-3); -webkit-mask: var(--i-chev) center / contain no-repeat; mask: var(--i-chev) center / contain no-repeat; transition: transform var(--dur-quick) var(--ease-out); }
.gl[open] summary::after { transform: rotate(180deg); }
.gl p { padding: 0 14px 12px; font-size: 14.5px; max-width: 75ch; }

.foot { max-width: 1400px; margin: 0 auto; padding: 0 var(--gutter) 32px; font-size: 13px; color: var(--ink-3); display: grid; gap: 4px; }
.foot a { color: inherit; }

@media (prefers-reduced-motion: no-preference) {
  .result:not([hidden]) .pillars { animation: rise 0.35s var(--ease-out); }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

/* ── Medium screens: one column; the palace under the chart ── */
.narrow-only { display: none; }
@media (min-width: 1100px) { .layout.side-open #edit-open { display: none; } }
/* Touch screens keep no hover: a tapped tab or day must not stay lit. */
@media (hover: none) {
  .tabs button:not([aria-selected="true"]):hover { color: var(--ink-2); }
  .md:hover { transform: none; }
}

@media (max-width: 1099px) {
  .narrow-only:not([hidden]) { display: inline-flex; }
  .birth-card { display: none !important; } /* the chart head carries the birth and its two actions */
  /* One column, in reading order: the birth (card or form), the result, the saved charts. */
  .layout, .layout.side-open { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .side, .layout.side-open .side { display: contents; }
  .birth-card, .form { order: 1; }
  .result { order: 2; }
  .saved { order: 3; }
  .wide-only { display: none !important; }
  .ziwei-grid { grid-template-columns: minmax(0, 1fr); }
  .palace-side { position: static; max-height: none; overflow: visible; }
  .bazi-lower { grid-template-columns: 1fr; }
  .saved-list { max-height: none; }
}

/* ── Phones: the chart keeps its 4×4 shape with the essentials; details open below ── */
@media (max-width: 640px) {
  body { --head-h: 56px; }
  .top .mark { font-size: 18px; }
  .who { display: none; }
  .acct-btn { padding: 4px; }
  .acct-btn .chev { display: none; }
  .layout { padding-top: 8px; }
  .ch-title { font-size: 1.8rem; }
  .ch-sub { font-size: 14px; }
  .ch-actions { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .ch-actions .btn-primary { grid-column: 1 / -1; }
  .ch-actions .save-done { justify-content: center; }
  .ch-actions .btn-quiet { padding: 0 8px; font-size: 14px; }
  .tabs-bar { margin: 0 calc(var(--gutter) * -1); padding: 6px var(--gutter) 10px; }
  .tabs { width: 100%; }
  .tabs button { padding: 0 14px; flex: none; }
  .ziwei-bar { gap: 4px 14px; }
  .school-field { width: 100%; justify-content: space-between; }
  .school-field select { min-width: 0; flex: 1; }
  .chart { grid-template-rows: repeat(4, minmax(104px, auto)); }
  .palace { padding: 5px 5px 20px; font-size: 11px; gap: 2px; }
  .p-head { flex-direction: column; align-items: flex-start; gap: 0; }
  .p-name { font-family: var(--sans); font-weight: 600; font-size: 12px; overflow-wrap: anywhere; }
  #print-chart { display: none; }
  .p-body { margin-left: 3px; font-size: 9.5px; padding: 0 3px; }
  .p-gz { font-size: 10px; }
  .chart-wrap { padding: 16px; margin: -16px; } /* room for the Tuần/Triệt seals on the frame (14px) */
  .seal-mark { font-size: 10px; padding: 1px 5px; }
  .seal-mark.left, .seal-mark.right { padding: 5px 0; width: 14px; text-align: center; }
  .star-major { font-size: 12.5px; line-height: 1.2; }
  .star-major .br, .p-minor, .p-adj, .p-han, .p-foot .ts { display: none; }
  .mut { font-size: 9.5px; padding: 0 3px; margin-left: 2px; }
  .p-foot { left: 5px; right: 5px; bottom: 3px; font-size: 10.5px; }
  .p-foot .th { padding: 0 4px; }
  .center { padding: 8px; gap: 4px; }
  .center h3 { font-size: 1.05rem; margin-bottom: 2px; }
  .center dl { font-size: 11.5px; gap: 1px 8px; }
  .center .opt { display: none; }
  .luck { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pillars > div { padding: 6px 3px; }
  .pillars .rowh { font-size: 11.5px; }
  .md { min-height: 48px; }
  .md .ml { font-size: 10px; }
  .day-facts, .rel-grid { grid-template-columns: 1fr; gap: 0; }
  .day-facts dt, .rel-grid dt { margin-top: 8px; }
  .folk-row { grid-template-columns: 1fr; gap: 4px; }
  .han-cards { grid-template-columns: 1fr; }
}

/* ── The night layer (1 Nov 2026): panels with a gold hairline, display type a size up (Cormorant runs small), and the
   tool's motion: palaces settle in clockwise, a chosen tab's pill slides, a panel rises as it opens, and the tam phương
   tứ chính of the chosen palace is drawn in the centre (app.js drawLinks). All motion stops for reduced motion. ── */
.han-card, .folk, .day-card, .bazi-lower > section, .calc, .save-bar, .empty { border-radius: 18px; }
.gl, .star-d, .sub, .best-day, .saved-open, .saved-del, .personal { box-shadow: inset 0 0 0 1px var(--rule); }
.han-card h4, .folk h3, .month-head h3, .best h3, .bazi-lower h3, .calc h3, .gloss h3, .saved h2 { font-size: 1.45rem; }
.day-solar { font-family: var(--serif); font-weight: 600; font-size: 1.8rem; font-variant-numeric: lining-nums tabular-nums; }
.han-card h4 { color: var(--gold); }
.pillars { box-shadow: 0 30px 70px -40px #000; border-color: color-mix(in oklab, var(--gold) 45%, transparent); background: color-mix(in oklab, var(--gold) 30%, transparent); }
.pillars .colh { font-weight: 600; font-size: 1.35rem; color: var(--gold); }
.pillars .glyph { font-weight: 600; }
.md.on { box-shadow: inset 0 0 0 2px var(--gold); }
.empty { background: var(--paper-sunk); }
.empty h2 { font-size: 1.8rem; color: var(--gold); }

/* Tam phương tứ chính: the chosen palace, its two tam hợp palaces (the triangle) and the one it faces (xung chiếu,
   dashed), joined where each palace meets the centre. */
.center svg.links { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; overflow: visible; }
.links .tri { fill: color-mix(in oklab, var(--gold) 6%, transparent); stroke: var(--gold); stroke-width: 1.3; stroke-linejoin: round; opacity: 0.5; }
.links .opp { stroke: var(--gold); stroke-width: 1.1; stroke-dasharray: 5 6; opacity: 0.4; }
.links circle { fill: var(--gold); }
.links circle.self { fill: var(--gold); stroke: color-mix(in oklab, var(--gold) 35%, transparent); stroke-width: 6; }

@media (prefers-reduced-motion: no-preference) {
  @keyframes p-in { from { opacity: 0; transform: translateY(6px) scale(0.985); } to { opacity: 1; transform: none; } }
  @keyframes panel-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  @keyframes draw { to { stroke-dashoffset: 0; } }
  @keyframes fade-in { from { opacity: 0; } }
  .chart .palace { animation: p-in 520ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 26ms); }
  .chart .center { animation: fade-in 700ms var(--ease-out) both 120ms; }
  [role="tabpanel"]:not([hidden]) { animation: panel-in 340ms var(--ease-out); }
  .palace-detail:not([hidden]) { animation: panel-in 340ms var(--ease-out); }
  .links.draw .tri { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 760ms var(--ease-out) forwards, fade-in 300ms both; }
  .links.draw .opp, .links.draw circle { animation: fade-in 500ms var(--ease-out) both 420ms; }
  .palace, .md, .best-day, .saved-open { transition: background var(--dur-quick), box-shadow 240ms var(--ease-out), transform var(--dur-quick); }
  .best-day:hover, .saved-open:hover { transform: translateX(2px); }
}
@media (prefers-reduced-motion: reduce) {
  .tabs::before { transition: none; }
}

/* ── Luận giải: the reading, set like an article in one readable column; each passage says what it rests on ── */
.luan { max-width: 760px; display: grid; gap: 8px; }
.luan-head { display: grid; gap: 10px; padding: 8px 0 18px; margin-bottom: 8px; }
.luan-head h2 { font-size: clamp(2rem, 1.5rem + 1.6vw, 2.8rem); color: var(--gold); line-height: 1.05; }
.luan-note { font-size: 14px; color: var(--ink-3); max-width: 64ch; }
.luan-toc { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.luan-toc a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--ink-2); text-decoration: none; box-shadow: inset 0 0 0 1px var(--rule-strong); transition: color var(--dur-quick), box-shadow var(--dur-quick); }
.luan-toc a:hover { color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.luan-s { padding: 20px 0 6px; scroll-margin-top: calc(var(--head-h) + 72px); }
.luan-s h3 { font-size: 1.75rem; margin-bottom: 10px; display: flex; align-items: center; gap: 12px; }
.luan-s h3::after { content: ''; flex: 1; height: 1px; background: linear-gradient(to right, var(--rule-strong), transparent); }
.luan-p { padding: 6px 0 14px; margin-bottom: 4px; }
.luan-p > p:first-child { font-size: 17px; line-height: 1.7; color: var(--ink); max-width: 66ch; }
.luan-why { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; margin-top: 6px; font-size: 13px; color: var(--ink-3); }
.luan-why .term-link { min-height: 28px; padding: 2px 0; color: var(--gold); text-decoration: underline; text-decoration-color: color-mix(in oklab, var(--gold) 40%, transparent); text-underline-offset: 3px; }
#luan-close .luan-p > p:first-child { font-family: var(--serif); font-size: 1.35rem; line-height: 1.45; }
.luan-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 24px; font-size: 14px; color: var(--ink-3); }

/* The readings under the Tử Vi chart and the Bát Tự table: set apart from the data above by a rule and some air. */
#luan-ziwei-box:not(:empty), #luan-bazi-box:not(:empty), #luan-num-box:not(:empty) { margin-top: 40px; padding-top: 8px; }
.luan-more { margin-top: 14px; font-size: 15px; color: var(--ink-2); }
.link-btn { appearance: none; background: none; border: 0; padding: 0; font: inherit; color: var(--gold); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 32px; }

/* ── Thần số học: the number cards and the birth chart ── */
.num-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; }
.num-card { display: grid; gap: 2px; padding: 16px 18px; border-radius: 18px; background: var(--paper-sunk); box-shadow: inset 0 0 0 1px var(--rule); }
.num-card b { font-family: var(--serif); font-size: 2.6rem; font-weight: 600; line-height: 1; color: var(--ink); font-variant-numeric: lining-nums; }
.num-card span { font-weight: 600; font-size: 15px; }
.num-card small { font-size: 13px; color: var(--ink-3); }
.num-card.main { background: color-mix(in oklab, var(--gold) 14%, var(--paper-sunk)); box-shadow: none; }
.num-card.main b { color: var(--gold); font-size: 3.2rem; }
.num-lower { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 24px; margin-top: 20px; align-items: start; }
.bc { background: var(--paper-sunk); border-radius: 18px; padding: 18px; box-shadow: inset 0 0 0 1px var(--rule); display: grid; gap: 12px; }
.bc h3 { font-size: 1.45rem; }
.bc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; aspect-ratio: 1; }
.bc-cell { position: relative; display: grid; place-items: center; border-radius: 12px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--rule); }
.bc-cell span { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; letter-spacing: 0.04em; color: var(--gold); font-variant-numeric: lining-nums; }
.bc-cell i { position: absolute; left: 8px; top: 6px; font-style: normal; font-size: 12px; color: var(--ink-3); }
.bc-cell.on { background: color-mix(in oklab, var(--gold) 12%, var(--paper)); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--gold) 50%, transparent); }
.num-name { display: grid; gap: 6px; background: var(--paper-sunk); border-radius: 18px; padding: 18px; box-shadow: inset 0 0 0 1px var(--rule); }
.num-name label { font-weight: 600; font-size: 15px; }
.num-name-row { display: flex; flex-wrap: wrap; gap: 8px; }
.num-name-row input { flex: 1 1 220px; width: auto; min-height: 46px; padding: 10px 12px; border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); background: var(--paper); font-size: 16px; color: var(--ink); }
@media (max-width: 640px) {
  .num-lower { grid-template-columns: 1fr; }
  .num-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .num-card b { font-size: 2.2rem; } .num-card.main b { font-size: 2.6rem; }
}
@media (prefers-reduced-motion: no-preference) {
  @keyframes num-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
  .num-card { animation: num-in 480ms var(--ease-out) both; }
  .num-card:nth-child(2) { animation-delay: 60ms; } .num-card:nth-child(3) { animation-delay: 120ms; } .num-card:nth-child(4) { animation-delay: 180ms; }
  .bc-cell.on span { animation: num-in 520ms var(--ease-out) both 200ms; }
}

/* ── Hỏi thêm về lá số: the floating button and its panel (AI coming soon) ── */
.ask-fab { position: fixed; z-index: 40; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); display: inline-flex; align-items: center; gap: 8px; min-height: 48px; max-width: calc(100vw - 36px); padding: 0 20px 0 16px; border: 0; border-radius: 999px; background: var(--gold); color: var(--on-clay); font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; box-shadow: 0 10px 24px -12px #000; transition: transform var(--dur-quick) var(--ease-out), box-shadow var(--dur-base); }
.ask-fab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ask-fab:hover { transform: translateY(-2px); }
.ask-fab:active { transform: scale(0.97); }
.ask-fab .ico { width: 18px; height: 18px; }
.ask-soon { font-size: 14px; color: var(--ink-2); background: color-mix(in oklab, var(--gold) 10%, var(--paper)); border-radius: 14px; padding: 12px 14px; box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--gold) 40%, transparent); }
.ask-soon b { color: var(--gold); }
.ask-k { margin: 16px 0 8px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.ask-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ask-chip { appearance: none; border: 0; border-radius: 999px; padding: 8px 14px; min-height: 40px; background: var(--paper); color: var(--ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer; transition: box-shadow var(--dur-quick), color var(--dur-quick); }
.ask-chip:hover { box-shadow: inset 0 0 0 1px var(--gold); color: var(--gold); }
.ask-log { display: grid; gap: 10px; margin: 16px 0; }
.ask-me { justify-self: end; max-width: 86%; padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: var(--paper-deep); font-size: 15px; }
.ask-ai { max-width: 92%; padding: 12px 14px; border-radius: 16px 16px 16px 4px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--rule); font-size: 15px; line-height: 1.6; color: var(--ink-2); }
.ask-form { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 12px 0 4px; background: var(--paper-sunk); }
.ask-form input { flex: 1; min-height: 48px; padding: 10px 14px; border: 1px solid var(--rule-strong); border-radius: 999px; background: var(--paper); font-size: 16px; color: var(--ink); }
.ask-form .btn-primary { min-width: 48px; padding: 0; }
.ask-fine { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }
.ask-modes { margin-top: 4px; }
.ask-modes legend { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.ask-modes label { flex-direction: column; min-height: 52px; gap: 0; line-height: 1.2; }
.ask-modes label span { display: grid; justify-items: center; gap: 2px; }
.ask-modes small { font-size: 12px; font-weight: 400; opacity: 0.85; }
.ask-ai p + p { margin-top: 8px; }
.ask-ai b { color: var(--ink); }
.ask-ai.err { box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--danger-ink) 50%, transparent); }
.ask-meta { margin-top: 10px; font-size: 12.5px; color: var(--ink-3); }
@media (prefers-reduced-motion: no-preference) {
  @keyframes ask-dots { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
  .ask-ai.typing > p:last-child::after { content: ' ●'; color: var(--gold); animation: ask-dots 900ms ease-in-out infinite; }
}
@media print { .ask-fab { display: none !important; } }
@media (max-width: 640px) {
  .ask-fab { right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); min-height: 46px; padding: 0 16px 0 14px; }
  /* The floating button never covers the last controls of the page. */
  #app { padding-bottom: 84px; }
  /* Phones: the suggestions are one row you swipe, so the answer gets the screen. */
  .ask-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -22px; padding: 2px 22px 6px; scroll-snap-type: x proximity; }
  .ask-chips::-webkit-scrollbar { display: none; }
  .ask-chip { flex: none; scroll-snap-align: start; white-space: nowrap; }
  .ask-sheet .ask-soon { font-size: 13.5px; }
  .ask-sheet.asked .ask-soon, .ask-sheet.asked .ask-modes legend { display: none; }
  .ask-me, .ask-ai { font-size: 15.5px; }
  .ask-form { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: no-preference) {
  @keyframes fab-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
  .ask-fab:not([hidden]) { animation: fab-in 420ms var(--ease-out) 300ms both; }
  .ask-me, .ask-ai { animation: panel-in 300ms var(--ease-out); }
}

/* ── Tra một từ: a sheet over the page (a side panel on wide screens, a bottom sheet on phones) ── */
.gloss-sheet { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(480px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh; padding: 0 22px 28px; border: 0; background: var(--paper-sunk); color: var(--ink); box-shadow: -1px 0 0 var(--rule-strong), -30px 0 80px -20px #000; overflow-y: auto; overscroll-behavior: contain; }
.gloss-sheet::backdrop { background: color-mix(in oklab, var(--night) 55%, transparent); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.gs-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0 12px; background: var(--paper-sunk); }
.gs-head h2 { font-size: 1.8rem; color: var(--gold); }
.gs-close { appearance: none; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--paper); color: var(--ink); cursor: pointer; box-shadow: inset 0 0 0 1px var(--rule); }
.gs-close:hover { box-shadow: inset 0 0 0 1px var(--gold); color: var(--gold); }
.gloss-sheet .gloss-search { margin-bottom: 14px; }
.gloss-sheet .gl { background: var(--paper); }
@media (max-width: 640px) {
  .gloss-sheet { inset: auto 0 0 0; width: 100vw; height: 86dvh; border-radius: 22px 22px 0 0; box-shadow: 0 -1px 0 var(--rule-strong), 0 -30px 80px -20px #000; }
  .luan-p > p:first-child { font-size: 16px; }
  .luan-s h3 { font-size: 1.55rem; }
}
@media (prefers-reduced-motion: no-preference) {
  @keyframes sheet-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  @keyframes sheet-up { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
  .gloss-sheet[open] { animation: sheet-in 320ms var(--ease-out); }
  .luan-s { animation: panel-in 420ms var(--ease-out) both; }
  .luan-s:nth-of-type(2) { animation-delay: 60ms; } .luan-s:nth-of-type(3) { animation-delay: 120ms; } .luan-s:nth-of-type(4) { animation-delay: 180ms; }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 640px) {
  .gloss-sheet[open] { animation: sheet-up 320ms var(--ease-out); }
}

/* ── The one sign-in (ui-tokens.css draws the card; this is its content) ── */
.auth-side p { max-width: 38ch; font-size: var(--t-lead); line-height: 1.45; }
.auth-choices h2 { font-size: var(--t-h3); }
.auth-lead { color: var(--ink-2); font-size: 15px; margin-bottom: 4px; }
.auth-provider { justify-content: center; font-weight: 600; }
.auth-provider:hover { border-color: var(--ink-2); }
.auth-email { display: grid; gap: 8px; }
.auth-email label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.auth-email input { padding: 8px 12px; border: 1px solid var(--rule-strong); background: var(--paper); color: var(--ink); }
.auth-email button { border: 0; background: var(--clay-fill); color: var(--on-clay); font-weight: 600; cursor: pointer; }

/* ── Print: the chart and its explanation, nothing else ── */
@media print {
  #landing, .top, .side, .save-bar, .sample-note, .ziwei-bar, .school-note, .tabs-bar, .ch-actions, .hint, .foot, #empty, .legend { display: none !important; }
  [role="tabpanel"]:not(#pane-ziwei) { display: none !important; }
  body { background: #fff; color: #000; }
  .layout { display: block; padding: 0; max-width: none; }
  .ziwei-grid { display: block; }
  .palace-side { position: static; max-height: none; overflow: visible; margin-top: 16px; }
  .chart-wrap { overflow: visible; margin: 0; padding: 12px; }
  .chart, .palace, .star-d { break-inside: avoid; }
}

/* Bài luận tổng hợp (pane-luan): the AI's one-piece reading, above the rule-by-rule sections. */
.compose { max-width: 760px; display: grid; gap: 10px; padding: 4px 0 22px; margin-bottom: 14px;  }
.compose h2 { font-size: clamp(1.7rem, 1.3rem + 1.2vw, 2.3rem); color: var(--gold); line-height: 1.1; }
.compose-note { font-size: 14px; color: var(--ink-3); max-width: 64ch; }
.compose-body { display: grid; gap: 12px; font-size: 17px; line-height: 1.7; color: var(--ink); max-width: 68ch; }
.compose-body b { color: var(--ink); font-weight: 600; }
.compose-body h3, .ask-ai h3 { font-family: var(--serif); color: var(--gold); font-size: 1.35em; line-height: 1.25; margin: 14px 0 0; }
.compose-body h3:first-child, .ask-ai h3:first-child { margin-top: 0; }
.compose-body ul, .ask-ai ul { margin: 0; padding-left: 1.2em; display: grid; gap: 8px; }
.compose-body li::marker, .ask-ai li::marker { color: var(--gold); }
.ask-ai h3 { font-size: 1.1em; }
.ask-ai ul + p, .ask-ai p + ul, .ask-ai h3 + p, .ask-ai h3 + ul { margin-top: 6px; }
.compose-cut { font-size: 14px; color: var(--ink-3); font-style: italic; }
.compose-wait { color: var(--ink-3); animation: compose-pulse 1.6s ease-in-out infinite; }
@keyframes compose-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .compose-wait { animation: none; } }
@media (max-width: 600px) { .compose-body { font-size: 16px; } }

/* Hợp tuổi (pane-hop): a short form for the second person, then the reading of the two together. */
.hop-form { max-width: 560px; display: grid; gap: 14px; }
.hop-form h2 { font-size: clamp(1.7rem, 1.3rem + 1.2vw, 2.3rem); color: var(--gold); line-height: 1.1; }
.hop-lead { font-size: 15px; color: var(--ink-3); }
.hop-result { max-width: 760px; display: grid; gap: 12px; margin-top: 24px; padding-top: 22px;  }
.hop-head { --tone: var(--gold); display: flex; align-items: center; gap: 18px; }
.hop-head.good { --tone: color-mix(in oklab, var(--gold) 55%, #6fbf8f); }
.hop-head.hard { --tone: oklch(0.7 0.15 12); }
.hop-ring { --p: 0; position: relative; flex: none; width: 84px; height: 84px; border-radius: 50%; display: grid; place-content: center; text-align: center; background: conic-gradient(var(--tone) calc(var(--p) * 1%), color-mix(in oklab, var(--ink) 12%, transparent) 0); }
.hop-ring::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--paper); }
.hop-ring b, .hop-ring small { position: relative; display: block; }
.hop-ring b { font-family: var(--serif); font-size: 28px; line-height: 1; color: var(--tone); font-variant-numeric: lining-nums tabular-nums; }
.hop-ring small { font-size: 11px; color: var(--ink-3); }
.hop-verdict { font-family: var(--serif); font-size: 26px; line-height: 1.15; color: var(--tone); }
.hop-rel { font-size: 14px; color: var(--ink-3); }
.hop-summary { font-size: 17px; line-height: 1.65; color: var(--ink); max-width: 66ch; }
.hop-result h3 { margin-top: 8px; font-size: 16px; font-weight: 600; color: var(--ink-3); }
.hop-signs, .hop-advice { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.hop-signs li { padding: 12px 14px; border-radius: 12px; background: var(--paper); font-size: 15.5px; line-height: 1.6; color: var(--ink-2); }
.hop-signs li b { display: block; margin-bottom: 2px; color: var(--ink); font-weight: 600; }
.hop-signs.good li { box-shadow: inset 0 0 0 1px color-mix(in oklab, #6fbf8f 40%, transparent); }
.hop-signs.hard li { box-shadow: inset 0 0 0 1px color-mix(in oklab, oklch(0.7 0.15 12) 55%, transparent); }
.hop-basis { display: block; margin-top: 4px; font-size: 13px; color: var(--ink-3); }
.hop-advice li { position: relative; padding-left: 18px; font-size: 15.5px; line-height: 1.6; color: var(--ink-2); }
.hop-advice li::before { content: ''; position: absolute; left: 2px; top: .7em; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.hop-note { font-size: 13.5px; color: var(--ink-3); }
@media (max-width: 600px) { .hop-ring { width: 72px; height: 72px; } .hop-verdict { font-size: 22px; } }

/* ── Hôm nay (pane-today): the person's day first. One focal element (the score), then the week, then three cards. ── */
.td { --good: color-mix(in oklab, var(--gold) 55%, #6fbf8f); --hard: oklch(0.7 0.15 12); display: grid; gap: 18px; max-width: 760px; }
.td-hero { display: grid; gap: 12px; }
.td-top h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(2rem, 1.5rem + 2vw, 2.8rem); line-height: 1.05; color: var(--ink); text-wrap: balance; }
.td-date { font-size: 15px; color: var(--ink-3); margin-top: 4px; }
.td-wait { color: var(--ink-3); }
.td-score { --tone: var(--gold); display: flex; align-items: center; gap: 16px; }
.td-score.good { --tone: var(--good); }
.td-score.hard { --tone: var(--hard); }
.td-ring { --p: 0; position: relative; flex: none; width: 88px; height: 88px; border-radius: 50%; display: grid; place-content: center; text-align: center; background: conic-gradient(var(--tone) calc(var(--p) * 1%), color-mix(in oklab, var(--ink) 12%, transparent) 0); }
.td-ring::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--paper); }
.td-ring b, .td-ring small { position: relative; display: block; }
.td-ring b { font-family: var(--serif); font-size: 32px; line-height: 1; color: var(--tone); font-variant-numeric: lining-nums tabular-nums; }
.td-ring small { font-size: 11px; color: var(--ink-3); }
.td-verdict { font-family: var(--serif); font-size: 28px; line-height: 1.1; color: var(--tone); }
.td-why { font-size: 15px; color: var(--ink-2); }
.td-note { padding: 10px 14px; border-radius: 12px; background: var(--paper-sunk); font-size: 15.5px; color: var(--ink); }
.td-note.good { box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--good) 45%, transparent); }
.td-note.hard { box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--hard) 55%, transparent); }
.td-k { font-size: 13px; font-weight: 600; letter-spacing: .04em; color: var(--ink-3); margin-top: 2px; }
.td-hours { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.td-hours li { padding: 5px 11px; border-radius: 999px; font-size: 14px; color: var(--ink); background: var(--paper-deep); }
.td-hours li span { color: var(--ink-3); }
.td-do { font-size: 15.5px; color: var(--ink-2); }
.td-do b { color: var(--good); font-weight: 600; margin-right: 4px; }
.td-do.no b { color: var(--hard); }
.td-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.td-day { --tone: var(--gold); display: grid; justify-items: center; gap: 2px; min-height: 64px; padding: 8px 0 6px; border: 0; border-radius: 12px; background: var(--paper-sunk); color: var(--ink-2); font: inherit; cursor: pointer; transition: box-shadow var(--dur-quick), background var(--dur-quick), transform 120ms var(--ease-out); }
.td-day.good { --tone: var(--good); }
.td-day.hard { --tone: var(--hard); }
.td-day span { font-size: 12px; color: var(--ink-3); }
.td-day b { font-size: 17px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.td-day i { font-style: normal; font-size: 11.5px; font-weight: 600; color: var(--tone); }
.td-day:hover { box-shadow: inset 0 0 0 1px var(--rule-strong); }
.td-day:active { transform: scale(.97); }
.td-day[aria-selected="true"] { background: color-mix(in oklab, var(--gold) 14%, var(--paper-sunk)); box-shadow: inset 0 0 0 1.5px var(--gold); }
.td-day:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.td-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.td-card { display: grid; align-content: start; gap: 8px; padding: 16px; border-radius: 14px; background: var(--paper-sunk); }
.td-card h3 { font-family: var(--serif); font-size: 22px; font-weight: 600; color: var(--gold); line-height: 1.15; }
.td-card p { font-size: 15.5px; color: var(--ink-2); }
.td-card p.td-lead { color: var(--ink); }
.td-card p.td-lead.good { color: color-mix(in oklab, var(--good) 70%, var(--ink)); }
.td-card p.td-lead.hard { color: color-mix(in oklab, var(--hard) 70%, var(--ink)); }
.td-checks { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 15px; color: var(--ink-2); }
.td-checks li { display: flex; align-items: baseline; gap: 8px; }
.td-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--good); transform: translateY(-1px); }
.td-checks li.hard .td-dot { background: var(--hard); }
.td-more { justify-self: start; min-height: 44px; padding: 0 2px; border: 0; background: none; color: var(--gold); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: underline; text-decoration-color: color-mix(in oklab, var(--gold) 45%, transparent); text-underline-offset: 5px; }
.td-more:hover { text-decoration-color: var(--gold); }
.td-acts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.td-act { display: grid; gap: 2px; justify-items: start; text-align: left; min-height: 64px; padding: 12px 14px; border: 0; border-radius: 14px; background: var(--paper-sunk); color: var(--ink); font: inherit; cursor: pointer; transition: box-shadow var(--dur-quick), transform 120ms var(--ease-out); }
.td-act b { font-weight: 600; font-size: 16px; }
.td-act span { font-size: 13.5px; color: var(--ink-3); }
.td-act:hover { box-shadow: inset 0 0 0 1px var(--gold); }
.td-act:active { transform: scale(.98); }
.td-act:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (min-width: 900px) { .td-acts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* The chart's options (school, vận hạn overlay) fold away: most people never change them. */
.ziwei-opts { margin-bottom: 12px; }
.ziwei-opts > summary { display: inline-flex; align-items: center; min-height: 44px; font-size: 15px; font-weight: 500; color: var(--ink-2); cursor: pointer; list-style: none; }
.ziwei-opts > summary::-webkit-details-marker { display: none; }
.ziwei-opts > summary::after { content: ""; width: 7px; height: 7px; margin-left: 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform var(--dur-quick); }
.ziwei-opts[open] > summary::after { transform: translateY(2px) rotate(-135deg); }

/* ── Phone: the five daily places at the thumb; the top tab row gives way to them. ── */
.bnav { display: none; }
.more-sheet { width: min(520px, calc(100vw - 24px)); margin: auto auto 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); border: 0; border-radius: 20px 20px 0 0; background: var(--paper-sunk); color: var(--ink); box-shadow: 0 -10px 40px -10px #000; }
.more-sheet::backdrop { background: color-mix(in oklab, #000 55%, transparent); }
.more-sheet h2 { font-family: var(--serif); font-size: 24px; color: var(--gold); margin-bottom: 10px; }
.more-list { display: grid; gap: 8px; margin-bottom: 12px; }
.more-list button { display: grid; gap: 1px; text-align: left; min-height: 56px; padding: 10px 14px; border: 0; border-radius: 12px; background: var(--paper); color: var(--ink); font: inherit; cursor: pointer; }
.more-list button b { font-weight: 600; }
.more-list button span { font-size: 13.5px; color: var(--ink-3); }
.more-list button:active { transform: scale(.99); }
@media (max-width: 760px) {
  .bnav:not([hidden]) { position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in oklab, var(--paper) 96%, transparent); box-shadow: 0 -1px 0 var(--rule); }
  .bnav button { display: grid; justify-items: center; gap: 3px; min-height: 52px; padding: 4px 0; border: 0; background: none; color: var(--ink-3); font: inherit; font-size: 11.5px; font-weight: 500; cursor: pointer; border-radius: 12px; }
  .bnav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
  .bnav button[aria-current="page"] { color: var(--gold); }
  .bnav button[aria-current="page"] svg { stroke-width: 1.8; }
  .bnav button:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
  body:has(.bnav:not([hidden])) .tabs-bar { display: none; }
  body:has(.bnav:not([hidden])) #app { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  body:has(.bnav:not([hidden])) .ask-fab { bottom: calc(76px + env(safe-area-inset-bottom)); min-height: 44px; padding: 0 16px 0 12px; font-size: 14px; }
  /* The chart's centre keeps to its square on a phone. */
  .center { padding: 8px 10px; gap: 3px; overflow: hidden; }
  .center h3 { font-size: 1.05rem; margin-bottom: 2px; }
  .center dl { font-size: 10.5px; gap: 1px 6px; line-height: 1.35; }
  .center p { font-size: 10.5px; line-height: 1.35; }
  .td-ring { width: 76px; height: 76px; }
  .td-ring b { font-size: 28px; }
  .td-verdict { font-size: 24px; }
}
.td-k { font-family: var(--sans); }
body.on-today .ask-fab, body.on-tool .ask-fab { display: none; }

/* Round 2: who the day is for, the chart-type segment, the sub tabs that left the row. */
.td-who { display: grid; gap: 8px; }
.td-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--gutter, 16px) * -1); padding: 2px var(--gutter, 16px); }
.td-chips::-webkit-scrollbar { display: none; }
.td-chip { flex: none; min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--paper-deep); color: var(--ink-2); font: inherit; font-size: 14.5px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: box-shadow var(--dur-quick), color var(--dur-quick); }
.td-chip small { color: var(--ink-3); font-size: 12.5px; }
.td-chip[aria-pressed="true"] { color: var(--on-clay); background: var(--gold); box-shadow: none; }
.td-chip[aria-pressed="true"] small { color: inherit; opacity: .75; }
.td-chip:focus-visible, .td-mine:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.td-mine { justify-self: start; min-height: 40px; padding: 0 2px; border: 0; background: none; color: var(--gold); font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 5px; text-decoration-color: color-mix(in oklab, var(--gold) 45%, transparent); }
@media (max-width: 760px) { .wide-only { display: none !important; } }
@media (max-width: 760px) { body:has(.td-chip) #saved-open { display: none; } .ch-actions { gap: 8px; } }

/* Vận hạn in plain words: the conclusion first, then what goes well and what to watch, the basis folded. */
.han-lead { font-size: 17px; color: var(--ink); }
.han-points { display: grid; gap: 8px; margin: 6px 0 0; padding: 0; list-style: none; }
.han-points li { display: flex; align-items: baseline; gap: 10px; font-size: 15.5px; color: var(--ink-2); }
.han-points li .td-dot { background: color-mix(in oklab, var(--gold) 55%, #6fbf8f); }
.han-points li.hard .td-dot { background: oklch(0.7 0.15 12); }
.han-basis { margin-top: 6px; }
.han-basis > summary { min-height: 40px; display: inline-flex; align-items: center; font-size: 14px; color: var(--ink-3); cursor: pointer; }
.folk-verdict { font-size: 17px; color: var(--ink); margin: 4px 0 10px; }

.day-more { margin-top: 10px; }
.day-more > summary { display: inline-flex; align-items: center; min-height: 44px; font-size: 15px; font-weight: 500; color: var(--ink-2); cursor: pointer; }

.bazi-tech { margin-top: 18px; }
.bazi-tech > summary { display: inline-flex; align-items: center; min-height: 44px; font-size: 15px; font-weight: 500; color: var(--ink-2); cursor: pointer; margin-bottom: 8px; }

/* After the inspector: readable measure everywhere, room before each heading, the period card's dates on their own line. */
#app p, #app li, #app dd { max-width: 70ch; }
.luan-s h3, .luan h3 { margin-top: 28px; }
.han-card h4 { flex-wrap: wrap; }
.han-card h4 .gz { flex-basis: 100%; background: none; padding: 0; font-size: 14px; font-weight: 500; color: var(--ink-3); font-family: var(--sans); }
.day-facts, .reasons, .day-lunar, .day-solar { font-size: 16px; }
@media (max-width: 900px) {
  .bnav:not([hidden]) { position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in oklab, var(--paper) 96%, transparent); box-shadow: 0 -1px 0 var(--rule); }
  .bnav button { display: grid; justify-items: center; gap: 3px; min-height: 52px; padding: 4px 0; border: 0; background: none; color: var(--ink-3); font: inherit; font-size: 11.5px; font-weight: 500; cursor: pointer; border-radius: 12px; }
  .bnav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
  .bnav button[aria-current="page"] { color: var(--gold); }
  body:has(.bnav:not([hidden])) .tabs-bar { display: none; }
  body:has(.bnav:not([hidden])) #app { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  body:has(.bnav:not([hidden])) .ask-fab { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
.p-gz, .p-minor, .seal, .tuan, .triet, .p-han { color: var(--ink-2); }
.han-sub { margin-top: -4px; font-size: 14px; color: var(--ink-3); }
.ask-keep { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; color: var(--ink-2); min-height: 44px; }
.ask-keep small { flex-basis: 100%; padding-left: 26px; font-size: 13px; color: var(--ink-3); }

/* Cách tính: one fixed line under every tab (owner, 2 Nov 2026: "chú thích tổng quan ở 1 chỗ cố định") */
.calc-line { margin-top: 40px; max-width: 72ch; font-size: 14px; line-height: 1.6; color: var(--ink-3); }
.link-btn { appearance: none; padding: 0; border: 0; background: none; color: var(--gold); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 24px; }
.link-btn:hover { color: var(--ink); }
#calc-sheet .calc { background: none; padding: 0; }

/* Bát Tự and Thần số on wide screens: the chart on the left, its reading beside it, like Tử Vi. */
@container result (min-width: 1040px) {
  #pane-bazi:not([hidden]), #pane-num:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 40px; align-items: start; }
  #pane-num:not([hidden]) > #num-box, #pane-bazi:not([hidden]) > .bazi-chart { min-width: 0; }
  #pane-bazi .bazi-lower, #pane-num .num-lower { grid-template-columns: 1fr; }
}
.pillars .about { font-size: 13px; line-height: 1.35; color: var(--ink-3); padding: 6px 4px; }
.pillars .about.daymaster { color: var(--gold); }
.bc-grid { max-width: 360px; }
@container result (min-width: 1040px) {
  #pane-bazi .luan-head, #pane-num .luan-head { padding-top: 0; }
}
/* Phones: the eight characters with what each pillar is about; the hidden stems and nạp âm stay on wider screens */
@media (max-width: 600px) { .pillars .tech { display: none; } }

/* Vào Chùa: the one gold button beside the logo, on the landing and in the app (owner, 2 Nov 2026: "to đẹp nổi bật") */
.chua-btn { flex: none; display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 22px 0 16px; margin-left: 18px; border-radius: 999px; background: var(--gold); color: #1d1405; font-family: var(--sans); font-weight: 700; font-size: 16px; letter-spacing: 0.01em; text-decoration: none; white-space: nowrap; transition: transform var(--dur-quick) var(--ease-out), background var(--dur-quick); }
.chua-btn:hover { background: color-mix(in oklab, var(--gold) 88%, #fff); transform: translateY(-1px); }
.chua-btn:active { transform: translateY(1px); }
.chua-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.chua-ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transform-origin: 50% 80%; animation: chua-breathe 3.6s var(--ease-out) infinite; }
@keyframes chua-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .chua-ico { animation: none; } }
@media (max-width: 600px) { .chua-btn { min-height: 42px; padding: 0 14px 0 11px; margin-left: 10px; font-size: 14.5px; gap: 7px; } .chua-ico { width: 19px; height: 19px; } }
@media (max-width: 360px) { .chua-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } .chua-btn { padding: 0 11px; } }

/* Round 2 (owner, 2 Nov 2026): every chart first, its reading underneath; no empty right half on wide screens. */
@container result (min-width: 1040px) {
  #pane-bazi:not([hidden]), #pane-num:not([hidden]) { display: block; }
  .ziwei-grid { grid-template-columns: minmax(0, 1fr); }
  .ziwei-main { max-width: 1080px; }
  .palace-side { max-width: 1080px; }
  .palace-detail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 28px; align-items: start; }
  .palace-detail > h3, .palace-detail > .lead, .palace-detail > .pd-note { grid-column: 1 / -1; }
  .bazi-chart { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .bazi-chart .bazi-lower { display: grid; gap: 16px; }
  .luan { max-width: none; }
  .luan-head { max-width: 76ch; }
  .luan-s { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; align-items: start; }
  .luan-s > h3 { grid-column: 1 / -1; }
  .luan-s .luan-p { padding: 18px 20px; border-radius: var(--radius-md); background: color-mix(in oklab, var(--paper-sunk) 70%, transparent); margin: 0; }
  .luan-s .luan-p > p:first-child { max-width: none; }
  /* Luận giải: the composed piece on top, the general reading under it (owner, 2 Nov 2026: "tách trên dưới thay vì song song") */
  #pane-luan .compose { max-width: none; margin: 0 0 36px; }
  #pane-luan .compose-body { max-width: none; column-count: 2; column-gap: 48px; display: block; }
  #pane-luan .compose-body > * { break-inside: avoid; margin-bottom: 12px; }
  #pane-luan .compose-body h3 { break-after: avoid; }
}

/* One place for each thing (owner, 2 Nov 2026: "Lá số đã lưu" and the birth card repeated the header and the profile panel):
   the saved charts live in the profile panel, the birth is edited from "Sửa thông tin"; the side column is only the form. */
#birth-card, #saved, #saved-open { display: none !important; }
.am-del { appearance: none; flex: none; width: 40px; min-height: 44px; display: grid; place-items: center; border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink-3); cursor: pointer; opacity: 0; transition: opacity var(--dur-quick), color var(--dur-quick); }
.am-del .ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.am-list li:hover .am-del, .am-del:focus-visible { opacity: 1; }
.am-del:hover { color: var(--ky, #e06c75); }
@media (hover: none) { .am-del { opacity: 1; } }
.td-chip { display: inline-flex; align-items: center; gap: 8px; }
.td-ini { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 8px; background: color-mix(in oklab, var(--ink) 10%, transparent); font-size: 12px; font-weight: 700; }
.td-chip[aria-pressed="true"] .td-ini { background: color-mix(in oklab, #000 14%, transparent); }

/* ── Gieo quẻ (owner, 2 Nov 2026). One focal motion: the coins' flip. ── */
.que-ask { display: grid; gap: 16px; max-width: 760px; }
.que-ask h2 { font-size: clamp(2rem, 1.5rem + 1.6vw, 2.8rem); color: var(--gold); line-height: 1.05; }
.que-lead { font-size: 17px; color: var(--ink-2); max-width: 60ch; }
.que-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px 16px; }
@media (max-width: 640px) { .que-form { grid-template-columns: minmax(0, 1fr); } }
.que-toss, .que-time { display: grid; gap: 16px; justify-items: start; padding: 22px; border-radius: var(--radius-lg); background: var(--paper-sunk); }
.coins { display: flex; gap: 18px; perspective: 600px; min-height: 72px; align-items: center; }
.coin { position: relative; width: 64px; height: 64px; border-radius: 50%; background: color-mix(in oklab, var(--gold) 35%, var(--paper-deep)); transform-style: preserve-3d; }
.coin::after { content: ''; position: absolute; inset: 24px; border-radius: 3px; background: var(--paper-sunk); }
.coin.up { background: var(--gold); }
.coin.down { background: color-mix(in oklab, var(--gold) 38%, #3a2a18); }
.coin.spin { animation: coin-flip 620ms var(--ease-out); }
@keyframes coin-flip { from { transform: rotateY(0) translateY(0); } 40% { transform: rotateY(540deg) translateY(-18px); } to { transform: rotateY(720deg) translateY(0); } }
@media (prefers-reduced-motion: reduce) { .coin.spin { animation: none; } }
.que-built { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; min-width: min(320px, 100%); }
.que-built li { display: flex; align-items: center; gap: 14px; font-size: 15px; color: var(--ink-2); }
.que-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }
.que-howto { max-width: 60ch; }

/* A line of a hexagram: one bar (dương) or two (âm); a moving line in gold with its mark. */
.yao { display: inline-flex; gap: 10px; width: 84px; height: 12px; flex: none; position: relative; }
.yao i { flex: 1; border-radius: 3px; background: var(--ink-2); }
.yao.mov i { background: var(--gold); }
.yao.mov::after { position: absolute; right: -22px; top: -5px; font-size: 15px; line-height: 1; color: var(--gold); }
.yao.yang.mov::after { content: '○'; }
.yao.yin.mov::after { content: '×'; }
.hexfig { display: grid; gap: 8px; padding: 6px 26px 6px 0; }
.hexfig .yao { width: 96px; height: 14px; }

.que-result { display: grid; gap: 22px; margin-top: 28px; max-width: 980px; }
.qr-head { display: flex; flex-wrap: wrap; gap: 24px 32px; align-items: center; padding: 24px; border-radius: var(--radius-lg); background: var(--paper-sunk); }
.qr-figs { display: flex; align-items: center; gap: 14px; }
.qr-arrow { font-size: 24px; color: var(--ink-3); }
.qr-names { display: grid; gap: 6px; min-width: 0; }
.qr-k { font-size: 14px; color: var(--ink-3); }
.qr-names h3 { font-size: clamp(1.6rem, 1.3rem + 1vw, 2.2rem); line-height: 1.1; }
.qr-names h3 small { font-size: 0.6em; color: var(--ink-3); font-family: var(--sans); }
.qr-bien { font-size: 16px; color: var(--ink-2); }
.qr-verdict { justify-self: start; margin-top: 4px; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 16px; background: color-mix(in oklab, var(--gold) 22%, transparent); color: var(--gold); }
.qr-verdict.good { background: color-mix(in oklab, var(--loc) 22%, transparent); color: var(--loc); }
.qr-verdict.hard { background: color-mix(in oklab, var(--ky) 22%, transparent); color: var(--ky); }
.qr-answer { display: grid; gap: 12px; max-width: 72ch; }
.qr-viec { font-size: 18px; line-height: 1.6; color: var(--ink); }
.qr-answer .reasons { font-size: 16px; gap: 8px; }
.qr-shi { font-size: 16px; color: var(--ink-2); }
.qr-text, .qr-moving, .qr-bien-s { display: grid; gap: 10px; max-width: 72ch; }
.qr-text h4, .qr-moving h4, .qr-bien-s h4 { font-family: var(--serif); font-size: 1.5rem; color: var(--gold); }
.qr-text p, .qr-moving p, .qr-bien-s p { font-size: 16px; line-height: 1.7; }
.qr-tuong { color: var(--ink-2); }
.qr-text blockquote { margin: 0; padding: 14px 18px; border-radius: var(--radius-md); background: var(--paper-sunk); }
.qr-text blockquote p { font-family: var(--serif); font-size: 1.25rem; line-height: 1.5; }
.qr-text blockquote footer { margin-top: 6px; font-size: 15px; color: var(--ink-3); }
.qr-tho { font-family: var(--serif); font-style: italic; font-size: 1.15rem; line-height: 1.6; color: var(--ink-2); }
.qr-hao { padding: 12px 0; display: grid; gap: 4px; }
.qr-hao-k { font-weight: 700; color: var(--gold); }
.qr-hao-y { color: var(--ink-2); }
.qr-han { font-size: 14px; color: var(--ink-3); }
.qr-tech summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.qr-tech > p { margin: 8px 0; }
.qr-table-wrap { overflow-x: auto; }
.qr-table { border-collapse: collapse; font-size: 14px; min-width: 640px; }
.qr-table th, .qr-table td { padding: 8px 10px; text-align: left; vertical-align: middle; white-space: nowrap; }
.qr-table th { color: var(--ink-3); font-weight: 600; }
.qr-table tbody tr:nth-child(odd) { background: color-mix(in oklab, var(--paper-sunk) 70%, transparent); }
.qr-table tr.mov td { color: var(--gold); }
.qr-table .yao { width: 64px; height: 10px; }

/* ── Giờ xuất hành ── */
.xh { display: grid; gap: 14px; margin-top: 18px; padding: 20px 22px; border-radius: var(--radius-lg); background: var(--paper-sunk); scroll-margin-top: calc(var(--head-h) + 72px); }
.xh h3 { font-family: var(--serif); font-size: 1.6rem; color: var(--gold); }
.xh-lead { font-size: 16px; color: var(--ink-2); }
.xh-hours { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.xh-hours li { display: grid; gap: 2px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--paper); }
.xh-hours li b { font-size: 16px; }
.xh-hours li.good { background: color-mix(in oklab, var(--loc) 16%, var(--paper)); }
.xh-hours li.good .xh-s { color: var(--loc); font-weight: 700; }
.xh-hours li.bad .xh-s { color: var(--ink-3); }
.xh-r, .xh-hours small { font-size: 13px; color: var(--ink-3); }
.xh-dirs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 16px; }
.xh-dirs li { display: grid; gap: 2px; }
.xh-dirs b { font-size: 15px; }
.xh-dirs span { font-size: 17px; color: var(--gold); font-weight: 600; }
.xh-dirs small { font-size: 13px; color: var(--ink-3); }
.xh-more summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.xh-more dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 6px 0; font-size: 15px; }
.xh-more dt.good { color: var(--loc); font-weight: 700; }
.xh-more dt.bad { color: var(--ink-3); font-weight: 700; }
.xh-more dd { margin: 0; }
.td-xh li span { color: var(--loc); }
.td-dirs { font-size: 15px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }

/* ── Grouped navigation (preview, ?nav=rail): a rail on wide screens, the same groups in the phone's sheet ── */
.rail { display: none; }
body.nav-rail .tabs-bar { display: none; }
@media (min-width: 1100px) {
  body.nav-rail .layout { grid-template-columns: 220px minmax(0, 1fr); }
  body.nav-rail .layout.side-open { grid-template-columns: 220px 320px minmax(0, 1fr); }
  body.nav-rail .rail { display: grid; gap: 18px; align-content: start; position: sticky; top: calc(var(--head-h) + 12px); padding: 6px 0 24px; }
}
.nav-g ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-gt { padding: 0 12px 6px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.rail-i, .more-i { appearance: none; width: 100%; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 12px; background: none; color: var(--ink-2); font: inherit; font-size: 15px; font-weight: 600; text-align: left; cursor: pointer; transition: background var(--dur-quick), color var(--dur-quick); }
.rail-i svg, .more-i svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.rail-i:hover, .more-i:hover { background: var(--paper-sunk); color: var(--ink); }
.rail-i[aria-current="page"], .more-i[aria-current="page"] { background: color-mix(in oklab, var(--gold) 18%, var(--paper-sunk)); color: var(--gold); }
.rail-i:focus-visible, .more-i:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.rail-i.soon, .more-i.soon { cursor: default; color: var(--ink-3); }
.rail-i.soon small, .more-i.soon small { margin-left: auto; font-size: 12px; font-weight: 500; }
.rail-i.soon:hover, .more-i.soon:hover { background: none; color: var(--ink-3); }
.more-groups { display: grid; gap: 14px; margin-bottom: 12px; max-height: min(70dvh, 560px); overflow-y: auto; scrollbar-width: none; }
.more-groups .more-i { min-height: 48px; background: var(--paper); }
.more-groups .nav-g ul { gap: 6px; }
/* Below the rail's width the grouped list is the phone and tablet way: the bottom bar and its sheet. */
@media (min-width: 761px) and (max-width: 1099px) {
  body.nav-rail .bnav:not([hidden]) { position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in oklab, var(--paper) 96%, transparent); box-shadow: 0 -1px 0 var(--rule); }
  body.nav-rail .bnav button { display: grid; justify-items: center; gap: 3px; min-height: 52px; padding: 4px 0; border: 0; background: none; color: var(--ink-3); font: inherit; font-size: 11.5px; font-weight: 500; cursor: pointer; border-radius: 12px; }
  body.nav-rail .bnav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
  body.nav-rail .bnav button[aria-current="page"] { color: var(--gold); }
  body.nav-rail .bnav button[aria-current="page"] svg { stroke-width: 1.8; }
  body.nav-rail .bnav button:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
  body.nav-rail:has(.bnav:not([hidden])) .tabs-bar { display: none; }
  body.nav-rail:has(.bnav:not([hidden])) #app { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  body.nav-rail:has(.bnav:not([hidden])) .ask-fab { bottom: calc(76px + env(safe-area-inset-bottom)); min-height: 44px; padding: 0 16px 0 12px; font-size: 14px; }
  /* The chart's centre keeps to its square on a phone. */
  body.nav-rail .center { padding: 8px 10px; gap: 3px; overflow: hidden; }
  body.nav-rail .center h3 { font-size: 1.05rem; margin-bottom: 2px; }
  body.nav-rail .center dl { font-size: 10.5px; gap: 1px 6px; line-height: 1.35; }
  body.nav-rail .center p { font-size: 10.5px; line-height: 1.35; }
  body.nav-rail .td-ring { width: 76px; height: 76px; }
  body.nav-rail .td-ring b { font-size: 28px; }
  body.nav-rail .td-verdict { font-size: 24px; }
}
.more-groups .nav-g ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.more-groups .nav-g:first-child ul { grid-template-columns: minmax(0, 1fr); }

/* ── Phong thủy (owner, 2 Nov 2026) ── */
#pane-phong { display: grid; gap: 28px; max-width: 1080px; }
#pane-phong[hidden] { display: none; }
.ft-head h2 { font-size: clamp(2rem, 1.5rem + 1.6vw, 2.8rem); color: var(--gold); line-height: 1.05; }
.ft-lead { margin-top: 8px; font-size: 17px; color: var(--ink-2); max-width: 64ch; }
.ft-sec { display: grid; gap: 14px; }
.ft-sec h3 { font-family: var(--serif); font-size: 1.7rem; color: var(--gold); }
.ft-sec h4 { font-family: var(--serif); font-size: 1.35rem; margin-top: 6px; }
.ft-p { font-size: 16px; line-height: 1.65; max-width: 72ch; }
.ft-me-grid { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 24px 32px; align-items: start; }
@media (max-width: 760px) { .ft-me-grid { grid-template-columns: minmax(0, 1fr); } }
.compass { width: 100%; max-width: 340px; height: auto; justify-self: center; }
.cw { stroke: var(--paper); stroke-width: 2; }
.cw.good { fill: color-mix(in oklab, var(--loc) 34%, var(--paper-sunk)); }
.cw.good.r1 { fill: color-mix(in oklab, var(--loc) 55%, var(--paper-sunk)); }
.cw.bad { fill: color-mix(in oklab, var(--ky) 22%, var(--paper-sunk)); }
.cw.bad.r8 { fill: color-mix(in oklab, var(--ky) 40%, var(--paper-sunk)); }
.cw-star { fill: var(--ink); font-size: 12.5px; font-weight: 700; font-family: var(--sans); }
.cw-dir { fill: var(--ink-2); font-size: 13px; font-weight: 600; font-family: var(--sans); }
.cw-hub { fill: var(--paper); }
.cw-c { fill: var(--gold); font-size: 15px; font-weight: 700; font-family: var(--serif); }
.ft-dirs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ft-dirs li, .ft-colors li { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--paper-sunk); }
.ft-dirs li b, .ft-colors li b { font-size: 16px; }
.ft-dirs li span, .ft-colors li span { font-weight: 600; }
.ft-dirs li small, .ft-colors li small { grid-column: 1 / -1; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); }
.ft-dirs li.good span, .ft-colors li.good span { color: var(--loc); }
.ft-dirs li.bad span, .ft-colors li.bad span { color: var(--ky); }
.ft-colors { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; }
.ft-more summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.ft-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 320px)); gap: 12px 16px; }
.ft-verdict { display: grid; gap: 4px; padding: 14px 16px; border-radius: var(--radius-md); background: var(--paper-sunk); font-size: 16px; line-height: 1.55; }
.ft-verdict b { font-size: 18px; }
.ft-verdict.good b { color: var(--loc); }
.ft-verdict.mid b { color: var(--gold); }
.ft-verdict small { color: var(--ink-2); font-size: 14.5px; }
.fs-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; max-width: 520px; }
.fs-cell { position: relative; display: grid; grid-template-columns: 1fr 1fr; align-items: center; min-height: 104px; padding: 26px 12px 10px; border-radius: 12px; background: var(--paper-sunk); text-align: center; }
.fs-cell.face { box-shadow: inset 0 0 0 2px var(--gold); }
.fs-d { position: absolute; top: 6px; left: 0; right: 0; font-size: 12.5px; color: var(--ink-3); }
.fs-ms, .fs-ws { font-family: var(--serif); font-size: 1.9rem; line-height: 1; }
.fs-ms { color: var(--ink); }
.fs-ws { color: var(--gold); }
.fs-p { grid-column: 1 / -1; font-size: 13px; color: var(--ink-3); }
.fs-cell .fs-n { grid-column: 1 / -1; font-family: var(--serif); font-size: 2rem; line-height: 1; }
.fs-cell .fs-name { grid-column: 1 / -1; font-size: 13px; color: var(--ink-2); }
.fs-cell.good .fs-n { color: var(--loc); }
.fs-cell.bad .fs-n { color: var(--ky); }
.ft-note { max-width: 72ch; }
.fs-cell.warn { box-shadow: inset 0 0 0 2px var(--ky); }

/* La bàn 24 sơn */
.lb { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 20px 32px; align-items: center; padding: 18px; border-radius: var(--radius-lg); background: var(--paper-sunk); }
@media (max-width: 760px) { .lb { grid-template-columns: minmax(0, 1fr); } }
.lb-dial-wrap { position: relative; width: 100%; max-width: 360px; aspect-ratio: 1; justify-self: center; }
.lb-dial { width: 100%; height: 100%; transform: rotate(var(--rot, 0deg)); }
.lb-dial svg { width: 100%; height: 100%; display: block; }
.lb-needle { position: absolute; left: 50%; top: 1%; width: 1.5px; height: 49%; margin-left: -0.75px; background: color-mix(in oklab, var(--ky) 55%, transparent); pointer-events: none; }
.lb-needle::before { content: ''; position: absolute; left: 50%; top: -14px; margin-left: -9px; border-left: 9px solid transparent; border-right: 9px solid transparent; border-top: 14px solid var(--ky); }
.lb-dial-wrap { margin-top: 14px; }
.lb-r0 { fill: color-mix(in oklab, var(--gold) 10%, var(--paper)); }
.lb-r1 { fill: color-mix(in oklab, var(--gold) 16%, var(--paper)); }
.lb-r2 { fill: var(--paper); }
.lb-r3 { fill: color-mix(in oklab, var(--gold) 12%, var(--paper)); }
.lb-t { stroke: var(--ink-3); stroke-width: 1; }
.lb-t.big { stroke: var(--gold); stroke-width: 2; }
.lb-sep { stroke: color-mix(in oklab, var(--gold) 40%, transparent); stroke-width: 1; }
.lb-m { fill: var(--ink-2); font-size: 12px; font-weight: 600; font-family: var(--sans); }
.lb-m.br { fill: var(--ink); font-weight: 800; }
.lb-g { fill: var(--gold); font-size: 14px; font-weight: 700; font-family: var(--serif); }
.lb-n { fill: var(--ky); font-size: 13px; font-weight: 800; font-family: var(--sans); }
.lb-hub { fill: var(--gold); }
.lb-side { display: grid; gap: 12px; }
.lb-read { font-size: 20px; }
.lb-read b { color: var(--gold); }
.lb-actions { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.lb-manual { display: flex; align-items: center; gap: 12px; font-size: 15px; color: var(--ink-2); }
.lb-manual input { flex: 1; min-height: 44px; accent-color: var(--gold); }

/* Gieo quẻ as at the temple: the censer and its smoke (the page's one ambient motion), and the keo âm dương */
.que-altar { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 8px 24px; align-items: center; }
@media (max-width: 640px) { .que-altar { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; } }
.censer { width: 200px; height: auto; overflow: visible; }
.cz-body, .cz-handle, .cz-leg { fill: color-mix(in oklab, var(--gold) 72%, #6b4a1c); }
.cz-rim { fill: color-mix(in oklab, var(--gold) 82%, #fff); }
.cz-band { fill: color-mix(in oklab, var(--gold) 45%, #3a2a12); }
.cz-ash { fill: color-mix(in oklab, var(--paper-deep) 70%, #8a8070); }
.stick { stroke: #b0412e; stroke-width: 2.4; stroke-linecap: round; }
.ember { fill: #ff8a4c; }
.smoke { fill: none; stroke: color-mix(in oklab, var(--ink) 55%, transparent); stroke-width: 2.2; stroke-linecap: round; opacity: 0; animation: smoke-rise 5.5s ease-out infinite; }
.smoke.s2 { animation-delay: 1.8s; }
.smoke.s3 { animation-delay: 3.6s; }
@keyframes smoke-rise { 0% { opacity: 0; transform: translateY(14px) scaleX(0.8); } 25% { opacity: 0.55; } 100% { opacity: 0; transform: translateY(-26px) scaleX(1.25); } }
@media (prefers-reduced-motion: reduce) { .smoke { animation: none; opacity: 0.35; } }
.que-keo { display: grid; gap: 16px; justify-items: center; padding: 24px 18px; border-radius: var(--radius-lg); background: var(--paper-sunk); text-align: center; }
.que-keo-lead { font-size: 17px; max-width: 52ch; }
.keos { display: flex; gap: 22px; perspective: 600px; min-height: 120px; align-items: center; }
.keo { position: relative; width: 52px; height: 108px; border-radius: 50% / 46%; background: #9b1c1c; transform: rotate(-14deg); }
.keo + .keo { transform: rotate(14deg); }
.keo.sap { background: #8f1818; }
.keo.sap::after { content: ''; position: absolute; inset: 14px 12px 40px 16px; border-radius: 50%; background: color-mix(in oklab, #ff9a8a 45%, transparent); }
.keo.ngua { background: #c9a26a; box-shadow: inset 0 0 0 5px #8f1818; }
.keo.spin { animation: keo-flip 850ms var(--ease-out); }
@keyframes keo-flip { 0% { transform: translateY(0) rotateX(0); } 45% { transform: translateY(-60px) rotateX(540deg); } 100% { transform: translateY(0) rotateX(720deg); } }
@media (prefers-reduced-motion: reduce) { .keo.spin { animation: none; } }
.que-keo-res { min-height: 1.6em; font-size: 17px; max-width: 56ch; }
.que-keo-res .good { color: var(--loc); }
.que-keo-res .bad { color: var(--ky); }

/* Tử Vi trọn đời: one long piece under the two columns of Luận giải, at full width, kept for the chart */
.lifetime { display: grid; gap: 12px; margin: 36px 0 0; padding: 24px 26px; border-radius: var(--radius-lg); background: color-mix(in oklab, var(--gold) 9%, var(--paper-sunk)); }
.lifetime .btn-primary { min-height: 52px; padding: 0 28px; font-size: 16px; }
@media (max-width: 600px) { .lifetime { padding: 18px 16px; } .lifetime .btn-primary { justify-self: stretch; } }
.lifetime h2 { font-size: clamp(1.8rem, 1.4rem + 1.2vw, 2.4rem); color: var(--gold); line-height: 1.1; }
.lifetime .btn-primary { justify-self: start; }
.lifetime .compose-body { max-width: 76ch; }
@container result (min-width: 1040px) {
  .lifetime .compose-body { max-width: none; column-count: 2; column-gap: 48px; display: block; }
  .lifetime .compose-body > * { break-inside: avoid; margin-bottom: 12px; }
  .lifetime .compose-body h3 { break-after: avoid; }
}

/* Xin xăm (owner, 2 Nov 2026): the temple's sets as cards, the cup that rattles and lets one stick rise, the lot read. */
.que-mode { max-width: 520px; }
.xam-box { display: grid; gap: 18px; }
.xam-sets { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 10px; }
.xam-sets legend { padding: 0; margin-bottom: 8px; font-size: 15px; font-weight: 600; color: var(--ink-2); }
.xam-set { position: relative; display: grid; gap: 4px; min-height: 76px; padding: 14px 16px; border-radius: var(--radius-md); background: var(--paper-sunk); box-shadow: inset 0 0 0 1px var(--rule); cursor: pointer; transition: background var(--dur-quick), box-shadow var(--dur-quick), transform var(--dur-quick); }
.xam-set:hover { background: var(--paper-deep); }
.xam-set:active { transform: scale(0.985); }
.xam-set input { position: absolute; opacity: 0; pointer-events: none; }
.xam-set b { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; color: var(--ink); }
.xam-set small { font-size: 14px; line-height: 1.45; color: var(--ink-3); }
.xam-set:has(input:checked) { box-shadow: inset 0 0 0 2px var(--gold); background: color-mix(in oklab, var(--gold) 10%, var(--paper-sunk)); }
.xam-set:has(input:checked) b { color: var(--gold); }
.xam-set:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.xam-stage { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 16px 28px; align-items: center; padding: 22px; border-radius: var(--radius-lg); background: var(--paper-sunk); }
@media (max-width: 640px) { .xam-stage { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; } }
.xam-side { display: grid; gap: 12px; justify-items: start; }
@media (max-width: 640px) { .xam-side { justify-items: center; } }
.xam-side .go { min-width: 220px; min-height: 52px; font-size: 17px; }
.xam-picked { min-height: 1.6em; font-size: 18px; }
.xam-picked b { color: var(--gold); font-family: var(--serif); font-size: 1.3em; }
.xam-cup { width: 160px; height: auto; overflow: visible; transform-origin: 50% 92%; }
.xam-tube { fill: #8f1818; }
.xam-lip { fill: #6e1010; }
.xam-band { fill: #c9a26a; }
.xam-word { fill: #e9cf9b; font-size: 40px; text-anchor: middle; font-family: var(--serif); }
.xam-sticks rect { fill: #d8b77d; stroke: #a8834a; stroke-width: 0.8; }
.xam-out { opacity: 0; transform: translateY(70px); transition: transform 650ms var(--ease-out), opacity 300ms; }
.xam-out rect { fill: #ecd29c; stroke: #a8834a; stroke-width: 0.8; }
.xam-out text { fill: #8f1818; font-size: 13px; font-weight: 700; text-anchor: middle; writing-mode: vertical-rl; font-family: var(--sans); }
.xam-cup.drawn .xam-out { opacity: 1; transform: translateY(-34px); }
.xam-cup.shaking { animation: xam-shake 1.5s ease-in-out; }
.xam-cup.shaking .xam-sticks { animation: xam-rattle 0.18s linear infinite; }
@keyframes xam-shake { 0%, 100% { transform: rotate(0); } 10% { transform: rotate(-16deg); } 20% { transform: rotate(12deg) translateY(-6px); } 30% { transform: rotate(-14deg); } 40% { transform: rotate(14deg) translateY(-8px); } 50% { transform: rotate(-12deg); } 60% { transform: rotate(16deg) translateY(-6px); } 70% { transform: rotate(-10deg); } 80% { transform: rotate(8deg); } 90% { transform: rotate(-4deg); } }
@keyframes xam-rattle { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .xam-cup.shaking, .xam-cup.shaking .xam-sticks { animation: none; } .xam-out { transition: opacity 200ms; } }

.xr-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px 26px; align-items: center; padding: 24px; border-radius: var(--radius-lg); background: var(--paper-sunk); }
.xr-stick { display: grid; justify-items: center; align-content: start; gap: 6px; width: 64px; min-height: 168px; padding: 12px 0; border-radius: 10px 10px 4px 4px; background: #ecd29c; box-shadow: inset 0 0 0 1px #a8834a; color: #8f1818; }
.xr-stick span { writing-mode: vertical-rl; font-size: 14px; font-weight: 600; letter-spacing: 0.08em; }
.xr-stick b { font-family: var(--serif); font-size: 26px; line-height: 1; }
.xr-names { display: grid; gap: 6px; min-width: 0; }
.xr-names h3 { font-size: clamp(1.6rem, 1.3rem + 1vw, 2.2rem); line-height: 1.1; }
.xr-names h3 small { font-size: 0.6em; color: var(--ink-3); font-family: var(--sans); }
.xr-grade { justify-self: start; margin-top: 4px; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 16px; background: color-mix(in oklab, var(--gold) 22%, transparent); color: var(--gold); }
.xr-grade small { font-weight: 500; opacity: 0.85; }
.xr-grade.good { background: color-mix(in oklab, var(--loc) 22%, transparent); color: var(--loc); }
.xr-grade.hard { background: color-mix(in oklab, var(--ky) 22%, transparent); color: var(--ky); }
.xr-story { font-size: 16px; color: var(--ink-2); }
.xr-story span { color: var(--ink-3); }
.xr-poem, .xr-y { display: grid; gap: 12px; max-width: 72ch; }
.xr-poem h4, .xr-y h4 { font-size: 1.25rem; }
.xr-poem-cols { display: flex; flex-wrap: wrap; gap: 12px 40px; padding: 20px 22px; border-radius: var(--radius-md); background: var(--paper-sunk); }
.xr-han { font-family: var(--serif); font-size: 1.45rem; line-height: 1.7; letter-spacing: 0.12em; color: var(--ink); }
.xr-am { font-size: 17px; line-height: 2; color: var(--ink-2); font-style: italic; }
.xr-dich { font-family: var(--serif); font-size: 1.2rem; line-height: 1.75; color: var(--ink); padding-left: 16px; box-shadow: inset 3px 0 0 var(--gold); }
.xr-y p { font-size: 17px; line-height: 1.65; }
@media (max-width: 480px) { .xr-head { grid-template-columns: minmax(0, 1fr); } .xr-stick { flex-direction: row; display: flex; width: auto; min-height: 0; padding: 8px 14px; border-radius: 8px; align-items: center; justify-content: center; } .xr-stick span { writing-mode: horizontal-tb; } }
.xam-box.in-keo #xam-shake, .xam-box.in-keo #xam-motion, .xam-box.in-keo #xam-howto, .xam-box.in-keo .xam-sets { display: none; }
@media (max-width: 480px) { .xr-am { font-size: 15.5px; line-height: 1.75; } .xr-han { font-size: 1.3rem; } }

/* ── Phong thủy ứng dụng (owner, 3 Nov 2026): goals, tips, the desk seat, the analysis, the vote ── */
.pt-ref-h { font-family: var(--serif); font-size: clamp(1.6rem, 1.3rem + 1vw, 2.1rem); color: var(--gold); line-height: 1.1; margin-top: 12px; padding-top: 22px; border-top: 1px solid var(--rule); }
.pt-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pt-chip { appearance: none; border: 0; border-radius: 999px; min-height: 44px; padding: 8px 16px; background: var(--paper-sunk); color: var(--ink); font: inherit; font-size: 15px; cursor: pointer; transition: background var(--dur-quick), color var(--dur-quick), box-shadow var(--dur-quick), transform var(--dur-quick); }
.pt-chip:hover { box-shadow: inset 0 0 0 1px var(--gold); }
.pt-chip:active { transform: scale(0.97); }
.pt-chip[aria-checked="true"] { background: var(--gold); color: var(--on-clay); font-weight: 600; box-shadow: none; }
.pt-chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
#pt-goal-out[aria-busy="true"], #pt-desk-out[aria-busy="true"] { opacity: 0.55; transition: opacity var(--dur-quick); }
.pt-tips { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pt-tip { display: grid; gap: 8px; padding: 16px; border-radius: var(--radius-md); background: var(--paper-sunk); }
.pt-tip-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.pt-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 10px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 700; letter-spacing: 0.01em; }
.pt-badge.nen { background: color-mix(in oklab, var(--loc) 20%, transparent); color: var(--loc); }
.pt-badge.tuy { background: color-mix(in oklab, var(--gold) 18%, transparent); color: var(--gold); }
.pt-badge.can-than { background: color-mix(in oklab, var(--ky) 20%, transparent); color: var(--ky); }
.pt-school { font-size: 13.5px; color: var(--ink-3); }
.pt-do { font-size: 17px; font-weight: 600; line-height: 1.5; color: var(--ink); text-wrap: pretty; }
.pt-dl { margin: 0; display: grid; gap: 6px; }
.pt-dl > div { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; font-size: 15px; line-height: 1.55; }
.pt-dl dt { font-size: 13.5px; font-weight: 600; color: var(--ink-3); padding-top: 1px; }
.pt-dl dd { margin: 0; color: var(--ink-2); }
.pt-dl .fit.good dd { color: color-mix(in oklab, var(--loc) 75%, var(--ink)); }
.pt-dl .fit.mid dd { color: var(--ink); }
.pt-dl .warn dt, .pt-dl .warn dd { color: color-mix(in oklab, var(--ky) 80%, var(--ink)); }
@media (max-width: 420px) { .pt-dl > div { grid-template-columns: minmax(0, 1fr); gap: 0; } }
.pt-real, .pt-summary { font-size: 16px; line-height: 1.6; padding: 14px 16px; border-radius: var(--radius-md); background: color-mix(in oklab, var(--gold) 10%, var(--paper)); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--gold) 35%, transparent); max-width: 72ch; }
.pt-real b { color: var(--gold); margin-right: 4px; }
.pt-desk { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 14px 18px; align-items: start; }
.pt-desk > div:last-child { grid-column: 1 / -1; }
.pt-face-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.pt-face-row .btn-quiet { min-height: 46px; white-space: nowrap; }
.pt-seg { grid-template-columns: repeat(2, minmax(0, 1fr)); border: 0; margin: 0; background: var(--paper-sunk); }
.pt-seg.pt-seg3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pt-seg label { font-size: 14.5px; text-align: center; padding: 4px 6px; line-height: 1.25; }
.pt-score { display: flex; align-items: center; gap: 16px; padding: 14px 16px; border-radius: var(--radius-md); background: var(--paper-sunk); --tone: var(--gold); }
.pt-score.good { --tone: var(--loc); }
.pt-score.hard { --tone: var(--ky); }
.pt-num { flex: none; display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; box-shadow: inset 0 0 0 3px var(--tone); }
.pt-num b { font-family: var(--serif); font-size: 28px; line-height: 1; color: var(--tone); font-variant-numeric: lining-nums tabular-nums; }
.pt-num small { font-size: 12px; color: var(--ink-3); margin-top: -14px; }
.pt-verdict { font-size: 18px; font-weight: 600; color: var(--tone); }
.pt-fixes { margin: 0; padding-left: 22px; display: grid; gap: 6px; font-size: 16px; line-height: 1.55; max-width: 72ch; }
.pt-fixes li::marker { color: var(--gold); font-weight: 700; }
#pt-text { width: 100%; min-height: 120px; padding: 12px; border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); background: var(--paper); color: var(--ink); font: inherit; font-size: 16px; line-height: 1.5; resize: vertical; }
#pt-text:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.pt-an-bar, .pt-vote-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.pt-vote { padding: 18px; border-radius: var(--radius-lg); background: color-mix(in oklab, var(--gold) 8%, var(--paper-sunk)); }
.pt-vote h3 { font-size: 1.4rem; }
.pt-vote-bar .btn-quiet { min-height: 44px; padding: 0 18px; }
.pt-vote-bar .btn-quiet[aria-pressed="true"] { color: var(--loc); }
.td-card p.td-fit { font-size: 14.5px; color: var(--ink-2); }
.td-card p.td-fit.good { color: color-mix(in oklab, var(--good) 70%, var(--ink)); }
@media (prefers-reduced-motion: reduce) { .pt-chip { transition: none; } .pt-chip:active { transform: none; } }

/* Phong thủy của lá số (src/phongthuy-overview.js) */
.pt-ov-sec { padding: 14px 0; border-top: 1px solid var(--rule); }
.pt-ov-sec:first-child { border-top: 0; padding-top: 4px; }
.pt-ov-sec h4 { margin: 0 0 8px; font-size: 20px; line-height: 1.25; color: var(--gold); }
.pt-ov-sec p { margin: 0 0 8px; line-height: 1.6; max-width: 68ch; }
.pt-ov-basis { font-size: 14px; color: var(--ink-soft); }

/* The language switcher (public/i18n.js): a quiet pill in the landing bar and in the app's header. */
.lang-sw { display: inline-flex; align-items: center; flex: none; }
.lang-sw select {
  font: inherit; font-size: 14px; color: var(--ink); cursor: pointer;
  min-block-size: 40px; padding: 0 12px; border-radius: 999px;
  background: color-mix(in oklch, var(--ink) 7%, var(--paper)); /* opaque: the popup takes this colour */
  border: 1px solid color-mix(in oklch, var(--ink) 18%, transparent);
}
.lang-sw select:hover { background: color-mix(in oklch, var(--ink) 12%, var(--paper)); }
.lang-sw select:focus-visible { outline: 2px solid var(--gold, currentColor); outline-offset: 2px; }

/* Type per language (public/i18n.js adds the Noto Sans file of the language): Be Vietnam Pro draws Vietnamese and Latin; the rest of the page's letters come from here. */
html[lang='ja'] { --sans: 'Be Vietnam Pro', 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic UI', system-ui, sans-serif; --serif: 'Cormorant Garamond', 'Yu Mincho', 'Hiragino Mincho ProN', serif; }
html[lang='ko'] { --sans: 'Be Vietnam Pro', 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif; --serif: 'Cormorant Garamond', 'AppleMyungjo', 'Batang', serif; }
html[lang='zh'] { --sans: 'Be Vietnam Pro', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif; --serif: 'Cormorant Garamond', 'Songti SC', 'SimSun', serif; }
html[lang='hi'] { --sans: 'Be Vietnam Pro', 'Noto Sans Devanagari', 'Nirmala UI', system-ui, sans-serif; --serif: 'Cormorant Garamond', 'Noto Serif Devanagari', 'Nirmala UI', serif; }
html[lang='ru'] { --sans: 'Be Vietnam Pro', 'Noto Sans', system-ui, sans-serif; --serif: 'Cormorant Garamond', 'Newsreader', 'Times New Roman', serif; }
