/* ============================================================
   SOAR SCAN — Proof-of-Behavior Terminal
   Amber phosphor (P3) on deep ink. Single committed visual world.
   ============================================================ */

:root{
  --bg:#07090E;
  --panel:#0C1017;
  --panel-2:#11161F;
  --line:#1E2735;
  --line-soft:#161D28;

  --txt:#C9D2E0;
  --dim:#7C879B;
  --faint:#4E5871;

  --amber:#F0A93B;
  --amber-hi:#FFC46B;
  --amber-deep:#8A5F17;
  --amber-ghost:rgba(240,169,59,.13);

  --good:#5FC57C;
  --warn:#E5B84E;
  --bad:#E0674C;

  --mono:"JetBrains Mono",ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  --disp:"Archivo","Helvetica Neue",Arial,sans-serif;

  --stage-w:320px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:var(--bg);
  color:var(--txt);
  font-family:var(--mono);
  font-size:14px;
  line-height:1.62;
  overflow:hidden;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}

/* ---------- CRT frame ---------- */
.crt{
  position:relative;
  height:100dvh;
  display:grid;
  grid-template-rows:auto minmax(0,1fr) auto;
  background:
    radial-gradient(120% 80% at 50% 0%, #0D1219 0%, var(--bg) 62%);
}
.scanlines{
  position:absolute; inset:0; z-index:6; pointer-events:none;
  background:repeating-linear-gradient(
    to bottom, rgba(255,255,255,.024) 0 1px, transparent 1px 3px);
  mix-blend-mode:overlay;
}
.vignette{
  position:absolute; inset:0; z-index:5; pointer-events:none;
  background:radial-gradient(130% 100% at 50% 45%, transparent 55%, rgba(0,0,0,.55) 100%);
}

/* ---------- top bar ---------- */
.bar{
  display:flex; align-items:center; justify-content:space-between; gap:1rem;
  padding:.55rem clamp(.7rem,2.2vw,1.4rem);
  border-bottom:1px solid var(--line);
  background:linear-gradient(180deg,var(--panel-2),var(--panel));
  z-index:7;
}
.bar-left{display:flex; align-items:center; gap:.55rem; min-width:0}
.led{
  width:8px;height:8px;border-radius:50%;background:var(--amber-deep);flex:none;
  box-shadow:0 0 0 0 var(--amber-ghost);
}
.led.on{background:var(--good); box-shadow:0 0 10px rgba(95,197,124,.8)}
.led.err{background:var(--bad); box-shadow:0 0 10px rgba(224,103,76,.8)}
.brand{
  font-family:var(--disp); font-weight:900; letter-spacing:.02em;
  font-size:.92rem; color:var(--amber); white-space:nowrap;
}
.brand-dim{color:var(--dim); font-weight:800}
.bar-sep{color:var(--line)}
.bar-meta{
  color:var(--dim); font-size:.72rem; letter-spacing:.06em;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.bar-right{display:flex; gap:.4rem; flex:none}
.bar-btn{
  font-family:var(--mono); font-size:.7rem; letter-spacing:.1em; text-transform:uppercase;
  color:var(--dim); background:transparent; border:1px solid var(--line);
  padding:.25rem .55rem; border-radius:3px; cursor:pointer; text-decoration:none;
  transition:color .15s, border-color .15s;
}
.bar-btn:hover{color:var(--amber); border-color:var(--amber-deep)}
.bar-btn:focus-visible,.chip:focus-visible{outline:2px solid var(--amber); outline-offset:2px}

/* ---------- shell ---------- */
.shell{
  display:grid; grid-template-columns:minmax(0,1fr) var(--stage-w);
  min-height:0; z-index:2;
}
@media (max-width:900px){
  .shell{grid-template-columns:minmax(0,1fr)}
  :root{--stage-w:0px}
}

/* ---------- console ---------- */
.console{
  min-height:0; overflow-y:auto; overflow-x:hidden;
  padding:clamp(.8rem,2.2vw,1.5rem) clamp(.7rem,2.2vw,1.4rem) 1.2rem;
  scrollbar-width:thin; scrollbar-color:var(--line) transparent;
}
.console::-webkit-scrollbar{width:8px}
.console::-webkit-scrollbar-thumb{background:var(--line); border-radius:4px}

.row{white-space:pre-wrap; word-break:break-word}
.block{margin:0 0 1.05rem}
.block:last-of-type{margin-bottom:.5rem}

.echo{color:var(--txt)}
.echo .prompt{color:var(--amber); margin-right:.5ch}
.k{color:var(--dim)}
.v{color:var(--txt)}
.hi{color:var(--amber)}
.ok{color:var(--good)}
.no{color:var(--bad)}
.wn{color:var(--warn)}
.ft{color:var(--faint)}
.b{font-weight:700}
.u{border-bottom:1px solid var(--line)}
a.lnk{color:var(--amber); text-decoration:none; border-bottom:1px solid var(--amber-deep)}
a.lnk:hover{border-bottom-color:var(--amber)}

.rule{border:0;border-top:1px solid var(--line-soft); margin:.55rem 0}

/* verdict banner */
.verdict{
  display:inline-flex; align-items:center; gap:.65rem;
  border:1px solid var(--line); border-left-width:3px;
  padding:.5rem .85rem; border-radius:3px; margin:.35rem 0 .1rem;
  background:var(--panel);
}
.verdict.good{border-left-color:var(--good)}
.verdict.warn{border-left-color:var(--warn)}
.verdict.bad{border-left-color:var(--bad)}
.verdict.unk{border-left-color:var(--faint)}
.verdict .grade{
  font-family:var(--disp); font-weight:900; font-size:1.6rem; line-height:1;
}
.verdict .label{font-size:.78rem; letter-spacing:.14em; text-transform:uppercase}

/* meters */
.meter{display:grid; grid-template-columns:12ch 1fr 5ch; gap:.7rem; align-items:center; margin:.16rem 0}
.meter .bar-track{height:6px; background:var(--line-soft); border-radius:3px; overflow:hidden}
.meter .bar-fill{height:100%; background:var(--amber); border-radius:3px}
.meter .bar-fill.good{background:var(--good)}
.meter .bar-fill.warn{background:var(--warn)}
.meter .bar-fill.bad{background:var(--bad)}
.meter .val{text-align:right; color:var(--dim); font-variant-numeric:tabular-nums}

table.t{border-collapse:collapse; margin:.2rem 0}
table.t td{padding:.14rem 1.3rem .14rem 0; vertical-align:top}
table.t td.n{text-align:right; font-variant-numeric:tabular-nums; padding-right:1.6rem}

/* ---------- input line ---------- */
.inputline{position:relative; display:flex; align-items:baseline; gap:.5ch; padding-top:.2rem}
.inputline .prompt{color:var(--amber); font-weight:700}
.typed{color:var(--txt); white-space:pre}
.ghost{color:var(--faint); white-space:pre; pointer-events:none}
.caret{
  display:inline-block; width:.6ch; height:1.15em; background:var(--amber);
  transform:translateY(.18em); animation:blink 1.05s steps(2,end) infinite;
}
.inputline.busy .caret{background:var(--dim); animation:none}
@keyframes blink{0%,52%{opacity:1}53%,100%{opacity:0}}
#cmd{
  position:absolute; inset:0; opacity:0; width:100%; border:0; background:transparent;
  font:inherit; color:transparent; caret-color:transparent; padding:0;
}
#cmd:focus{outline:none}

/* ---------- character stage ---------- */
.stage{
  position:relative; border-left:1px solid var(--line);
  background:linear-gradient(180deg, var(--panel) 0%, #090C12 100%);
  display:flex; flex-direction:column; align-items:center; justify-content:flex-end;
  padding:1rem 1rem 1.2rem; gap:.7rem; overflow:hidden;
}
@media (max-width:900px){ .stage{display:none} }
.stage::before{
  content:""; position:absolute; left:50%; bottom:34%; translate:-50% 0;
  width:230px; height:230px; border-radius:50%;
  background:radial-gradient(circle, var(--amber-ghost) 0%, transparent 70%);
  pointer-events:none;
}
.stage-frame{
  position:relative; flex:1; width:100%; min-height:0;
  display:flex; align-items:flex-end; justify-content:center;
}
.sprite{
  max-width:100%; max-height:100%; object-fit:contain; object-position:bottom center;
  filter:drop-shadow(0 14px 22px rgba(0,0,0,.6)) saturate(.92);
  animation:breathe 5.2s ease-in-out infinite;
  transition:opacity .18s ease;
  will-change:transform;
}
.sprite.swap{opacity:0}
@keyframes breathe{
  0%,100%{transform:translateY(0) scale(1)}
  50%{transform:translateY(-6px) scale(1.008)}
}
.stage-plate{
  display:flex; align-items:baseline; gap:.5rem;
  border-top:1px solid var(--line); padding-top:.7rem; width:100%; justify-content:center;
}
.stage-name{font-family:var(--disp); font-weight:900; color:var(--amber); letter-spacing:.06em}
.stage-role{font-size:.68rem; letter-spacing:.16em; text-transform:uppercase; color:var(--faint)}
.stage-say{
  margin:0; font-size:.78rem; line-height:1.55; color:var(--dim);
  text-align:center; min-height:3.4em;
}

/* ---------- chips ---------- */
.chips{
  display:flex; gap:.45rem; flex-wrap:wrap; z-index:7;
  padding:.6rem clamp(.7rem,2.2vw,1.4rem);
  border-top:1px solid var(--line); background:var(--panel);
}
.chip{
  font-family:var(--mono); font-size:.74rem; color:var(--amber);
  background:transparent; border:1px solid var(--amber-deep);
  padding:.3rem .7rem; border-radius:3px; cursor:pointer; white-space:nowrap;
  transition:background .15s, color .15s;
}
.chip:hover{background:var(--amber-ghost)}
.chip-ghost{color:var(--dim); border-color:var(--line)}
.chip-ghost:hover{color:var(--txt); background:transparent}

/* ---------- motion ---------- */
@media (prefers-reduced-motion:reduce){
  .sprite{animation:none}
  .caret{animation:none}
  .scanlines{display:none}
}

/* ---------- live counters ---------- */
.live{
  display:inline-flex;align-items:center;gap:.35rem;
  font-family:var(--mono);font-size:.68rem;letter-spacing:.06em;
  color:var(--dim);padding:.25rem .5rem;border:1px solid var(--line);border-radius:3px;
  font-variant-numeric:tabular-nums;
}
.live-dot{
  width:6px;height:6px;border-radius:50%;background:var(--good);flex:none;
  animation:pulse 2.4s ease-in-out infinite;
}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.35}}
.live-lbl{color:var(--faint);text-transform:uppercase;margin-left:.15rem}
.live-sep{color:var(--line)}
.bar-home{color:var(--amber);border-color:var(--amber-deep)}
@media (max-width:720px){ .live{display:none} }
@media (prefers-reduced-motion:reduce){ .live-dot{animation:none} }

