/* MiroFish × Polymarket — D88 visual system (spec §2).
   Dark, calm, professional. Deep sea-slate ground, sea-glass for the AI crowd,
   sand for the market, green/red ONLY for money and health, amber ONLY for
   "needs your attention". Hanken Grotesk for everything; Newsreader for the
   one-sentence answer and the Home balance; no monospace. Radius follows
   hierarchy: panels 10, nested 8, pills 999. No drop shadows.

   RULE: the :root block below is the only place a raw colour value may appear.
   Everything else uses var(--token) or color-mix() of tokens.

   Sections: tokens · base · layout · header · status pill & System popover ·
   tab bar · page head · figures · sections & panels · folds · lists · badges ·
   gap bar · progress · checks · notices · buttons · inputs · tabs · toasts ·
   charts · headings & tables · vote histogram · kit · motion.
   Screen-only rules live in css/<screen>.css, each scoped under its screen's
   wrapper class (.scr-home, .scr-bets, …). */

/* ======================================================================= tokens */
:root {
  color-scheme: dark;

  /* colour (spec §2.1) — meaning, and nothing else */
  --bg: #0C1316;          /* page background (deep sea-slate) */
  --surface: #121C20;     /* panels */
  --surface-2: #18252A;   /* inputs, hover, nested blocks */
  --line: #223238;        /* hairlines and dividers */
  --line-2: #2E434A;      /* stronger borders; focus ring base */
  --text: #E6ECEA;        /* primary text */
  --text-2: #A3B3B2;      /* secondary text */
  --text-3: #6F8483;      /* tertiary text, placeholders; never needed to decide */
  --crowd: #6BD3C2;       /* sea-glass: the AI crowd / our model; links; focus */
  --market: #E2C28A;      /* sand: the market's price / Polymarket odds */
  --up: #5BC98C;          /* money up, healthy */
  --down: #EF7A6D;        /* money down; the Stop button; errors */
  --attention: #E9B04F;   /* needs the owner's attention */

  /* tints: always a mix of a token, never a second palette */
  --tint-up: color-mix(in srgb, var(--up) 14%, transparent);
  --tint-down: color-mix(in srgb, var(--down) 14%, transparent);
  --tint-attention: color-mix(in srgb, var(--attention) 14%, transparent);
  --tint-crowd: color-mix(in srgb, var(--crowd) 14%, transparent);
  --tint-market: color-mix(in srgb, var(--market) 14%, transparent);
  --tint-text: color-mix(in srgb, var(--text) 8%, transparent);
  --scrim: color-mix(in srgb, var(--bg) 90%, transparent);

  /* type (spec §2.2) */
  --font-ui: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-serif: "Newsreader", ui-serif, Georgia, "Times New Roman", serif;
  --font-code: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;  /* <code> in folds only */
  --fs-micro: 12px; --fs-small: 13px; --fs-body: 15px; --fs-title: 18px;
  --fs-figure: 22px; --fs-answer: 34px; --fs-balance: 44px;

  /* space (spec §2.3: 4 8 12 16 24 32 48 64) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --gutter: 24px;
  --maxw: 1120px;
  --hdr-h: 60px;
  --tabbar-h: 60px;
  --r-panel: 10px; --r-nested: 8px; --r-pill: 999px;
}
@media (max-width: 640px) {
  :root { --gutter: 16px; --hdr-h: 52px; --fs-answer: 26px; --fs-balance: 34px; }
}

/* ======================================================================= base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--hdr-h) + 16px); }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 400 var(--fs-body)/1.5 var(--font-ui);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--crowd); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--crowd); outline-offset: 2px; border-radius: 4px; }
::selection { background: color-mix(in srgb, var(--crowd) 30%, transparent); }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.005em; color: var(--text); }
b, strong { font-weight: 600; }
img, svg { max-width: 100%; }
svg.ico { display: inline-block; flex: none; vertical-align: -0.2em; }
[hidden] { display: none !important; }
code { font-family: var(--font-ui); font-size: .92em; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 0 5px; }
details code, .fold code { font-family: var(--font-code); font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s5) 0; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--surface-2); color: var(--text);
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line-2); }
.skip-link:focus { top: 8px; }

/* tone utilities: colour carries MEANING only (spec §2.1) */
.up { color: var(--up); }
.down { color: var(--down); }
.attention { color: var(--attention); }
.crowd { color: var(--crowd); }
.market { color: var(--market); }
.t2 { color: var(--text-2); }
.t3 { color: var(--text-3); }
.small { font-size: var(--fs-small); }
.micro { font-size: var(--fs-micro); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.stack > * + * { margin-top: var(--s4); }
.row-gap { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }

/* ======================================================================= layout */
main#view {
  flex: 1; width: 100%; max-width: calc(var(--maxw) + 2 * var(--gutter)); margin: 0 auto;
  padding: var(--s6) var(--gutter) var(--s8); outline: none;
}
.foot { width: 100%; max-width: calc(var(--maxw) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter);
  color: var(--text-3); font-size: var(--fs-small); }
.foot > span { display: block; border-top: 1px solid var(--line); padding: var(--s5) 0 var(--s6); }
.loading { color: var(--text-2); margin: 0; }

/* ======================================================================= header */
.hdr {
  position: sticky; top: 0; z-index: 40; height: var(--hdr-h);
  background: var(--scrim); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
body.mode-real .hdr { border-bottom: 2px solid var(--down); }
.hdr-in {
  height: 100%; max-width: calc(var(--maxw) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter);
  display: flex; align-items: center; gap: var(--s5);
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-weight: 700; font-size: 17px;
  letter-spacing: -0.015em; flex: none; }
.brand:hover { text-decoration: none; }
.brand-glyph { display: inline-flex; color: var(--crowd); }
.nav { display: flex; align-items: center; gap: 2px; min-width: 0; }
.nav a { color: var(--text-2); font-weight: 500; font-size: var(--fs-body); padding: 6px 12px; border-radius: var(--r-nested);
  white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--surface-2); }
.hdr-right { margin-left: auto; display: flex; align-items: center; gap: var(--s2); flex: none; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: var(--r-nested); color: var(--text-2); background: transparent; border: 1px solid transparent; cursor: pointer; padding: 0; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.icon-btn.active { color: var(--text); background: var(--surface-2); }

/* Stop / Restart (spec §3.1, S1): outlined --down; filled --attention when engaged */
.kill { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px 0 11px; border-radius: var(--r-nested);
  border: 1px solid var(--down); background: transparent; color: var(--down); font: 600 var(--fs-small)/1 var(--font-ui);
  cursor: pointer; white-space: nowrap; }
.kill:hover { background: var(--tint-down); }
.kill.engaged { background: var(--attention); border-color: var(--attention); color: var(--bg); }
.kill.engaged:hover { background: color-mix(in srgb, var(--attention) 86%, var(--text)); }
.kill:disabled { opacity: .55; cursor: progress; }
.kill-ico { display: inline-flex; }

/* ======================================================================= status pill & System popover */
.sys { position: relative; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px 0 12px;
  border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  font: 500 var(--fs-small)/1 var(--font-ui); cursor: pointer; white-space: nowrap; }
.status-pill:hover { background: var(--surface-2); }
.status-pill[aria-expanded="true"] { background: var(--surface-2); border-color: var(--text-3); }
.status-pill .pill-chev { display: inline-flex; color: var(--text-3); transform: rotate(90deg); transition: transform .15s; }
.status-pill[aria-expanded="true"] .pill-chev { transform: rotate(-90deg); }
.status-pill .sdot { width: 8px; height: 8px; }
.status-pill .pill-short { display: none; }
.status-pill.st-ok .sdot { background: var(--up); }
.status-pill.st-stopped .sdot { background: var(--attention); }
.status-pill.st-paused .sdot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-2); }
.status-pill.st-offline .sdot { background: var(--down); }
.status-pill.st-checking .sdot { background: var(--text-3); }
.status-pill.st-real { border-color: var(--down); color: var(--down); background: var(--tint-down); }
.status-pill.st-real .sdot { background: var(--down); }
.status-pill.st-real .pill-chev { color: var(--down); }

