/* Solana Ghost monitor. Look follows the Stealth Phantom sample (docs/ui-style/dist): graphite surfaces, thin borders,
   DM Sans body + Space Grotesk display, letter-spaced eyebrows, small pills, one accent per subsystem.
   Layout is our own: Warrior | Solana Ghost | Academy. Dark only. */

:root {
  color-scheme: dark;
  --bg: #090c11;
  --top: #0e1216;
  --panel: #11161e;
  --raised: #161c25;
  --border: #29313e;
  --line: #222a35;
  --text: #edf3f3;
  --muted: #9aa7b4;
  --subtle: #8491a0;
  --mint: #9cf6d4;
  --green: #91deb7;
  --violet: #b79aff;
  --red: #ee91a1;
  --amber: #e9c18a;

  --font: "DM Sans", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --display: "Space Grotesk", "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;

  --pad: clamp(16px, 1.7vw, 44px);
  --gap: clamp(12px, 1.15vw, 30px);
  --frame-pad: clamp(10px, 0.9vw, 22px);
  --radius: 12px;

  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
@media (min-width: 1880px) { :root { font-size: 16px; } }
@media (min-width: 2300px) { :root { font-size: 18px; } }
@media (min-width: 2500px) and (min-height: 1300px) { :root { font-size: 19px; } }

/* Accent families (sample view themes). --acc-rgb feeds glows. */
.sys-warrior { --acc: #9cf6d4; --acc-rgb: 156 246 212; --acc-soft: #15221e; --acc-line: #34574a; }
.sys-academy { --acc: #c2a8ff; --acc-rgb: 183 154 255; --acc-soft: #1d1929; --acc-line: #4e4068; }
.acc-watcher { --acc: #98ebc5; --acc-rgb: 152 235 197; --acc-soft: #16241f; --acc-line: #3c6853; }
.acc-sniper { --acc: #eac18a; --acc-rgb: 234 193 138; --acc-soft: #251f18; --acc-line: #745b3f; }
.acc-radar { --acc: #8ddcec; --acc-rgb: 141 220 236; --acc-soft: #14222a; --acc-line: #3c6777; }
.acc-scope { --acc: #c4b0f3; --acc-rgb: 189 166 240; --acc-soft: #1f1a2b; --acc-line: #695080; }

/* State palette. Every state is also spelled out with an icon and a word. */
[data-state] { --st: #b4bfca; --st-rgb: 150 160 172; --st-bg: #1b222b; --st-line: #38424e; }
[data-state="running"] { --st: #a6e6c4; --st-rgb: 145 222 183; --st-bg: #16271e; --st-line: #36573f; }
/* idle is alive-but-waiting: a dim cool cyan, never a second grey (offline below is the grey one). */
[data-state="idle"] { --st: #9fd8e8; --st-rgb: 143 205 224; --st-bg: #152029; --st-line: #2f4b58; }
[data-state="paused"], [data-state="stale"], [data-state="degraded"] { --st: #efc894; --st-rgb: 233 193 138; --st-bg: #2e2619; --st-line: #624e31; }
[data-state="offline"] { --st: #adb7c2; --st-rgb: 110 120 132; --st-bg: #181d24; --st-line: #353d48; }
[data-state="error"] { --st: #f5acb8; --st-rgb: 238 145 161; --st-bg: #341c24; --st-line: #6d3947; }

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 500; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; border-radius: 4px; }
img { max-width: 100%; }
[hidden] { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: fixed; top: -80px; left: 16px; z-index: 100; padding: 10px 14px; border-radius: 7px; background: var(--mint); color: #10251b; font-weight: 600; }
.skip:focus { top: 10px; }
.eyebrow { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--subtle); }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  min-height: 4.4rem;
  padding: 0.55rem var(--pad);
  background: rgb(14 18 22 / 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
body[data-mode="live"] .topbar { box-shadow: inset 0 3px 0 #ee91a1; }
.brand { display: flex; align-items: center; gap: 0.5rem; font: 500 1.28rem/1.02 var(--display); letter-spacing: -0.045em; padding-right: 4px; }
.brand img { width: 2.75rem; height: 2.75rem; object-fit: contain; }
.brand b { display: block; color: var(--mint); font-weight: 500; }
.brand b > span { color: var(--violet); }
.topbar-pills { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 0.5rem; min-width: 0; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  min-height: 2.15rem;
  padding: 0.3rem 0.72rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #141a22;
  color: #c6cfd8;
  font-size: 0.86rem;
  white-space: nowrap;
}
.pill .icon { width: 1.05rem; height: 1.05rem; color: var(--st, var(--subtle)); }
.pill b { font-weight: 600; color: var(--st, var(--text)); }
.pill .short { display: none; }
#pill-chain[data-state="running"] .icon { color: var(--mint); }
#pill-chain span, #updated-text { font-variant-numeric: tabular-nums; }
#pill-updated[data-state="running"] { --st: #aab6c2; }
#pill-updated[data-state="error"], #pill-updated[data-state="stale"] { border-color: var(--st-line); background: var(--st-bg); color: var(--st); }
/* A dead database or chain must be visible from the top bar, not only from the centre badge. */
#pill-db:is([data-state="offline"], [data-state="error"], [data-state="degraded"], [data-state="stale"]),
#pill-chain:is([data-state="offline"], [data-state="error"], [data-state="degraded"], [data-state="stale"]) {
  --st: #efc894;
  --st-rgb: 233 193 138;
  border-color: #624e31;
  background: #2e2619;
  color: var(--st);
}

/* History: what the dashboard counts from (observation marks, D-034) */
.hist-wrap { position: relative; }
/* The header (D-051): mode, wallet and risk up front; history only while it counts from a chosen start (the menu opens
   it otherwise); database, chain and connection folded into one health light; the rest in one menu. */
.hist-wrap:has(.pill-hist[data-on="false"]):has(.hist-pop[hidden]) { display: none; }
.health-wrap, .menu-wrap { position: relative; }
.hist-pop.pop-right { left: auto; right: 0; }
button.pill-health, button.pill-menu { font: inherit; font-size: 0.86rem; cursor: pointer; }
button.pill-health:hover, button.pill-menu:hover { border-color: #45505b; background: #19202a; }
.health-dot { width: 0.62rem; height: 0.62rem; border-radius: 50%; background: #7a8794; flex: none; }
.pill-health[data-state="running"] .health-dot { background: var(--green); box-shadow: 0 0 0 3px rgb(145 222 183 / 0.15); }
.pill-health[data-state="degraded"] { color: #efc894; border-color: #624e31; background: #2e2619; }
.pill-health[data-state="degraded"] .health-dot { background: #efc894; }
.pill-health[data-state="error"] { color: var(--red); border-color: #6d3947; background: #2a1419; }
.pill-health[data-state="error"] .health-dot { background: var(--red); }
.health-rows { display: grid; gap: 0.4rem; margin: 0.6rem 0; }
.health-rows .pill { justify-content: flex-start; width: 100%; box-sizing: border-box; }
.health-rows .pill .long { display: inline; }
.health-rows .pill .short { display: none; }
.menu-pop { width: min(17rem, calc(100vw - 2rem)); padding: 0.35rem; display: grid; gap: 2px; }
.menu-item { display: flex; align-items: center; gap: 0.6rem; width: 100%; box-sizing: border-box; padding: 0.55rem 0.65rem; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: 0.9rem; text-align: left; text-decoration: none; cursor: pointer; }
.menu-item .icon { width: 1.05rem; height: 1.05rem; color: var(--muted); flex: none; }
.menu-item:hover, .menu-item:focus-visible { background: #1b2330; outline: none; }
.menu-item[hidden] { display: none; }
#signout { border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; margin-top: 0.2rem; color: var(--muted); }
.pill-hist { cursor: pointer; }
.pill-hist[data-on="true"] { color: #f1d9a8; background: #2a2418; border-color: #5b4a2f; }
.pill-hist[data-on="true"] .icon { color: #e9c18a; }
.pill-hist span { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; }
.hist-pop { position: absolute; left: 0; top: calc(100% + 6px); z-index: 70; width: min(26rem, calc(100vw - 2rem)); padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--raised, #151b23); box-shadow: 0 18px 40px #000a; color: var(--muted); font-size: 0.86rem; white-space: normal; }
.hist-title { margin: 0 0 0.35rem; color: var(--text); font-weight: 600; font-size: 0.95rem; }
.hist-now { margin: 0 0 0.7rem; }
.hist-now b { color: #f1d9a8; font-weight: 600; }
.hist-form { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.hist-form input { flex: 1 1 10rem; min-width: 0; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 7px; background: #0e1319; color: var(--text); font: inherit; }
.hist-all { margin-top: 0.55rem; }
.hist-sub { margin: 0.8rem 0 0.3rem; color: var(--subtle); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; }
.hist-list { list-style: none; margin: 0; padding: 0; max-height: 14rem; overflow: auto; border-top: 1px solid var(--line); }
.hist-list li { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
.hist-list li > span { min-width: 0; }
.hist-list b { display: block; color: #dbe3ea; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-list small { color: var(--subtle); }
.hist-list li > span small { display: block; font-variant-numeric: tabular-nums; }
.hist-list li[data-current="true"] b { color: #f1d9a8; }
.hist-list button { flex: none; }
@media (max-width: 640px) { .hist-pop { position: fixed; left: 1rem; right: 1rem; top: 4.5rem; width: auto; } }
.pill-mode { font-weight: 600; }
.pill-mode[data-mode="paper"] { color: #d2c5f3; background: #1c1827; border-color: #3d3353; }
.pill-mode[data-mode="paper"] .icon { color: #c1a9f5; }
.pill-mode[data-mode="live"] {
  position: relative;
  color: #2a0a12;
  background: #f09aaa;
  border-color: #ffc4ce;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 0 0 3px rgb(238 145 161 / 0.22), 0 0 22px rgb(238 145 161 / 0.35);
  animation: live-pulse 2.4s ease-in-out infinite;
}
.pill-mode[data-mode="live"] .icon { color: #2a0a12; fill: #2a0a12; }
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgb(238 145 161 / 0.22), 0 0 18px rgb(238 145 161 / 0.3); }
  50% { box-shadow: 0 0 0 5px rgb(238 145 161 / 0.12), 0 0 30px rgb(238 145 161 / 0.5); }
}

.signout {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  min-height: 2.15rem;
  padding: 0.3rem 0.72rem;
  border: 1px solid #313a43;
  border-radius: 7px;
  background: #191f27;
  color: #cfd8e0;
  font-size: 0.86rem;
}
.signout:hover { background: #222a33; border-color: #45505b; }
.signout .icon { width: 1rem; height: 1rem; color: var(--muted); }

/* ---------------------------------------------------------------- platform power button (the centre badge) */
.power-wrap { position: relative; }
.core-power { font: 600 1.02rem/1.3 var(--display); cursor: pointer; transition: filter 0.15s, box-shadow 0.15s; }
.core-power:not(:disabled):hover { filter: brightness(1.18); box-shadow: 0 0 0 4px #090c11, 0 0 18px rgb(var(--st-rgb, 156 246 212) / 0.35); }
.core-power:focus-visible { outline: 2px solid var(--st); outline-offset: 3px; }
.core-power:disabled { cursor: default; }
.core-power[data-power="pending"] .icon { animation: power-wait 1.2s ease-in-out infinite; }
@keyframes power-wait { 50% { opacity: 0.3; } }
.power-confirm {
  position: absolute;
  top: calc(100% + 0.6rem);
  left: 50%;
  transform: translateX(-50%);
  text-align: left;
  z-index: 30;
  width: min(22rem, calc(100vw - 32px));
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--raised);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.45);
  white-space: normal;
}
.power-confirm-title { margin: 0 0 0.4rem; font-weight: 600; color: var(--text); }
.power-confirm ul { margin: 0 0 0.8rem; padding-left: 1.1rem; color: var(--muted); font-size: 0.86rem; }
.power-confirm li + li { margin-top: 0.2rem; }
.power-confirm-error { margin: 0 0 0.7rem; color: var(--red); font-size: 0.86rem; }
.power-confirm-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
.power-go {
  min-height: 2.15rem;
  padding: 0.3rem 0.9rem;
  border: 1px solid #6b3a48;
  border-radius: 7px;
  background: #35202a;
  color: #f3b7c2;
  font-size: 0.86rem;
  font-weight: 600;
}
.power-go:hover { background: #43262f; }
.power-go[data-action="on"] { border-color: #34574a; background: #15221e; color: var(--mint); }
.power-go[data-action="on"]:hover { background: #1b2c26; }
.power-go:disabled { opacity: 0.6; cursor: wait; }

/* ---------------------------------------------------------------- toasts (new events) */
.toasts {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 4.6rem);
  right: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(23rem, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  --tc: var(--mint);
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.7rem 0.6rem 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--tc);
  border-radius: 10px;
  background: var(--raised);
  box-shadow: 0 12px 30px rgb(0 0 0 / 0.45);
  color: var(--muted);
  font-size: 0.86rem;
  pointer-events: auto;
  animation: toast-in 0.22s ease-out;
}
.toast[data-level="info"] { --tc: var(--amber); }
.toast[data-level="warn"] { --tc: var(--amber); }
.toast[data-level="error"] { --tc: var(--red); }
.toast > .icon { flex: none; width: 1.1rem; height: 1.1rem; margin-top: 0.1rem; color: var(--tc); }
.toast-body { flex: 1; min-width: 0; }
.toast-body p { margin: 0; overflow-wrap: anywhere; }
.toast-body .toast-title { margin-bottom: 0.15rem; color: var(--text); font-weight: 600; }
.toast-body a { display: inline-block; margin-top: 0.3rem; color: var(--tc); font-weight: 600; }
.toast-close {
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--subtle);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.toast-close:hover { background: #222a33; color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---------------------------------------------------------------- notices */
.notice {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: var(--gap) var(--pad) 0;
  padding: 0.6rem 0.95rem;
  border: 1px solid;
  border-radius: 9px;
  font-size: 0.92rem;
}
.notice .icon { width: 1.1rem; height: 1.1rem; }
.notice strong { font-weight: 650; }
.setup-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 auto 0 0;
  padding: 0.35rem 0.8rem;
  border: 1px solid #6a5337;
  border-radius: 7px;
  background: linear-gradient(90deg, #2c2419, #1a1a19);
  color: #efd3a8;
  font-size: 0.86rem;
  line-height: 1.35;
}
.setup-note .icon { width: 1.05rem; height: 1.05rem; color: var(--amber); }
.setup-note strong { font-weight: 650; }
.notice + .notice { margin-top: 8px; }

/* ---------------------------------------------------------------- stage */
.stage {
  --core-w: clamp(13.5rem, 22vw, 31rem);
  flex: 1 0 auto;
  width: 100%;
  max-width: 2440px;
  margin: 0 auto;
  padding: var(--gap) var(--pad) calc(var(--gap) + 4px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--core-w) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
  column-gap: var(--gap);
  row-gap: var(--gap);
  outline: none;
}

/* Systems ("screens") */
.system {
  position: relative;
  grid-row: 1 / 4;
  display: grid;
  grid-template-rows: subgrid;
  min-width: 0;
  padding: var(--frame-pad);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background:
    radial-gradient(ellipse 22% 19% at var(--pool-x, 15%) 13%, var(--mark-ground) 0%, var(--mark-ground) 58%, transparent 100%),
    radial-gradient(120% 60% at var(--glow-x, 0%) 0%, var(--acc-soft) 0%, transparent 60%),
    linear-gradient(180deg, #0f141b, #0c1016);
}
.system::before {
  content: "";
  position: absolute;
  inset: -1px -1px auto;
  height: 2px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(90deg, transparent 4%, var(--acc) 50%, transparent 96%);
  opacity: 0.75;
}
.sys-warrior { grid-column: 1; --glow-x: 0%; }
body[data-mode="live"] .sys-warrior { border-color: #6d3947; box-shadow: 0 0 0 1px rgb(238 145 161 / 0.12), 0 0 40px rgb(238 145 161 / 0.06); }
.sys-academy { grid-column: 3; --glow-x: 100%; --pool-x: 86%; } /* the marks sit on the right on this screen */

.system-head {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 1.4vw, 2.2rem);
  min-width: 0;
  padding: 0.2rem clamp(0.2rem, 0.6vw, 1rem) 0;
}
.sys-academy .system-head { flex-direction: row-reverse; }
.system-copy { container: copy / inline-size; flex: 0 1 34rem; min-width: 0; }
.system-title .eyebrow { display: block; color: var(--acc); letter-spacing: 0.24em; }
.system-name { display: block; margin-top: 0.1rem; font: 500 clamp(1.9rem, 2.4vw, 3.3rem)/1.02 var(--display); letter-spacing: -0.035em; }
.system-role { margin-top: 0.3rem; color: var(--muted); font-size: 0.92rem; }
.state-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.6rem; margin-top: 0.75rem; }
.detail { color: var(--muted); font-size: 0.9rem; min-width: 0; }
.system-head[data-state="error"] .detail,
.system-head[data-state="stale"] .detail,
.system-head[data-state="paused"] .detail { color: var(--st); }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.45rem; margin-top: 0.85rem; max-width: 34rem; }
.facts > div { min-width: 0; padding: 0.45rem 0.7rem 0.5rem; border: 1px solid var(--border); border-radius: 8px; background: #121821; }
.facts dt { font-size: 0.74rem; color: var(--subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.facts dd { display: flex; align-items: center; gap: 0.3rem; font: 500 1.08rem/1.25 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.facts dd .icon { width: 0.95rem; height: 0.95rem; }
.facts dd[data-tone="live"] { color: #f5acb8; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.facts dd[data-tone="paper"] { color: #d2c5f3; }
.facts dd[data-tone="on"] { color: #a6e6c4; }
.facts dd[data-tone="off"] { color: #efc894; }
.facts dd[data-tone="bad"] { color: #f5acb8; }
.facts > div:has(dd[data-tone="live"]) { border-color: #6d3947; background: #2a161d; }
.facts > div:has(dd[data-tone="bad"]) { border-color: #6d3947; }

@container copy (max-width: 21.5em) {
  .system-role { display: none; }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 0; margin-top: 0.7rem; border: 1px solid var(--border); border-radius: 8px; background: #121821; overflow: hidden; }
  .facts > div { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; padding: 0.28rem 0.65rem; border: 0; border-radius: 0; background: none; }
  .facts > div + div { border-top: 1px solid var(--line); }
  .facts dd { font-size: 0.95rem; }
}

/* ---------------------------------------------------------------- marks (characters) */
/* Each .mark hosts the owner's animated character: marks.js builds an inline SVG over the shared concept sheets and
   ghost.js dresses it (.mark-ground, .mark-art). The art lightens against a near-black ground inside the SVG and the
   host paints the same colour on the card as a soft vignette, so the sheet background disappears, the character keeps
   its blacks, and no rectangle shows. (A page-level mix-blend-mode would do the same, but then every animation frame
   re-composites the whole viewport on machines without GPU compositing.)
   State is carried by motion as well as by the aura, the ring, the gem and the badge:
     running          full motion (--motion-speed 1), breathing accent rim glow, glowing accent ring
     idle             calm motion (--motion-speed 0.6), no aura, soft accent ring
     paused / stale   motion frozen, amber ring and aura, slightly dimmed
     offline          motion frozen, grayscale and dimmed, dashed grey ring
     error            motion frozen, red ring and aura
   Motion also freezes while the tab is hidden, while a mark is scrolled out of view and while the connection is lost.
   prefers-reduced-motion: marks.js and the rule at the end of this file stop all animation. */
/* The sheets' own background is near-black (max channel ~11/255). The ground under the character is kept that dark so
   `lighten` replaces only that background — never the black cloaks, the hood interiors or the Sniper's rifle, which a
   card-coloured ground used to swallow. A little of the card accent keeps it from reading as a grey blob.
   The same colour is also pooled into the card / panel around the mark (--pool-* below): a background painted on the
   .mark itself is clipped by its own box and ended in a hard 1 px step — a faint rectangle — while the pool belongs to
   the much larger card and can fade out over ~40 px, so the mark sinks into the card with no edge at all. */
.system, .unit { --mark-ground: color-mix(in srgb, var(--acc-soft) 22%, #06090c); }
.mark {
  position: relative;
  flex: none;
  aspect-ratio: 2 / 3;
  --motion-speed: 1;
  --aura-rgb: var(--acc-rgb);
  --ring: rgb(var(--st-rgb) / 0.5);
  --ring-glow: transparent;
  background: none; /* the character floats on the card: its own dark art lightens away, so no box shows */
}
/* The state aura is a rim glow on the host, painted behind the SVG: the character's own ground covers its middle, so the
   accent haloes the silhouette instead of shining through it. Outside the SVG it also costs no per-frame filter. */
.mark::before {
  content: "";
  position: absolute;
  inset: -8% -12% -2%;
  background: radial-gradient(ellipse 50% 46% at 50% 46%, rgb(var(--aura-rgb) / 0.34) 0%, rgb(var(--aura-rgb) / 0.13) 58%, transparent 78%);
  opacity: 0;
  transition: opacity 0.5s ease;
}
/* marks.js failed to load: no character, so drop the empty box (heading and badge still name and state the subsystem). */
.mark:not(:has(> .ghost-mark)) { display: none; }
.mark > .ghost-mark {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  -webkit-mask-image: radial-gradient(ellipse 62% 58% at 50% 46%, #000 62%, transparent 100%);
  mask-image: radial-gradient(ellipse 62% 58% at 50% 46%, #000 62%, transparent 100%);
}
.mark-ground { fill: transparent; }
.mark > .ghost-mark { isolation: auto; mix-blend-mode: screen; }  /* the character screens onto the card: its dark sheet drops out */
.mark-art { mix-blend-mode: normal; transition: filter 0.6s ease; }
.mark::after {
  content: "";
  position: absolute;
  left: 13%;
  right: 13%;
  bottom: 2.5%;
  height: 10%;
  border-radius: 50%;
  border: 2px solid var(--ring);
  box-shadow: 0 0 16px var(--ring-glow), inset 0 0 12px var(--ring-glow);
  transition: border-color 0.5s ease, box-shadow 0.5s ease;
}
.gem {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  width: clamp(0.95rem, 20%, 2.2rem);
  aspect-ratio: 1;
  transform: translate(-50%, 18%);
  border: 1.5px solid var(--st-line);
  border-radius: 50%;
  background: var(--st-bg);
  color: var(--st);
  box-shadow: 0 0 0 3px #0d1117;
}
.gem .icon { width: 58%; height: 58%; stroke-width: 2; }
.mark[data-state="running"] .gem { border-color: rgb(var(--acc-rgb) / 0.8); }

/* running: full motion + accent glow */
.mark[data-state="running"] { --ring: rgb(var(--acc-rgb) / 0.95); --ring-glow: rgb(var(--acc-rgb) / 0.5); }
.mark[data-state="running"]::before { opacity: 1; animation: aura 3.6s ease-in-out infinite; }
/* idle: calm motion, accent ring kept (alive, waiting), no glow */
.mark[data-state="idle"] { --motion-speed: 0.6; --ring: rgb(var(--acc-rgb) / 0.42); }
/* every other state freezes the character where it stands; the eyes stay open */
.mark:not([data-state="running"], [data-state="idle"]) .ghost-mark * { animation-play-state: paused !important; }
.mark:not([data-state="running"], [data-state="idle"]) .ghost-mark .eyes { animation-name: none !important; }
.mark[data-state="paused"], .mark[data-state="stale"] { --ring: #e9c18a; --ring-glow: rgb(233 193 138 / 0.4); --aura-rgb: 233 193 138; }
.mark[data-state="paused"]::before, .mark[data-state="stale"]::before { opacity: 0.55; }
.mark[data-state="paused"] .mark-art, .mark[data-state="stale"] .mark-art { filter: brightness(0.74) saturate(0.62); }
.mark[data-state="offline"] { --ring: #4d5663; }
.mark[data-state="offline"]::after { border-style: dashed; }
.mark[data-state="offline"] .mark-art { filter: grayscale(1) brightness(0.52); }
.mark[data-state="error"] { --ring: #ee91a1; --ring-glow: rgb(238 145 161 / 0.5); --aura-rgb: 238 145 161; }
.mark[data-state="error"]::before { opacity: 0.7; }
.mark[data-state="error"] .mark-art { filter: saturate(0.8) brightness(0.9); }
.mark[data-state="unknown"] .mark-art { filter: grayscale(0.8) brightness(0.55); }
/* off screen: nothing to see, nothing to animate */
.mark[data-inview="false"] .ghost-mark * { animation-play-state: paused !important; }
@keyframes aura {
  0%, 100% { opacity: 0.55; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1.05); }
}

/* CPU budget: the four small unit marks drop the blurred fog/mist ellipses, the drifting particles and the whole-body
   float — every one of those re-rasterises the masked 512x768 character (over a 1536x1024 sheet) each frame. What is
   left is what identifies the state: the blink and the role effect (scan, sweep, glint, lens, knowledge). The two large
   system marks keep the full performance. */
.mark-sm .ghost-mark .fog,
.mark-sm .ghost-mark .particle { display: none; }
.mark-sm .ghost-mark .float { animation-name: none; }

/* The same reasoning applied to the two large marks: their drifting mist and particles are wide blurred surfaces that
   repaint every frame and read as noise at card size, while the card already has its own ambient glow. The emblem
   "breathe" pulse keeps its rhythm but loses the 24px blur, which is the single most expensive filter in the sheet. */
.ghost-mark .fog,
.ghost-mark .particle { display: none; }
.ghost-mark .breathe { filter: none; opacity: 0.22; }

.mark-lg { width: clamp(6.6rem, 9vw, 15rem); max-height: 100%; }
.mark-sm { width: clamp(4.6rem, 6.3vw, 11.5rem); }
/* The Sniper art is framed wider (rifle); bring the character to the same visual size as the others. */
.acc-sniper .mark > .ghost-mark { transform: scale(1.1); transform-origin: 50% 58%; }

/* ---------------------------------------------------------------- subsystem units */
.unit {
  container: unit / inline-size;
  position: relative;
  display: flex;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  --card-from: var(--acc-soft);
  --card-to: #10151c;
  background:
    radial-gradient(ellipse 26% 58% at var(--pool-x, 13%) 50%, var(--mark-ground) 0%, var(--mark-ground) 56%, transparent 100%),
    linear-gradient(140deg, var(--card-from), var(--card-to) 62%);
  transition: border-color 0.4s ease;
}
.unit::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgb(var(--acc-rgb) / 0.7), transparent);
}
.unit[data-state="running"], .unit[data-state="idle"] { border-color: var(--acc-line); }
.unit[data-state="paused"], .unit[data-state="stale"] { border-color: #624e31; }
.unit[data-state="error"] { border-color: #7a3d4c; box-shadow: inset 0 0 0 1px rgb(238 145 161 / 0.12); }
.unit[data-state="offline"], .unit[data-state="unknown"] { --card-from: #13171d; --card-to: #0f1318; }
.unit[data-state="offline"]::before, .unit[data-state="unknown"]::before { opacity: 0.25; }

.unit-in {
  flex: 1;
  display: flex;
  align-items: center;
  gap: clamp(0.7rem, 3cqi, 1.8rem);
  min-width: 0;
  padding: clamp(0.6rem, 2cqi, 1.3rem) clamp(0.8rem, 3cqi, 1.7rem);
}
.sys-academy .unit-in { flex-direction: row-reverse; }
.unit .mark-sm { width: clamp(3.4rem, 13cqi, 6.5rem); max-height: 92%; align-self: center; }
.unit-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.unit-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 0.35rem 0.75rem; }
.unit-name { min-width: 0; }
.unit-name .eyebrow { color: var(--acc); font-size: 0.66rem; letter-spacing: 0.17em; }
.unit h3 { display: flex; align-items: center; gap: 0.45rem; margin-top: 0.1rem; font-size: clamp(1.25rem, 5cqi, 1.9rem); line-height: 1.12; letter-spacing: -0.025em; }
.unit h3 .icon { width: 0.85em; height: 0.85em; color: var(--acc); }
.unit-detail { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.55rem; margin-top: 0.25rem; color: var(--muted); font-size: 0.9rem; }
.unit[data-state="error"] .unit-detail > [data-f="detail"],
.unit[data-state="stale"] .unit-detail > [data-f="detail"],
.unit[data-state="paused"] .unit-detail > [data-f="detail"] { color: var(--st); font-weight: 500; }
.tag { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.05rem 0.45rem; border: 1px solid var(--line); border-radius: 5px; background: #121820; color: #b9c4cf; font-size: 0.76rem; white-space: nowrap; }
.tag .icon { width: 0.85rem; height: 0.85rem; color: var(--acc); }

/* State badge */
.state {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.2rem 0.62rem 0.2rem 0.48rem;
  border: 1px solid var(--st-line);
  border-radius: 6px;
  background: var(--st-bg);
  color: var(--st);
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.35;
  white-space: nowrap;
}
.state .icon { width: 0.98rem; height: 0.98rem; stroke-width: 2; }
.state-xl { gap: 0.5rem; padding: 0.38rem 0.95rem 0.38rem 0.75rem; border-radius: 999px; font: 600 1.02rem/1.3 var(--display); letter-spacing: 0.01em; box-shadow: 0 0 0 4px #090c11; }
.state-xl .icon { width: 1.15rem; height: 1.15rem; }

/* Metrics */
.metrics {
  display: grid;
  gap: 1px;
  margin-top: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
}
.metrics.m4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metrics.m3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metrics > div { min-width: 0; padding: 0.42rem 0.65rem 0.48rem; background: #0f141a; }
.metrics dt { font-size: 0.72rem; color: var(--subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The floor is low on purpose: a long value must shrink before the ellipsis eats digits (ghost.js also compacts big
   numbers, so this is only the safety net). */
.metrics dd { font: 500 clamp(0.85rem, 4cqi, 1.6rem)/1.2 var(--display); letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.metrics dd[data-sign="pos"], .metrics dd [data-sign="pos"] { color: var(--green); }
.metrics dd[data-sign="neg"], .metrics dd [data-sign="neg"] { color: var(--red); }
.unit-suffix { margin-left: 0.25rem; font: 400 0.62em var(--font); color: var(--subtle); letter-spacing: 0; }
.pipeline dd[data-zero="true"] { color: #7b8794; }
.unit[data-state="offline"] .metrics dd, .unit[data-state="unknown"] .metrics dd { color: #8b96a3; }
@container unit (min-width: 30em) {
  .metrics.m4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* Watcher labels are longer ("Candidates 1h"): stay 2 x 2 until the body has room for four columns. */
@container unit (min-width: 27.01em) and (max-width: 33.5em) {
  .acc-watcher .metrics.m4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Narrow units (tablet, phone, 1024 px): small mark beside the title, data full width below. */
@container unit (max-width: 27em) {
  .unit-in { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 0.8rem; row-gap: 0; align-items: center; align-content: center; padding: 0.7rem 0.8rem 0.65rem; }
  .unit-head { justify-content: flex-start; align-items: center; gap: 0.15rem 0.6rem; }
  .unit-name { display: contents; }
  .unit-name .eyebrow { flex: 0 0 100%; letter-spacing: 0.13em; }
  .unit h3 { margin-top: 0; }
  .sys-academy .unit-in { grid-template-columns: minmax(0, 1fr) auto; }
  .unit-body { display: contents; }
  .unit .mark-sm { grid-column: 1; grid-row: 1 / span 2; width: clamp(3.4rem, 17cqi, 4.4rem); }
  .sys-academy .unit .mark-sm { grid-column: 2; }
  .unit-head, .unit-detail { grid-column: 2; }
  .sys-academy .unit-head, .sys-academy .unit-detail { grid-column: 1; }
  .unit-detail { align-self: start; }
  .unit-head { align-self: end; }
  .progress, .metrics, .unit-foot { grid-column: 1 / -1; }
  .metrics.m4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .metrics > div { padding: 0.36rem 0.5rem 0.4rem; }
  .metrics dt { font-size: 0.68rem; }
  /* At ~57 px the ground ring must stay a ring: widen it, thin its stroke and keep the gem inside its height. */
  .mark::after { left: 6%; right: 6%; height: 15%; border-width: 1.5px; }
  .gem { box-shadow: 0 0 0 2px #0d1117; }
  .gem .icon { stroke-width: 2.4; }
}
@container unit (max-width: 19.5em) {
  .metrics.m4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics.m3 > div { padding-inline: 0.4rem; }
  .metrics.m3 dd { font-size: 1rem; letter-spacing: -0.03em; }
}

/* Progress: job progress */
.progress { margin-top: 0.55rem; }
.progress-label { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.32rem; font-size: 0.82rem; color: #b8c3ce; }
.progress-label > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-label b { font: 600 0.9rem var(--display); color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.track { position: relative; height: 6px; border-radius: 6px; background: #222a33; overflow: hidden; }
.track > i { display: block; width: var(--p, 0%); height: 100%; border-radius: 6px; background: linear-gradient(90deg, rgb(var(--acc-rgb) / 0.55), var(--acc)); box-shadow: 0 0 10px rgb(var(--acc-rgb) / 0.45); transition: width 0.6s ease; }
.progress[data-active="false"] .progress-label > span { color: var(--subtle); }
.progress[data-active="false"] .track { background: repeating-linear-gradient(90deg, #222a33 0 6px, transparent 6px 10px); }
.unit[data-state="paused"] .track > i, .unit[data-state="stale"] .track > i { background: #b89768; box-shadow: none; }


/* Foot: strategy + heartbeat */
.unit-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.35rem 0.9rem; margin-top: 0.6rem; padding-top: 0.5rem; border-top: 1px solid var(--line); font-size: 0.82rem; color: var(--muted); }
.strategy { display: inline-flex; align-items: center; gap: 0.4rem; min-width: 0; max-width: 100%; }
.strategy .icon { width: 0.95rem; height: 0.95rem; color: var(--acc, var(--subtle)); }
.strategy .k { color: var(--subtle); }
.strategy .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #dbe3ea; font-weight: 500; }
.strategy[data-empty="true"] .name { color: var(--subtle); font-weight: 400; }
/* the API keys the subsystem runs on: the stored key's name and last four characters; a key file not in the table
   is dashed, a key switched off in the table is amber */
.keyline { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0.3rem 0.4rem; min-width: 0; max-width: 100%; }
.keyline .icon { width: 0.95rem; height: 0.95rem; color: var(--acc, var(--subtle)); }
.keyline .k { color: var(--subtle); }
.keyline .names { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; min-width: 0; color: #dbe3ea; }
.keyline[data-empty="true"] .names { color: var(--subtle); }
.k-inuse { display: block; margin-top: 0.1rem; color: var(--mint, #7fe0b0); font-size: 0.72rem; }
.keyfile[data-stored="true"] { border-color: var(--line); background: transparent; }
.kchip { display: inline-flex; align-items: baseline; gap: 0.3rem; max-width: 100%; padding: 0 0.4rem; border: 1px solid var(--line); border-radius: 5px; background: #121820; color: #dbe3ea; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kchip small { color: var(--subtle); font-weight: 400; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.kchip[data-stored="false"] { border-style: dashed; color: #b9c4cf; }
.kchip[data-status="disabled"], .kchip[data-status="standby"] { border-color: #b89768; color: #d9c29a; }
.beat { display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.beat .icon { width: 0.95rem; height: 0.95rem; color: var(--subtle); }
.unit[data-state="running"] .beat .icon { color: var(--acc); }
.unit[data-state="stale"] .beat { color: var(--st); }
.unit[data-state="stale"] .beat .icon { color: var(--st); }

.chip { flex: none; padding: 0.02rem 0.42rem; border: 1px solid #38414b; border-radius: 4px; background: #1d242d; color: #b5c0cb; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em; }
.chip[data-status="backtested"] { color: #cdbdf1; background: #261f36; border-color: #45385c; }
.chip[data-status="paper"], .chip[data-status="running"] { color: #a8dde8; background: #172a33; border-color: #325465; }
.chip[data-status="active"], .chip[data-status="live"] { color: #a6e6c4; background: #16271e; border-color: #36573f; }
.chip[data-status="retired"], .chip[data-status="failed"] { color: #f5acb8; background: #341c24; border-color: #6d3947; }

/* ---------------------------------------------------------------- center: Solana Ghost */
.core {
  grid-column: 2;
  grid-row: 1 / 4;
  display: grid;
  grid-template-rows: subgrid;
  min-width: 0;
  padding-block: var(--frame-pad);
}
.core-hero { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-width: 0; }
.core-title .eyebrow { color: #aebbc6; letter-spacing: 0.3em; }
/* The Solana Ghost keeps its static phantom (inline SVG: page-coloured ground, state glow, art lightened on top, all
   blended inside the SVG). A slow float and the glow follow platform.state:
   running = float + spinning halo + breathing mint glow, degraded = slower float + amber glow, offline = still, grey. */
.core-mark { --hero: clamp(10rem, min(18vw, 23.5vh), 30rem); --float: 6.4s; --float-speed: 1; position: relative; width: min(100%, var(--hero)); aspect-ratio: 1; }
.core-glyph {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  -webkit-mask-image: radial-gradient(circle closest-side, #000 72%, transparent 100%);
  mask-image: radial-gradient(circle closest-side, #000 72%, transparent 100%);
}
.core-ground { fill: var(--core-ground, var(--bg)); } /* the colour behind the mark: page ground, or the login card */
.core-glow { opacity: 0.8; }
.core-glow-0 { stop-color: rgb(var(--st-rgb)); stop-opacity: 0.2; }
.core-glow-1 { stop-color: rgb(var(--st-rgb)); stop-opacity: 0.06; }
.core-glow-2 { stop-color: rgb(var(--st-rgb)); stop-opacity: 0; }
.core-art {
  mix-blend-mode: lighten;
  transition: filter 0.6s ease;
  animation: core-float calc(var(--float) / var(--float-speed)) ease-in-out infinite;
}
/* The halo spins by animating the gradient angle (a registered property) rather than rotating a masked layer, and its
   outer glow is static: both keep the per-frame work small on machines without GPU compositing. */
@property --halo-turn { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.halo { position: absolute; inset: 1%; border-radius: 50%; box-shadow: 0 0 60px rgb(var(--st-rgb) / 0.18); }
.halo::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from var(--halo-turn), rgb(var(--st-rgb) / 0) 0deg, rgb(var(--st-rgb) / 0.95) 70deg, rgb(var(--st-rgb) / 0) 150deg, rgb(var(--st-rgb) / 0) 180deg, rgb(var(--st-rgb) / 0.95) 250deg, rgb(var(--st-rgb) / 0) 330deg);
  -webkit-mask-image: radial-gradient(closest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  mask-image: radial-gradient(closest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
}
.halo::after {
  content: "";
  position: absolute;
  inset: 5%;
  border-radius: 50%;
  border: 1px solid rgb(var(--st-rgb) / 0.3);
}
.core-mark[data-state="running"] { --st-rgb: 156 246 212; }
.core-mark[data-state="running"] .halo::before { animation: halo-turn 16s linear infinite; }
.core-mark[data-state="running"] .core-glow,
.core-mark[data-state="degraded"] .core-glow { animation: halo-breathe calc(var(--float) / var(--float-speed)) ease-in-out infinite; }
.core-mark[data-state="degraded"] { --float-speed: 0.55; }
.core-mark[data-state="degraded"] .core-art { filter: brightness(0.85) saturate(0.85); }
.core-mark[data-state="offline"] { --st-rgb: 238 145 161; }
.core-mark[data-state="offline"] .core-art { filter: grayscale(0.85) brightness(0.55); }
.core-mark[data-state="unknown"] .core-art { filter: grayscale(0.8) brightness(0.55); }
.core-mark[data-state="offline"] .core-art, .core-mark[data-state="unknown"] .core-art { animation-play-state: paused; }
.core-mark[data-state="unknown"] .halo::before { opacity: 0.3; }
@keyframes halo-turn { to { --halo-turn: 360deg; } }
/* Glow peaks when the ghost is at the top of its float. (Names must not collide with marks.js keyframes.) */
@keyframes halo-breathe { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
@keyframes core-float { 0%, 100% { transform: translateY(11px); } 50% { transform: translateY(-18px); } } /* SVG user units (720 box) */
.core-copy { display: flex; flex-direction: column; align-items: center; min-width: 0; margin-top: -1.35rem; }
.core-state { position: relative; }
.core-detail { max-width: 22rem; min-height: 2.8em; margin-top: 0.4rem; color: var(--muted); font-size: 0.84rem; line-height: 1.4; white-space: pre-line; }
.core-hero[data-state="degraded"] .core-detail, .core-hero[data-state="offline"] .core-detail { color: var(--st); }
#platform-state[data-state="offline"], .core-hero[data-state="offline"] { --st: #f5acb8; --st-bg: #341c24; --st-line: #6d3947; }

/* Connectors: Academy (right) -> Warrior (left). Thin lines only — the strategy itself is named in the card footers. */
.pipe {
  align-self: center;
  display: grid;
  justify-items: center;
  gap: 0.3rem;
  min-width: 0;
  text-align: center;
  --to-c: #98ebc5;
  --from-c: #8ddcec;
  --from-rgb: 141 220 236;
}
.pipe-trading { --to-c: #eac18a; --from-c: #c4b0f3; --from-rgb: 189 166 240; }
.pipe-line {
  position: relative;
  width: calc(100% + 2 * var(--gap) + 2px);
  margin-inline: calc(-1 * var(--gap) - 1px);
  height: 14px;
}
.pipe-line::before {
  content: "";
  position: absolute;
  left: 9px;
  right: 6px;
  top: 6px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--to-c), var(--from-c));
  opacity: 0.55;
}
.pipe-line::after {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  border-block: 5px solid transparent;
  border-right: 10px solid var(--to-c);
  filter: drop-shadow(0 0 5px var(--to-c));
}
.pipe-origin { position: absolute; right: 0; top: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--from-c); box-shadow: 0 0 10px var(--from-c); }
.pipe-flow {
  position: absolute;
  left: 12px;
  right: 10px;
  top: 3px;
  height: 8px;
  background: radial-gradient(circle at center, #fff 0 1.3px, rgb(var(--from-rgb) / 0.9) 1.8px, transparent 4px) 0 50% / 26px 8px repeat-x;
  opacity: 0;
}
.pipe[data-flow="on"] .pipe-flow { opacity: 1; animation: flow 1.5s linear infinite; }
.pipe[data-flow="on"] .pipe-line::before { opacity: 0.8; }
.pipe[data-flow="off"] .pipe-line::before { background: repeating-linear-gradient(90deg, #4a5360 0 6px, transparent 6px 11px); opacity: 1; }
.pipe[data-flow="off"] .pipe-line::after { border-right-color: #4a5360; filter: none; }
.pipe[data-flow="off"] .pipe-origin { background: #4a5360; box-shadow: none; }
.pipe[data-flow="idle"] .pipe-line::before { opacity: 0.4; }
@keyframes flow { from { background-position: 0 50%; } to { background-position: -26px 50%; } }
.pipe-ends { display: flex; justify-content: space-between; width: 100%; font-size: 0.74rem; font-weight: 600; }
.pipe-ends .to { color: var(--to-c); }
.pipe-ends .from { color: var(--from-c); }
.pipe[data-flow="off"] .pipe-ends span { color: #8a95a2; }

/* No transitions on the first paint (unknown -> real state). */
body:not([data-painted]) *, body:not([data-painted]) *::before, body:not([data-painted]) *::after { transition: none !important; }

/* Connection lost: keep data, freeze motion */
body[data-conn="lost"] .stage *, body[data-conn="lost"] .stage *::before, body[data-conn="lost"] .stage *::after { animation-play-state: paused !important; }
/* Hidden tab: freeze every animation (characters, halo, pipes, live pill) to save CPU. */
html[data-tab="hidden"] *, html[data-tab="hidden"] *::before, html[data-tab="hidden"] *::after { animation-play-state: paused !important; }

/* ---------------------------------------------------------------- responsive */
/* Tall screens: a bigger Solana Ghost. */
@media (min-width: 1024px) and (min-height: 1100px) {
  .core-mark { --hero: clamp(10rem, min(19vw, 30vh), 34rem); }
}
@media (min-width: 2200px) and (min-height: 1300px) {
  .mark-lg { width: clamp(6.6rem, 9.5vw, 17rem); }
}

/* Short desktop (720p and 900p laptops, wall screens): trim the vertical rhythm so both screens fit without scrolling —
   the Sniper and Scope Lab footers carry the strategy provenance and must not fall below the fold. */
@media (min-width: 1150.02px) and (max-height: 900px) {
  :root { --gap: 0.75rem; }
  .system-head { padding-block: 0; }
  .unit-in { padding-block: 0.55rem 0.5rem; }
  .metrics > div { padding-block: 0.3rem 0.34rem; }
  .metrics dd { font-size: clamp(1rem, 3.4cqi, 1.5rem); }
  .facts { margin-top: 0.6rem; }
  .facts > div { padding-block: 0.34rem 0.38rem; }
  .state-line { margin-top: 0.55rem; }
  .unit-foot { margin-top: 0.45rem; padding-top: 0.4rem; }
  .progress { margin-top: 0.42rem; }
  .mark-lg { width: clamp(5.2rem, 7vw, 10rem); }
  .core-mark { --hero: clamp(8rem, min(14vw, 21vh), 30rem); }
  .core-detail { min-height: 0; }
}
@media (min-width: 1150.02px) and (max-height: 780px) {
  .system-role { display: none; }
  .core-state { margin-top: -1rem; }
}

/* Tablet / small laptop (1024 px included): Solana Ghost row on top, Warrior | Academy side by side. */
@media (max-width: 1150px) {
  .stage {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto auto auto auto;
  }
  .core {
    grid-column: 1 / 3;
    grid-row: 1;
    grid-template-rows: auto auto;
    grid-template-columns: minmax(11rem, 40%) minmax(0, 1fr);
    align-items: center;
    column-gap: clamp(16px, 4vw, 48px);
    row-gap: 1.1rem;
    padding: 0.25rem clamp(4px, 2vw, 24px) 0.4rem;
  }
  .core-hero { grid-column: 1; grid-row: 1 / 3; }
  .pipe-discovery { grid-column: 2; grid-row: 1; align-self: end; }
  .pipe-trading { grid-column: 2; grid-row: 2; align-self: start; }
  .pipe-line { width: 100%; margin-inline: 0; }
  .core-mark { --hero: clamp(8.5rem, min(26vw, 22vh), 14rem); }
  .sys-warrior { grid-column: 1; grid-row: 2 / 5; }
  .sys-academy { grid-column: 2; grid-row: 2 / 5; }
  .mark-lg { width: clamp(4.6rem, 11vw, 7rem); }
  .system-head { gap: 0.7rem; }
}
/* Short landscape phones / tablets: the centre becomes a horizontal strip so the two screens start inside the fold. */
@media (max-width: 1150px) and (max-height: 520px) {
  .topbar { position: static; }
  .core-mark { --hero: 5.5rem; }
  .core-hero { flex-direction: row; align-items: center; justify-content: flex-start; gap: 0.8rem; text-align: left; }
  .core-detail { min-height: 0; max-width: none; margin-top: 0.2rem; }
  .core-state { margin-top: 0; }
  .core-hero > .core-copy { min-width: 0; }
}

/* Phones: stack Solana Ghost, Warrior, Academy. */
@media (max-width: 699.98px) {
  .topbar { position: static; }
  .pill .long { display: none; }
  .pill .short { display: inline; }
  .stage { display: flex; flex-direction: column; }
  /* The fold must carry subsystem state, not only a reassuring platform badge: keep the hero small and push the
     connectors below the Warrior and Academy screens. */
  .core { order: -1; display: flex; flex-direction: column; gap: 0.75rem; padding: 0.25rem 0 0.4rem; }
  /* Stacked, a horizontal Radar Lab -> Watcher connector says nothing the card footers do not; dropping it keeps the
     Warrior header and the Watcher badge inside the first screenful. */
  .pipe { display: none; }
  .core-mark { --hero: clamp(6rem, 30vw, 9rem); }
  .core-detail { min-height: 0; }
  .system { display: flex; flex-direction: column; gap: var(--gap); }
  .system-copy { flex: 1 1 auto; }
  /* Stacked, both screens put their marks on the left again, so the ground pool moves with them. */
  .sys-academy { --pool-x: 15%; }
  .sys-academy .system-head { flex-direction: row; }
  .mark-lg { width: clamp(4.6rem, 22vw, 6.5rem); }
  .stage .sys-academy .unit-in { flex-direction: row; grid-template-columns: auto minmax(0, 1fr); }
  .stage .sys-academy .unit .mark-sm { grid-column: 1; }
  .stage .sys-academy .unit-head, .stage .sys-academy .unit-detail { grid-column: 2; }
}
@media (max-width: 420px) {
  .topbar { gap: 8px 12px; }
  .brand { font-size: 1.12rem; }
  .brand img { width: 2.3rem; height: 2.3rem; }
  .topbar-pills { justify-content: flex-start; gap: 0.4rem; }
  .pill, .signout { font-size: 0.8rem; padding-inline: 0.55rem; min-height: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------- login */
/* The glows are backgrounds of body itself: body is not a stacking context, so a z-index:-1 pseudo-element would be
   painted underneath body's own opaque background and never show. */
.login-body {
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(60% 50% at 50% 30%, #13201c 0%, transparent 70%),
    radial-gradient(50% 40% at 70% 80%, #1a1626 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
.login {
  width: min(420px, 100%);
  padding: clamp(20px, 5vw, 32px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, #121820, #0e1319);
  box-shadow: 0 30px 120px #0008;
  position: relative;
}
.login::before {
  content: "";
  position: absolute;
  inset: -1px -1px auto;
  height: 2px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(90deg, transparent 6%, var(--mint) 40%, var(--violet) 70%, transparent 94%);
  opacity: 0.8;
}
.login-mark { position: relative; width: min(220px, 62%); aspect-ratio: 1; margin: -6px auto 0; --st-rgb: 156 246 212; --core-ground: #11171f; }
.login-mark .halo::before { animation: halo-turn 16s linear infinite; }
.login .brand { justify-content: center; margin-top: 4px; }
.login .brand img { display: none; }
.login h1 { margin-top: 18px; font-size: 1.9rem; letter-spacing: -0.04em; text-align: center; }
.login-sub { margin-top: 4px; color: var(--muted); text-align: center; }
.login form { display: grid; gap: 6px; margin-top: 22px; }
.login label { margin-top: 8px; font-size: 0.86rem; color: #c6cfd8; }
.login input {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid #36414e;
  border-radius: 8px;
  background: #0e1419;
  color: var(--text);
  font: inherit;
}
.login input:focus { border-color: var(--mint); }
.login input:focus-visible { outline: 2px solid var(--mint); outline-offset: 1px; }
.login button[type="submit"] {
  margin-top: 16px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid #b7ffdf;
  border-radius: 8px;
  background: var(--mint);
  color: #10251b;
  font-weight: 600;
}
.login button[type="submit"]:hover { background: #b0ffdb; }
.login button[type="submit"]:disabled { opacity: 0.6; cursor: progress; }
#login-error { min-height: 1.35em; margin-top: 6px; color: #f5acb8; font-size: 0.88rem; }
.login-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--subtle); font-size: 0.8rem; text-align: center; }

/* ===================================================================================================================
   v2 layout — hero (Warrior · Solana Ghost · Academy) over a floor of the four clickable subsystems.
   This block is last in source, so it wins over the older grid rules above for the shared selectors it redefines.
   =================================================================================================================== */
.stage {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.4vh, 26px);
  width: 100%;
  max-width: 2200px;
  margin: 0 auto;
  padding: clamp(10px, 1.4vh, 24px) var(--pad);
  flex: 1 1 auto;
  min-height: 0;
}

/* ---- hero: the two halves flank the centre ---- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(10px, 2vw, 56px);
}
.half {
  display: grid;
  justify-items: center;
  align-content: center;
  text-align: center;
  gap: 0.12rem;
  padding: 0.2rem 0.4rem;
}
.half .mark-lg { width: clamp(4.4rem, 6.2vw, 8rem); margin-bottom: 0.15rem; }
.half-eyebrow { font-size: 0.66rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--acc); font-weight: 600; }
.half-name { font: 500 clamp(1.5rem, 2.1vw, 2.7rem)/1.02 var(--display); letter-spacing: -0.035em; }
.half-sub { color: var(--muted); font-size: 0.82rem; }
.half .state { margin-top: 0.35rem; }
.half-facts { display: flex; gap: 0.5rem; margin-top: 0.45rem; }
.half-facts > div { min-width: 4.4rem; padding: 0.28rem 0.6rem; border: 1px solid var(--line); border-radius: 8px; background: #10151c; }
.half-facts dt { font-size: 0.64rem; letter-spacing: 0.02em; color: var(--subtle); }
.half-facts dd { font: 500 0.98rem var(--display); letter-spacing: -0.01em; }
.half-facts dd[data-tone="live"] { color: var(--red); }
.half-facts dd[data-tone="paper"], .half-facts dd[data-tone="on"] { color: var(--green); }
.half-facts dd[data-tone="off"] { color: var(--amber); }
.half-facts dd[data-tone="bad"] { color: var(--red); }

/* the centre, now a plain flex column (its inner .core-mark / .halo / .core-copy rules above still apply) */
.core { grid-column: auto; grid-row: auto; display: flex; flex-direction: column; align-items: center; min-width: 0; padding: 0; }
.core-mark { --hero: clamp(9rem, min(15.5vw, 22vh), 19.5rem); }
.core-copy { margin-top: -0.6rem; }
.core-detail { min-height: 0; margin-top: 0.35rem; }

/* ---- floor: two columns of subsystem cards, a centre gutter of strategy feeds ---- */
.floor {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(12px, 1.6vw, 32px);
  align-items: stretch;
}
.col { display: flex; flex-direction: column; gap: clamp(8px, 1vh, 18px); min-width: 0; min-height: 0; }
.col .unit { flex: 1 1 0; min-height: 0; }
.gutter { display: flex; flex-direction: column; justify-content: center; gap: clamp(1.5rem, 6vh, 4rem); width: clamp(72px, 8vw, 150px); }
.gutter .pipe { width: 100%; }
.gutter .pipe-line { width: 100%; margin-inline: 0; }
.gutter .pipe-ends { display: flex; flex-direction: column; gap: 0.1rem; font-size: 0.66rem; }
.gutter .pipe-ends .from { color: var(--from-c); }
.gutter .pipe-ends .to { color: var(--to-c); }

/* ---- the subsystem card: bordered, clickable ---- */
.unit {
  position: relative;
  display: flex;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  background:
    radial-gradient(150% 90% at 0% 0%, var(--acc-soft) 0%, transparent 55%),
    linear-gradient(180deg, #10151c, #0d1218);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.12s ease;
}
.unit::before {
  content: "";
  position: absolute;
  inset: -1px -1px auto;
  height: 2px;
  border-radius: 14px 14px 0 0;
  background: linear-gradient(90deg, transparent 6%, var(--acc) 50%, transparent 94%);
  opacity: 0.6;
}
.unit-in { flex: 1; min-width: 0; }
.unit-link { position: absolute; inset: 0; z-index: 3; border-radius: inherit; }
.unit:hover { border-color: var(--acc-line); box-shadow: 0 0 0 1px rgb(var(--acc-rgb) / 0.25), 0 14px 40px #0007; transform: translateY(-1px); }
.unit:focus-within { border-color: var(--acc); box-shadow: 0 0 0 2px rgb(var(--acc-rgb) / 0.4); }
.unit-link:focus-visible { outline: 2px solid var(--acc); outline-offset: -3px; }
/* the API keys the subsystem runs on sit top-right, where the "open" chevron was; they and the strategy sit above
   the card's link so their full names show on hover (a click on them still opens the card, ghost.js) */
.unit-body { position: relative; }
.unit-head .keyline { margin-left: auto; justify-content: flex-end; font-size: 0.8rem; }
.unit .keyline, .unit .strategy { position: relative; z-index: 4; cursor: pointer; }
body.detail .unit.is-open .keyline, body.detail .unit.is-open .strategy { cursor: auto; }
/* The Watcher's and the Sniper's strategy line opens Settings › Strategies (D-036), open card or not. */
#watcher .strategy, #sniper .strategy, body.detail .unit.is-open#watcher .strategy, body.detail .unit.is-open#sniper .strategy { cursor: pointer; }
#watcher .strategy:hover .k, #sniper .strategy:hover .k, #watcher .strategy:focus-visible .k, #sniper .strategy:focus-visible .k { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
#watcher .strategy:focus-visible, #sniper .strategy:focus-visible { outline: 2px solid #5b6b7c; outline-offset: 2px; border-radius: 4px; }

/* ---- Watcher -> Sniper hand-off ---- */
.handoff {
  display: grid;
  justify-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0;
  color: var(--subtle);
}
.handoff-rail { position: relative; width: 2px; height: clamp(14px, 2.2vh, 26px); border-radius: 2px; background: linear-gradient(180deg, var(--acc-watcher-c, #98ebc5), var(--acc-sniper-c, #eac18a)); opacity: 0.5; overflow: visible; }
.handoff { --acc-watcher-c: #98ebc5; --acc-sniper-c: #eac18a; }
.handoff-dot { position: absolute; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: #cfe8dd; opacity: 0; }
.handoff-label { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.72rem; }
.handoff-label::after { content: "▾"; color: var(--subtle); font-size: 0.7em; }
.handoff[data-flow="on"] .handoff-rail { opacity: 0.9; }
.handoff[data-flow="on"] .handoff-dot { animation: handoff-fall 1.4s linear infinite; opacity: 0.9; }
.handoff[data-flow="on"] .handoff-dot:nth-child(2) { animation-delay: 0.47s; }
.handoff[data-flow="on"] .handoff-dot:nth-child(3) { animation-delay: 0.93s; }
.handoff[data-flow="held"] .handoff-rail { background: var(--amber); opacity: 0.7; }
.handoff[data-flow="held"] .handoff-label { color: var(--amber); }
.handoff[data-flow="off"] .handoff-rail { opacity: 0.28; }
@keyframes handoff-fall { 0% { top: 0; opacity: 0; } 15% { opacity: 0.95; } 85% { opacity: 0.95; } 100% { top: 100%; opacity: 0; } }

/* detail-only content stays hidden on the overview */
.detail-extra { display: none; }

/* ---- detail view (body.detail): one subsystem, full width ---- */
.detail-bar { display: none; }
body.detail .detail-bar {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.5rem var(--pad);
  border-bottom: 1px solid var(--line);
  background: rgb(14 18 22 / 0.9);
}
.detail-bar .back { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.35rem 0.7rem; border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-weight: 500; }
.detail-bar .back:hover { border-color: var(--muted); background: #141b23; }
.detail-bar .crumb { display: flex; align-items: center; gap: 0.4rem; color: var(--subtle); font-size: 0.9rem; }
.detail-bar .crumb .sep { width: 0.9rem; height: 0.9rem; }
.detail-bar .crumb-here { color: var(--text); font-weight: 500; }
body.detail .hero, body.detail .gutter, body.detail .handoff { display: none; }
/* The open subsystem fills the browser like the overview does: full width, at least the window's height below the
   bars; longer content scrolls with the page (wide tables scroll inside their own .table-wrap). */
body.detail .floor { display: flex; flex-direction: column; flex: 1 0 auto; }
body.detail .col { display: flex; flex-direction: column; flex: 1 0 auto; }
body.detail .unit:not(.is-open) { display: none; }
body.detail .col:not(:has(.is-open)) { display: none; }
body.detail .unit.is-open {
  flex: 1 0 auto;
  min-height: auto;
  width: 100%;
  max-width: none;
  margin: 0;
  border-color: var(--acc-line);
  box-shadow: 0 0 0 1px rgb(var(--acc-rgb) / 0.22), 0 30px 90px #000a;
}
body.detail .unit.is-open .unit-in { align-items: flex-start; }
body.detail .unit.is-open .mark-sm { align-self: flex-start; max-height: none; }
body.detail .unit.is-open .unit-link { display: none; }
body.detail .unit.is-open .unit-in { padding: clamp(16px, 3vw, 32px); }
body.detail .unit.is-open .mark-sm { width: clamp(6rem, 14vw, 11rem); }
body.detail .unit.is-open h3 { font-size: 1.5rem; }
body.detail .unit.is-open .metrics dd { font-size: clamp(1.1rem, 3cqi, 1.8rem); }
body.detail .unit.is-open .detail-extra { display: block; margin-top: 0.9rem; }
.detail-extra .about { color: var(--muted); font-size: 0.95rem; line-height: 1.55; }
.detail-extra .about b { color: var(--text); font-weight: 600; }
.detail-extra .metrics { margin-top: 0.8rem; }

/* ---- fit tiers: trim the vertical rhythm so the overview fills the viewport without scrolling ---- */
@media (min-width: 900px) and (max-height: 920px) {
  .half .mark-lg { width: clamp(3.8rem, 5vw, 6rem); }
  .half-sub { display: none; }
  .core-mark { --hero: clamp(8rem, min(13vw, 19.5vh), 15.5rem); }
  .metrics > div { padding-block: 0.32rem 0.36rem; }
  .unit-foot { margin-top: 0.45rem; padding-top: 0.42rem; }
  .about, .detail-extra { }
}
@media (min-width: 900px) and (max-height: 820px) {
  .half-facts { margin-top: 0.3rem; }
  .half .state { margin-top: 0.25rem; }
  .core-copy { margin-top: -0.3rem; }
  .core-detail { display: none; }
  .unit-detail { margin-top: 0.2rem; }
  .metrics { margin-top: 0.4rem; }
}

/* ---- stacked layout for narrow screens ---- */
@media (max-width: 899.98px) {
  .stage { overflow: visible; }
  .hero { grid-template-columns: 1fr auto 1fr; gap: 8px; }
  .half-facts { display: none; }
  .half .mark-lg { width: clamp(3rem, 13vw, 4.8rem); }
  .half-name { font-size: clamp(1.1rem, 4.5vw, 1.6rem); }
  .core-mark { --hero: clamp(6.5rem, 28vw, 10.5rem); }
  .floor { grid-template-columns: 1fr; }
  .gutter { flex-direction: row; width: auto; justify-content: center; gap: 1.5rem; }
  .gutter .pipe-ends { flex-direction: row; gap: 0.4rem; }
  .col .unit { flex: none; }
  body.detail .unit.is-open .unit-in { padding: 16px; }
}

/* ---- Watcher <-> Sniper link, shown as a status lamp on both cards ---- */
.linkline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
  padding: 0.16rem 0.5rem 0.16rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #10151c;
  font-size: 0.74rem;
  color: var(--muted);
  width: max-content;
  max-width: 100%;
}
.linkline .arw { width: 0.85rem; height: 0.85rem; color: var(--subtle); }
.linkline .back-arw { transform: scaleX(-1); }
.linkline .linktext { font-weight: 600; color: #cdd6df; }
.linkline .linkstate { color: var(--subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linkline .lamp {
  flex: none;
  width: 9px; height: 9px; border-radius: 50%;
  background: #4d5663;
  box-shadow: 0 0 0 3px #10151c, 0 0 0 4px #2a323c;
}
.linkline[data-flow="on"] { border-color: #2f5a48; }
.linkline[data-flow="on"] .lamp { background: #7ee3b8; box-shadow: 0 0 0 3px #10151c, 0 0 8px 1px rgb(126 227 184 / 0.8); animation: lamp-pulse 1.4s ease-in-out infinite; }
.linkline[data-flow="on"] .linkstate { color: var(--green); }
.linkline[data-flow="held"] { border-color: #5b4a2c; }
.linkline[data-flow="held"] .lamp { background: var(--amber); box-shadow: 0 0 0 3px #10151c, 0 0 7px 1px rgb(233 193 138 / 0.7); }
.linkline[data-flow="held"] .linkstate { color: var(--amber); }
.linkline[data-flow="off"] .lamp { background: #4d5663; }
@keyframes lamp-pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
body[data-conn="lost"] .linkline .lamp { animation: none !important; }

/* ===================================================================================================================
   Header pills in fixed slots, and animated centred subsystem arrows.
   =================================================================================================================== */
/* Fixed positions: the status pills keep their place and width as their values change (they no longer reflow when
   "Paper mode" becomes "Live · real funds" or the slot number grows). One row on desktop; they wrap on small screens. */
@media (min-width: 760px) {
  .topbar { flex-wrap: nowrap; }
  .topbar-pills { flex-wrap: nowrap; justify-content: flex-end; }
  .pill { justify-content: flex-start; overflow: hidden; }
  .pill > span:not(.short), .pill > b { overflow: hidden; text-overflow: ellipsis; }
  #pill-mode { width: 11.5rem; }
  #pill-db { width: 7.5rem; }
  #pill-db .long { display: none; }
  #pill-db .short { display: inline; }
  #pill-chain { width: 10rem; }
  #pill-clock { width: 14.5rem; }
  #pill-updated { width: 11rem; }
}

/* Subsystem feed arrows (Radar Lab -> Watcher, Scope Lab -> Sniper): centred in the gutter and always reading as a
   live connection — flowing dots when a strategy is actually being served, a slow shimmer when idle, static when off. */
.gutter { justify-content: center; gap: clamp(2.5rem, 12vh, 7rem); }
.pipe { align-self: center; }
.pipe[data-flow="idle"] .pipe-flow { opacity: 0.5; animation: flow 3.2s linear infinite; }
.pipe[data-flow="idle"] .pipe-origin { animation: origin-pulse 2.4s ease-in-out infinite; }
.pipe[data-flow="on"] .pipe-origin { animation: origin-pulse 1.5s ease-in-out infinite; }
@keyframes origin-pulse { 0%, 100% { transform: scale(1); opacity: 0.8; } 50% { transform: scale(1.5); opacity: 1; } }
/* A touch more presence on the flowing line. */
.pipe[data-flow="on"] .pipe-line::after { animation: arrow-nudge 1.5s ease-in-out infinite; }
@keyframes arrow-nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-3px); } }

/* ===================================================================================================================
   Declutter: no connector arrows, no per-card state text (the character icon + its gem show the state).
   =================================================================================================================== */
.floor { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(12px, 1.6vw, 32px); }

/* The gem under each character is now the explicit state read: a coloured ring + state icon that follows data-state. */
.gem {
  position: absolute;
  left: 50%;
  bottom: 3%;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  width: 26%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #0c1117;
  border: 1.5px solid var(--st, #4d5663);
  box-shadow: 0 0 0 3px #0a0e13, 0 0 10px rgb(var(--st-rgb) / 0.45);
  color: var(--st, var(--subtle));
}
.gem .icon { width: 62%; height: 62%; stroke-width: 2.2; }
.mark[data-state="running"] .gem, .mark[data-state="idle"] .gem { animation: gem-live 2s ease-in-out infinite; }
@keyframes gem-live { 0%, 100% { box-shadow: 0 0 0 3px #0a0e13, 0 0 8px rgb(var(--st-rgb) / 0.4); } 50% { box-shadow: 0 0 0 3px #0a0e13, 0 0 14px rgb(var(--st-rgb) / 0.75); } }
/* In the detail view the gem is the one place state is spelled out, so give it a word beside the icon. */
body.detail .unit.is-open .mark .gem { width: auto; aspect-ratio: auto; padding: 0.2rem 0.6rem 0.2rem 0.4rem; border-radius: 999px; bottom: -0.4rem; gap: 0.3rem; grid-auto-flow: column; }
body.detail .unit.is-open .mark .gem .icon { width: 1rem; height: 1rem; }
body.detail .unit.is-open .mark .gem::after { content: attr(data-word); font: 600 0.82rem var(--display); color: var(--st); letter-spacing: 0.01em; }

/* The floor columns reuse .sys-warrior/.sys-academy for their accent, but those classes also carry grid-column:1/3
   from the old three-column stage. Pin the floor columns to the two-column grid. */
.floor > .col.sys-warrior { grid-column: 1; }
.floor > .col.sys-academy { grid-column: 2; }

/* ---- Watcher view lists (06 §3.2): potentially profitable tokens, candidates ---- */
.wlist { margin-top: 1.4rem; }
.wlist-title { font-family: var(--display); font-size: 1.05rem; font-weight: 500; color: var(--text); margin: 0 0 0.5rem; }
.wlist-note { font-family: var(--font); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--subtle); margin-left: 0.5rem; }
.wlist-empty { color: var(--muted); font-size: 0.9rem; margin: 0.3rem 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.wtable { width: 100%; border-collapse: collapse; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.wtable th { text-align: left; font-weight: 600; font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--subtle); padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.wtable td { padding: 0.5rem 0.7rem; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); white-space: nowrap; color: var(--text); }
.wtable tr:last-child td { border-bottom: 0; }
.wtable .num { text-align: right; }
.wtable [data-sign="pos"] { color: #7fe0b0; }
.wtable [data-sign="neg"] { color: #f08a8a; }
.wtable[data-stale="true"] td { opacity: 0.55; }
.mint-btn { font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--acc); background: none; border: 0; padding: 0; cursor: pointer; }
.mint-btn:hover, .mint-btn:focus-visible { text-decoration: underline; }
.mint-btn[data-copied="true"]::after { content: " copied"; color: var(--subtle); font-family: var(--font); font-size: 0.75rem; }
.tier { font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* ===================================================================================================================
   Panel scaling (owner, 2026-09-23): the content of each overview panel scales and rearranges with the panel itself.
   Each card is a size container; its content takes one font size from the card's own width and height (within a
   readable floor and a ceiling), and every size inside is in em of that, so text, numbers, icons, the character and the
   spacing grow and shrink together. Short cards drop their secondary lines, then the character, instead of overflowing.
   The detail view scales with the card's width only: its height follows the content there, so it cannot be a size
   container, and the height rules below never match it.
   =================================================================================================================== */
.floor .unit-in {
  --fit: clamp(12px, 3.3cqw, 16px); /* stacked (narrow) layout: the card's height follows its content, so width only */
  font-size: var(--fit);
  gap: 1.3em;
  padding: 1.1em 1.5em;
  align-items: center;
}
.floor .unit .mark-sm { width: min(10.5em, 26cqw, 60cqh); max-height: 88cqh; }
.floor .unit-name .eyebrow { font-size: 0.7em; }
.floor .unit-head .keyline { font-size: 0.82em; }
.floor .keyline .icon { width: 1.15em; height: 1.15em; }
.floor .unit h3 { font-size: 1.95em; }
.floor .unit-detail { font-size: 0.95em; gap: 0.3em 0.55em; margin-top: 0.25em; }
.floor .tag { font-size: 0.82em; padding: 0.05em 0.45em; }
.tag[data-f="positions"][data-on="true"] { border-color: rgb(var(--acc-rgb) / 0.6); color: var(--acc); }
.floor .tag .icon { width: 1.1em; height: 1.1em; }
.floor .linkline { font-size: 0.85em; margin-top: 0.35em; }
.floor .unit .state { font-size: 0.88em; }
.floor .unit .state .icon { width: 1.2em; height: 1.2em; }
.floor .metrics { margin-top: 0.65em; border-radius: 0.6em; }
.floor .metrics > div { padding: 0.45em 0.8em 0.5em; }
.floor .metrics dt { font-size: 0.78em; }
.floor .metrics dd { font-size: 1.85em; line-height: 1.3; }
.floor .progress { margin-top: 0.6em; }
.floor .progress-label { font-size: 0.88em; margin-bottom: 0.35em; }
.floor .progress-label b { font-size: 1.05em; }
.floor .track { height: 0.45em; }
.floor .unit-foot { font-size: 0.88em; margin-top: 0.7em; padding-top: 0.55em; gap: 0.35em 0.9em; }
.floor .strategy .icon, .floor .beat .icon { width: 1.15em; height: 1.15em; }
.floor .chip { font-size: 0.85em; }

/* Detail view: one card as wide as the window, scaled by its width. */
body.detail .floor .unit.is-open .unit-in { --fit: clamp(14px, 1.05cqw, 22px); }
body.detail .floor .unit.is-open h3 { font-size: 2.1em; }
body.detail .floor .unit.is-open .metrics dd { font-size: 2em; }
body.detail .floor .unit.is-open .detail-extra .about { font-size: 1em; }
body.detail .floor .unit.is-open .mark-sm { width: min(12em, 18cqw); }
body.detail .floor .unit.is-open .wlist-title { font-size: 1.2em; }
body.detail .floor .unit.is-open .wlist-note { font-size: 0.7em; }
body.detail .floor .unit.is-open .wlist-empty { font-size: 0.95em; }
body.detail .floor .unit.is-open .wtable { font-size: 0.92em; }

@media (min-width: 900px) {
  body:not(.detail) .floor .unit { container: unit / size; }
  body:not(.detail) .floor .unit-in { --fit: clamp(10.5px, min(2.1cqw, 5.4cqh), 36px); }
  .stage { max-width: 3400px; }
}

/* Stacked (phone, tablet): four numbers share a narrow row, so the numbers are smaller than on a wide card. */
@media (max-width: 899.98px) {
  .floor .metrics dd { font-size: 1.4em; }
  .floor .metrics dt { font-size: 0.74em; }
  .floor .metrics > div { padding: 0.4em 0.55em 0.45em; }
  .floor .unit .mark-sm { width: min(6.5em, 24cqw); }
}

/* Rearrange instead of overflowing: a short card first drops its secondary lines, then the character. */
@container unit (max-height: 15em) {
  .unit-name .eyebrow, .linkline, .progress-label { display: none; }
}
@container unit (max-height: 12em) {
  .unit-foot { display: none; }
}
@container unit (max-height: 9.5em) {
  .unit .mark-sm { display: none; }
  .unit-detail { display: none; }
}

/* The .sys-warrior/.sys-academy accents also carry grid cells from the old three-column stage, which scattered the
   hero and kept the floor two columns wide on phones. Place both rows explicitly. */
.hero > .half, .hero > .core { grid-row: 1; }
.hero > .half.sys-warrior { grid-column: 1; }
.hero > .core { grid-column: 2; }
.hero > .half.sys-academy { grid-column: 3; }
@media (max-width: 899.98px) {
  .floor { grid-template-columns: minmax(0, 1fr); }
  .floor > .col.sys-warrior, .floor > .col.sys-academy { grid-column: 1; grid-row: auto; }
}

/* Detail view on a desktop window (owner, 2026-09-23): the panel is fixed to the window and the components inside it
   scroll, not the page. Head, numbers and foot stay put; the detail section takes the rest of the height and each
   Watcher list scrolls in its own box with its column heads pinned. Phones keep the page scroll. */
@media (min-width: 900px) and (min-height: 560px) {
  body.detail { height: 100vh; height: 100dvh; overflow: hidden; }
  body.detail .stage { flex: 1 1 0; min-height: 0; overflow: hidden; }
  body.detail .floor, body.detail .col { flex: 1 1 0; min-height: 0; }
  body.detail .unit.is-open { flex: 1 1 0; min-height: 0; overflow: hidden; }
  body.detail .unit.is-open .unit-in { min-height: 0; }
  body.detail .unit.is-open .unit-body { align-self: stretch; min-height: 0; }
  body.detail .unit.is-open .detail-extra { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
  body.detail .unit.is-open .detail-extra:has(.wlist) { overflow: hidden; }
  body.detail .unit.is-open .wlist { flex: 1 1 0; min-height: 6em; display: flex; flex-direction: column; }
  body.detail .unit.is-open .wlist .table-wrap { flex: 0 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
  body.detail .unit.is-open .wtable thead th { position: sticky; top: 0; z-index: 1; background: #10151c; }
  /* Radar Lab: the form stays put, the studies scroll in their own box */
  body.detail .unit.is-open .lab-study .study-list { flex: 1 1 0; min-height: 0; overflow: auto; overscroll-behavior: contain; padding-right: 0.2rem; }
}
/* A short window gives the Watcher lists the room: the one-paragraph description goes. */
@media (min-width: 900px) and (min-height: 560px) and (max-height: 900px) {
  body.detail .unit.is-open .detail-extra:has(.wlist) .about { display: none; }
  body.detail .unit.is-open .wlist { margin-top: 0.8rem; }
}

/* ---- the wallet (top bar pill) ---- */
.pill-wallet b { margin-left: 0.15rem; font-variant-numeric: tabular-nums; }
.pill-wallet #wallet-text { font-variant-numeric: tabular-nums; }
.pill-wallet #wallet-mode { margin-right: 0.3rem; }
@media (max-width: 1250px) { .pill-wallet #wallet-mode { display: none; } }
.pill-wallet[data-sign="pos"] b { color: var(--green); }
.pill-wallet[data-sign="neg"] b { color: var(--red); }
.pill-wallet .icon { color: var(--amber); }

/* ---- Sniper view: equity curve and per-trade bars (inline SVG, no chart library: strict CSP) ---- */
/* Open positions and execution quality side by side: both are short */
.srow { display: grid; grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr); gap: 0 1.2rem; align-items: start; }
.srow > .wlist { min-width: 0; }
#sl-exec th, #sl-exec td { padding-inline: 0.55rem; white-space: nowrap; }
body.detail .acc-sniper.is-open #sp-overall .srow .wlist { margin-top: 0.9rem; }
@media (max-width: 1099.98px) { .srow { grid-template-columns: minmax(0, 1fr); } }
.scharts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; margin-top: 1rem; }
.schart { min-width: 0; }
.chart { display: block; width: 100%; height: 9.5em; border: 1px solid var(--line); border-radius: 8px; background: #0e1319; }
.chart-zero { stroke: #3a4452; stroke-width: 1; stroke-dasharray: 3 4; }
.chart-line { fill: none; stroke-width: 2; }
.chart-line.pos { stroke: var(--green); }
.chart-line.neg { stroke: var(--red); }
.chart-line.zero { stroke: var(--muted); }
.chart-area { stroke: none; opacity: 0.14; }
.chart-area.pos { fill: var(--green); }
.chart-area.neg { fill: var(--red); }
.chart-area.zero { fill: var(--muted); }
.chart-bar.pos { fill: var(--green); }
.chart-bar.neg { fill: var(--red); }
.chart-bar.zero { fill: var(--muted); }
@media (max-width: 699.98px) { .scharts { grid-template-columns: minmax(0, 1fr); } }
body.detail .floor .unit.is-open .scharts { font-size: 1em; flex: none; }

/* the Sniper card names the unit in the label on the overview (four figures share a narrow row), and after the
   number in the roomier detail view */
body:not(.detail) .acc-sniper .metrics .unit-suffix { display: none; }
body.detail .acc-sniper .metrics .dt-unit { display: none; }

/* ---- Sniper view: the candidate list (left) and the overall or one token's pane (right) ---- */
.sdesk { display: grid; grid-template-columns: minmax(15rem, 19rem) minmax(0, 1fr); gap: 1.2rem; margin-top: 0.9rem; }
.spane { min-width: 0; }
.clist { min-width: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; background: #0d1218; overflow: hidden; }
.clist-head { padding: 0.75rem 0.75rem 0.6rem; border-bottom: 1px solid var(--line); }
.clist-head .wlist-title { margin-bottom: 0.5rem; }
.clist .wlist-empty { padding: 0.2rem 0.9rem 0.8rem; }
.seg { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.seg button { font: inherit; font-size: 0.74rem; padding: 0.2rem 0.55rem; border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--muted); cursor: pointer; }
.seg button b { margin-left: 0.15rem; color: var(--subtle); font-weight: 600; font-variant-numeric: tabular-nums; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { border-color: var(--acc-line); background: rgb(var(--acc-rgb) / 0.12); color: var(--text); }
.seg button[aria-pressed="true"] b { color: var(--acc); }
.clist-items { list-style: none; margin: 0; padding: 0.35rem; overflow: auto; overscroll-behavior: contain; flex: 1 1 auto; min-height: 0; }
.citem { display: grid; gap: 0.3rem; width: 100%; padding: 0.5rem 0.6rem; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.citem:hover { background: #121922; }
.citem:focus-visible { outline: 2px solid var(--acc-line); outline-offset: -2px; }
.citem[aria-pressed="true"] { border-color: var(--acc-line); background: rgb(var(--acc-rgb) / 0.1); box-shadow: inset 3px 0 0 var(--acc); }
.citem-all { margin-bottom: 0.3rem; border-color: var(--line); }
.ci-top, .ci-bottom { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.ci-name { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.88rem; font-weight: 600; white-space: nowrap; }
.ci-name .icon { width: 1rem; height: 1rem; color: var(--acc); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.ci-age { margin-left: auto; color: var(--subtle); font-size: 0.72rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ci-stage { color: var(--muted); font-size: 0.68rem; letter-spacing: 0.09em; text-transform: uppercase; white-space: nowrap; }
.ci-val { margin-left: auto; min-width: 0; overflow: hidden; color: var(--muted); font-size: 0.8rem; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ci-val[data-sign="pos"], .tk-stats dd[data-sign="pos"] { color: var(--green); }
.ci-val[data-sign="neg"], .tk-stats dd[data-sign="neg"] { color: var(--red); }
.tk-stats dd[data-sign="warn"] { color: var(--amber); }
.citem[data-stage="watching"] .ci-stage, .citem[data-stage="trading"] .ci-stage, .citem[data-stage="screening"] .ci-stage { color: var(--acc); }
.citem[data-stage="traded"] .ci-stage { color: var(--text); }
.citem[data-stage="skipped"], .citem[data-stage="unscreened"], .citem[data-stage="no_entry"] { opacity: 0.72; }
.citem[data-stage="skipped"][aria-pressed="true"], .citem[data-stage="unscreened"][aria-pressed="true"], .citem[data-stage="no_entry"][aria-pressed="true"] { opacity: 1; }
/* the four steps a token can take: flagged, screened, entered, closed */
.ci-trail { display: inline-flex; align-items: center; gap: 3px; }
.ci-trail i, .tk-trail li::before { width: 7px; height: 7px; border-radius: 50%; background: #29313c; box-sizing: border-box; }
.ci-trail i[data-s="done"], .tk-trail li[data-s="done"]::before { background: var(--green); }
.ci-trail i[data-s="loss"], .tk-trail li[data-s="loss"]::before { background: var(--red); }
.ci-trail i[data-s="fail"], .tk-trail li[data-s="fail"]::before { background: none; border: 1.5px solid var(--muted); }
.ci-trail i[data-s="now"], .tk-trail li[data-s="now"]::before { background: var(--acc); box-shadow: 0 0 0 0 rgb(var(--acc-rgb) / 0.6); animation: ci-pulse 1.6s ease-out infinite; }
@keyframes ci-pulse { to { box-shadow: 0 0 0 6px rgb(var(--acc-rgb) / 0); } }
@media (prefers-reduced-motion: reduce) { .ci-trail i[data-s="now"], .tk-trail li[data-s="now"]::before { animation: none; } }

.tk-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 1rem; }
.tk-id { display: flex; align-items: center; gap: 0.7rem; margin: 0; }
#tk-mint { font-size: 1.15rem; font-weight: 600; }
.tk-stage { padding: 0.15rem 0.55rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; }
.tk-stage[data-stage="watching"], .tk-stage[data-stage="trading"], .tk-stage[data-stage="screening"] { border-color: var(--acc-line); color: var(--acc); }
.tk-stage[data-stage="traded"] { border-color: #3a4452; color: var(--text); }
.tk-sub { margin: 0; color: var(--muted); font-size: 0.86rem; }
.tk-trail { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0.9rem 0 0; padding: 0; list-style: none; }
.tk-trail li { position: relative; min-width: 0; padding-top: 1.05rem; color: var(--subtle); font-size: 0.76rem; }
.tk-trail li::before { content: ""; position: absolute; top: 0; left: 0; width: 10px; height: 10px; }
.tk-trail li:not(:last-child)::after { content: ""; position: absolute; top: 4.5px; left: 16px; right: 8px; height: 1px; background: #29313c; }
.tk-trail li[data-s="done"]:not(:last-child)::after { background: rgb(145 222 183 / 0.45); }
.tk-trail li b { display: block; color: var(--text); font-size: 0.82rem; font-weight: 600; }
.tk-trail li span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-trail li[data-s="off"] b { color: var(--subtle); font-weight: 500; }
.tk-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.2rem, 1fr)); gap: 0.5rem; margin: 0.9rem 0 0; }
.tk-stats div { padding: 0.45rem 0.65rem; border: 1px solid var(--line); border-radius: 8px; background: #0e1319; }
.tk-stats dt { color: var(--subtle); font-size: 0.64rem; letter-spacing: 0.09em; text-transform: uppercase; white-space: nowrap; }
.tk-stats dd { margin: 0.15rem 0 0; font: 600 1.05rem var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tk-chart { margin-top: 1.1rem; }
.tk-plot { position: relative; }
.tk-svg { display: block; width: 100%; height: clamp(16rem, calc(100vh - 33rem), 34rem); border: 1px solid var(--line); border-radius: 8px; background: #0e1319; touch-action: pan-y; }
.tk-tip { position: absolute; top: 8px; display: grid; gap: 2px; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--raised); box-shadow: 0 8px 24px #0009; color: var(--muted); font-size: 0.78rem; white-space: nowrap; font-variant-numeric: tabular-nums; pointer-events: none; }
.tk-tip b { color: var(--text); }
.tk-window { fill: rgb(var(--acc-rgb) / 0.055); }
.tk-met { fill: rgb(145 222 183 / 0.17); }
.tk-grid { stroke: #19212a; stroke-width: 1; }
.tk-axis { fill: var(--subtle); font: 10px var(--font); font-variant-numeric: tabular-nums; }
.tk-note { fill: var(--subtle); font: 10px var(--font); letter-spacing: 0.05em; }
.tk-price { fill: none; stroke: #dfe6ee; stroke-width: 1.4; stroke-linejoin: round; }
.tk-band { fill: #dfe6ee; opacity: 0.12; }
.tk-flow-area { fill: rgb(var(--acc-rgb) / 0.13); }
.tk-flow-net { fill: none; stroke: var(--acc); stroke-width: 1.4; stroke-linejoin: round; }
.tk-flow-count { fill: none; stroke: #8e9aab; stroke-width: 1; stroke-dasharray: 2 3; }
.tk-bar { stroke: #c7cfda; stroke-width: 1; stroke-dasharray: 6 4; opacity: 0.55; }
.tk-zero { stroke: #333d49; stroke-width: 1; }
.tk-tp { stroke: var(--green); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.75; }
.tk-trip { stroke-width: 1.6; opacity: 0.85; }
.tk-trip.pos { stroke: var(--green); }
.tk-trip.neg { stroke: var(--red); }
.tk-enter { stroke: var(--acc); stroke-width: 1; stroke-dasharray: 4 3; }
.tk-enter-label { fill: var(--acc); }
.tk-now { stroke: var(--amber); stroke-width: 1; stroke-dasharray: 2 3; }
.tk-mk.buy { fill: var(--green); stroke: #0e1319; stroke-width: 1; }
.tk-mk.sell { fill: #f3a86b; stroke: #0e1319; stroke-width: 1; }
.tk-mk.fail { fill: none; stroke: var(--red); stroke-width: 1.7; stroke-linecap: round; }
.tk-cross { stroke: #6f7b8b; stroke-width: 1; stroke-dasharray: 2 2; pointer-events: none; }
/* the replay: play, a scrubber over the session, speed; the state at the cursor below */
.tk-replay { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-top: 0.55rem; }
.rp-play { display: grid; place-items: center; width: 2rem; height: 2rem; flex: none; border: 1px solid var(--acc-line); border-radius: 50%; background: rgb(var(--acc-rgb) / 0.12); color: var(--acc); cursor: pointer; }
.rp-play:hover { background: rgb(var(--acc-rgb) / 0.22); }
.rp-play .icon { width: 0.95rem; height: 0.95rem; fill: currentColor; }
.rp-play use[href="#i-pause"] { fill: none; }
.rp-range { flex: 1 1 12rem; min-width: 8rem; accent-color: var(--acc); cursor: pointer; }
.rp-time { min-width: 4.6rem; color: var(--text); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.rp-live { padding: 0.2rem 0.6rem; border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--amber); font: inherit; font-size: 0.74rem; cursor: pointer; }
.rp-state div { min-width: 0; border-color: var(--acc-line); background: rgb(var(--acc-rgb) / 0.06); }
.rp-state dd { overflow: hidden; font-size: 0.95rem; text-overflow: ellipsis; }
.rp-state dt { color: var(--acc); }
.tk-cursor { stroke: var(--acc); stroke-width: 1.5; }
.tk-cursor-label { fill: var(--acc); font-weight: 600; }
.tk-plot { cursor: crosshair; }
.tk-legend { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; margin: 0.5rem 0 0; color: var(--subtle); font-size: 0.74rem; }
.lg-buy { color: var(--green); }
.lg-sell { color: #f3a86b; }
.lg-fail { color: var(--red); }
.lg-tp::before, .lg-win::before, .lg-met::before { content: ""; display: inline-block; width: 1.1rem; height: 0.55rem; margin-right: 0.35rem; vertical-align: 0; border-radius: 2px; }
.lg-tp::before { height: 0; border-top: 1px dashed var(--green); vertical-align: 0.2rem; }
.lg-win::before { background: rgb(var(--acc-rgb) / 0.14); }
.lg-met::before { background: rgb(145 222 183 / 0.3); }
.tk-orders tr[data-status="failed"] td { color: var(--muted); }
.side-buy { color: var(--green) !important; }
.side-sell { color: #f3a86b !important; }

/* the Overall charts are a glance, not the page: short, so the open positions and sessions below stay in view */
body.detail .floor .unit.is-open .chart { height: clamp(4.25rem, 10vh, 6.5rem); }
body.detail .floor .unit.is-open .schart .wlist-title { margin-bottom: 0.35rem; }
body.detail .acc-sniper.is-open #sp-overall .wlist { margin-top: 0.9rem; }

/* Desktop: the fixed panel gives the list and the pane the height left; each scrolls on its own */
@media (min-width: 900px) and (min-height: 560px) {
  body.detail .acc-sniper.is-open .detail-extra { overflow: hidden; }
  body.detail .acc-sniper.is-open .sdesk { flex: 1 1 0; min-height: 0; }
  body.detail .acc-sniper.is-open .clist { min-height: 0; }
  body.detail .acc-sniper.is-open .spane { min-height: 0; overflow: auto; overscroll-behavior: contain; padding-right: 0.25rem; }
  body.detail .acc-sniper.is-open #sp-overall:not([hidden]) { display: flex; flex-direction: column; overflow: auto; }
  body.detail .acc-sniper.is-open #sp-overall .scharts { margin-top: 0; }
  body.detail .acc-sniper.is-open #sp-overall .srow { flex: none; }
  body.detail .acc-sniper.is-open #sp-overall .srow .table-wrap:has(#sl-open) { max-height: 6.5rem; overflow: auto; }
  body.detail .acc-sniper.is-open #sp-overall .wlist:has(#sl-sess) { flex: 1 1 0; min-height: 12rem; display: flex; flex-direction: column; }
  /* the token's chart takes the height left under its head (at least 18rem); its orders follow, below the fold */
  body.detail .acc-sniper.is-open #sp-token:not([hidden]) { display: flex; flex-direction: column; }
  body.detail .acc-sniper.is-open #sp-token > * { flex: none; }
  body.detail .acc-sniper.is-open #sp-token > .tk-chart { flex: 1 0 auto; min-height: 21rem; display: flex; flex-direction: column; }
  body.detail .acc-sniper.is-open #sp-token > .tk-chart > * { flex: none; }
  body.detail .acc-sniper.is-open #sp-token > .tk-chart > .tk-plot { flex: 1 1 0; min-height: 15rem; }
  body.detail .acc-sniper.is-open .tk-svg { position: absolute; inset: 0; height: 100%; }
  body.detail .acc-sniper.is-open #sp-token .wlist { display: block; min-height: 0; }
  body.detail .acc-sniper.is-open #sp-token .table-wrap { max-height: 22rem; }
}
@media (max-width: 899.98px) {
  .sdesk { grid-template-columns: minmax(0, 1fr); }
  .clist-items { max-height: 17rem; }
}
@media (min-width: 900px) and (min-height: 560px) and (max-height: 1150px) {
  body.detail .acc-sniper.is-open .detail-extra > .about { display: none; }
}
@media (max-width: 699.98px) {
  body.detail .floor .unit.is-open .metrics dd { font-size: 1.45em; }
  body.detail .acc-sniper .metrics .unit-suffix { display: none; }
  body.detail .acc-sniper .metrics .dt-unit { display: inline; }
}
/* the wallet pill gets a fixed slot like the others; on narrower windows the wall clock (then the slot) makes room */
@media (min-width: 760px) {
  #pill-wallet { width: 16rem; }
}
@media (min-width: 760px) and (max-width: 1250px) {
  #pill-wallet { width: 10.5rem; }
  #pill-clock { display: none; }
}
@media (min-width: 760px) and (max-width: 900px) {
  #pill-chain { display: none; }
}

/* ---- Settings dialog (trading mode; API keys) ---- */
button.pill { font: inherit; font-size: 0.86rem; cursor: pointer; }
button.pill-mode:hover { border-color: #45505b; background: #19202a; }
.settings {
  width: min(66rem, calc(100vw - 32px));
  max-height: min(92vh, 60rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0f141a;
  color: var(--text);
  box-shadow: 0 30px 90px #000c;
}
.settings::backdrop { background: rgb(4 7 10 / 0.72); backdrop-filter: blur(3px); }
.settings[open] { display: flex; flex-direction: column; }
.settings-head { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; padding: 1rem 1.2rem 0.8rem; border-bottom: 1px solid var(--line); background: #0f141a; }
.settings-head h2 { margin: 0; font: 600 1.25rem var(--display); }
.settings-tabs { margin-right: auto; }
.settings-tabs [role=tab] { font: inherit; font-size: 0.8rem; padding: 0.3rem 0.8rem; border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--muted); cursor: pointer; }
.settings-tabs [role=tab][aria-selected="true"] { border-color: #45505b; background: #1a212b; color: var(--text); }
.settings-close { width: 2rem; height: 2rem; border: 1px solid var(--line); border-radius: 8px; background: none; color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.settings-close:hover { color: var(--text); border-color: #45505b; }
.settings-panel { padding: 1rem 1.2rem 1.3rem; overflow: auto; }
.settings-empty { color: var(--muted); }
.settings-h { margin: 1.3rem 0 0.6rem; font: 500 1.02rem var(--display); }
.mode-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0.8rem; }
.mode-card { display: flex; flex-direction: column; gap: 0.45rem; padding: 0.9rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: #121820; }
.mode-card p { margin: 0; color: var(--muted); font-size: 0.86rem; line-height: 1.45; }
.mode-card .mode-card-name { display: flex; align-items: center; gap: 0.45rem; color: var(--text); font: 600 1rem var(--display); }
.mode-card .mode-card-name .icon { width: 1.1rem; height: 1.1rem; }
.mode-card[data-card="paper"] .icon { color: #c1a9f5; }
.mode-card[data-card="live"] .icon { color: var(--red); }
.mode-card[data-current="true"] { border-color: #45505b; box-shadow: inset 0 0 0 1px #45505b; }
.mode-card[data-card="live"][data-current="true"] { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.mode-card button { align-self: flex-start; margin-top: auto; }
.mode-verdict { margin-top: auto !important; color: var(--text) !important; font-weight: 600; }
.checklist { display: grid; gap: 0.35rem; margin: 0; padding: 0; list-style: none; }
.checklist li { padding: 0.5rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; background: #121820; }
.checklist li p { margin: 0; }
.checklist li > p:first-child { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.55rem; font-size: 0.88rem; }
.check-mark { width: 1rem; font-weight: 700; text-align: center; }
.checklist li[data-ok="true"] .check-mark { color: var(--green); }
.checklist li[data-ok="false"] .check-mark { color: var(--red); }
.check-detail { color: var(--subtle); font-size: 0.8rem; }
.check-fix { margin-top: 0.25rem !important; padding-left: 1.55rem; color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.live-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.8rem 1rem; }
.live-field { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.live-field:has(.mono) { grid-column: 1 / -1; }
.live-label { color: var(--text); font-size: 0.85rem; font-weight: 600; }
.live-help { color: var(--subtle); font-size: 0.76rem; }
.settings input[type=text], .settings input[type=number], .settings input[type=password], .settings select {
  min-width: 0; padding: 0.45rem 0.6rem; border: 1px solid #313a43; border-radius: 7px; background: #0b1016; color: var(--text); font: inherit; font-size: 0.9rem;
}
.settings input:focus-visible, .settings select:focus-visible { outline: 2px solid #5b6b7c; outline-offset: 1px; }
.settings input:disabled { opacity: 0.6; }
.region-set { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; font-size: 0.86rem; color: var(--muted); }
.region { display: inline-flex; align-items: center; gap: 0.2rem; text-transform: capitalize; }
.live-costs { margin: 0.8rem 0 0; color: var(--subtle); font-size: 0.8rem; }
.live-form-actions { display: flex; align-items: center; gap: 0.8rem; margin-top: 0.8rem; }
.form-msg { color: var(--muted); font-size: 0.84rem; }
.form-msg[data-tone="ok"] { color: var(--green); }
.form-msg[data-tone="error"] { color: var(--red); }
.live-switch { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem 0.8rem; margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.live-password { display: flex; flex-direction: column; gap: 0.3rem; color: var(--muted); font-size: 0.82rem; }
.live-go:not(:disabled) { border-color: var(--red); color: #ffd7dd; background: #3a1a22; }
.live-go:disabled, .settings button:disabled { opacity: 0.5; cursor: not-allowed; }
.live-switch .form-msg { flex-basis: 100%; margin: 0; }

/* ---- Settings › API keys: per provider, one row per key ---- */
.keyfile { margin-bottom: 1rem; padding: 0.7rem 0.9rem; border: 1px solid #5b4a33; border-radius: 10px; background: rgb(233 193 138 / 0.06); color: var(--muted); font-size: 0.88rem; }
.keyfile-act { display: inline-flex; gap: 0.4rem; align-items: center; }
.keyfile-warn { margin: 0.35rem 0 0; color: var(--amber); font-size: 0.8rem; }
.linkish { padding: 0; border: 0; background: none; color: var(--amber); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.ktable { width: 100%; margin-bottom: 0.9rem; border-collapse: separate; border-spacing: 0; border: 1px solid var(--line); border-radius: 10px; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.ktable th { padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--line); color: var(--subtle); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.09em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.ktable td { padding: 0.55rem 0.7rem; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); color: var(--text); vertical-align: middle; white-space: nowrap; }
.ktable tr:last-child td { border-bottom: 0; }
.ktable td.num { text-align: right; }
.ktable th:nth-child(4), .ktable th:nth-child(5) { text-align: right; }
.ktable tr[data-on="false"] td:not(:nth-child(3)):not(.k-more) { opacity: 0.55; }
/* keys grouped by type (D-060): a section per provider, an edit row and a shown key under a key's row */
.kgroup { margin-bottom: 1.1rem; }
.kgroup-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem; margin-bottom: 0.45rem; }
.kgroup-head h4 { margin: 0; font: 600 0.98rem var(--display); color: var(--text); }
.kgroup-facts { color: var(--subtle); font-size: 0.8rem; }
.kgroup-head .signout { margin-left: auto; }
.ktable tr.kextra td { white-space: normal; background: #10151c; }
.kedit { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.6rem 0.9rem; padding: 0.3rem 0; }
.kedit input, .kedit select, .kedit textarea { width: 100%; box-sizing: border-box; font: inherit; font-size: 0.86rem; padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 7px; background: #0b0f14; color: var(--text); }
.kedit textarea { min-height: 3.2rem; resize: vertical; }
.kedit .key-add-actions { grid-column: 1 / -1; }
.kreveal-box { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.7rem; }
.kreveal-value { padding: 0.35rem 0.55rem; border: 1px solid #624e31; border-radius: 7px; background: #2e2619; color: #efc894; font: 500 0.86rem ui-monospace, Menlo, monospace; word-break: break-all; user-select: all; }
.kreveal-left { color: var(--subtle); font-size: 0.78rem; }
.kreveal .key-safe { flex-basis: 100%; margin: 0; }
.k-name { display: flex; flex-direction: column; gap: 0.1rem; }
.k-name b { font-weight: 600; }
.k-hint { color: var(--subtle); font-size: 0.76rem; }
.k-more { width: 2.5rem; }
.ktable-empty { color: var(--muted); font-style: italic; white-space: normal !important; }
/* narrow: each key becomes a small labelled card */
@media (max-width: 640px) {
  .ktable, .ktable tbody, .ktable tr, .ktable td { display: block; width: 100%; }
  .ktable { border: 0; }
  .ktable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ktable tr { position: relative; margin-bottom: 0.5rem; padding: 0.6rem 0.8rem; border: 1px solid var(--line); border-radius: 10px; background: #121820; }
  .ktable td { display: flex; justify-content: space-between; gap: 1rem; padding: 0.2rem 0; border: 0; white-space: normal; }
  .ktable td.num { text-align: left; }
  .ktable td[data-label]:not([data-label=""])::before { content: attr(data-label); color: var(--subtle); font-size: 0.75rem; }
  .ktable td:first-child { padding-right: 3rem; }
  .ktable td:first-child::before { display: none; }
  .ktable td.k-more { position: absolute; top: 0.5rem; right: 0.5rem; width: auto; padding: 0; }
}
.key-switch { position: relative; width: 2.6rem; height: 1.45rem; flex: none; border: 1px solid #3a4452; border-radius: 999px; background: #1c232c; cursor: pointer; }
.key-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: calc(1.45rem - 6px); height: calc(1.45rem - 6px); border-radius: 50%; background: #6f7b8b; transition: transform 0.15s ease, background 0.15s ease; }
.key-switch[aria-checked="true"] { border-color: #3c6853; background: #16302a; }
.key-switch[aria-checked="true"]::after { transform: translateX(1.15rem); background: var(--green); }
.key-switch:focus-visible { outline: 2px solid #5b6b7c; outline-offset: 2px; }
.key-menu { position: relative; flex: none; }
.key-menu summary { list-style: none; width: 2rem; height: 2rem; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); cursor: pointer; }
.key-menu summary::-webkit-details-marker { display: none; }
.key-menu[open] summary { color: var(--text); border-color: #45505b; }
.key-menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 3; display: flex; flex-direction: column; gap: 0.3rem; min-width: 12rem; padding: 0.4rem; border: 1px solid var(--border); border-radius: 10px; background: var(--raised); box-shadow: 0 12px 30px #0009; }
.key-menu-list > button { padding: 0.4rem 0.6rem; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 0.85rem; text-align: left; cursor: pointer; }
.key-menu-list > button:hover { background: #222a33; }
.key-menu-list > button.danger { color: #f3b3bd; }
.key-menu-list input { min-width: 0; }
.key-add-open { margin-top: 0.3rem; }
.key-add { display: grid; gap: 0.7rem; margin-top: 0.4rem; padding: 0.9rem; border: 1px solid var(--line); border-radius: 10px; background: #121820; }
.key-provider { justify-self: start; }
.key-provider [role=radio] { font: inherit; font-size: 0.85rem; padding: 0.3rem 0.9rem; border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--muted); cursor: pointer; }
.key-provider [role=radio][aria-checked="true"] { border-color: #45505b; background: #1a212b; color: var(--text); }
.key-in { display: grid; gap: 0.3rem; color: var(--text); font-size: 0.85rem; font-weight: 600; }
.key-more summary { color: var(--muted); font-size: 0.84rem; cursor: pointer; }
.key-more[open] { display: grid; gap: 0.7rem; }
.key-add-actions { display: flex; align-items: center; gap: 0.6rem; }
.key-safe { margin: 0; color: var(--subtle); font-size: 0.78rem; }

/* the Paper | Live switch at the top of the Trading mode tab */
.mode-switch-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; margin-bottom: 1rem; padding: 0.8rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: #121820; }
.mode-switch-label { color: var(--text); font: 600 1rem var(--display); }
.mode-switch { display: inline-flex; padding: 3px; border: 1px solid #313a43; border-radius: 999px; background: #0b1016; }
.mode-opt { display: inline-flex; align-items: center; gap: 0.4rem; min-width: 6.5rem; justify-content: center; padding: 0.45rem 1rem; border: 0; border-radius: 999px; background: none; color: var(--muted); font: 600 0.9rem var(--font); cursor: pointer; }
.mode-opt .icon { width: 1rem; height: 1rem; }
.mode-opt[aria-checked="true"][data-mode="paper"] { background: #2a2140; color: #e3d8ff; box-shadow: 0 0 0 1px #5a4a86; }
.mode-opt[aria-checked="true"][data-mode="live"] { background: #4a1a24; color: #ffd7dd; box-shadow: 0 0 0 1px var(--red); }
.mode-opt:not([aria-checked="true"]):hover { color: var(--text); }
.mode-opt:focus-visible { outline: 2px solid #5b6b7c; outline-offset: 2px; }
.mode-switch-note { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 0.84rem; }
.mode-switch-note[data-tone="error"] { color: var(--amber); }
/* the header's mode pill is the way into the switch: a small toggle mark says so */
button.pill-mode::after { content: ""; width: 1.5rem; height: 0.8rem; margin-left: 0.15rem; border-radius: 999px; background: #262f3a radial-gradient(circle at 30% 50%, #c1a9f5 0 0.28rem, transparent 0.3rem); }
body[data-mode="live"] button.pill-mode::after { background: #4a1a24 radial-gradient(circle at 70% 50%, #ff8da0 0 0.28rem, transparent 0.3rem); }

/* Settings › Strategies (D-036): the stored strategies of one slot, what each does, and Deploy. */
.strat-slots { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.8rem; }
.strat-slots button { display: inline-flex; align-items: center; gap: 0.4rem; font: inherit; font-size: 0.84rem; padding: 0.35rem 0.85rem; border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--muted); cursor: pointer; }
.strat-slots button span { color: var(--subtle); font-size: 0.76rem; }
.strat-slots button .icon { width: 0.95rem; height: 0.95rem; }
.strat-slots button:hover { color: var(--text); }
.strat-slots button[aria-pressed="true"] { border-color: #45505b; background: #1a212b; color: var(--text); }
.strat-list { list-style: none; margin: 0.6rem 0 0; padding: 0; display: grid; gap: 0.7rem; }
.strat-item { padding: 0.8rem 0.95rem; border: 1px solid var(--line); border-radius: 10px; background: #10151c; }
.strat-item[data-deployed="true"] { border-color: #325465; background: linear-gradient(140deg, rgb(23 42 51 / 0.55), #10151c 70%); }
.strat-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.55rem; }
.strat-head b { color: var(--text); font-weight: 600; }
.strat-version { color: var(--muted); font-size: 0.86rem; overflow-wrap: anywhere; }
.strat-hash { margin-left: auto; color: var(--subtle); font-size: 0.76rem; }
.strat-sum { margin: 0.45rem 0 0; padding-left: 1.1rem; color: #c3ccd6; font-size: 0.86rem; line-height: 1.5; }
.strat-res { margin: 0.45rem 0 0; color: var(--text); font-size: 0.86rem; }
.strat-meta { margin: 0.2rem 0 0; color: var(--subtle); font-size: 0.78rem; }
.strat-act { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.6rem; }
.strat-act input { max-width: 12rem; }
.strat-doc { margin-top: 0.5rem; color: var(--muted); font-size: 0.8rem; }
.strat-doc summary { cursor: pointer; width: max-content; }
.strat-doc pre { max-height: 16rem; margin: 0.4rem 0 0; padding: 0.6rem 0.7rem; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: #0b0f14; color: #c3ccd6; font-size: 0.76rem; line-height: 1.45; }
.strat-empty { color: var(--muted); font-size: 0.9rem; }
.signout.danger { border-color: #6d3947; color: var(--red); }


/* Radar Lab › Wallet study (D-038): a bot wallet in, a Watcher rule out, run by the Academy worker. */
.lab-study { margin-top: 1rem; }
.study-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem 0.8rem; margin: 0.5rem 0 0.8rem; padding: 0.8rem 0.9rem; border: 1px solid var(--line); border-radius: 10px; background: #10151c; }
.study-in { display: flex; flex-direction: column; gap: 0.25rem; color: var(--muted); font-size: 0.8rem; }
.study-wallet { flex: 1 1 22rem; min-width: 0; }
.study-in input, .study-in select { font: inherit; font-size: 0.88rem; padding: 0.4rem 0.55rem; border: 1px solid var(--border); border-radius: 7px; background: #0b0f14; color: var(--text); min-width: 0; }
.study-wallet input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; width: 100%; }
.study-in input:focus-visible, .study-in select:focus-visible { outline: 2px solid #5b6b7c; outline-offset: 1px; }
.study-form .signout:disabled { opacity: 0.5; cursor: not-allowed; }
.study-note { flex-basis: 100%; margin: 0; color: var(--subtle); font-size: 0.78rem; }
.study-num input { width: 6.5rem; }
.study-check { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.8rem; padding-bottom: 0.45rem; }
.study-check input { accent-color: #5b8fa8; }
/* Scope Lab › AI Scope model (D-061, D-065): the unseen tokens, the model next to the base. */
.ms-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.5rem; margin-top: 0.55rem; }
.ms-cell { padding: 0.5rem 0.65rem; border: 1px solid var(--line); border-radius: 8px; background: #0d1218; }
.ms-cell h5 { margin: 0 0 0.25rem; font-size: 0.76rem; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.ms-cell p { margin: 0; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.ms-cell .ms-vs { color: var(--subtle); font-size: 0.78rem; }
.ms-feats { margin: 0.5rem 0 0; font-size: 0.78rem; color: var(--subtle); }
.study-form .form-msg { flex-basis: 100%; margin: 0; }
.study-form .form-msg:empty { display: none; }
.study-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.study-item { padding: 0.7rem 0.9rem; border: 1px solid var(--line); border-radius: 10px; background: #10151c; }
.study-item[data-status="running"] { border-color: #325465; }
.study-item .track { margin-top: 0.55rem; }
.study-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.6rem; }
.study-wallet-id { color: var(--text); font-weight: 600; font-size: 0.86rem; }
.study-days { color: var(--muted); font-size: 0.84rem; }
.study-when { margin-left: auto; color: var(--subtle); font-size: 0.76rem; }
.study-line { margin: 0.4rem 0 0; color: #c3ccd6; font-size: 0.84rem; overflow-wrap: anywhere; }
.study-error { color: var(--red); }
.study-act { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.7rem; margin-top: 0.55rem; }
.study-act .study-line { margin: 0; color: var(--subtle); font-size: 0.8rem; }

/* Header › Risk (D-039): the Sniper's stops, the kill switch and the limits. */
.risk-wrap { position: relative; }
.pill-risk { cursor: pointer; }
.pill-risk[data-state="ok"] { color: #bfe9d3; }
.pill-risk[data-state="ok"] .icon { color: var(--green); }
.pill-risk[data-state="warning"] { color: #f1d9a8; background: #2a2418; border-color: #5b4a2f; }
.pill-risk[data-state="warning"] .icon { color: var(--amber); }
.pill-risk[data-state="stopped"] { color: #f7c3cc; background: #341c24; border-color: #6d3947; }
.pill-risk[data-state="stopped"] .icon { color: var(--red); }
.risk-pop { width: min(28rem, calc(100vw - 2rem)); }
.risk-list { list-style: none; margin: 0.5rem 0 0.7rem; padding: 0; display: grid; gap: 0.55rem; }
.risk-item { padding: 0.55rem 0.65rem; border: 1px solid var(--line); border-radius: 9px; background: #10151c; }
.risk-item[data-active="true"] { border-color: #6d3947; background: rgb(52 28 36 / 0.55); }
.risk-head { display: flex; justify-content: space-between; gap: 0.6rem; align-items: baseline; }
.risk-head b { color: var(--text); font-weight: 600; font-size: 0.86rem; }
.risk-val { color: #c3ccd6; font-size: 0.8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.risk-track { margin-top: 0.4rem; height: 5px; }
.risk-track > i { background: var(--green); box-shadow: none; }
.risk-track[data-level="warn"] > i { background: var(--amber); }
.risk-track[data-level="stop"] > i { background: var(--red); }
.risk-foot { margin: 0.3rem 0 0; color: var(--subtle); font-size: 0.74rem; }
.risk-act, .risk-kill { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.45rem; }
.risk-act input, .risk-kill input { font: inherit; font-size: 0.84rem; padding: 0.3rem 0.5rem; border: 1px solid var(--border); border-radius: 7px; background: #0b0f14; color: var(--text); max-width: 11rem; }
.risk-limits { margin-top: 0.7rem; }
.risk-limits summary { cursor: pointer; color: var(--muted); font-size: 0.84rem; width: max-content; }
.risk-form { display: grid; gap: 0.5rem; margin-top: 0.5rem; }
.risk-form label { display: flex; flex-direction: column; gap: 0.2rem; color: var(--muted); font-size: 0.78rem; }
.risk-form input, .risk-form select { font: inherit; font-size: 0.86rem; padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 7px; background: #0b0f14; color: var(--text); }
.risk-form .signout { justify-self: start; }
@media (max-width: 640px) { .risk-pop { position: fixed; left: 1rem; right: 1rem; top: 4.5rem; width: auto; max-height: calc(100vh - 6rem); overflow: auto; } }
.risk-top { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.risk-books { display: flex; gap: 0.3rem; }
.risk-books button { font: inherit; font-size: 0.74rem; padding: 0.15rem 0.6rem; border: 1px solid var(--line); border-radius: 999px; background: none; color: var(--muted); cursor: pointer; }
.risk-books button[aria-pressed="true"] { border-color: #45505b; background: #1a212b; color: var(--text); }

/* A lab's studio card (D-048): the same in both labs — title, one line, then the studio and the bot library. */
.lab-card-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; }
.lab-card-row .study-note { flex: 1 1 18rem; font-size: 0.85rem; line-height: 1.45; }
.lab-card-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
body.detail .unit.is-open .wlist.lab-card { flex: none; min-height: 0; display: block; }
/* the Lab views scroll as a whole: each study (the bot profile, the wallet study, the AI models) takes its natural
   height, its list and report included */
body.detail .unit.is-open.acc-scope .detail-extra, body.detail .unit.is-open.acc-radar .detail-extra { overflow: auto; }
body.detail .unit.is-open.acc-scope .lab-study, body.detail .unit.is-open.acc-radar .lab-study { flex: none; }
body.detail .unit.is-open.acc-scope .lab-study .study-list,
body.detail .unit.is-open.acc-radar .lab-study .study-list { flex: none; overflow: visible; }

/* Scope Lab: the bot profile report (sections a reader can fold) */
.bp-report { display: grid; gap: 0.6rem; margin-top: 0.8rem; min-width: 0; }
.pf-sec { border: 1px solid var(--line); border-radius: 10px; background: #10151c; padding: 0.55rem 0.9rem; min-width: 0; }
.pf-sec > summary { cursor: pointer; font-family: var(--display); font-weight: 600; color: var(--text); }
.pf-sec > summary .chip { margin-left: 0.4rem; font-size: 0.72rem; vertical-align: middle; }
.pf-rows { display: grid; grid-template-columns: minmax(8rem, 15rem) minmax(0, 1fr); gap: 0.25rem 0.9rem; margin: 0.55rem 0 0; font-size: 0.86rem; }
.pf-rows dt { color: var(--muted); }
.pf-rows dd { margin: 0; color: #c3ccd6; overflow-wrap: anywhere; min-width: 0; }
.pf-bars { display: block; width: 100%; max-width: 32rem; height: auto; margin-top: 0.6rem; }
.pf-bars rect { fill: var(--mint); opacity: 0.75; }
.pf-bars text { fill: var(--subtle); font-size: 9px; font-family: var(--font); }
@media (max-width: 560px) {
  .pf-rows { grid-template-columns: minmax(0, 1fr); }
  .pf-rows dd { margin-bottom: 0.35rem; }
}
