/* ============================================================================
   The 61 Da Vinci — site stylesheet.
   Layout concept: alternating warm-paper sections and full-bleed ink bands,
   square architectural blocks, the four-pillars motif as structural rhythm.
   Tokens follow the brand design system (paper / ink / cinnabar / gold).
   ==========================================================================*/

:root {
  /* brand palette — light (Paper) */
  --paper: #faf6ee;
  --ink: #141210;
  --ink-raised: #2a241e;
  --ink-muted: #5c544a;
  --cinnabar: #c8102e;
  --gold: #c9a227;
  --gold-deep: #8a6a12;
  --line: #e4dccb;

  /* semantic roles */
  --bg: var(--paper);
  --fg: var(--ink);
  --fg-muted: var(--ink-muted);
  --panel: #fffdf7;
  --wash: rgba(20, 18, 16, 0.035);
  --rule: var(--line);
  --accent: var(--cinnabar);
  --accent-quiet: var(--gold-deep);
  --band-bg: var(--ink);
  --band-fg: var(--paper);
  --band-panel: var(--ink-raised);
  --band-fg-muted: #a9a096;
  --band-rule: rgba(201, 162, 39, 0.26);
  --good: #2f6b4f;
  --warn: #8a6a12;
  --bad: #c8102e;
  --focus: var(--cinnabar);

  /* type */
  --serif: "Playfair Display", "Noto Serif SC", Georgia, "Songti SC", serif;
  --sans: "DM Sans", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* space + shape */
  --s2: 8px; --s4: 16px; --s6: 24px; --s12: 48px;
  --r-none: 0px; --r-sm: 4px; --r-pill: 999px;
  --maxw: 1140px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--ink);
    --fg: var(--paper);
    --fg-muted: #a9a096;
    --panel: var(--ink-raised);
    --wash: rgba(250, 246, 238, 0.045);
    --rule: rgba(201, 162, 39, 0.22);
    --accent: var(--gold);
    --accent-quiet: var(--gold);
    --band-bg: #0b0a08;
    --band-panel: var(--ink-raised);
    --band-rule: rgba(201, 162, 39, 0.26);
    --good: #74b893;
    --warn: #d8b43f;
    --bad: #e4697e;
    --focus: var(--gold);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: var(--ink);
  --fg: var(--paper);
  --fg-muted: #a9a096;
  --panel: var(--ink-raised);
  --wash: rgba(250, 246, 238, 0.045);
  --rule: rgba(201, 162, 39, 0.22);
  --accent: var(--gold);
  --accent-quiet: var(--gold);
  --band-bg: #0b0a08;
  --band-panel: var(--ink-raised);
  --band-rule: rgba(201, 162, 39, 0.26);
  --good: #74b893;
  --warn: #d8b43f;
  --bad: #e4697e;
  --focus: var(--gold);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 26px;
  -webkit-text-size-adjust: 100%;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 40;
  background: var(--band-bg);
}
h1, h2, h3, h4 { font-family: var(--serif); text-wrap: balance; margin: 0; }
h1 { font-size: 40px; line-height: 46px; font-weight: 700; }
h2 { font-size: 28px; line-height: 34px; font-weight: 600; }
h3 { font-size: 20px; line-height: 26px; font-weight: 600; }
p { margin: 0; }
a { color: inherit; text-decoration-color: var(--accent-quiet); text-underline-offset: 3px; }
a:hover { color: var(--accent-quiet); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 0; }
small { font-size: 14px; line-height: 20px; }

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.band { background: var(--band-bg); color: var(--band-fg); }
.band h1, .band h2, .band h3 { color: var(--band-fg); }
.band .eyebrow { color: var(--gold); }
.band a { text-decoration-color: var(--gold); }
.band a:hover { color: var(--gold); }
.sect { padding-block: var(--s12); }
@media (min-width: 760px) { .sect { padding-block: 96px; } }