/* ---------- dialog ---------- */
.dlg{
  border:1px solid var(--line);border-radius:6px;background:var(--panel);
  color:var(--txt);padding:0;max-width:34rem;width:calc(100% - 2rem);
  box-shadow:0 30px 70px -20px rgba(0,0,0,.8);
}
.dlg::backdrop{background:rgba(4,6,10,.72)}
.dlg-in{display:flex;flex-direction:column;gap:.55rem;padding:1.4rem}
.dlg-h{font-family:var(--disp);font-weight:900;font-size:1.15rem;margin:0;color:var(--amber)}
.dlg-p{margin:0 0 .4rem;font-size:.82rem;line-height:1.5;color:var(--dim)}
.dlg-l{font-size:.7rem;letter-spacing:.12em;text-transform:uppercase;color:var(--dim);margin-top:.4rem}
.dlg-opt{color:var(--faint);letter-spacing:0;text-transform:none}
.dlg-i,.dlg-t{
  font-family:var(--mono);font-size:.82rem;color:var(--txt);
  background:var(--bg);border:1px solid var(--line);border-radius:3px;padding:.5rem .6rem;
  width:100%;resize:vertical;
}
.dlg-i:focus,.dlg-t:focus{outline:none;border-color:var(--amber-deep)}
.dlg-row{display:flex;gap:.5rem;justify-content:flex-end;margin-top:.8rem}
.dlg-note{margin:.3rem 0 0;font-size:.74rem;color:var(--faint);min-height:1.1em}
.dlg-note.ok{color:var(--good)}
.dlg-note.err{color:var(--bad)}

