/* FELLAS board — tokens */
:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);

  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem; --space-5: 1.25rem;
  --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem;

  --font-body: 'Satoshi', 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  --radius: 14px; --radius-sm: 9px;
  --shadow: 0 1px 2px oklch(0 0 0 / .06), 0 8px 24px -12px oklch(0 0 0 / .18);

  /* light */
  --bg: oklch(97.5% 0.004 80);
  --surface: oklch(100% 0 0);
  --surface-2: oklch(95.5% 0.005 80);
  --line: oklch(90% 0.006 80);
  --ink: oklch(20% 0.012 260);
  --ink-2: oklch(45% 0.012 260);
  --ink-3: oklch(62% 0.01 260);
  --accent: oklch(78% 0.15 80);           /* amber: needs you */
  --accent-ink: oklch(32% 0.08 80);
  --accent-soft: oklch(94% 0.06 85);
  --good: oklch(62% 0.15 150);
  --good-soft: oklch(94% 0.05 150);
  --bad: oklch(58% 0.19 25);
  --bad-soft: oklch(94% 0.05 25);
  --info-soft: oklch(94% 0.03 250);
}
[data-theme="dark"] {
  --bg: oklch(16% 0.01 260);
  --surface: oklch(21% 0.012 260);
  --surface-2: oklch(26% 0.012 260);
  --line: oklch(30% 0.012 260);
  --ink: oklch(94% 0.005 80);
  --ink-2: oklch(72% 0.01 260);
  --ink-3: oklch(56% 0.01 260);
  --accent: oklch(80% 0.14 80);
  --accent-ink: oklch(92% 0.08 85);
  --accent-soft: oklch(30% 0.055 80);
  --good: oklch(72% 0.14 150);
  --good-soft: oklch(30% 0.05 150);
  --bad: oklch(70% 0.16 25);
  --bad-soft: oklch(32% 0.06 25);
  --info-soft: oklch(30% 0.03 250);
  --shadow: 0 1px 2px oklch(0 0 0 / .3), 0 8px 24px -12px oklch(0 0 0 / .5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: oklch(16% 0.01 260);
    --surface: oklch(21% 0.012 260);
    --surface-2: oklch(26% 0.012 260);
    --line: oklch(30% 0.012 260);
    --ink: oklch(94% 0.005 80);
    --ink-2: oklch(72% 0.01 260);
    --ink-3: oklch(56% 0.01 260);
    --accent: oklch(80% 0.14 80);
    --accent-ink: oklch(92% 0.08 85);
    --accent-soft: oklch(30% 0.055 80);
    --good: oklch(72% 0.14 150);
    --good-soft: oklch(30% 0.05 150);
    --bad: oklch(70% 0.16 25);
    --bad-soft: oklch(32% 0.06 25);
    --info-soft: oklch(30% 0.03 250);
    --shadow: 0 1px 2px oklch(0 0 0 / .3), 0 8px 24px -12px oklch(0 0 0 / .5);
  }
}

/* base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: var(--text-base); line-height: 1.5;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h2 { font-size: var(--text-lg); font-weight: 700; }
h3.sub-head { font-size: var(--text-sm); color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; margin: var(--space-8) 0 var(--space-3); }
p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums lining-nums; }
.muted { color: var(--ink-2); }
.tiny { font-size: var(--text-xs); }
[hidden] { display: none !important; }

/* shell */
.app { height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--space-3) + env(safe-area-inset-top)) var(--space-4) var(--space-3);
  background: var(--bg); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.brand { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 700; letter-spacing: .04em; font-size: var(--text-sm); }
.brand .logo { width: 26px; height: 26px; color: var(--ink); }
.brand-lg { font-size: var(--text-base); }
.brand-lg .logo { width: 36px; height: 36px; }
.topbar-right { display: flex; align-items: center; gap: var(--space-2); }
.updated { font-size: var(--text-xs); color: var(--ink-3); margin-right: var(--space-2); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--surface-2); }
:root:not([data-theme="dark"]) .icon-btn .moon { display: none; }
[data-theme="dark"] .icon-btn .sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-btn .sun { display: none; }
  :root:not([data-theme="light"]) .icon-btn .moon { display: block; }
}