.eyebrow {
  font-size: 12px; line-height: 16px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase; color: var(--accent);
  margin: 0;
}
.muted { color: var(--fg-muted); }
.band .muted { color: var(--band-fg-muted); }
.lede { font-size: 18px; line-height: 29px; max-width: 62ch; }
.nums { font-variant-numeric: tabular-nums; }

/* ---- header ------------------------------------------------------------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30;
  background: var(--band-bg); color: var(--band-fg);
  border-bottom: 1px solid var(--band-rule);
}
.topbar .wrap { display: flex; align-items: center; gap: var(--s6); padding-block: 12px; }
.brand { font-family: var(--serif); font-weight: 700; font-size: 19px; letter-spacing: .2px;
  text-decoration: none; color: var(--band-fg); white-space: nowrap; }
.brand b { color: var(--cinnabar); font-weight: 700; }
:root[data-theme="dark"] .brand b, .topbar .brand b { color: var(--gold); }
.nav { display: flex; gap: 18px; margin-left: auto; flex-wrap: wrap;
  font-size: 14px; line-height: 20px; }
.nav a { color: var(--band-fg-muted); text-decoration: none; padding: 4px 0;
  border-bottom: 1px solid transparent; }
.nav a:hover { color: var(--gold); }
.nav a[aria-current="page"] { color: var(--band-fg); border-bottom-color: var(--gold); }
.topbar-tools { display: flex; gap: var(--s2); align-items: center; }
.ghost {
  background: transparent; color: var(--band-fg-muted);
  border: 1px solid var(--band-rule); border-radius: var(--r-sm);
  font: inherit; font-size: 13px; padding: 5px 9px; cursor: pointer;
}
.ghost:hover { color: var(--gold); border-color: var(--gold); }

/* ---- hero --------------------------------------------------------------- */
.hero { position: relative; overflow: hidden; }
.hero-grid { display: grid; gap: var(--s12); align-items: center; padding-block: var(--s12); }
@media (min-width: 900px) {
  .hero-grid { grid-template-columns: 1.05fr 1fr; padding-block: 72px; }
}
.hero h1 { font-size: 40px; line-height: 44px; }
@media (min-width: 760px) { .hero h1 { font-size: 56px; line-height: 60px; letter-spacing: -0.5px; } }
.hero-stage { position: relative; max-width: 100%; min-width: 0; }
.hero-stage canvas { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; }
.stage-note { margin-top: 10px; font-size: 12px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--band-fg-muted); }

/* ---- pillars motif ------------------------------------------------------ */
.pillars { display: flex; gap: 6px; align-items: flex-end; height: 56px; }
.pillars i { display: block; width: 14px; }
.pillars i:nth-child(1) { height: 100%; background: var(--gold); }
.pillars i:nth-child(2) { height: 62%; background: var(--cinnabar); }
.pillars i:nth-child(3) { height: 84%; background: var(--ink-raised); }
.pillars i:nth-child(4) { height: 44%; background: var(--gold-deep); }
.band .pillars i:nth-child(3) { background: var(--paper); }