/* ---------- inline "this was wrong" ---------- */
.wrongbtn{
  font-family:var(--mono);font-size:.62rem;letter-spacing:.08em;text-transform:uppercase;
  color:var(--faint);background:transparent;border:1px solid var(--line-soft);
  padding:.1rem .4rem;border-radius:2px;cursor:pointer;margin-left:.6rem;
}
.wrongbtn:hover{color:var(--bad);border-color:var(--bad)}
.beta{
  font-family:var(--mono);font-size:.58rem;letter-spacing:.12em;font-weight:700;
  color:var(--bg);background:var(--warn);padding:.08rem .3rem;border-radius:2px;
  margin-left:.5rem;vertical-align:.08em;
}

.nextbtn{
  font-family:var(--mono);font-size:.72rem;color:var(--amber);
  background:transparent;border:1px solid var(--amber-deep);
  padding:.1rem .45rem;border-radius:2px;cursor:pointer;
}
.nextbtn:hover{background:var(--amber-ghost)}

/* ============================================================
   Responsive output
   Layout used to live inside the strings: a 26-character dot leader plus a
   44-character mint address is 70 columns, and a 390px phone fits about 43.
   Structure now carries it, so the same output reads on both.
   ============================================================ */

.kv{display:flex;align-items:baseline;gap:0;margin:.05rem 0}
.kv-lab{color:var(--dim);white-space:nowrap;flex:none}
.kv-dots{color:var(--dim);flex:none;white-space:pre;padding:0 .6ch 0 .6ch}
.kv-val{color:var(--txt);flex:1 1 auto;min-width:0;word-break:break-word;text-align:left}
.kv-val.k{color:var(--dim)}
.kv-val.ft{color:var(--faint)}
.kv-val.hi{color:var(--amber)}