.sys-pop { position: absolute; top: calc(100% + 10px); right: 0; z-index: 50; width: 360px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; padding: var(--s4) var(--s5) var(--s4); }
.sys-head { display: flex; align-items: center; justify-content: space-between; margin: -4px -8px var(--s2) 0; }
.sys-title { font-size: var(--fs-title); margin: 0; }
.sys-close { width: 32px; height: 32px; }
.sys-list { margin: 0; }
.sys-row { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: var(--s3); padding: 9px 0;
  border-top: 1px solid var(--line); }
.sys-row:first-child { border-top: 0; }
.sys-row dt { color: var(--text-2); font-size: var(--fs-small); padding-top: 1px; }
.sys-row dd { margin: 0; min-width: 0; }
.sys-sub { display: block; color: var(--text-2); font-size: var(--fs-small); margin-top: 2px; }
.sys-run { display: block; color: var(--crowd); overflow-wrap: anywhere; }
.sys-block { border-top: 1px solid var(--line); padding: var(--s3) 0 var(--s1); }
.sys-block .pbar-field + .pbar-field { margin-top: var(--s3); }
.sys-label { color: var(--text-2); font-size: var(--fs-small); margin-bottom: var(--s2); }
.sys-clock-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sys-clock-time { font-size: var(--fs-figure); font-weight: 600; letter-spacing: -.01em; }
#sys-clock-utc { font-size: var(--fs-small); margin-top: 2px; }
#sys-clock.stale .sys-clock-time { color: var(--attention); }
.sys-note { font-size: var(--fs-small); margin: 6px 0 0; }
.sys-foot { display: flex; align-items: center; gap: 8px; margin: var(--s2) 0 -4px; padding-top: var(--s3);
  border-top: 1px solid var(--line); color: var(--text-2); font-size: var(--fs-small); }
.sys-foot:hover { color: var(--text); text-decoration: none; }

/* ======================================================================= narrow screens: header + tab bar */
/* The six nav items, the pill, Stop and the gear need about 820px. Below
   that the nav moves to the bottom tab bar (phones, and narrow tablets);
   the compact 52px phone header starts at 640px (spec §3). */
.tabbar { display: none; }
.nav { overflow-x: auto; scrollbar-width: none; }      /* never slide under the pill */
.nav::-webkit-scrollbar { display: none; }
@media (max-width: 1000px) {
  .hdr-in { gap: var(--s3); }
  .nav a { padding: 6px 9px; }
}
@media (max-width: 920px) and (min-width: 821px) {
  .brand-word { display: none; }
}
@media (max-width: 820px) {
  .nav { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 94%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--text-2); font-size: 11px; font-weight: 500; min-width: 0; }
  .tabbar a > span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar a:hover { text-decoration: none; color: var(--text); }
  .tabbar a.active { color: var(--text); }
  .tabbar a.active svg { stroke-width: 2.1; }
  .tabbar a span[data-icon] { display: inline-flex; }
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
}
@media (max-width: 640px) {
  .hdr-in { gap: var(--s2); }
  .brand { font-size: 16px; gap: 7px; }
  .hdr-right { gap: 6px; }
  .status-pill { height: 32px; padding: 0 9px 0 10px; gap: 7px; font-size: var(--fs-micro); }
  .status-pill .pill-chev { display: none; }
  .kill { height: 32px; padding: 0 10px 0 8px; gap: 5px; font-size: var(--fs-micro); }
  /* the header never scrolls sideways: the pill shows its short label and,
     as a safety net, takes what is left and ellipsizes (no overflow:hidden on
     the pill itself, which would clip its ::after tap area) */
  .hdr-right { flex: 0 1 auto; min-width: 0; }
  .sys { min-width: 0; }
  .status-pill { max-width: 100%; min-width: 0; }
  #status-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .status-pill .pill-long { display: none; }
  .status-pill .pill-short { display: inline; }
  .icon-btn { width: 40px; height: 40px; }
  /* 32px to look calm, 42px to hit (spec §2.6: tap targets >= 40px) */
  .status-pill, .kill { position: relative; }
  .status-pill::after, .kill::after { content: ""; position: absolute; inset: -5px -3px; }
  .sys-pop { position: fixed; top: calc(var(--hdr-h) + 8px); left: 8px; right: 8px; width: auto;
    max-height: calc(100vh - var(--hdr-h) - var(--tabbar-h) - 24px); overflow-y: auto; }
  main#view { padding-top: var(--s5); padding-bottom: var(--s7); }
}
@media (max-width: 370px) {
  .brand-word { display: none; }
}