.main { overflow-y: auto; overscroll-behavior: contain; padding: var(--space-4) var(--space-4) var(--space-8); max-width: 960px; width: 100%; margin: 0 auto; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); margin-bottom: var(--space-6); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.kpi-label { font-size: var(--text-xs); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: var(--text-lg); font-weight: 600; }
.kpi-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.kpi-accent .kpi-label { color: var(--accent-ink); opacity: .8; }
@media (max-width: 420px) { .kpis { grid-template-columns: repeat(2, 1fr); } }

/* sections */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.seg-btn { border: 0; background: transparent; border-radius: 999px; padding: 6px 12px; font-size: var(--text-xs); font-weight: 500; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.seg-btn.is-on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px oklch(0 0 0 / .08); }

.list { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.row {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4);
  display: grid; grid-template-columns: 1fr auto; gap: var(--space-3); align-items: start;
}
.row-title { font-weight: 500; }
.row-meta { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-top: var(--space-2); font-size: var(--text-xs); color: var(--ink-2); }
.row.is-done { opacity: .55; }
.row.is-done .row-title { text-decoration: line-through; }
.row a.pr-link { text-decoration: none; }
.row a.pr-link:hover .row-title { text-decoration: underline; }

a.pill { text-decoration: none; }
a.pill:hover { text-decoration: underline; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: var(--text-xs); font-weight: 500; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill-accent { background: var(--accent-soft); color: var(--accent-ink); }
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-info { background: var(--info-soft); color: var(--ink); }

.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: var(--text-sm); font-weight: 600; cursor: pointer; min-height: 44px;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { opacity: .9; background: var(--ink); }
.btn-done { background: var(--accent); color: oklch(22% 0.05 80); border-color: transparent; padding: 8px 12px; min-height: 40px; }
.btn-done:hover { background: var(--accent); filter: brightness(.96); }
.btn:disabled { opacity: .5; cursor: progress; }

/* bet cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-3); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; gap: var(--space-2); align-items: start; }
.card-title { font-weight: 700; }
.card-id { font-size: var(--text-xs); color: var(--ink-3); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); }
.stat-label { display: block; font-size: var(--text-xs); color: var(--ink-2); }
.stat-value { display: block; font-size: var(--text-base); font-weight: 600; }
.kill { font-size: var(--text-xs); color: var(--ink-2); border-left: 2px solid var(--line); padding-left: var(--space-3); }
.card.is-parked { opacity: .65; box-shadow: none; }

/* progress meter */
.meter { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--good); border-radius: 999px; transition: width .4s ease; }
.meter.is-warn > i { background: var(--accent); }
.meter.is-bad > i { background: var(--bad); }

/* tab bar */
.tabbar {
  display: grid; grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--line); background: var(--bg);
  padding: var(--space-1) var(--space-2) calc(var(--space-2) + env(safe-area-inset-bottom));
}
.tab-btn { position: relative; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--space-2) 0; color: var(--ink-3); font-size: var(--text-xs); cursor: pointer; border-radius: var(--radius-sm); }
.tab-btn svg { width: 22px; height: 22px; }
.tab-btn.is-on { color: var(--ink); }
.tab-btn.is-on svg { color: var(--accent-ink); }
[data-theme="dark"] .tab-btn.is-on svg { color: var(--accent); }
.badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: oklch(22% 0.05 80); font-style: normal; font-size: 11px; font-weight: 700; display: grid; place-items: center; font-family: var(--font-mono); }
@media (min-width: 720px) {
  .tabbar { grid-template-columns: repeat(5, minmax(0, 140px)); justify-content: center; }
}