/* tabular blocks */
.tbl{margin:.35rem 0}
.tbl-h,.tbl-r{display:grid;grid-template-columns:repeat(var(--cols,3),minmax(0,1fr));gap:.6rem}
.tbl-h{color:var(--faint);font-size:.72rem;letter-spacing:.1em;text-transform:uppercase;
  padding-bottom:.25rem;border-bottom:1px solid var(--line-soft);margin-bottom:.3rem}
.tbl-r{padding:.12rem 0}
.tbl-r span{font-variant-numeric:tabular-nums}
.tbl-r span:first-child{color:var(--txt)}
.tbl-r span:not(:first-child){color:var(--dim)}
.tbl-r.on span{color:var(--amber);font-weight:700}

@media (max-width:640px){
  /* label above value: nothing truncates, nothing wraps mid-address */
  .kv{flex-direction:column;gap:0;margin:.35rem 0}
  .kv-dots{display:none}
  .kv-lab{font-size:.66rem;letter-spacing:.14em;text-transform:uppercase;color:var(--faint)}
  .kv-val{max-width:100%;text-align:left;word-break:break-all}

  /* a three-column table becomes one labelled row per line */
  .tbl-h{display:none}
  .tbl-r{grid-template-columns:1fr;gap:0;padding:.45rem 0;
    border-bottom:1px solid var(--line-soft)}
  .tbl-r span{display:flex;justify-content:space-between;gap:1rem;padding:.05rem 0}
  .tbl-r span::before{
    content:attr(data-l);color:var(--faint);font-size:.68rem;
    letter-spacing:.1em;text-transform:uppercase;flex:none;
  }
  .tbl-r span:empty{display:none}
}

/* ============================================================
   Phone layout
   Desktop is untouched. Below 900px the character panel was simply hidden,
   which removed the part of the terminal that does the explaining. It becomes
   a strip above the console instead: same sprite, same line, less room.
   ============================================================ */

