/* RECEPTA · terminal register. Decisions (one line each, antislop R-31):
   - Type: JetBrains Mono only (owner-locked monospace voice; a register is columns of data).
   - Colour: two neutral inks + one amber phosphor accent; status hues only carry meaning (ok/fail/planned).
   - Layout: one column stream, because a terminal is one column and the register leads.
   - Corners: square everywhere (terminal cells have no radius). Shadows: none.
   - Motion: stepped glyph changes driven by one JS loop; CSS only for hover/focus feedback. */

@font-face { font-family: 'JetBrains Mono'; src: url('/fonts/JetBrainsMono-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/fonts/JetBrainsMono-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --maxw: 1120px;
  --gut: clamp(16px, 4vw, 40px);
  --sec: clamp(64px, 9vw, 120px);
  --t-h1: clamp(30px, 5.2vw, 64px);
  --t-h2: clamp(20px, 2.4vw, 28px);
  --t-body: 16px;
  --t-data: 14px;
  --t-small: 13px;
  --lh: 1.55;
  color-scheme: dark;
}
html[data-theme='dark'] {
  --bg: #0b0e0c; --surface: #111612; --line: #222a25; --line-2: #2f3a33;
  --ink: #e4e9e5; --dim: #97a39b; --faint: #39443d; --ghost: #1b221e;
  --accent: #f5a524; --on-accent: #0b0e0c;
  --ok: #6cd690; --fail: #ff7a6b; --plan: #8db4e2;
  --glow: 0 0 8px rgba(245, 165, 36, .35);
  color-scheme: dark;
}
html[data-theme='light'] {
  --bg: #eceeec; --surface: #f6f7f6; --line: #cfd5d1; --line-2: #b9c1bc;
  --ink: #0f1311; --dim: #4a544e; --faint: #b4bdb7; --ghost: #dde1de;
  --accent: #8f4f00; --on-accent: #f6f7f6;
  --ok: #1d6b37; --fail: #b0261b; --plan: #2b5a8a;
  --glow: none;
  color-scheme: light;
}
:lang(zh) body { font-family: var(--mono), 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', 'Noto Sans CJK SC', sans-serif; }
:lang(ja) body { font-family: var(--mono), 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Meiryo', 'Noto Sans JP', 'Noto Sans CJK JP', sans-serif; line-break: strict; }
:lang(ko) body { font-family: var(--mono), 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', 'Noto Sans CJK KR', sans-serif; word-break: keep-all; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--t-body)/var(--lh) var(--mono); -webkit-font-smoothing: antialiased; overflow-x: clip; }
::selection { background: var(--accent); color: var(--on-accent); }
a { color: inherit; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); color: var(--accent); }
a, button, summary, label[for], select, [role='button'] { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-weight: 700; margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
code, pre, kbd { font-family: var(--mono); }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--accent); color: var(--on-accent); padding: 10px 14px; }
.skip:focus { top: 8px; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gut); }
.dim { color: var(--dim); }
.acc { color: var(--accent); }
.ok { color: var(--ok); } .fail { color: var(--fail); } .plan { color: var(--plan); }
.tnum { font-variant-numeric: tabular-nums; }
.w2 { display: inline-block; width: 2ch; text-align: center; overflow: hidden; vertical-align: bottom; }

/* Bracket flags: real status only (LIVE / PLANNED / SIMULATION / STUB). */
.flag { display: inline-block; font-size: var(--t-small); line-height: 1.2; padding: 2px 6px; border: 1px solid currentColor; white-space: nowrap; vertical-align: 1px; }
.flag::before { content: '['; } .flag::after { content: ']'; }
.flag.plan { color: var(--plan); } .flag.sim, .flag.stub { color: var(--dim); border-style: dashed; } .flag.live { color: var(--ok); }

/* Buttons: inverse video on hover, the terminal's own highlight. */
.btn { font: 700 var(--t-data)/1 var(--mono); color: var(--ink); background: transparent; border: 1px solid var(--line-2); min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease); }
.btn:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.primary:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: .45; background: transparent; color: var(--dim); border-color: var(--line); transform: none; }
.btn.sm { min-height: 36px; padding: 0 10px; font-size: var(--t-small); }