/* ======================================================================= page head */
.page-head { margin: 0 0 var(--s7); }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: var(--fs-small);
  margin-bottom: var(--s3); }
.back-link:hover { color: var(--text); text-decoration: none; }
.page-title { font-size: var(--fs-figure); line-height: 1.3; margin: 0; max-width: 46em; overflow-wrap: anywhere; }
.page-meta { color: var(--text-2); font-size: var(--fs-small); margin: 6px 0 0; }
/* the batch's name in ui.batchLine ("Current batch: Batch 5, started …") */
.page-meta a.batch-name { color: var(--text); font-weight: 500; }
.page-meta a.batch-name:hover { color: var(--crowd); }
.answer { font-family: var(--font-serif); font-size: var(--fs-answer); line-height: 1.2; font-weight: 400;
  letter-spacing: -0.012em; margin: 0; max-width: 24em; color: var(--text); text-wrap: balance;
  font-variant-numeric: lining-nums proportional-nums; font-optical-sizing: auto; }
.page-title + .answer, .page-meta + .answer { margin-top: var(--s5); }
.answer + .figures, .page-meta + .figures, .page-title + .figures { margin-top: var(--s6); }
.page-head > .notice { margin-top: var(--s5); }

/* ======================================================================= figures row */
.figures { display: flex; align-items: stretch; flex-wrap: wrap; row-gap: var(--s5); }
.figure { flex: 1 1 0; min-width: 150px; max-width: 300px; padding: 0 var(--s5); border-left: 1px solid var(--line);
  color: var(--text); display: flex; flex-direction: column; gap: 3px; }
.figure:first-child { padding-left: 0; border-left: 0; }
a.figure:hover { text-decoration: none; }
a.figure:hover .figure-label { color: var(--text); }
.figure-label { font-size: var(--fs-small); color: var(--text-2); display: inline-flex; align-items: center; gap: 2px; }
.figure-chev { color: var(--text-3); }
.figure-value { font-size: var(--fs-figure); font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
.figure-sub { font-size: var(--fs-small); color: var(--text-2); }
.figure-hero .figure-value { font-family: var(--font-serif); font-size: var(--fs-balance); font-weight: 400; line-height: 1.1;
  letter-spacing: -0.02em; font-variant-numeric: lining-nums; }
.figure-hero { max-width: none; flex-grow: 1.4; }
@media (max-width: 640px) {
  .figures { display: grid; grid-template-columns: 1fr 1fr; column-gap: 0; row-gap: var(--s5); }
  .figure { max-width: none; min-width: 0; padding: 0 0 0 var(--s4); }
  .figure:nth-child(odd) { padding-left: 0; border-left: 0; padding-right: var(--s3); }
  .figure-hero { grid-column: 1 / -1; padding: 0; border: 0; }
  .figure-hero ~ .figure:nth-child(odd) { padding-left: var(--s4); border-left: 1px solid var(--line); padding-right: 0; }
  .figure-hero ~ .figure:nth-child(even) { padding-left: 0; border-left: 0; padding-right: var(--s3); }
}

/* ======================================================================= sections & panels */
.section { margin-top: var(--s7); }
.section:first-child, .page-head + .section { margin-top: 0; }
.page-head + .notice + .section, .notice + .section { margin-top: var(--s6); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s3); }
.section-titles { min-width: 0; }
.section-title { font-size: var(--fs-title); line-height: 1.35; margin: 0; }
.section-desc { font-size: var(--fs-small); color: var(--text-2); margin: 2px 0 0; }
.section-action { flex: none; display: flex; align-items: center; gap: var(--s2); }
@media (max-width: 640px) {
  .section { margin-top: var(--s6); }
  .section-head { flex-wrap: wrap; align-items: center; }
}

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: var(--s5);
  margin-bottom: var(--s4); }
.section > .panel { margin-bottom: 0; }
.panel > :first-child { margin-top: 0; }
.panel > :last-child { margin-bottom: 0; }
.nest { background: var(--surface-2); border-radius: var(--r-nested); padding: var(--s4); }
@media (max-width: 640px) { .panel { padding: var(--s4); } }

.dl { margin: 0; }
.dl-row { display: grid; grid-template-columns: minmax(120px, 34%) minmax(0, 1fr); gap: var(--s4); padding: 8px 0;
  border-top: 1px solid var(--line); }
.dl-row:first-child { border-top: 0; }
.dl dt { color: var(--text-2); font-size: var(--fs-small); padding-top: 1px; }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) { .dl-row { grid-template-columns: 1fr; gap: 2px; } }

/* ======================================================================= folds (details) */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::marker { content: ""; }
details.fold { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); }
details.fold + details.fold { margin-top: var(--s2); }
details.fold > summary { display: flex; align-items: center; gap: var(--s3); min-height: 52px; padding: 12px var(--s5);
  cursor: pointer; font-weight: 500; color: var(--text); border-radius: var(--r-panel); }