@media (max-width:900px){
  .shell{grid-template-rows:auto minmax(0,1fr)}

  .stage{
    display:grid !important;
    order:-1;                       /* above the console, not after it */
    grid-template-columns:auto minmax(0,1fr);
    grid-template-rows:auto auto;
    grid-template-areas:"face plate" "face say";
    align-items:center;
    column-gap:.8rem;row-gap:.1rem;
    border-left:0;
    border-bottom:1px solid var(--line);
    padding:.55rem clamp(.7rem,2.2vw,1.4rem);
    background:linear-gradient(180deg,var(--panel),#090C12);
  }
  .stage::before{display:none}       /* the glow needs room it does not have */

  .stage-frame{
    grid-area:face;
    width:52px;height:52px;flex:none;
    align-items:center;justify-content:center;
  }
  .sprite{
    max-height:52px;object-position:center;
    filter:drop-shadow(0 3px 6px rgba(0,0,0,.5)) saturate(.92);
    animation:none;                  /* a 52px figure bobbing is just noise */
  }
  .stage-plate{
    grid-area:plate;border-top:0;padding-top:0;justify-content:flex-start;
    gap:.45rem;align-self:end;margin:0;
  }
  .stage-name{font-size:.78rem}
  .stage-role{font-size:.58rem}
  .stage-say{
    grid-area:say;text-align:left;min-height:0;font-size:.74rem;
    line-height:1.35;margin:0;align-self:start;
    display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
  }

  /* the badge is small and it is the only proof the thing is alive */
  .live{display:inline-flex}
  .bar-btn{padding:.22rem .45rem;font-size:.64rem}
  .bar-meta{display:none}

  /* iOS zooms the page when a focused input is under 16px */
  #cmd{font-size:16px}
  .console{font-size:13px}
  .chips{gap:.35rem;padding:.5rem clamp(.7rem,2.2vw,1.4rem)}
  .chip{font-size:.7rem;padding:.28rem .55rem}
}

@media (max-width:400px){
  .stage-say{-webkit-line-clamp:2;font-size:.7rem}
  .console{font-size:12.5px}
}

/* command list in `help` */
.cmdrow{display:grid;grid-template-columns:14rem minmax(0,1fr);gap:.6rem;padding:.06rem 0}
/* The help list. The column takes the width of the longest signature in its
   group rather than a fixed guess, so no usage string wraps in half. */
.cmdgrid{display:grid;grid-template-columns:max-content minmax(0,1fr);
  column-gap:1.1rem;row-gap:.1rem;max-width:100%}
.cmdgrid .cmdrow-sig{white-space:nowrap}
.cmdrow-sig{color:var(--txt)}
.cmdrow-desc{color:var(--dim)}

/* long identifiers must break rather than push the page sideways */
.brk{word-break:break-all;overflow-wrap:anywhere}

@media (max-width:640px){
  .cmdrow{grid-template-columns:1fr;gap:0;padding:.3rem 0}
  /* On a phone the two columns become two lines, and the signature is
     allowed to wrap again because there is no column left to break. */
  .cmdgrid{grid-template-columns:1fr;row-gap:0}
  .cmdgrid .cmdrow-sig{white-space:normal;padding-top:.35rem}
  .cmdrow-sig{color:var(--amber)}
  .cmdrow-desc{font-size:.9em}

  /* nothing in the console may exceed its box, whatever it contains */
  .row,.kv-val,.tbl-r span{overflow-wrap:anywhere;word-break:break-word}
  .console{overflow-x:hidden}
}

/* ============================================================
   Shrinkability
   A grid or flex child will not go below its content width unless told to.
   The header's right-hand group measured 413px on its own, so at 390px it
   pushed the whole page wider and every line inside inherited the overflow.
   ============================================================ */
.crt,.shell,.console,.bar,.bar-right{min-width:0}
.crt > *{min-width:0}
.bar-right{flex-wrap:wrap;justify-content:flex-end}

@media (max-width:640px){
  .hide-sm{display:none}
  .bar{padding:.45rem .7rem;gap:.5rem}
  .brand{font-size:.8rem}
  .bar-sep{display:none}
  .live{padding:.2rem .4rem;font-size:.62rem;gap:.25rem}
  .live-lbl{display:none}          /* the numbers carry it; the words do not fit */
  .bar-right{gap:.3rem}
  .chips{overflow-x:auto;flex-wrap:nowrap;scrollbar-width:none}
  .chips::-webkit-scrollbar{display:none}
  .chip{flex:none}
}

/* ============================================================
   Keep the leader short
   Letting the dots flex across a 1120px console throws every value to the far
   right edge — technically aligned, visually broken. The original ASCII layout
   was a fixed ~26 columns, so cap the row instead of letting it stretch.
   ============================================================ */
.tbl{max-width:62ch}
.cmdrow{max-width:74ch}

@media (max-width:640px){
  .kv,.tbl,.cmdrow{max-width:100%}
}

/* ============================================================
   Header rows
   Desktop keeps everything on one line. A phone gets two: the counters and the
   way home on top, the actions underneath — all of it visible, none of it
   truncated or hidden.
   ============================================================ */
.bar-right{display:flex;align-items:center;gap:.4rem;flex-wrap:nowrap}
.bar-row{display:flex;align-items:center;gap:.35rem;flex-wrap:wrap}
.live{display:inline-flex;align-items:center;gap:.3rem;border:0;padding:0}
.live-pill{
  display:inline-flex;align-items:center;gap:.3rem;
  border:1px solid var(--line);border-radius:3px;padding:.2rem .45rem;
  font-variant-numeric:tabular-nums;white-space:nowrap;
}
.live-sep{display:none}

@media (max-width:640px){
  .bar{align-items:flex-start;padding:.5rem .7rem}
  .bar-left{align-self:center}
  .bar-right{flex-direction:column;align-items:flex-end;gap:.3rem}
  .bar-row{justify-content:flex-end}
  .live-lbl{display:inline}            /* the words fit again now they have a row */
  .hide-sm{display:inline-flex}        /* nothing needs hiding any more */
  .live-pill{font-size:.6rem;padding:.16rem .38rem}
  .bar-btn{font-size:.62rem;padding:.2rem .42rem}

  /* every action visible at once — a swipe hides options people never find */
  .chips{overflow-x:visible;flex-wrap:wrap}
  .chip{flex:0 1 auto}
}


/* ============================================================
   COMPACT MODE
   A column kept open beside a chart, not a page that is visited.
   Everything here is gated behind .compact, which is set only by
   ?compact=1 — the full terminal is untouched by any of it.
   ============================================================ */

/* The mobile strip forces the character back on with !important, and a compact
   column is narrow enough to trip that query. Compact outranks it deliberately:
   the whole point of the column is that nothing on it is introduction. */
body.compact .stage,
body.compact .chips,
body.compact .scanlines,
body.compact .vignette { display: none !important; }

body.compact .crt { padding: 0; }

body.compact .bar {
  padding: 6px 10px;
  gap: 8px;
}
body.compact .brand-dim,
body.compact .bar-sep,
body.compact .bar-home,
body.compact .bar-btn[data-run="report-bug"] { display: none; }
body.compact .bar-meta { font-size: 10px; }

body.compact .shell {
  display: block;
  padding: 0;
}
body.compact .console {
  padding: 8px 10px 10px;
  font-size: 12px;
  line-height: 1.45;
}

/* The dot leaders assume a wide row; in a third-width column they are the
   first thing to go, and the label-to-value pairing survives without them. */
body.compact .kv-dots { display: none; }
body.compact .kv { gap: 8px; justify-content: space-between; }

body.compact .tbl-h,
body.compact .tbl-r { font-size: 11px; }

/* The holder badge. Only ever shows a balance the server verified. */
.bar-badge{
  font-size:.62rem; letter-spacing:.08em; color:var(--amber-hi);
  border:1px solid var(--amber-deep); background:var(--amber-ghost);
  padding:.1rem .4rem; white-space:nowrap;
}

/* Wallet picker buttons. The icon comes from the wallet itself via the Wallet
   Standard, so we never ship or guess anyone's branding. */
.walletbtn{display:inline-flex;align-items:center;gap:.4em}
.walleticon{width:1.1em;height:1.1em;border-radius:2px;display:block}

/* The gate button when a wallet is connected. */
.bar-btn-on{color:var(--amber-hi);border-color:var(--amber-deep);background:var(--amber-ghost)}