/* ---------- header (sticky command line) ---------- */
.bar { position: sticky; top: 0; z-index: 50; background: var(--bg); border-bottom: 1px solid transparent; transition: border-color .2s var(--ease); }
.bar.solid { border-bottom-color: var(--line); }
.bar .wrap { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: .02em; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.brand .cur { display: inline-block; width: .6em; height: 1.05em; background: var(--accent); vertical-align: -2px; }
.nav { display: flex; gap: 2px; margin-left: 8px; }
.nav a { font-size: var(--t-small); text-decoration: none; padding: 0 8px; min-height: 44px; display: inline-flex; align-items: center; color: var(--dim); }
.nav a:hover, .nav a[aria-current='true'] { color: var(--ink); }
.nav a[aria-current='true']::before { content: '>'; color: var(--accent); margin-right: 4px; }
.pager { margin-left: auto; font-size: var(--t-small); color: var(--dim); white-space: pre; }
.ctl { display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); }
.seg button { font: 400 var(--t-small)/1 var(--mono); background: transparent; color: var(--dim); border: 0; min-width: 40px; min-height: 40px; padding: 0 8px; }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button:hover { color: var(--ink); background: var(--ghost); }
.seg button[aria-pressed='true'] { background: var(--ink); color: var(--bg); }
.menu-btn { display: none; }
.sheet { display: none; }

/* ---------- hero ---------- */
.hero { padding-top: 8px; }
.scene { display: block; width: 100%; }
.loom { height: clamp(150px, 24vw, 300px); }
.hero h1 { font-size: var(--t-h1); line-height: 1.08; letter-spacing: -.02em; margin-top: clamp(20px, 3vw, 36px); max-width: 18ch; }
.hero .lead { margin-top: 16px; max-width: 64ch; color: var(--dim); font-size: clamp(16px, 1.3vw, 18px); }

/* ---------- console (the try-it box) ---------- */
.console { margin-top: clamp(24px, 3.4vw, 40px); border: 1px solid var(--line-2); background: var(--surface); }
.console .row1 { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px 6px; }
.ps1 { color: var(--accent); white-space: nowrap; font-weight: 700; }
.console textarea { flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: transparent; color: var(--ink); font: 400 var(--t-body)/1.5 var(--mono); padding: 0; min-height: 3em; caret-color: var(--accent); }
.console textarea::placeholder { color: var(--dim); }
.console .row1:focus-within { box-shadow: inset 0 -1px 0 var(--accent); }
.console .row2 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 16px 14px; border-top: 1px dashed var(--line); font-size: var(--t-small); color: var(--dim); }
.console .row2 b { color: var(--ink); font-weight: 400; }
.console .row2 .flag { white-space: normal; max-width: 100%; }
.console .row2 .send { margin-left: auto; }
.rail { margin: 0; padding: 12px 16px; border-top: 1px solid var(--line); font-size: var(--t-data); line-height: 1.3; white-space: pre; overflow: hidden; color: var(--faint); }
.rail .lbl { color: var(--dim); } .rail .lit { color: var(--accent); text-shadow: var(--glow); } .rail .pk { color: var(--accent); } .rail .x { color: var(--fail); } .rail .gh { color: var(--dim); }
.reply { border-top: 1px solid var(--line); padding: 14px 16px; display: none; }
.reply.on { display: block; }
.reply .txt { white-space: pre-wrap; overflow-wrap: anywhere; }
.reply .foot { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; font-size: var(--t-small); color: var(--dim); }
.state { padding: 0 16px; font-size: var(--t-small); }
.state:not(:empty) { padding: 12px 16px; border-top: 1px solid var(--line); }
.state.warn { color: var(--fail); }
.vmine { margin-top: 10px; font-size: var(--t-small); white-space: pre-wrap; overflow-wrap: anywhere; }
.hint { font-size: var(--t-small); color: var(--dim); margin-top: 10px; }
.hint a { display: inline-flex; align-items: center; min-height: 44px; }