details.fold > summary:hover { background: var(--surface-2); }
details.fold[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.fold-sum { min-width: 0; }
.fold-meta { color: var(--text-2); font-size: var(--fs-small); font-weight: 400; margin-left: auto; }
.fold-chev { color: var(--text-2); transition: transform .15s ease; flex: none; }
details.fold > summary > .fold-chev:last-child { margin-left: auto; }
details.fold > summary > .fold-meta + .fold-chev { margin-left: 0; }
details[open] > summary > .fold-chev { transform: rotate(90deg); }
.fold-body { padding: var(--s2) var(--s5) var(--s5); }
.fold-body > :first-child { margin-top: 0; }
.fold-body > :last-child { margin-bottom: 0; }
.table-wrap { overflow-x: auto; }
.fold-body > table { display: block; overflow-x: auto; }
@media (max-width: 640px) {
  details.fold > summary { padding: 12px var(--s4); }
  .fold-body { padding: var(--s2) var(--s4) var(--s4); }
}
/* the quiet in-row variant */
details.fold-inline { background: none; border: 0; border-radius: 0; }
details.fold-inline > summary { display: inline-flex; min-height: 32px; padding: 4px 0; gap: 6px; font-size: var(--fs-small);
  font-weight: 500; color: var(--text-2); border-radius: 6px; }
details.fold-inline > summary:hover { background: none; color: var(--text); }
details.fold-inline .fold-body { padding: var(--s2) 0 var(--s1) 20px; color: var(--text-2); font-size: var(--fs-body); }
details.fold-inline + details.fold-inline { margin-top: 0; }

/* ======================================================================= lists (spec §2.3) */
.list { display: grid; grid-template-columns: var(--cols, minmax(0, 1fr) max-content); column-gap: var(--s5);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.panel > .list { background: none; border: 0; border-radius: calc(var(--r-panel) - 1px);
  margin-left: calc(-1 * var(--s5)); margin-right: calc(-1 * var(--s5)); }
.panel > .list:first-child { margin-top: calc(-1 * var(--s5)); }
.panel > .list:last-child { margin-bottom: calc(-1 * var(--s5)); }
.panel > .list:not(:last-child) { border-bottom: 1px solid var(--line); border-radius: 0; margin-bottom: var(--s4); }
.list-head, .row { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: center;
  padding: 0 var(--s5); }
.list-head { min-height: 40px; font-size: var(--fs-small); color: var(--text-2); border-bottom: 1px solid var(--line); }
.list-head > span.num { text-align: right; }
.row { min-height: 56px; padding-top: var(--s3); padding-bottom: var(--s3); color: var(--text); }
.list > .row + .row { border-top: 1px solid var(--line); }
a.row:hover { background: var(--surface-2); text-decoration: none; }
a.row:hover .row-title { color: var(--text); }
.row.dim { opacity: .5; }
.row-title { font-weight: 500; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
a.row-title:hover { color: var(--crowd); }
.row-meta { display: contents; }
.row-cell { min-width: 0; color: var(--text-2); }
.row-cell.num { text-align: right; justify-self: end; white-space: nowrap; }
.row-lead { order: -1; color: var(--text-2); font-size: var(--fs-small); white-space: nowrap; }
.row-key { justify-self: end; text-align: right; font-weight: 600; white-space: nowrap; }
.row-key-sub { display: block; font-size: var(--fs-small); font-weight: 400; color: var(--text-2); }
.row-actions { justify-self: end; display: flex; gap: var(--s2); }
/* a market's page on Polymarket (2026-11-06): quiet, opens a new tab */
.pm-link { display: inline-flex; align-items: center; gap: 2px; font-size: var(--fs-small); color: var(--text-2);
  white-space: nowrap; align-self: center; }
.pm-link:hover, .pm-link:focus-visible { color: var(--crowd); }
.page-meta .pm-link { margin-left: var(--s2); }
.row-below { grid-column: 1 / -1; min-width: 0; }
.list-empty { display: block; }
.list-empty .empty { border: 0; }
/* ui.cellUnit / CELL_DASH: a cell's unit word shows only on a phone, where the
   column head is hidden; an empty value is dropped from a phone's meta line */
.cell-unit { display: none; }
.vs { color: var(--text-2); font-weight: 400; font-size: .8em; margin: 0 2px; }
@media (max-width: 640px) {
  .list { display: block; }
  .panel > .list { margin-left: calc(-1 * var(--s4)); margin-right: calc(-1 * var(--s4)); }
  .panel > .list:first-child { margin-top: calc(-1 * var(--s4)); }
  .panel > .list:last-child { margin-bottom: calc(-1 * var(--s4)); }
  .list-head { display: none; }
  .row { display: grid; grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "title key" "meta key" "actions actions" "below below";
    column-gap: var(--s3); row-gap: 3px; padding: var(--s3) var(--s4); min-height: 0; }
  .list > .row + .row { border-top: 1px solid var(--line); }
  .row-title { grid-area: title; }
  .row-meta { grid-area: meta; display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--s3);
    font-size: var(--fs-small); color: var(--text-2); min-width: 0; }
  .row-meta > .row-cell { font-size: var(--fs-small); text-align: left; justify-self: auto; }
  .row-meta > .row-cell:empty { display: none; }
  .row-key { grid-area: key; align-self: center; }
  .row-actions { grid-area: actions; justify-self: start; margin-top: var(--s2); }
  .row-actions:empty { display: none; }
  .row-below { grid-area: below; }
  .hide-phone { display: none !important; }
  .cell-unit { display: inline; }
  .row-meta > .row-cell:has(> .cell-dash:only-child), .row-key:has(> .cell-dash:only-child) { display: none; }
}

/* ======================================================================= badges & status */
.side-badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: var(--r-pill);
  border: 1px solid color-mix(in srgb, var(--text) 42%, transparent); color: var(--text);
  font-size: var(--fs-micro); font-weight: 600; letter-spacing: .03em; text-transform: uppercase; line-height: 1; white-space: nowrap; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: var(--r-pill);
  border: 1px solid var(--line-2); color: var(--text-2); background: transparent;
  font-size: var(--fs-micro); font-weight: 500; line-height: 1; white-space: nowrap; }
.tag-attention { color: var(--attention); border-color: color-mix(in srgb, var(--attention) 45%, transparent); background: var(--tint-attention); }
.tag-up { color: var(--up); border-color: color-mix(in srgb, var(--up) 45%, transparent); background: var(--tint-up); }
.tag-down { color: var(--down); border-color: color-mix(in srgb, var(--down) 45%, transparent); background: var(--tint-down); }
.tag-crowd { color: var(--crowd); border-color: color-mix(in srgb, var(--crowd) 45%, transparent); background: var(--tint-crowd); }
.tag-market { color: var(--market); border-color: color-mix(in srgb, var(--market) 45%, transparent); background: var(--tint-market); }
.status { display: inline-flex; align-items: center; gap: 8px; }
.sdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-3); }
.sdot-up { background: var(--up); }
.sdot-down { background: var(--down); }
.sdot-attention { background: var(--attention); }
.sdot-idle { background: var(--text-3); }
.sdot-off, .sdot-upcoming { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-3); }
.sdot-off { box-shadow: inset 0 0 0 1.5px var(--text-2); }
.sdot-running { background: var(--crowd); animation: sdot-pulse 1.6s ease-in-out infinite; }
@keyframes sdot-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--crowd) 55%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--crowd) 0%, transparent); } }

