/* Burse · direction C "Instrument": a calm control panel for an eighteen-year trust.
   Brass is only for keys and key state; green/red only for paid/refused. */
:root {
  --bg: #ffffff; --panel: #f6f6f4; --chip: #ffffff; --ink: #171717; --muted: #707070; --line: #e8e8e5;
  --accent: #b07a1f; --accent-soft: #f6ecda; --ok: #1d7a46; --ok-soft: #e6f2ea; --bad: #b3261e; --bad-soft: #f8e7e5;
  --font-head: "Varela Round", "Figtree", system-ui, sans-serif;
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --r-panel: 26px; --r-stat: 20px; --r-slip: 18px;
  --gap: 18px; --pad: 22px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e0e; --panel: #171717; --chip: #1e1e1e; --ink: #f0f0ee; --muted: #9b9b98; --line: #262626;
    --accent: #e0a94b; --accent-soft: #2a2114; --ok: #5fcf8f; --ok-soft: #12261a; --bad: #ff8a80; --bad-soft: #2c1513; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e0e; --panel: #171717; --chip: #1e1e1e; --ink: #f0f0ee; --muted: #9b9b98; --line: #262626;
  --accent: #e0a94b; --accent-soft: #2a2114; --ok: #5fcf8f; --ok-soft: #12261a; --bad: #ff8a80; --bad-soft: #2c1513; color-scheme: dark;
}

* { box-sizing: border-box }
html { -webkit-text-size-adjust: 100% }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.55 var(--font); font-variant-numeric: tabular-nums; min-height: 100vh; display: flex; flex-direction: column }
a { color: inherit }
button { font: inherit; color: inherit }
h1, h2, h3 { font-family: var(--font-head); font-weight: 400; margin: 0; letter-spacing: -.01em }
h1 { font-size: clamp(1.55rem, 3.4vw, 2.2rem); line-height: 1.15; text-wrap: balance }
h2 { font-size: 1.25rem; line-height: 1.25 }
h3 { font-size: 1.05rem; line-height: 1.3 }
p { margin: 0 }
.mono { font-family: var(--mono); font-size: .8em; letter-spacing: 0 }
.muted { color: var(--muted) }
.small { font-size: .85rem }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line) }
.top-in { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 12px 22px }
.brand { font-family: var(--font-head); font-size: 1.25rem; display: flex; align-items: center; gap: 9px; text-decoration: none; flex: none }
.brand i { width: 20px; height: 20px; border-radius: 50%; background: var(--ink); display: inline-block; position: relative }
.brand i::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--accent) }
.seg { display: flex; background: var(--panel); border-radius: 999px; padding: 4px; gap: 2px; min-width: 0 }
.seg a, .seg button { padding: 6px 14px; border-radius: 999px; font-size: .88rem; color: var(--muted); text-decoration: none; white-space: nowrap; border: 0; background: none; cursor: pointer; transition: color .2s, background .2s }
.seg a:hover, .seg button:hover { color: var(--ink) }
.seg a[aria-current="page"], .seg button[aria-pressed="true"] { background: var(--chip); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08) }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: none }
.mode { display: inline-flex; align-items: center; gap: 8px; font-size: .84rem; padding: 6px 12px 6px 10px; border-radius: 999px; background: var(--panel); white-space: nowrap }
.led { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); flex: none }
.mode[data-state="sunset"] .led { background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent) }
.mode[data-state="qday"] .led { background: var(--bad); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 22%, transparent) }
.mode[data-state="closed"] .led { background: var(--muted); box-shadow: 0 0 0 4px color-mix(in srgb, var(--muted) 18%, transparent) }
.mode.pulse .led { animation: pulse .8s var(--ease) 1 }
@keyframes pulse { 40% { transform: scale(1.8) } }
.theme { border: 1px solid var(--line); background: var(--chip); border-radius: 999px; width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; flex: none }
.theme svg { width: 16px; height: 16px }

/* ---------- layout ---------- */
main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 22px 22px 56px }
.grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: var(--gap); align-items: start }
.col { display: grid; gap: var(--gap); min-width: 0; align-content: start }
.panel { background: var(--panel); border-radius: var(--r-panel); padding: var(--pad); min-width: 0 }
.panel > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap }
.panel > header p { font-size: .85rem; color: var(--muted) }
.chip { background: var(--chip); border-radius: var(--r-slip); padding: 16px }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap) }
.stack { display: grid; gap: 10px }

/* intro band */
.intro { display: flex; align-items: end; justify-content: space-between; gap: 18px 28px; flex-wrap: wrap; margin: 4px 0 20px }
.intro .lede { max-width: 640px }
.intro .lede p { color: var(--muted); margin-top: 8px; max-width: 58ch }
.doors { display: flex; gap: 8px; flex-wrap: wrap }