/* ---------- section heads ---------- */
.sec { padding-top: var(--sec); }
.cmd { font-size: var(--t-h2); line-height: 1.3; display: flex; gap: .6ch; align-items: baseline; flex-wrap: wrap; }
.cmd .p { color: var(--accent); }
.cmd .typed { min-height: 1.3em; }
.cmd .flag { font-weight: 400; }
.desc { margin-top: 12px; color: var(--dim); max-width: 68ch; }

/* ---------- register ---------- */
.reg-head { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 10px 28px; align-items: flex-end; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat .k { font-size: var(--t-small); color: var(--dim); }
.stat .v { font-size: clamp(18px, 2vw, 24px); font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .v.hash { font-size: var(--t-data); font-weight: 400; }
.reg-tools { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.live-dot { font-size: var(--t-small); color: var(--dim); display: inline-flex; align-items: center; gap: 6px; }
.led { display: inline-block; width: 8px; height: 8px; background: var(--dim); }
.led.on { background: var(--ok); } .led.off { background: var(--fail); }
.filter { font: 400 var(--t-data)/1 var(--mono); color: var(--ink); background: transparent; border: 1px solid var(--line-2); min-height: 36px; padding: 0 10px; width: 22ch; max-width: 100%; }
.filter::placeholder { color: var(--dim); }
.reg { list-style: none; margin: 0; padding: 0; font-size: var(--t-data); }
.reg > li { border-bottom: 1px solid var(--line); }
.rrow { all: unset; box-sizing: border-box; display: grid; grid-template-columns: 2ch 9ch 10ch minmax(0, 1fr) auto; gap: 0 14px; align-items: baseline; width: 100%; padding: 9px 4px; cursor: pointer; font: 400 var(--t-data)/1.5 var(--mono); }
.rrow:hover { background: var(--ghost); }
.rrow:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rrow .st { color: var(--ok); }
.rrow .st.bad { color: var(--fail); }
.rrow .id { font-weight: 700; }
.rrow .tm { color: var(--dim); }
.rrow .mid { display: flex; flex-wrap: wrap; gap: 0 14px; min-width: 0; overflow: hidden; }
.rrow .mid span { white-space: nowrap; }
.rrow .hx { color: var(--accent); white-space: nowrap; }
.rrow.fresh { background: var(--ghost); }
.rbox { margin: 0; padding: 4px 4px 14px; white-space: pre; overflow-x: auto; font-size: var(--t-data); line-height: 1.45; color: var(--ink); }
.rbox .k { color: var(--dim); } .rbox .b { color: var(--faint); }
.rx { padding: 0 4px 14px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; font-size: var(--t-small); }
.reg-state { padding: 18px 4px; color: var(--dim); font-size: var(--t-data); }
.reg-state.err { color: var(--fail); }
.reg-more { margin-top: 14px; }

/* ---------- verify ---------- */
.vgrid { margin-top: 28px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(20px, 3vw, 40px); }
.panel { border: 1px solid var(--line); background: var(--surface); padding: 16px; min-width: 0; }
.panel h3 { font-size: var(--t-data); color: var(--dim); font-weight: 400; margin-bottom: 12px; }
.field { display: block; font-size: var(--t-small); color: var(--dim); margin-bottom: 6px; }
.input { width: 100%; font: 400 var(--t-body)/1.4 var(--mono); color: var(--ink); background: var(--bg); border: 1px solid var(--line-2); padding: 10px 12px; min-height: 44px; }
.input:focus { border-color: var(--accent); outline: none; }
.hashline { margin-top: 12px; font-size: var(--t-data); line-height: 1.5; overflow-wrap: anywhere; word-break: break-all; }
.hashline .df { color: var(--accent); }
.hashline .prevh { color: var(--faint); }
.vlog { margin: 12px 0 0; max-height: 260px; overflow: auto; font-size: var(--t-small); line-height: 1.6; white-space: pre-wrap; }
.vbtns { display: flex; flex-wrap: wrap; gap: 8px; }
.how { margin: 0; padding: 0; list-style: none; font-size: var(--t-small); line-height: 1.7; }
.how li { padding-left: 2ch; text-indent: -2ch; overflow-wrap: anywhere; }
.how li::before { content: '# '; color: var(--accent); }
.links { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: var(--t-small); }
.links a { min-height: 44px; display: inline-flex; align-items: center; }

/* ---------- models ---------- */
.mt { margin-top: 28px; width: 100%; border-collapse: collapse; font-size: var(--t-data); }
.mt th { text-align: left; font-weight: 400; color: var(--dim); font-size: var(--t-small); padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); }
.mt td { padding: 12px 12px 12px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.mt td:first-child { font-weight: 700; white-space: nowrap; }
.measure { margin-top: 28px; }
.mbar { margin: 10px 0 0; font-size: var(--t-data); white-space: pre; overflow: hidden; }
.mbar .r { color: var(--accent); } .mbar .o { color: var(--ink); } .mbar .u { color: var(--faint); }
.legend { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: var(--t-small); color: var(--dim); }
.legend i { font-style: normal; }

/* ---------- quota ---------- */
.qgrid { margin-top: 28px; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(20px, 3vw, 40px); align-items: start; }
.meter { margin-bottom: 18px; }
.meter .k { font-size: var(--t-small); color: var(--dim); display: flex; justify-content: space-between; gap: 12px; }
.meter .bar { font-size: var(--t-data); white-space: pre; overflow: hidden; color: var(--accent); margin-top: 4px; }
.meter .bar .u { color: var(--faint); }
.breaker { margin: 0; font-size: var(--t-data); line-height: 1.25; white-space: pre; overflow: hidden; color: var(--dim); }
.breaker .w { color: var(--ok); } .breaker .x { color: var(--fail); } .breaker .a { color: var(--accent); }
.rules { margin: 18px 0 0; padding: 0; list-style: none; font-size: var(--t-small); color: var(--dim); line-height: 1.8; }
.rules li::before { content: '- '; color: var(--accent); }
.countdown { font-size: clamp(18px, 2vw, 22px); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- pay + token ---------- */
.split { margin-top: 28px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(20px, 3vw, 40px); align-items: start; }
.kv { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 20px; font-size: var(--t-data); }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ascii { margin: 0; font-size: var(--t-data); line-height: 1.3; white-space: pre; overflow: hidden; color: var(--dim); }
.ascii .a { color: var(--accent); } .ascii .i { color: var(--ink); } .ascii .f { color: var(--faint); } .ascii .g { color: var(--ok); }
.scene-cap { margin-top: 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: var(--t-small); color: var(--dim); }
.pot { height: 200px; margin-top: 14px; }

/* ---------- man page ---------- */
.manhead { margin-top: 28px; display: flex; justify-content: space-between; gap: 12px; font-size: var(--t-small); color: var(--dim); border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.man h3 { font-size: var(--t-data); margin-top: 22px; }
.man .ind { margin-top: 6px; padding-left: 4ch; max-width: 76ch; }
.syn { position: relative; margin: 8px 0 0 4ch; border: 1px solid var(--line); background: var(--surface); }
.syn pre { margin: 0; padding: 14px; overflow-x: auto; font-size: var(--t-small); line-height: 1.6; }
.syn .btn { position: absolute; top: 6px; right: 6px; }
.faq { margin: 8px 0 0 4ch; }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { list-style: none; padding: 12px 0; min-height: 44px; display: flex; gap: 1ch; align-items: baseline; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: '+'; color: var(--accent); width: 1ch; flex: none; }
.faq details[open] summary::before { content: '-'; }
.faq summary:hover { color: var(--accent); }
.faq .ans { padding: 0 0 14px 2ch; color: var(--dim); max-width: 72ch; }

/* ---------- footer ---------- */
.foot { margin-top: var(--sec); border-top: 1px solid var(--line); padding: 28px 0 40px; }
.foot .wrap { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: baseline; font-size: var(--t-small); }
.foot nav { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.foot nav a { min-height: 44px; display: inline-flex; align-items: center; }
.foot .bye { margin-left: auto; color: var(--dim); }
.caret { display: inline-block; width: .6em; height: 1.1em; background: var(--accent); vertical-align: -3px; animation: blink 1.1s step-end infinite; }
@keyframes blink { 0%, 72% { opacity: 1; } 73%, 100% { opacity: 0; } }

/* ---------- contracts page ---------- */
.ctable { margin-top: 28px; width: 100%; border-collapse: collapse; font-size: var(--t-data); }
.ctable th { text-align: left; font-weight: 400; color: var(--dim); padding: 14px 16px 14px 0; border-bottom: 1px solid var(--line); vertical-align: top; width: 30%; }
.ctable td { padding: 14px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; word-break: break-word; }
.ctable td .btn { margin-left: 8px; }
.anti { margin-top: 36px; border: 1px solid var(--accent); padding: 18px; }
.anti h2 { font-size: var(--t-data); color: var(--accent); }
.anti ul { margin: 10px 0 0; padding: 0; list-style: none; line-height: 1.8; }
.anti li::before { content: '! '; color: var(--accent); font-weight: 700; }

/* ---------- theme wipe overlay ---------- */
#wipe { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 200; pointer-events: none; display: none; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .nav, .pager { display: none; }
  .menu-btn { display: inline-flex; }
  .ctl { margin-left: auto; }
  .sheet.open { display: block; position: fixed; inset: 64px 0 0; z-index: 49; background: var(--bg); border-top: 1px solid var(--line); padding: 12px var(--gut) 40px; overflow-y: auto; }
  .sheet a { display: flex; align-items: center; min-height: 52px; border-bottom: 1px solid var(--line); text-decoration: none; font-size: 18px; gap: 1ch; }
  .sheet a::before { content: 'cd'; color: var(--accent); font-size: var(--t-small); width: 3ch; }
  .sheet .seg { margin-top: 20px; }
  .vgrid, .qgrid, .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  :root { --t-data: 13.5px; }
  .bar .wrap { gap: 10px; height: 60px; }
  .sheet.open { inset: 60px 0 0; }
  .ctl .seg.lang { display: none; }
  .rrow { grid-template-columns: 2ch auto minmax(0, 1fr); gap: 2px 10px; }
  .rrow .tm { justify-self: end; }
  .rrow .mid { grid-column: 2 / -1; }
  .rrow .hx { grid-column: 2 / -1; }
  .console .row2 .send { margin-left: 0; width: 100%; justify-content: center; }
  .console textarea { min-height: 4.5em; }
  .reg-tools { margin-left: 0; width: 100%; }
  .filter { flex: 1; width: auto; }
  .mt:not(.cat) th:nth-child(3), .mt:not(.cat) td:nth-child(3) { display: none; }
  .cat td { padding-right: 8px; }
  .cat td:first-child { white-space: normal; overflow-wrap: anywhere; }
  .man .ind, .syn, .faq { margin-left: 0; padding-left: 0; }
  .ctable th, .ctable td { display: block; width: 100%; padding: 4px 0; border: 0; }
  .ctable tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .foot .bye { margin-left: 0; }
}
@media (min-width: 981px) { .sheet { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
@media print { .bar, .console, #wipe, .reg-tools { display: none; } }

/* utility classes (no inline styles: CSP style-src 'self') */
.mt24 { margin-top: 24px; } .mt10 { margin-top: 10px; }
.small { font-size: var(--t-small); }
.subh { font-size: var(--t-small); font-weight: 400; color: var(--dim); }
.herobar { display: flex; justify-content: flex-end; }

/* models --all: the full supply list */
.catalog { margin-top: 40px; }
.cmd.sub { font-size: clamp(16px, 1.6vw, 20px); }
.listhead { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--dim); }
.cat td { padding-top: 9px; padding-bottom: 9px; }

/* jon fix 27 Nov: the hidden attribute must always win over .flag display */
[hidden] { display: none !important; }