/* ======================================================================= the crowd-vs-market bar (spec §2.4) */
.gap { display: block; }
.gap-track { position: relative; display: block; height: 8px; border-radius: var(--r-pill);
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.gap-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line-2); transform: translateX(-50%); }
.gap-seg { position: absolute; top: 0; bottom: 0; border-radius: var(--r-pill); }
.gap-seg.seg-crowd { background: color-mix(in srgb, var(--crowd) 25%, transparent); }
.gap-seg.seg-market { background: color-mix(in srgb, var(--market) 25%, transparent); }
.gap-mk { position: absolute; top: 50%; width: 2px; height: 24px; border-radius: 1px; background: var(--market);
  transform: translate(-50%, -50%); }
.gap-dot { position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; background: var(--crowd);
  box-shadow: 0 0 0 2.5px var(--surface); transform: translate(-50%, -50%); }
.gap-lg { width: 100%; }
.gap-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 14px; }
.gap-end { font-size: var(--fs-micro); color: var(--text-3); }
.gap-plot { position: relative; padding: 30px 0; }
.gap-lbl { position: absolute; transform: translateX(-50%); white-space: nowrap; font-size: var(--fs-small); line-height: 1; }
.gap-lbl b { font-weight: 600; }
.gap-lbl.a-start { transform: translateX(-7px); }
.gap-lbl.a-end { transform: translateX(calc(-100% + 7px)); }
.gap-lbl-market { top: 2px; color: var(--market); }
.gap-lbl-crowd { bottom: 2px; color: var(--crowd); }
.gap-cap { margin: var(--s2) 0 0; color: var(--text-2); font-size: var(--fs-body); }
.gap-sm { display: inline-block; width: 120px; padding: 3px 5px; vertical-align: middle; flex: none; }
.gap-sm .gap-track { height: 8px; }
.gap-sm .gap-mk { height: 16px; }
.gap-sm .gap-dot { width: 9px; height: 9px; box-shadow: 0 0 0 1.5px var(--surface); }
a.row:hover .gap-sm .gap-dot, .nest .gap-dot { box-shadow: 0 0 0 1.5px var(--surface-2); }

/* ======================================================================= progress bars */
.pbar { position: relative; height: 8px; border-radius: var(--r-pill); background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.pbar-sm { height: 6px; }
.pbar > i { display: block; height: 100%; border-radius: inherit; background: var(--text-2); transition: width .4s ease; }
.pbar.tone-up > i { background: var(--up); }
.pbar.tone-down > i { background: var(--down); }
.pbar.tone-attention > i { background: var(--attention); }
.pbar.tone-crowd > i { background: var(--crowd); }
.pbar.tone-market > i { background: var(--market); }
.pbar.tone-running > i { background: var(--crowd); animation: pbar-pulse 1.8s ease-in-out infinite; }
@keyframes pbar-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.pbar-head { display: flex; justify-content: space-between; gap: var(--s3); font-size: var(--fs-small); color: var(--text-2);
  margin-bottom: 6px; }
.pbar-val { color: var(--text); font-weight: 500; }

/* ======================================================================= "Ready for real money?" checks */
.checks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.check { background: var(--surface-2); border-radius: var(--r-nested); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.check-head { display: flex; align-items: center; gap: 10px; }
.check-mark { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none;
  box-shadow: inset 0 0 0 1.5px var(--text-3); }
.check-pass .check-mark { background: var(--tint-up); color: var(--up); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--up) 60%, transparent); }
.check-none .check-mark { box-shadow: inset 0 0 0 1.5px var(--line-2); }
.check-title { font-weight: 600; flex: 1; min-width: 0; }
.check-state { font-size: var(--fs-small); color: var(--text-2); white-space: nowrap; }
.check-pass .check-state { color: var(--up); }
.check-value { font-size: var(--fs-figure); font-weight: 600; letter-spacing: -.01em; }
.check-line { margin: 0; color: var(--text-2); font-size: var(--fs-small); }
.checks-summary { margin: var(--s3) 0 0; color: var(--text-2); font-size: var(--fs-small); }
.checks-wrap > .fold-inline { margin-top: var(--s1); }
@media (max-width: 900px) { .checks { grid-template-columns: 1fr; gap: var(--s3); } }

/* ======================================================================= notices, empty and error states */
.notice { display: flex; align-items: center; gap: var(--s3); padding: 14px var(--s4) 14px var(--s4);
  border-radius: var(--r-panel); border: 1px solid var(--line-2); background: var(--surface); }