/* ---------- buttons, pills, badges ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 999px; padding: 10px 17px; font-weight: 600; font-size: .9rem; background: var(--ink); color: var(--bg); border: 1px solid var(--ink); text-decoration: none; cursor: pointer; transition: transform .2s var(--ease), opacity .2s; white-space: nowrap }
.btn:hover { transform: translateY(-1px) }
.btn:active { transform: none }
.btn.sec { background: var(--chip); color: var(--ink); border-color: var(--line) }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line) }
.btn.small { padding: 7px 13px; font-size: .84rem }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none }
.btn .spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite }
@keyframes spin { to { transform: rotate(360deg) } }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; border-radius: 999px; padding: 3px 10px; width: fit-content; white-space: nowrap }
.badge.key { background: var(--accent-soft); color: var(--accent) }
.badge.ok { background: var(--ok-soft); color: var(--ok) }
.badge.bad { background: var(--bad-soft); color: var(--bad) }
.badge.plain { background: var(--chip); color: var(--muted); border: 1px solid var(--line) }
.badge.drill { background: transparent; color: var(--ink); border: 1px dashed var(--muted); letter-spacing: .04em; text-transform: uppercase; font-size: .7rem }
.tx { font-family: var(--mono); font-size: .74rem; color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap }
.tx:hover { color: var(--ink); text-decoration: underline }
.tx svg { width: 10px; height: 10px }
.amount { font-weight: 600 }
.amount small { font-weight: 500; color: var(--muted); font-size: .78em; margin-left: 3px }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px }
.stat { background: var(--panel); border-radius: var(--r-stat); padding: 14px 16px; min-width: 0 }
.stat small { color: var(--muted); font-size: .76rem; display: block }
.stat b { display: block; font-size: 1.45rem; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.stat b small { display: inline; font-size: .62em; font-weight: 500 }
.stat .sub { font-size: .76rem; color: var(--muted); margin-top: 2px }

/* ---------- Last Key slips ---------- */
.keys { background: var(--panel); border-radius: var(--r-panel); padding: 20px; display: grid; gap: 14px; align-content: start }
.slip { background: var(--chip); border-radius: var(--r-slip); padding: 16px; border: 1px dashed color-mix(in srgb, var(--muted) 45%, var(--line)); display: grid; gap: 8px; position: relative; transition: opacity .4s var(--ease) }
.slip.retired { opacity: .55 }
.slip .gen { font-family: var(--mono); font-size: .7rem; color: var(--muted); letter-spacing: .04em }
.slip b { font-weight: 600 }
.chains { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; margin-top: 2px }
.chains i { height: 13px; border-radius: 4px; background: var(--line); transition: background .25s }
.chains i.lit { background: var(--accent) }

/* ---------- lanes ---------- */
.scrub { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; margin-bottom: 4px }
.age { font-family: var(--font-head); font-size: 2.2rem; line-height: 1; min-width: 3.2ch }
.age small { font-family: var(--font); font-size: .8rem; color: var(--muted); display: block; margin-top: 4px; white-space: nowrap }
input[type=range] { width: 100%; accent-color: var(--ink); margin: 0 }
.lanes { display: grid; gap: 7px; margin-top: 14px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin }
.lane { display: grid; grid-template-columns: 84px repeat(18, minmax(22px, 1fr)); gap: 3px; align-items: center; font-size: .76rem; color: var(--muted); min-width: 560px }
.lane.ages span { text-align: center; font-size: .68rem }
.lane.ages span:first-child { text-align: left }
.cell { height: 22px; border-radius: 6px; display: flex; gap: 2px; padding: 0; overflow: hidden }
.cell.none { border: 1px dashed var(--line) }
.cell i { flex: 1; border-radius: 4px; background: color-mix(in srgb, var(--accent) 55%, var(--panel)); transition: background .45s var(--ease) }
.cell i.p { background: var(--ink) }
.cell i.x { background: var(--line) }
.cell.now { outline: 2px solid var(--ink); outline-offset: 1px }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .76rem; color: var(--muted); margin-top: 10px }
.legend span { display: inline-flex; align-items: center; gap: 6px }
.legend i { width: 14px; height: 10px; border-radius: 3px; display: inline-block }

/* ---------- journal ---------- */
.journal { font-family: var(--mono); font-size: .76rem; display: grid; gap: 7px }
.journal li { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; list-style: none; animation: slide .5s var(--ease) both }
.journal ol { margin: 0; padding: 0; display: grid; gap: 7px }
.journal .t { color: var(--muted) }
.journal .k-refused { color: var(--bad) }
.journal .k-payment { color: var(--ink) }
@keyframes slide { from { opacity: 0; transform: translateY(-6px) } }