/* auth */
.auth { grid-row: 1 / -1; display: grid; place-items: center; padding: var(--space-6); overflow-y: auto; }
.auth-card { width: min(100%, 420px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-8) var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); box-shadow: var(--shadow); }
.auth-title { font-size: var(--text-xl); font-weight: 700; margin-top: var(--space-2); }
.auth-form { display: flex; flex-direction: column; gap: var(--space-3); }
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.label { font-size: var(--text-xs); color: var(--ink-2); font-weight: 500; }
input { font: inherit; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg); color: var(--ink); min-height: 46px; }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.otp summary { cursor: pointer; font-size: var(--text-sm); color: var(--ink-2); }
.otp[open] summary { margin-bottom: var(--space-3); }
.auth-msg { min-height: 1.5em; font-size: var(--text-sm); }
.auth-msg.is-ok { color: var(--good); }
.auth-msg.is-bad { color: var(--bad); }

/* skeleton + empty */
.skel { height: 64px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: sh 1.2s infinite; border: 1px solid var(--line); }
@keyframes sh { to { background-position: -200% 0; } }
.empty { text-align: center; padding: var(--space-10) var(--space-4); color: var(--ink-2); border: 1px dashed var(--line); border-radius: var(--radius); font-size: var(--text-sm); }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: var(--text-sm); box-shadow: var(--shadow); z-index: 20; max-width: calc(100% - 32px); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Charts (inline SVG, no library) */
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4) var(--space-4) var(--space-3); margin-bottom: var(--space-3); box-shadow: var(--shadow); }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 12px; margin-bottom: 8px; flex-wrap: wrap; }
.chart-title { white-space: nowrap; }
.chart-title { font-weight: 700; font-size: 15px; }
.chart-legend { display: flex; gap: 12px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart-card svg { display: block; width: 100%; max-width: 520px; height: auto; overflow: visible; margin: 0 auto; }
.chart-card text { font-family: var(--font-body); font-size: 11px; fill: var(--ink-2); }
.chart-card text.mono { font-family: var(--font-mono); }
.chart-card text.strong { fill: var(--ink); font-weight: 600; }
.chart-card .track { fill: var(--surface-2, var(--line)); }
.chart-card .bar-spent { fill: var(--ink-2); }
.chart-card .bar-spent.is-warn { fill: var(--accent); }
.chart-card .bar-spent.is-bad { fill: var(--bad); }
.chart-card .bar-open { fill: var(--ink-2); opacity: .55; }
.chart-card .bar-merged { fill: var(--good); }
.chart-card .grid { stroke: var(--line); stroke-width: 1; }
.chart-card .kill-tick { stroke: var(--bad); stroke-width: 2; }
.chart-card .rev-dot { fill: var(--good); }
.chart-empty { color: var(--ink-2); font-size: 13px; padding: 6px 0 2px; }

/* ---------- HQ ---------- */
.brand .hq { font-weight: 700; color: var(--accent-ink); letter-spacing: .08em; }
[data-theme="dark"] .brand .hq { color: var(--accent); }
.topnav { display: none; gap: var(--space-1); }
.topnav a { text-decoration: none; padding: 6px 12px; border-radius: 999px; font-size: var(--text-sm); color: var(--ink-2); font-weight: 500; }
.topnav a:hover { background: var(--surface-2); color: var(--ink); }
.topnav a.is-on { background: var(--surface-2); color: var(--ink); }
.tab-btn { text-decoration: none; }
@media (min-width: 900px) {
  .topnav { display: flex; }
  .tabbar { display: none !important; }
}
.main { max-width: 1080px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-4); }
.page-head h1 { font-size: var(--text-xl); margin: 0; letter-spacing: -.01em; }
.seg .badge { position: static; display: inline-grid; margin-left: 4px; }
.hero { margin: var(--space-2) 0 var(--space-6); }
.eyebrow { font-size: var(--text-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; margin-bottom: var(--space-2); }
.hero-title { font-size: var(--text-xl); margin: 0 0 var(--space-1); letter-spacing: -.01em; }
.lede { color: var(--ink-2); max-width: 68ch; margin-bottom: var(--space-6); }
.link { color: var(--ink-2); text-decoration: none; font-size: var(--text-sm); }
.link:hover { color: var(--ink); text-decoration: underline; }
.list .more, .list .empty { list-style: none; padding: var(--space-2) var(--space-1); color: var(--ink-2); }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); margin: var(--space-6) 0 var(--space-8); }
@media (min-width: 900px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; box-shadow: var(--shadow); transition: transform .15s ease, border-color .15s ease; min-height: 120px; }
.tile:hover { transform: translateY(-2px); border-color: var(--ink-3); }
.tile-k { font-weight: 700; }
.tile-t { color: var(--ink-2); font-size: var(--text-sm); flex: 1; }
.tile-m { font-size: var(--text-xs); color: var(--ink-3); }
.timeline { list-style: none; margin: 0 0 var(--space-6); padding: 0; border-left: 2px solid var(--line); }
.timeline li { display: grid; grid-template-columns: 76px 1fr; gap: var(--space-3); padding: var(--space-2) 0 var(--space-2) var(--space-4); position: relative; font-size: var(--text-sm); }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink-3); }
.timeline .t { color: var(--ink-2); font-size: var(--text-xs); padding-top: 2px; }
.timeline li.is-past { color: var(--ink-3); }
.timeline li.is-past::before { background: var(--ink-3); }
.timeline li.is-now::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.timeline li.is-now { font-weight: 600; }
.timeline li.is-off { color: var(--ink-3); }
.grid2 { display: grid; gap: var(--space-6); grid-template-columns: 1fr; margin-bottom: var(--space-6); }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.cards-3 { display: grid; gap: var(--space-3); grid-template-columns: 1fr; margin-bottom: var(--space-6); }
@media (min-width: 720px) { .cards-3 { grid-template-columns: repeat(3, 1fr); } }
code { font-family: var(--font-mono); font-size: .9em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.ticks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); font-size: var(--text-sm); }
.ticks li { padding-left: 22px; position: relative; }
.ticks li::before { content: '✓'; position: absolute; left: 0; color: var(--good); font-weight: 700; }
.ticks-no li::before { content: '×'; color: var(--bad); }
.pill-warn { background: var(--accent-soft); color: var(--accent-ink); }
.team { display: grid; gap: var(--space-3); grid-template-columns: 1fr; margin-bottom: var(--space-6); }
@media (min-width: 640px) { .team { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .team { grid-template-columns: repeat(3, 1fr); } }
.team-div.is-held { opacity: .7; box-shadow: none; }
.bots { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.bots li { display: flex; justify-content: space-between; gap: var(--space-2); font-size: var(--text-sm); padding: 4px 0; border-top: 1px solid var(--line); }
.bots li:first-child { border-top: 0; }
.wf-list { display: flex; flex-direction: column; gap: var(--space-4); margin-bottom: var(--space-4); }
.wf p { max-width: 72ch; }
.wf-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding-top: var(--space-2); border-top: 1px solid var(--line); }
.btn-sm { padding: 6px 12px; font-size: var(--text-xs); min-height: 0; text-decoration: none; }
.stall { font-size: var(--text-xs); color: var(--bad); margin-top: 4px; }
.slots, .steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.slots li { display: grid; grid-template-columns: 60px 1fr; gap: var(--space-3); padding: var(--space-2) var(--space-3); background: var(--surface-2); border-radius: var(--radius-sm); font-size: var(--text-sm); }
.slots li.is-off { opacity: .55; }
.slots .t { font-weight: 600; }
.steps li { display: grid; grid-template-columns: 28px 1fr; gap: var(--space-3); align-items: start; }
.step-n { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.by { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; padding: 1px 6px; border-radius: 4px; margin-left: 4px; font-weight: 600; vertical-align: 2px; }
.by-script { background: var(--info-soft); color: var(--ink); }
.by-agent { background: var(--good-soft); color: var(--good); }
.by-person { background: var(--accent-soft); color: var(--accent-ink); }
.live-jarvis { margin-bottom: var(--space-6); }
.jv-bar { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.jv-url { display: flex; gap: var(--space-2); }
.jv-url input { flex: 1; font: inherit; font-size: var(--text-sm); padding: .4rem .6rem; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.jv-frame { width: 100%; height: min(70dvh, 640px); min-height: 26rem; border: 1px solid var(--line); border-radius: var(--radius); background: #000; display: block; }