.notice + .notice { margin-top: var(--s2); }
.notice-mark { display: inline-flex; flex: none; color: var(--text-2); }
.notice-text { margin: 0; flex: 1; min-width: 0; color: var(--text); }
.notice-action { flex: none; display: flex; gap: var(--s2); }
.notice-attention { border-color: color-mix(in srgb, var(--attention) 45%, transparent); background: color-mix(in srgb, var(--attention) 10%, var(--surface)); }
.notice-attention .notice-mark { color: var(--attention); }
.notice-down { border-color: color-mix(in srgb, var(--down) 45%, transparent); background: color-mix(in srgb, var(--down) 10%, var(--surface)); }
.notice-down .notice-mark { color: var(--down); }
.notice-up { border-color: color-mix(in srgb, var(--up) 40%, transparent); background: color-mix(in srgb, var(--up) 10%, var(--surface)); }
.notice-up .notice-mark { color: var(--up); }
@media (max-width: 640px) {
  .notice { flex-wrap: wrap; align-items: flex-start; }
  .notice-text { flex-basis: calc(100% - 40px); }
  .notice-action { margin-left: 30px; }
}
.empty { padding: var(--s5); }
.panel > .empty { padding: var(--s2) 0; }
.empty-text { margin: 0; color: var(--text-2); max-width: 60ch; }
.empty-action { margin-top: var(--s3); display: flex; gap: var(--s2); flex-wrap: wrap; }
.error-state > * + * { margin-top: var(--s2); }

/* ======================================================================= buttons */
.btn, button.primary, button.ghost, button.green, button.secondary, button.danger, button.close-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px;
  border-radius: var(--r-nested); border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
  font: 600 var(--fs-body)/1 var(--font-ui); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease; }
.btn:hover, button.ghost:hover, button.secondary:hover { text-decoration: none; border-color: var(--text-3);
  background: color-mix(in srgb, var(--surface-2) 70%, var(--line-2)); }
.btn.primary, button.primary, button.green { background: var(--crowd); border-color: var(--crowd); color: var(--bg); }
.btn.primary:hover, button.primary:hover, button.green:hover { background: color-mix(in srgb, var(--crowd) 85%, var(--text));
  border-color: color-mix(in srgb, var(--crowd) 85%, var(--text)); }
.btn.ghost, button.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover, button.ghost:hover { color: var(--text); background: var(--surface-2); border-color: transparent; }
button.ghost { border-color: var(--line-2); color: var(--text); }
.btn.danger, button.danger { background: transparent; border-color: var(--down); color: var(--down); }
.btn.danger:hover, button.danger:hover { background: var(--tint-down); border-color: var(--down); }
.btn.attention { background: var(--attention); border-color: var(--attention); color: var(--bg); }
.btn.attention:hover { background: color-mix(in srgb, var(--attention) 86%, var(--text)); border-color: color-mix(in srgb, var(--attention) 86%, var(--text)); }
.btn.small, button.close-btn { height: 30px; padding: 0 11px; font-size: var(--fs-small); gap: 6px; border-radius: 7px; }
.btn:disabled, button:disabled { opacity: .45; cursor: not-allowed; }
.btn[aria-busy="true"], button[aria-busy="true"] { cursor: progress; }
/* works, but can't do anything right now (e.g. Run now while the bot is
   stopped: a press still gets the server's refusal) */
.btn[aria-disabled="true"] { opacity: .55; }
.btn .ico { flex: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
@media (max-width: 640px) {
  .btn, button.primary, button.ghost, button.green, button.secondary, button.danger { min-height: 40px; }
  .btn.small, button.close-btn { min-height: 40px; padding: 0 14px; }
}

/* ======================================================================= inputs */
.input, input[type="text"], input[type="number"], input[type="search"], input[type="email"], input[type="password"],
input:not([type]), select, textarea {
  height: 40px; padding: 0 12px; border-radius: var(--r-nested); border: 1px solid var(--line-2); background: var(--surface-2);
  color: var(--text); font: 400 var(--fs-body) var(--font-ui); font-variant-numeric: tabular-nums; min-width: 0; }
textarea { height: auto; padding: 10px 12px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus { border-color: var(--crowd); }
input[type="number"] { -moz-appearance: textfield; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
select option { background: var(--surface); color: var(--text); }
.field { display: inline-flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: var(--fs-small); color: var(--text-2); }
.input-wrap { position: relative; display: inline-flex; align-items: center; }
.input-wrap .input { padding-right: 52px; width: 100%; }
.input-suffix { position: absolute; right: 12px; color: var(--text-2); font-size: var(--fs-small); pointer-events: none; }

/* custom checkbox and radio: no white native controls (spec §2.6) */
input[type="checkbox"], input[type="radio"] {
  appearance: none; -webkit-appearance: none; width: 18px; height: 18px; margin: 0; flex: none; padding: 0;
  border: 1.5px solid var(--text-3); background: var(--surface-2); display: inline-grid; place-content: center;
  cursor: pointer; vertical-align: -3px; transition: background-color .12s, border-color .12s; }
input[type="checkbox"] { border-radius: 5px; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]::after { content: ""; width: 9px; height: 5px; border: solid var(--bg); border-width: 0 0 2px 2px;
  transform: translateY(-1px) rotate(-45deg); opacity: 0; }
input[type="checkbox"]:checked { background: var(--crowd); border-color: var(--crowd); }
input[type="checkbox"]:checked::after { opacity: 1; }
input[type="radio"]:checked { border-color: var(--crowd); background: var(--crowd); box-shadow: inset 0 0 0 3.5px var(--surface-2); }
input[type="checkbox"]:hover:not(:disabled), input[type="radio"]:hover:not(:disabled) { border-color: var(--text-2); }
input[type="checkbox"]:checked:hover, input[type="radio"]:checked:hover { border-color: var(--crowd); }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: .45; cursor: not-allowed; }
.check-field { display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; min-height: 32px; padding: 4px 0; }
.check-field input { margin-top: 2px; }
.check-field.disabled { cursor: not-allowed; color: var(--text-2); }
.cf-text { display: flex; flex-direction: column; }
.cf-desc { color: var(--text-2); font-size: var(--fs-small); }

.radio-cards { display: grid; gap: var(--s2); }
.radio-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 12px; cursor: pointer;
  padding: 14px var(--s4); border: 1px solid var(--line-2); border-radius: var(--r-panel); background: var(--surface); }
.radio-card:hover { border-color: var(--text-3); }
.radio-card:has(input:checked) { border-color: var(--crowd); background: color-mix(in srgb, var(--crowd) 7%, var(--surface)); }
.radio-card:has(input:focus-visible) { outline: 2px solid var(--crowd); outline-offset: 2px; }
.radio-card input { margin-top: 2px; }
.radio-card.disabled { cursor: not-allowed; opacity: .5; }
.rc-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rc-title { font-weight: 600; }
.rc-desc { color: var(--text-2); font-size: var(--fs-small); }
.rc-meta { color: var(--text-2); font-size: var(--fs-small); white-space: nowrap; }

/* filter chips and the segmented control */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border-radius: var(--r-pill);
  border: 1px solid var(--line-2); background: transparent; color: var(--text-2); font: 500 var(--fs-small)/1 var(--font-ui);
  cursor: pointer; white-space: nowrap; }