/* ---------- lists / tables ---------- */
.list { display: grid; gap: 2px }
.item { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 12px; border-radius: 14px; background: var(--chip) }
.item .when { font-family: var(--mono); font-size: .74rem; color: var(--muted) }
.item .what { min-width: 0 }
.item .what p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.item .what .sub { font-size: .8rem; color: var(--muted); white-space: normal }
.item .right { text-align: right; display: grid; gap: 3px; justify-items: end }
.filter { margin-bottom: 14px }

/* ---------- timeline (replay) ---------- */
.timeline { display: grid; gap: 0; position: relative }
.ev { display: grid; grid-template-columns: 64px 18px minmax(0, 1fr); gap: 0 14px; padding: 0 0 18px; position: relative }
.ev .yr { font-family: var(--font-head); font-size: 1.1rem; text-align: right; padding-top: 1px }
.ev .yr small { display: block; font-family: var(--font); font-size: .7rem; color: var(--muted) }
.ev .dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line); background: var(--bg); margin-top: 6px; position: relative; z-index: 1 }
.ev::before { content: ""; position: absolute; left: 84.5px; top: 20px; bottom: -4px; width: 2px; background: var(--line) }
.ev:last-child::before { display: none }
.ev.k-paid .dot { border-color: var(--ok); background: var(--ok) }
.ev.k-sunset .dot, .ev.k-handover .dot { border-color: var(--accent); background: var(--accent) }
.ev.k-drill .dot { border-style: dashed; border-color: var(--ink) }
.ev.k-refused .dot { border-color: var(--bad); background: var(--bad) }
.ev .body { min-width: 0; display: grid; gap: 6px }
.ev .txs { display: flex; flex-wrap: wrap; gap: 4px 12px }
.ev.future { opacity: .35 }
.ev.current .body > p:first-child { font-weight: 600 }

/* ---------- doors ---------- */
.door-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--gap) }
.item.float-try, .item.float-try:is(*) { grid-template-columns: minmax(0, 1fr) auto }
.item.tagged { grid-template-columns: minmax(0, 1fr) auto }
.item.tagged .what p .badge { margin-right: 6px; vertical-align: 1px }
.proof { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); margin-bottom: 18px }
.proof a { display: block; padding: 16px 18px; border-radius: 20px; background: var(--panel); color: inherit; text-decoration: none; border: 1px solid transparent }
.proof a:hover, .proof a:focus-visible { border-color: var(--line) }
.proof b { display: block; font-family: "Varela Round", system-ui, sans-serif; font-weight: 400; font-size: 1.9rem; line-height: 1.1; font-variant-numeric: tabular-nums }
.proof b small { font-size: .9rem; color: var(--muted) }
.proof span { display: block; font-size: .84rem; color: var(--muted); margin-top: 6px }
.door { background: var(--panel); border-radius: var(--r-panel); padding: 22px; display: grid; gap: 12px; align-content: start; text-decoration: none; transition: transform .3s var(--ease) }
.door:hover { transform: translateY(-2px) }
.door .n { font-family: var(--mono); font-size: .72rem; color: var(--muted) }
.door p { color: var(--muted); font-size: .92rem }

/* ---------- steps (school, Q-Day) ---------- */
.steps { display: grid; gap: 8px; counter-reset: s }
.step { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: start; padding: 12px; border-radius: 16px; background: var(--chip); transition: opacity .3s }
.step::before { counter-increment: s; content: counter(s); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 700; background: var(--panel); color: var(--muted) }
.step.wait { opacity: .45 }
.step.run::before { content: ""; border: 2px solid var(--ink); border-right-color: transparent; animation: spin .8s linear infinite; width: 22px; height: 22px; margin: 2px }
.step.done::before { content: "✓"; background: var(--ok); color: #fff }
.step.no::before { content: "✕"; background: var(--bad); color: #fff }
.step .d { font-size: .82rem; color: var(--muted); overflow-wrap: anywhere }
.step .d code { font-family: var(--mono); font-size: .72rem }
.vs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap) }
.counter { font-family: var(--font-head); font-size: clamp(2.2rem, 6vw, 3.4rem); line-height: 1 }
.counter.ok { color: var(--ok) } .counter.bad { color: var(--bad) }
.amounts { display: flex; flex-wrap: wrap; gap: 6px }