/* ---- cards / panels ----------------------------------------------------- */
.panel { background: var(--panel); border: 1px solid var(--rule); padding: var(--s6); }
.band .panel { background: var(--band-panel); border-color: var(--band-rule); color: var(--band-fg); }
.grid { display: grid; gap: var(--s6); }
.g2 { grid-template-columns: 1fr; }
.g3 { grid-template-columns: 1fr; }
.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 860px) {
  .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.card { display: block; background: var(--panel); border: 1px solid var(--rule);
  padding: var(--s6); text-decoration: none; color: inherit; min-width: 0; }
a.card:hover { border-color: var(--accent-quiet); }
a.card:hover h3 { color: var(--accent-quiet); }
.card .k { font-family: var(--serif); font-size: 32px; line-height: 1; color: var(--accent-quiet); }
.band .card { background: var(--band-panel); border-color: var(--band-rule); }

/* ---- element badges ----------------------------------------------------- */
.el {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: var(--r-pill); border: 1px solid currentColor;
  padding: 1px 10px; font-size: 13px; line-height: 20px; font-weight: 700;
  white-space: nowrap;
}
.el-wood { color: #2f6b4f; } .el-fire { color: var(--cinnabar); }
.el-earth { color: var(--gold-deep); } .el-metal { color: #6b6257; }
.el-water { color: #2b5a78; }
:root[data-theme="dark"] .el-wood, :root[data-theme="dark"] .el-metal,
:root[data-theme="dark"] .el-water, :root[data-theme="dark"] .el-earth,
:root[data-theme="dark"] .el-fire { color: inherit; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .el-wood { color: #74b893; }
  :root:not([data-theme="light"]) .el-fire { color: #e4697e; }
  :root:not([data-theme="light"]) .el-earth { color: var(--gold); }
  :root:not([data-theme="light"]) .el-metal { color: #c3bbb0; }
  :root:not([data-theme="light"]) .el-water { color: #7eb4d4; }
}
:root[data-theme="dark"] .el-wood { color: #74b893; }
:root[data-theme="dark"] .el-fire { color: #e4697e; }
:root[data-theme="dark"] .el-earth { color: var(--gold); }
:root[data-theme="dark"] .el-metal { color: #c3bbb0; }
:root[data-theme="dark"] .el-water { color: #7eb4d4; }

/* ---- chips / tones ------------------------------------------------------ */
.chip { display: inline-block; border-radius: var(--r-pill); padding: 1px 10px;
  font-size: 13px; line-height: 20px; border: 1px solid currentColor; white-space: nowrap; }
.t-good { color: var(--good); } .t-warn { color: var(--warn); }
.t-bad { color: var(--bad); } .t-neutral { color: var(--fg-muted); }
.band .t-neutral { color: var(--band-fg-muted); }
.fill-good { background: var(--good); color: var(--paper); border-color: var(--good); }
.fill-bad { background: var(--bad); color: var(--paper); border-color: var(--bad); }

/* ---- verdict block ------------------------------------------------------ */
.verdict { display: grid; gap: var(--s4); }
.verdict-head { display: flex; align-items: baseline; gap: var(--s4); flex-wrap: wrap; }
.verdict-mark { font-family: var(--serif); font-size: 64px; line-height: 1; font-weight: 700; }
.v-great, .v-good { color: var(--good); }
.v-fair { color: var(--warn); }
.v-caution { color: var(--warn); }
.v-bad { color: var(--bad); }
.meter { display: block; height: 8px; background: var(--wash); border: 1px solid var(--rule);
  position: relative; min-width: 40px; }
.band .meter { border-color: var(--band-rule); }
.meter > i { display: block; height: 100%; background: var(--accent); }
.band .meter > i { background: var(--gold); }

/* ---- tables ------------------------------------------------------------- */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; line-height: 20px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.band th, .band td { border-color: var(--band-rule); }
th { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--fg-muted);
  font-weight: 700; white-space: nowrap; }
.band th { color: var(--band-fg-muted); }
td.gz { font-family: var(--serif); font-size: 19px; }

/* ---- forms -------------------------------------------------------------- */
.form { display: grid; gap: var(--s4); }
.row { display: grid; gap: var(--s4); grid-template-columns: 1fr; }
@media (min-width: 620px) { .row-2 { grid-template-columns: 1fr 1fr; } .row-3 { grid-template-columns: repeat(3, 1fr); } }
label { display: block; font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
  font-weight: 700; color: var(--fg-muted); margin-bottom: 5px; }
input, select, textarea, button {
  font: inherit; font-size: 15px; color: var(--fg); background: var(--bg);
  border: 1px solid var(--fg-muted); border-radius: var(--r-sm);
  padding: 9px 10px; width: 100%; min-width: 0;
}
input[type="checkbox"] { width: auto; }
.inline { display: flex; align-items: center; gap: var(--s2); }
.inline label { margin: 0; text-transform: none; letter-spacing: 0; font-size: 14px;
  font-weight: 400; color: var(--fg); }
button.go {
  background: var(--cinnabar); color: #fff; border-color: var(--cinnabar);
  font-weight: 700; cursor: pointer; letter-spacing: .3px;
}
button.go:hover { background: #a60d26; border-color: #a60d26; }
button.alt { background: transparent; cursor: pointer; }
button.alt:hover { border-color: var(--accent-quiet); color: var(--accent-quiet); }
fieldset { border: 1px solid var(--rule); padding: var(--s4); margin: 0; border-radius: var(--r-none); }
legend { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--fg-muted);
  font-weight: 700; padding: 0 6px; }

/* ---- tabs --------------------------------------------------------------- */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--rule); }
.tabs button {
  width: auto; background: transparent; border: 1px solid transparent; border-bottom: none;
  border-radius: 0; color: var(--fg-muted); cursor: pointer; font-size: 14px; font-weight: 700;
  padding: 9px 14px; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] {
  color: var(--fg); border-color: var(--rule); background: var(--panel);
  border-bottom: 1px solid var(--panel);
}

/* ---- nine-palace grids -------------------------------------------------- */
.palace-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px;
  background: var(--rule); border: 1px solid var(--rule); }
.band .palace-grid { background: var(--band-rule); border-color: var(--band-rule); }
.palace { background: var(--panel); padding: 10px; min-height: 104px; min-width: 0;
  display: flex; flex-direction: column; gap: 4px; }
.band .palace { background: var(--band-panel); }
.palace .ph { display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--fg-muted); }
.band .palace .ph { color: var(--band-fg-muted); }
.palace .big { font-family: var(--serif); font-size: 26px; line-height: 1.1; }
.palace .pr { display: flex; gap: 6px; flex-wrap: wrap; font-size: 13px; line-height: 18px; }
.palace.is-center { background: var(--wash); }
.palace.hi { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---- hours strip -------------------------------------------------------- */
.hours { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px;
  background: var(--rule); border: 1px solid var(--rule); }
@media (min-width: 560px) { .hours { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .hours { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.hour { background: var(--panel); padding: 10px; min-width: 0; }
.band .hour { background: var(--band-panel); }
.hour.now { background: var(--wash); outline: 2px solid var(--accent); outline-offset: -2px; }
.hour .hb { font-family: var(--serif); font-size: 21px; }
.hour .hr { font-size: 12px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.band .hour .hr { color: var(--band-fg-muted); }

/* ---- lists -------------------------------------------------------------- */
.stack { display: grid; gap: var(--s4); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px var(--s4); font-size: 14px; }
.kv dt { color: var(--fg-muted); font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
  font-weight: 700; padding-top: 2px; }
.band .kv dt { color: var(--band-fg-muted); }
.kv dd { margin: 0; }
.taglist { display: flex; gap: 6px; flex-wrap: wrap; }
.reasons { display: grid; gap: 6px; font-size: 14px; line-height: 20px; margin: 0; padding: 0; list-style: none; }
.reasons li { display: grid; grid-template-columns: auto 1fr; gap: var(--s2); }
.ledger { font-size: 14px; }
.ledger td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- footer ------------------------------------------------------------- */
.foot { background: var(--band-bg); color: var(--band-fg-muted); font-size: 14px; }
.foot .wrap { padding-block: var(--s12); display: grid; gap: var(--s6); }
@media (min-width: 760px) { .foot .wrap { grid-template-columns: 1.4fr 1fr 1fr; } }
.foot h4 { font-family: var(--sans); font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--gold); margin-bottom: var(--s2); }
.foot a { color: var(--band-fg-muted); text-decoration: none; display: block; padding: 3px 0; }
.foot a:hover { color: var(--gold); }
.disclaim { border-top: 1px solid var(--band-rule); padding-block: var(--s4); font-size: 13px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- month picker ------------------------------------------------------- */
.mgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px;
  background: var(--rule); border: 1px solid var(--rule); }
.mhead { background: var(--panel); text-align: center; font-size: 11px; font-weight: 700;
  letter-spacing: 1px; color: var(--fg-muted); padding: 6px 0; }
.mcell { background: var(--panel); border: 0; border-radius: 0; padding: 6px 4px; min-height: 76px;
  display: flex; flex-direction: column; gap: 1px; align-items: flex-start; cursor: pointer;
  text-align: left; color: inherit; width: 100%; font: inherit; }
.mcell.is-pad { background: var(--wash); cursor: default; min-height: 76px; }
.mcell:hover { background: var(--wash); }
.mcell[aria-current="date"] { outline: 2px solid var(--accent); outline-offset: -2px; }
.mcell .md { font-family: var(--serif); font-size: 17px; line-height: 1.1; }
.mcell .mv { font-size: 13px; font-weight: 700; }
.mcell .mj, .mcell .ml { font-size: 10px; line-height: 13px; }
.mcell .mj { color: var(--fg-muted); }
.monthbar { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.datebar { display: flex; gap: var(--s2); align-items: end; flex-wrap: wrap; }
.datebar > div { min-width: 150px; }
.datebar button { width: auto; white-space: nowrap; }
.monthbar button { width: auto; }

/* element-coloured meters */
.meter.m-wood > i { background: #2f6b4f; } .meter.m-fire > i { background: var(--cinnabar); }
.meter.m-earth > i { background: var(--gold-deep); } .meter.m-metal > i { background: #6b6257; }
.meter.m-water > i { background: #2b5a78; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .meter.m-wood > i { background: #74b893; }
  :root:not([data-theme="light"]) .meter.m-fire > i { background: #e4697e; }
  :root:not([data-theme="light"]) .meter.m-earth > i { background: var(--gold); }
  :root:not([data-theme="light"]) .meter.m-metal > i { background: #c3bbb0; }
  :root:not([data-theme="light"]) .meter.m-water > i { background: #7eb4d4; }
}
:root[data-theme="dark"] .meter.m-wood > i { background: #74b893; }
:root[data-theme="dark"] .meter.m-fire > i { background: #e4697e; }
:root[data-theme="dark"] .meter.m-earth > i { background: var(--gold); }
:root[data-theme="dark"] .meter.m-metal > i { background: #c3bbb0; }
:root[data-theme="dark"] .meter.m-water > i { background: #7eb4d4; }

/* quiet inline tags — used where chips would be too dense (plate cells) */
.tag { font-size: 13px; line-height: 18px; font-weight: 700; }
.tag.t-neutral { font-weight: 400; }
.palace .stems { font-family: var(--serif); line-height: 1.15; display: grid; gap: 2px; margin: 2px 0; }
.palace .stems b { font-size: 24px; font-weight: 700; }
.palace .stems span { font-size: 11px; font-family: var(--sans); color: var(--fg-muted);
  letter-spacing: 1px; }
.palace .notes { font-size: 11px; line-height: 16px; display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- narrow-width safety: grid items must be allowed to shrink ---------- */
.stack > *, .grid > *, .row > *, .verdict > * { min-width: 0; }
.panel, .card, .palace-grid, .hours, .mgrid, .tablewrap { min-width: 0; max-width: 100%; }
.tablewrap > table { min-width: max-content; }
.topbar .wrap { flex-wrap: wrap; row-gap: 6px; }
@media (max-width: 560px) {
  .nav { gap: 12px; font-size: 13px; }
  .verdict-mark { font-size: 48px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .datebar > div { min-width: 0; flex: 1 1 100%; }
}
