:root {
  --bg: #0a0a0a;
  --panel: #0d0d0d;
  --line: #262626;
  --line-2: #3a3a3a;
  --text: #e8e6e1;
  --muted: #8b8984;
  --dim: #5b5954;
  --red: #ff3b1f;
  --hoard: #f2b134;
  --ward: #5cc8ff;
  --heart: #ff3b5c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 13px/1.5 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace; -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
button, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
::selection { background: var(--red); color: #000; }

.app { min-height: 100vh; display: grid; grid-template-rows: auto minmax(0, 1fr); }

/* ---------- top bar ---------- */
.bar { display: flex; align-items: center; gap: 14px; height: 46px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.logo { text-decoration: none; letter-spacing: 0.04em; font-size: 14px; }
.logo b { font-weight: 700; }
.logo span { color: var(--dim); }
.net { border: 1px solid var(--line-2); padding: 0 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; }
.net:empty { display: none; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; letter-spacing: 0.06em; }
.live b { font-weight: 500; }
.live i { width: 8px; height: 8px; background: var(--red); animation: blink 1.2s steps(2, jump-none) infinite; }
.live.asleep i { background: var(--dim); animation: none; }
.live.over i { background: var(--text); animation: none; }
@keyframes blink { 50% { opacity: 0; } }
.bar nav { margin-left: auto; display: flex; gap: 8px; }
.tbtn { background: transparent; border: 1px solid var(--line-2); padding: 5px 10px; cursor: pointer; font-size: 12px; letter-spacing: 0.06em; white-space: nowrap; }
.tbtn:hover { background: var(--text); color: var(--bg); border-color: var(--text); }
a.tbtn { text-decoration: none; }

/* $CERBO contract address, on the boot screen and under the vault readout */
.ca { display: flex; align-items: center; gap: 10px; font-size: 12px; min-width: 0; }
.ca span { color: var(--muted); font-size: 11px; letter-spacing: 0.1em; white-space: nowrap; }
.ca code { font: inherit; color: var(--text); flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ca button { background: transparent; border: 1px solid var(--line-2); padding: 3px 8px; cursor: pointer; font-size: 11px; letter-spacing: 0.06em; }
.ca button:hover { background: var(--text); color: var(--bg); border-color: var(--text); }
.readout .ca { margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--line); }
.boot .ca { margin-top: 12px; padding: 9px 12px; border: 1px solid var(--line-2); }
.tbtn.x { display: inline-flex; align-items: center; gap: 7px; }

/* ---------- layout ---------- */
.grid {
  display: grid; gap: 10px; padding: 10px; min-height: 0;
  grid-template-columns: minmax(0, 1.45fr) minmax(400px, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "readout log" "cam log" "heads speak";
  height: calc(100vh - 46px);
}
.readout { grid-area: readout; }
.cam { grid-area: cam; }
.heads { grid-area: heads; }
.log { grid-area: log; }
.speak { grid-area: speak; }

fieldset.panel { margin: 0; padding: 10px 12px 12px; border: 1px solid var(--line); min-width: 0; min-height: 0; background: var(--panel); }
legend { padding: 0 6px; margin-left: 2px; font-size: 11px; letter-spacing: 0.14em; color: var(--muted); }

/* ---------- readout ---------- */
.cells { display: grid; grid-template-columns: 1.6fr 1fr 1fr 0.8fr; }
.cell { display: flex; flex-direction: column; gap: 4px; padding: 2px clamp(8px, 1vw, 14px); border-left: 1px solid var(--line); min-width: 0; }
.cell:first-child { border-left: 0; padding-left: 2px; }
.cell > span { font-size: 11px; color: var(--muted); letter-spacing: 0.12em; white-space: nowrap; }
.cell b { font-weight: 500; font-size: clamp(14px, 1.25vw, 18px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell.pot b { font-size: clamp(26px, 2.6vw, 38px); font-weight: 600; line-height: 1.05; letter-spacing: -0.02em; }
.cell.pot em { font-style: normal; font-size: 0.45em; color: var(--muted); font-weight: 500; letter-spacing: 0.04em; }

/* ---------- camera feed ---------- */
.cam { display: flex; flex-direction: column; padding: 8px; }
.feedcam { position: relative; flex: 1; min-height: 320px; overflow: hidden; background: #070303; }
.lair { position: absolute; inset: 0; }
.lair canvas { display: block; }
/* faint scan lines: it is a camera feed */
.feedcam::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px); }
.hud { position: absolute; z-index: 2; font-size: 11px; letter-spacing: 0.1em; color: #d8d5cf; padding: 2px 6px; background: rgba(8, 8, 8, 0.55); }
.hud a { text-decoration: none; }
.hud a:hover { text-decoration: underline; }
.tl { top: 14px; left: 14px; }
.tr { top: 14px; right: 14px; display: flex; align-items: center; gap: 6px; }
.bl { bottom: 14px; left: 14px; }
.br { bottom: 14px; right: 14px; }
.br:empty { display: none; }
.rec { width: 7px; height: 7px; background: var(--red); border-radius: 50%; animation: blink 1.2s steps(2, jump-none) infinite; }
.corner { position: absolute; z-index: 2; width: 18px; height: 18px; border: 0 solid rgba(232, 230, 225, 0.7); pointer-events: none; }
.c1 { top: 6px; left: 6px; border-top-width: 1px; border-left-width: 1px; }
.c2 { top: 6px; right: 6px; border-top-width: 1px; border-right-width: 1px; }
.c3 { bottom: 6px; left: 6px; border-bottom-width: 1px; border-left-width: 1px; }
.c4 { bottom: 6px; right: 6px; border-bottom-width: 1px; border-right-width: 1px; }
.head-tag {
  position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; opacity: 0; transition: opacity 0.6s;
  font-size: 11px; letter-spacing: 0.1em; padding: 2px 6px; white-space: nowrap;
  color: var(--c); border: 1px solid var(--c); background: rgba(8, 8, 8, 0.78);
}
.head-tag span { color: var(--muted); }

/* ---------- the three heads ---------- */
.heads { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); background: var(--panel); }
.head { display: grid; grid-template-columns: 44px 1fr; gap: 10px; padding: 10px 12px; border-left: 1px solid var(--line); min-width: 0; }
.head:first-child { border-left: 0; }
.head > div { min-width: 0; }
.head img { width: 44px; height: 44px; object-fit: cover; border: 1px solid var(--c); display: block; filter: saturate(0.85); }
.head .nm { color: var(--c); font-weight: 600; letter-spacing: 0.1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head .nm span { color: var(--dim); font-weight: 400; letter-spacing: 0.04em; }
.head .st { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head .st b { color: var(--text); font-weight: 500; }
.head .bl { font-size: 11.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- log ---------- */
.log { display: flex; flex-direction: column; }
.log-head { display: flex; align-items: center; gap: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; }
.tabs button { background: none; border: 1px solid var(--line-2); padding: 2px 10px; cursor: pointer; color: var(--muted); font-size: 12px; letter-spacing: 0.08em; }
.tabs button + button { border-left: 0; }
.tabs button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.queue { margin-left: auto; font-size: 11px; color: var(--muted); letter-spacing: 0.08em; }
.log-body { flex: 1; overflow-y: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.more { display: block; width: 100%; background: none; border: 0; color: var(--dim); padding: 10px 0; cursor: pointer; letter-spacing: 0.08em; font-size: 11px; }
.more:hover { color: var(--text); }
.sys { margin: 10px 0; padding: 8px 10px; border: 1px solid var(--line-2); color: var(--text); font-size: 12px; }
.sys.won { border-color: var(--text); background: var(--text); color: var(--bg); }
.sys.won a { color: var(--bg); }
.sys a { color: var(--muted); }
.feed { list-style: none; margin: 0; padding: 0; }
.empty { color: var(--dim); padding: 24px 0; }
.empty::after { content: '█'; margin-left: 4px; animation: blink 1s steps(2, jump-none) infinite; }

.entry { padding: 12px 0 14px; border-bottom: 1px dashed var(--line); }
.entry.refunded { opacity: 0.55; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--dim); font-size: 11.5px; }
.meta .id { color: var(--muted); }
.meta .you { color: var(--text); }
.meta a { text-decoration: none; margin-left: auto; }
.meta a:hover { color: var(--text); }
.said { margin: 6px 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); font-size: 13.5px; }
.said::before { content: '> '; color: var(--red); }
.v { display: grid; grid-template-columns: 58px 54px minmax(0, 1fr); gap: 10px; padding: 2px 0; font-size: 12.5px; }
.v .n { color: var(--c); letter-spacing: 0.08em; }
.v .d { letter-spacing: 0.08em; }
.v .d.deny { color: var(--red); }
.v .d.grant { color: var(--bg); background: var(--text); text-align: center; }
.v .r { color: #bdb9b1; overflow-wrap: anywhere; }
.v .r.reading { color: var(--dim); }
.v .r.reading::after, .v .r.typing::after { content: '█'; animation: blink 1s steps(2, jump-none) infinite; }
.note { margin-top: 8px; font-size: 12px; color: var(--dim); }
.entry.ev { padding: 8px 0; }
.entry.ev .evt { color: var(--muted); }
.entry.ev b { color: var(--text); font-weight: 600; }
.entry.ev.burn b { color: var(--red); }
.modal .kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px dashed var(--line); }
.modal .kv span { color: var(--muted); letter-spacing: 0.08em; font-size: 12px; }
.modal .kv a { text-decoration: none; }
.modal .evlist { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--muted); }
.modal .evlist li { display: block; padding: 4px 0; border-top: 1px dashed var(--line); counter-increment: none; color: var(--muted); }
.modal .evlist li::before { content: none; }
.note.won { color: var(--bg); background: var(--text); padding: 4px 8px; }

/* ---------- speak ---------- */
.speak { padding: 10px 12px; }
.prompt { display: flex; gap: 8px; align-items: flex-start; }
.prompt span { color: var(--red); padding-top: 1px; }
.prompt textarea { flex: 1; min-height: 64px; resize: none; background: transparent; border: 0; outline: none; padding: 0; line-height: 1.5; caret-color: var(--red); }
.prompt textarea::placeholder { color: var(--dim); }
.speak-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.count { color: var(--dim); font-size: 11.5px; }
.count.over { color: var(--red); }
.hint { color: var(--dim); font-size: 11.5px; }
.send { margin-left: auto; background: var(--red); color: #0a0a0a; border: 1px solid var(--red); padding: 8px 14px; cursor: pointer; font-weight: 700; letter-spacing: 0.08em; }
.send:hover:not(:disabled) { background: var(--text); border-color: var(--text); }
.send:disabled { background: transparent; color: var(--dim); border-color: var(--line-2); cursor: default; }

/* ---------- modal + toasts ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72); display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal { margin: 0; background: var(--panel); border: 1px solid var(--line-2); padding: 16px 18px 18px; width: min(560px, 100%); max-height: 86vh; overflow: auto; position: relative; }
.modal legend { color: var(--text); }
.modal p { color: var(--muted); margin: 0 0 12px; }
.modal ol { list-style: none; margin: 0; padding: 0; counter-reset: p; }
.modal li { counter-increment: p; display: grid; grid-template-columns: 34px 1fr; padding: 8px 0; border-top: 1px dashed var(--line); color: #cfccc5; }
.modal li::before { content: counter(p, decimal-leading-zero); color: var(--red); }
.modal .x { position: absolute; top: -9px; right: 10px; background: var(--panel); border: 1px solid var(--line-2); cursor: pointer; padding: 0 6px; color: var(--muted); }
.modal .x:hover { color: var(--text); }
.wl { display: flex; flex-direction: column; margin-top: 4px; }
.wl > * { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border: 0; border-top: 1px dashed var(--line); background: none; text-decoration: none; cursor: pointer; text-align: left; }
.wl > *:hover { color: var(--bg); background: var(--text); }
.wl .dot { width: 22px; height: 22px; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.wl .tag { margin-left: auto; color: inherit; opacity: 0.6; border: 0; font-size: 11px; }
.toasts { position: fixed; bottom: 14px; right: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 70; width: min(420px, calc(100% - 28px)); }
.toast { background: var(--panel); border: 1px solid var(--line-2); padding: 8px 12px; font-size: 12px; }
.toast::before { content: '[OK] '; color: var(--muted); }
.toast.err { border-color: var(--red); }
.toast.err::before { content: '[ERR] '; color: var(--red); }
.toast a { color: var(--muted); }

/* ---------- boot screen ---------- */
body.booting { overflow: hidden; }
.boot { position: fixed; inset: 0; z-index: 80; background: var(--bg); display: grid; place-items: center; padding: 20px; overflow-y: auto; transition: opacity 0.5s, visibility 0.5s; }
.boot.out { visibility: hidden; transition: visibility 0s 0.55s; }
.boot.out .boot-in { animation: crt-off 0.5s cubic-bezier(0.7, 0, 0.84, 0) forwards; }
/* a tube monitor switching on: a bright line opens into the picture */
.boot-in { animation: crt-on 0.75s cubic-bezier(0.16, 1, 0.3, 1) both; transform-origin: 50% 50%; }
@keyframes crt-on {
  0% { transform: scale(0.6, 0.004); filter: brightness(4); opacity: 0.2; }
  35% { transform: scale(1, 0.004); filter: brightness(3); opacity: 1; }
  100% { transform: none; filter: none; opacity: 1; }
}
@keyframes crt-off {
  0% { transform: none; filter: none; opacity: 1; }
  55% { transform: scale(1, 0.004); filter: brightness(3); opacity: 1; }
  100% { transform: scale(0, 0.004); filter: brightness(4); opacity: 0; }
}
.boot-in { width: min(1080px, 100%); display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 0 28px; transition: transform 0.5s; }
.boot-top { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding-bottom: 12px; margin-bottom: 18px; border-bottom: 1px solid var(--line); font-size: 13px; }
.boot-top span { color: var(--dim); }
.boot-top em { font-style: normal; font-size: 11px; color: var(--muted); border: 1px solid var(--line-2); padding: 0 6px; text-transform: uppercase; }
.boot-top em:empty { display: none; }
.boot-top i { margin-left: auto; font-style: normal; color: var(--muted); font-size: 12px; }
.boot-cam { position: relative; margin: 0; border: 1px solid var(--line); background: #070303; aspect-ratio: 16 / 10; overflow: hidden; align-self: start; }
.boot-cam img { width: 100%; height: 100%; object-fit: cover; display: block; filter: grayscale(1) contrast(1.15) brightness(0.8); transition: filter 1.2s; }
.boot-cam.locked img { filter: none; }
.boot-cam::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px); }
.boot-noise { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; pointer-events: none; mix-blend-mode: screen; transition: opacity 0.6s; }
.boot-scan { position: absolute; left: 0; right: 0; top: -20%; height: 20%; pointer-events: none; background: linear-gradient(180deg, transparent, rgba(232, 230, 225, 0.07) 60%, rgba(232, 230, 225, 0.16) 96%, transparent); animation: scan 2.6s linear infinite; }
@keyframes scan { to { top: 100%; } }
.boot-sig { position: absolute; top: 12px; left: 14px; z-index: 2; font-size: 11px; letter-spacing: 0.1em; padding: 2px 6px; background: rgba(8, 8, 8, 0.6); color: var(--muted); }
.boot-sig::after { content: '█'; margin-left: 4px; animation: blink 1s steps(2, jump-none) infinite; }
.boot-cam.locked .boot-sig { color: var(--text); }
.boot-cam.locked .boot-sig::after { content: none; }
.boot-rec { position: absolute; top: 12px; right: 14px; z-index: 2; display: flex; align-items: center; gap: 6px; font-size: 11px; letter-spacing: 0.1em; padding: 2px 6px; background: rgba(8, 8, 8, 0.6); opacity: 0.25; }
.boot-rec i { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.boot-cam.locked .boot-rec { opacity: 1; }
.boot-cam.locked .boot-rec i { background: var(--red); animation: blink 1.2s steps(2, jump-none) infinite; }
/* the picture locks in: a short colour split, like a feed catching its sync */
.boot-cam.lock img { animation: lock 0.42s steps(3, end); }
@keyframes lock {
  0% { transform: translateX(-6px); filter: drop-shadow(5px 0 0 rgba(255, 40, 60, 0.75)) drop-shadow(-5px 0 0 rgba(60, 200, 255, 0.75)); }
  50% { transform: translateX(4px) skewX(-2deg); filter: drop-shadow(-4px 0 0 rgba(255, 40, 60, 0.6)) drop-shadow(4px 0 0 rgba(60, 200, 255, 0.6)); }
  100% { transform: none; filter: none; }
}
.boot-cam figcaption { position: absolute; left: 14px; bottom: 12px; z-index: 2; font-size: 11px; letter-spacing: 0.1em; padding: 2px 6px; background: rgba(8, 8, 8, 0.6); }
.boot-copy { display: flex; flex-direction: column; min-width: 0; }
.boot-copy h1 { margin: 0; font-size: clamp(26px, 3.3vw, 46px); line-height: 1; font-weight: 700; letter-spacing: -0.03em; min-height: 2em; }
.boot-copy h1.typing::after { content: '█'; font-weight: 400; margin-left: 0.05em; animation: blink 0.8s steps(2, jump-none) infinite; }
.boot-copy p { color: var(--muted); margin: 14px 0 20px; font-size: 14px; max-width: 44ch; transition: opacity 0.5s, transform 0.5s; }
.boot.anim .boot-copy p.wait { opacity: 0; transform: translateY(6px); }
.boot-log { list-style: none; margin: 0 0 14px; padding: 0; font-size: 12.5px; }
.boot-log li { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; color: var(--dim); transition: opacity 0.25s, transform 0.25s; }
.boot.anim .boot-log li:not(.show) { opacity: 0; transform: translateX(-8px); }
.boot-log li::before { content: '>'; color: var(--dim); }
.boot-log li span { white-space: nowrap; }
.boot-log li::after { content: ''; order: 1; flex: 1; border-bottom: 1px dotted var(--line-2); transform: translateY(-3px); }
.boot-log li b { order: 2; font-weight: 500; white-space: nowrap; }
.boot-log li.wip { color: var(--muted); }
.boot-log li.wip b::after { content: '█'; margin-left: 4px; animation: blink 1s steps(2, jump-none) infinite; }
.boot-log li.ok { color: var(--text); }
.boot-log li.ok::before { color: var(--red); }
.boot-log li.ok b { color: var(--text); }
.boot-log .hd { margin-left: 6px; }
.boot-bar { position: relative; height: 18px; border: 1px solid var(--line-2); margin: 0 48px 16px 0; }
.boot-bar i { position: absolute; left: 2px; top: 2px; bottom: 2px; width: 0; max-width: calc(100% - 4px); background: repeating-linear-gradient(90deg, var(--text) 0 9px, transparent 9px 12px); transition: width 0.35s steps(6, end); }
.boot-bar span { position: absolute; right: -48px; width: 42px; text-align: right; top: 0; line-height: 16px; font-size: 11px; color: var(--muted); }
.boot-enter { background: var(--red); color: #0a0a0a; border: 1px solid var(--red); padding: 14px 16px; cursor: pointer; font-weight: 700; letter-spacing: 0.1em; font-size: 14px; text-align: left; }
.boot-enter:hover:not(:disabled) { background: var(--text); border-color: var(--text); }
.boot-enter:disabled { background: transparent; color: var(--dim); border-color: var(--line-2); cursor: default; }
.boot-enter:not(:disabled)::after { content: '▌'; margin-left: 6px; animation: blink 1s steps(2, jump-none) infinite; }
.boot-enter.armed { animation: armed 0.5s steps(2, jump-none) 2; }
@keyframes armed { 50% { background: var(--text); border-color: var(--text); } }
@media (max-width: 760px) {
  .boot { place-items: start center; }
  .boot-in { grid-template-columns: minmax(0, 1fr); }
  .boot-cam { margin-bottom: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .boot, .boot-in, .boot-cam img, .boot-bar i, .boot-log li, .boot-copy p { transition: none; animation: none; }
  .boot-scan, .boot-noise { display: none; }
  .boot.out .boot-in, .boot-cam.lock img, .boot-enter.armed { animation: none; }
}

@media (max-width: 980px) {
  .grid { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "readout" "cam" "speak" "heads" "log"; }
  .feedcam { flex: none; min-height: 0; height: 62vh; }
  .log-body { flex: none; max-height: none; overflow: visible; }
  .cells { grid-template-columns: 1fr 1fr; row-gap: 10px; }
  .cell:nth-child(3) { border-left: 0; padding-left: 2px; }
  .heads { grid-template-columns: 1fr; }
  .head { border-left: 0; border-top: 1px solid var(--line); }
  .head:first-child { border-top: 0; }
}
@media (max-width: 560px) {
  .bar { gap: 10px; padding: 0 10px; }
  .wide, .net, .hint, .logo span, .live .rd, .hud.bl { display: none; }
  .live { white-space: nowrap; }
  .live { font-size: 11px; }
  .tbtn { padding: 4px 8px; font-size: 11px; }
  #pact-btn { display: none; } /* DOCS covers it on phones */
  .bar:has(#token-btn:not([hidden])) .live b { display: none; } /* keep the dot, give $CERBO the room */
  .v { grid-template-columns: 52px 48px minmax(0, 1fr); gap: 8px; }
  .meta a { margin-left: 0; }
}