/* ---------- chat ---------- */
.chat { display: grid; gap: 10px; align-content: start; min-height: 260px }
.msg { max-width: 86%; padding: 11px 14px; border-radius: 18px; font-size: .94rem; animation: slide .4s var(--ease) both }
.msg.me { background: var(--ink); color: var(--bg); justify-self: end; border-bottom-right-radius: 6px }
.msg.agent { background: var(--chip); justify-self: start; border-bottom-left-radius: 6px }
.msg .src { display: block; font-size: .72rem; color: var(--muted); margin-top: 6px }
.msg .tri { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; font-size: .72rem; color: var(--muted) }
.msg.chain { background: var(--bad-soft); color: var(--ink); max-width: 100% }
.compose { display: flex; gap: 8px; margin-top: 14px }
.compose input, .field input, .field select { flex: 1; min-width: 0; font: inherit; color: var(--ink); background: var(--chip); border: 1px solid var(--line); border-radius: 999px; padding: 10px 16px }
.compose input:focus, .field input:focus { outline: 2px solid var(--accent); outline-offset: 1px }
.suggest { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px }
.field { display: grid; gap: 6px; font-size: .85rem }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; font-size: .88rem }
.kv dt { color: var(--muted) } .kv dd { margin: 0; text-align: right; overflow-wrap: anywhere }

/* ---------- states ---------- */
.state { border-radius: var(--r-slip); padding: 18px; display: grid; gap: 10px; justify-items: start; background: var(--chip) }
.state.error { background: var(--bad-soft) }
.skel { background: linear-gradient(90deg, var(--line) 0 30%, color-mix(in srgb, var(--line) 50%, var(--panel)) 50%, var(--line) 70%); background-size: 300% 100%; animation: sk 1.4s ease-in-out infinite; border-radius: 10px }
@keyframes sk { from { background-position: 100% 0 } to { background-position: 0 0 } }
.note { font-size: .8rem; color: var(--muted); border-left: 2px solid var(--line); padding-left: 10px }

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem }
footer .in { max-width: 1240px; margin: 0 auto; padding: 18px 22px; display: flex; gap: 10px 22px; flex-wrap: wrap; align-items: center }
footer a { color: var(--muted) }
footer .roles { display: flex; gap: 14px }

/* ---------- motion ---------- */
.fade { animation: fade .5s var(--ease) both }
@keyframes fade { from { opacity: 0; transform: translateY(6px) } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important }
}

/* ---------- phones: designed, not squeezed ---------- */
@media (max-width: 980px) {
  .grid { grid-template-columns: 1fr }
  .keys { order: 2 }
  .door-grid { grid-template-columns: 1fr }
}
@media (max-width: 760px) {
  .top-in { flex-wrap: wrap; padding: 10px 16px; gap: 10px }
  .top .seg { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none }
  .top .seg::-webkit-scrollbar { display: none }
  .top .seg a { flex: 1; text-align: center; padding: 7px 8px; font-size: .84rem }
  .theft { grid-template-columns: 1fr; gap: 6px }
  .mode .label-long { display: none }
  main { padding: 16px 16px 48px }
  .panel { padding: 18px; border-radius: 22px }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px }
  .stat b { font-size: 1.2rem }
  .row2 { grid-template-columns: 1fr }
  .vs { gap: 10px }
  .vs .panel { padding: 14px; border-radius: 20px }
  .vs .panel header { display: grid; gap: 2px }
  .vs .counter { font-size: 2.1rem }
  .item { grid-template-columns: 44px minmax(0, 1fr); }
  .item.float-try { grid-template-columns: minmax(0, 1fr) auto }
  .item.tagged { grid-template-columns: minmax(0, 1fr) }
  .item.tagged .right { grid-column: 1 }
  .proof { grid-template-columns: 1fr; gap: 8px }
  .proof a { padding: 12px 14px; display: grid; grid-template-columns: 6.2rem minmax(0, 1fr); gap: 4px 12px; align-items: baseline }
  .proof b { font-size: 1.45rem }
  .proof b small { display: block; font-size: .72rem; margin-top: 2px }
  .proof span { margin-top: 0; font-size: .8rem }
  .item .right { grid-column: 2; justify-items: start; text-align: left; display: flex; gap: 10px; align-items: center; flex-wrap: wrap }
  .ev { grid-template-columns: 44px 14px minmax(0, 1fr); gap: 0 10px }
  .ev::before { left: 60px }
  .msg { max-width: 94% }
  .scrub { grid-template-columns: auto minmax(0, 1fr) }
  .scrub .btn { grid-column: 1 / -1 }
  footer .in { padding: 16px }
}

/* ---------- replay ---------- */
.tl-scroll { max-height: min(68vh, 720px); overflow-y: auto; padding: 4px 4px 0 0; overscroll-behavior: contain; scrollbar-width: thin }
.theft { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; font-size: .88rem; padding: 8px 10px; border-radius: 14px; background: var(--chip) }
.theft .d { font-family: var(--mono); font-size: .72rem; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px }
.panel .stat { background: var(--chip) }
.list.wrap .item .what p { white-space: normal }
.seg.amounts { flex-wrap: nowrap; width: fit-content; max-width: 100% }
.seg.amounts button { flex: 1; padding: 6px 12px }