.chip-btn:hover:not(:disabled) { color: var(--text); border-color: var(--text-3); }
.chip-btn.active { color: var(--text); background: var(--tint-text); border-color: var(--text-2); }
.chip-n { color: var(--text-3); font-weight: 500; }
.chip-btn.active .chip-n { color: var(--text-2); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line-2); }
.seg-btn { height: 30px; padding: 0 14px; border-radius: 7px; border: 0; background: transparent; color: var(--text-2);
  font: 500 var(--fs-small)/1 var(--font-ui); cursor: pointer; white-space: nowrap; }
.seg-btn:hover:not(:disabled) { color: var(--text); }
.seg-btn.active { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
@media (max-width: 640px) {
  .chip-btn { height: 40px; padding: 0 15px; }
  .tf-btn, .cat-tab, .chip-f { min-height: 38px; }
}

/* ======================================================================= tabs */
.tabs { display: flex; gap: var(--s5); border-bottom: 1px solid var(--line); margin-bottom: var(--s4); overflow-x: auto;
  scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; height: 42px; padding: 0 2px; background: none; border: 0; color: var(--text-2); cursor: pointer;
  font: 500 var(--fs-body)/1 var(--font-ui); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--text); }
.tab-n { color: var(--text-3); font-size: var(--fs-small); }

/* ======================================================================= toasts */
.toasts { position: fixed; right: var(--s5); bottom: var(--s5); z-index: 80; display: flex; flex-direction: column;
  align-items: flex-end; gap: var(--s2); pointer-events: none; max-width: min(440px, calc(100vw - 32px)); }
.toast { pointer-events: auto; background: var(--surface-2); color: var(--text); border: 1px solid var(--line-2);
  border-left: 3px solid var(--text-2); border-radius: var(--r-panel); padding: 12px var(--s4); font-size: var(--fs-body);
  animation: toast-in .18s ease-out; }
.toast.err { border-left-color: var(--down); }
.toast.toast-up { border-left-color: var(--up); }
.toast.toast-attention { border-left-color: var(--attention); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (max-width: 820px) {   /* with the tab bar (above) */
  .toasts { left: var(--s4); right: var(--s4); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
    align-items: stretch; max-width: none; }
}

/* ======================================================================= charts */
.chart { display: block; overflow: visible; }
.chart-box { position: relative; margin: var(--s3) 0 var(--s1); }
.chart-lbl { fill: var(--text-3); font-size: 12px; font-family: var(--font-ui); font-variant-numeric: tabular-nums; }
.ch-grid { stroke: var(--line); stroke-dasharray: 2 5; }
.ch-mid { stroke: var(--line-2); stroke-dasharray: 3 4; }
.ch-stop-a { stop-color: var(--market); stop-opacity: .22; }
.ch-stop-b { stop-color: var(--market); stop-opacity: 0; }
.ch-line-market { fill: none; stroke: var(--market); stroke-width: 1.8; stroke-linejoin: round; }
.ch-dot-market { fill: var(--market); }
.ch-lbl-market { fill: var(--market); font-weight: 600; }
.ch-line { fill: none; stroke: var(--text-2); stroke-width: 2; stroke-linejoin: round; }
/* our trades on the price chart (2026-11-06): buys, sales, the crowd's forecasts, and dashed price lines */
.ch-lvl line { stroke-width: 1.3; stroke-dasharray: 5 4; }
.ch-lvl-paid line { stroke: var(--text-2); }
.ch-lvl-tp line { stroke: var(--up); }
.ch-lvl-offer line { stroke: var(--crowd); stroke-dasharray: 2 4; }
.ch-lvl-lbl { font-size: 11px; }
.ch-lvl-paid .ch-lvl-lbl { fill: var(--text-2); }
.ch-lvl-tp .ch-lvl-lbl { fill: var(--up); }
.ch-lvl-offer .ch-lvl-lbl { fill: var(--crowd); }
.ch-mk-buy path { fill: var(--up); stroke: var(--bg); stroke-width: 1.5; }
.ch-mk-sell path { fill: var(--down); stroke: var(--bg); stroke-width: 1.5; }
.ch-mk-crowd circle { fill: var(--bg); stroke: var(--crowd); stroke-width: 2; }
.ch-legend { margin-top: var(--s1); }
.legend i.lg-mk { width: 0; height: 0; border-radius: 0; background: none; border-left: 5px solid transparent;
  border-right: 5px solid transparent; }
.legend i.lg-buy { border-bottom: 9px solid var(--up); }
.legend i.lg-sell { border-top: 9px solid var(--down); }
.legend i.lg-crowdpt { width: 8px; height: 8px; border: 2px solid var(--crowd); border-radius: 50%; background: transparent; }
.legend i.lg-dash { width: 14px; height: 0; border-radius: 0; background: none; border-top: 2px dashed var(--text-2); vertical-align: 3px; }
.legend i.lg-tp { border-top-color: var(--up); }
.legend i.lg-offer { border-top: 2px dotted var(--crowd); }
.mkd-ours { margin-top: var(--s3); }
.mkd-ours p { margin: 0 0 var(--s1); }
/* re-checks of a bet on the trade page (owner, 2026-11-09): the newest one's results, then every one */
.rcs { display: grid; gap: var(--s3); min-width: 0; }
.rcs > p { margin: 0; }
.rcs-when { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); color: var(--text-2); }
.rcs-verdict { font-weight: 500; }
.rcs-h4 { font-size: var(--fs-small); font-weight: 600; color: var(--text-2); margin: var(--s2) 0 0; }
.rcs-why ul { margin: var(--s1) 0 0; padding-left: 1.2em; }
.rcs-why li + li { margin-top: 4px; }
.rcs-list .rcs-entry .row-title, .rcs-list .rcs-entry .row-key { color: var(--text-2); font-weight: 400; }
.rcs-next, .rcs-rule { color: var(--text-2); }
.rcs-host + .rcs-host { margin-top: var(--s5); padding-top: var(--s5); border-top: 1px solid var(--line); }
.ch-pt { stroke: var(--surface); stroke-width: 2; }
.ch-pt.won { fill: var(--up); } .ch-pt.lost { fill: var(--down); } .ch-pt.void { fill: var(--text-3); }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: 6px; padding: 3px 8px; font-size: var(--fs-small); transform: translate(-50%, -140%); white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--fs-micro); color: var(--text-2); margin-bottom: var(--s2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px;
  background: var(--text-3); }
.legend i.lg-crowd, .legend i.lg-bar { background: var(--crowd); }
.legend i.lg-bar { background: color-mix(in srgb, var(--crowd) 55%, transparent); }
.legend i.lg-market { background: var(--market); }

/* ======================================================================= headings & tables */
h1 { font-size: var(--fs-figure); line-height: 1.3; margin: 0 0 var(--s5); }
h2 { font-size: var(--fs-title); line-height: 1.35; margin: 0 0 var(--s3); }
.panel > h2:first-child { margin-top: 0; }
/* tables appear only inside Details folds (spec §2.3), in a .table-wrap that
   scrolls sideways by itself on a phone */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--text-2); font-weight: 500; font-size: var(--fs-small); white-space: nowrap; }
td { font-size: var(--fs-body); }
tr:last-child td { border-bottom: 0; }

/* ======================================================================= vote histogram (ui.voteHistogram) */
.votes { margin: var(--s2) 0 var(--s1); }
.vhist { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 76px; padding: 16px 4px 0;
  background: var(--surface-2); border-radius: var(--r-nested); }
.vhist i { position: relative; flex: 1; min-width: 0; min-height: 2px; border-radius: 2px 2px 0 0; background: color-mix(in srgb, var(--crowd) 55%, transparent); }
/* the number of votes on each bar, and the crowd's and market's values (2026-11-06) */
.vhist i .vh-n { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font: 600 10px/1.4 var(--font-ui);
  font-style: normal; color: var(--text-2); font-variant-numeric: tabular-nums; pointer-events: none; }
.vmarks { position: relative; height: 18px; margin-bottom: 2px; }
.vmarks.two { height: 34px; }
.vml { position: absolute; top: 0; transform: translateX(-50%); font: 600 var(--fs-micro)/1.4 var(--font-ui); white-space: nowrap;
  font-variant-numeric: tabular-nums; }
.vml.row2 { top: 16px; }
.vml.edge-l { transform: none; }
.vml.edge-r { transform: translateX(-100%); }
.vml.model { color: var(--crowd); }
.vml.market { color: var(--market); }
.vhist i.vh-empty { background: var(--line); }
.vhist i:hover { background: var(--crowd); }
.vmk { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 1px; }
.vmk.model { background: var(--crowd); }
.vmk.market { background: var(--market); }
.vaxis { display: flex; justify-content: space-between; font-size: var(--fs-micro); color: var(--text-3); margin-top: 4px; }
.votes .legend { margin-top: 6px; }

/* ======================================================================= component kit (#/_kit) */
.kit-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s3); }
.kit-swatch { display: flex; align-items: center; gap: 10px; font-size: var(--fs-small); }
.kit-swatch i { width: 28px; height: 28px; border-radius: 7px; flex: none; box-shadow: inset 0 0 0 1px var(--line-2); }
.kit-swatch span { display: flex; flex-direction: column; min-width: 0; }
.kit-swatch small { color: var(--text-3); font-size: var(--fs-micro); }
.kit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4) var(--s6); }
.kit-cell > .kit-label { font-size: var(--fs-small); color: var(--text-2); margin: 0 0 var(--s2); }
.kit-icons { display: flex; flex-wrap: wrap; gap: var(--s4) var(--s5); color: var(--text); }
.kit-icons span { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; font-size: var(--fs-micro); color: var(--text-2); min-width: 52px; }
.kit-icons svg { color: var(--text); }
.kit-type > * + * { margin-top: var(--s3); }
@media (max-width: 760px) { .kit-grid { grid-template-columns: 1fr; } }

/* ======================================================================= phone tap targets (spec §2.6) */
/* Last in the file on purpose: these must win over the component rules above. */
@media (max-width: 640px) {
  details.fold-inline > summary, .back-link, .check-field, .brand { min-height: 40px; }
  .seg-btn { height: 40px; }
  .check-field { align-items: center; }
  .check-field input { margin-top: 0; }
}

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

/* 2026-10-22: every reason a simulation passed or bought */
.run-why-list { margin: .35em 0 0 1.2em; padding: 0; }
.run-why-list li { margin: .2em 0; }

/* 2026-10-22: crowd vs market scoreboard */
.rs-sub { margin: 1.1em 0 .4em; font-size: .95em; }

/* the real-money password dialog (2026-11-05) */
.rp-dialog { width: min(440px, calc(100vw - 32px)); padding: var(--s5); border: 1px solid var(--down);
  border-radius: 12px; background: var(--surface); color: var(--text); }
.rp-dialog::backdrop { background: rgb(0 0 0 / 0.6); }
.rp-form { margin: 0; }
.rp-title { font-size: var(--fs-title); margin: 0 0 var(--s3); color: var(--down); }
.rp-line { margin: 0 0 var(--s2); overflow-wrap: anywhere; }
.rp-field { display: grid; gap: 6px; margin-top: var(--s3); }
.rp-field .input { width: 100%; }
.rp-hint { color: var(--text-2); font-size: var(--fs-small); margin: var(--s2) 0 var(--s4); }
.rp-actions { justify-content: flex-end; }
