/* Trader Desk (the Paper Desk look). Ink on paper; one warm accent. Light and dark. */
:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #ece7dc;
  --ink: #1d2733;
  --ink-2: #4b5562;
  --ink-3: #6f7884;
  --line: #ddd5c6;
  --accent: #b8502a;
  --accent-ink: #ffffff;
  --accent-soft: #f5e0d3;
  --good: #23705f;
  --good-soft: #dcefe8;
  --bad: #a83434;
  --bad-soft: #f6dddd;
  --warn: #8a5a0e;
  --shadow: 0 1px 0 rgba(29, 39, 51, 0.06), 0 1px 3px rgba(29, 39, 51, 0.06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --tabbar: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121519;
    --surface: #1a1f26;
    --surface-2: #242a33;
    --ink: #ece6da;
    --ink-2: #bdb6aa;
    --ink-3: #959083;
    --line: #2f3741;
    --accent: #e9875c;
    --accent-ink: #1a1208;
    --accent-soft: #3b261b;
    --good: #6cc3aa;
    --good-soft: #17322b;
    --bad: #ec8a8a;
    --bad-soft: #3a1f21;
    --warn: #e0b060;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121519;
  --surface: #1a1f26;
  --surface-2: #242a33;
  --ink: #ece6da;
  --ink-2: #bdb6aa;
  --ink-3: #959083;
  --line: #2f3741;
  --accent: #e9875c;
  --accent-ink: #1a1208;
  --accent-soft: #3b261b;
  --good: #6cc3aa;
  --good-soft: #17322b;
  --bad: #ec8a8a;
  --bad-soft: #3a1f21;
  --warn: #e0b060;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.boot { padding: 40px 16px; color: var(--ink-3); text-align: center; }
.num, .tab-num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 0.86em; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.hidden { display: none !important; }

/* header */
.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.brand-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px 6px; }
.brand { font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: 0.2px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; flex: none; }
.paper-pill {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase;
  border: 1px solid var(--ink-3); color: var(--ink-2); border-radius: 999px; padding: 1px 7px;
}
.who { margin-left: auto; font-size: 13px; color: var(--ink-2); }
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 10px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 6px 12px; min-height: 34px; font-size: 14px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.dim { color: var(--ink-3); border-style: dashed; }
.chip .count { font-size: 11px; margin-left: 5px; opacity: 0.75; }
.chip-sep { flex: none; width: 1px; background: var(--line); margin: 4px 2px; }

/* main */
main { padding: 14px 16px calc(var(--tabbar) + 28px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 18px; margin: 20px 0 8px; }
h3 { font-size: 16px; }
.screen-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; min-height: 40px; }
.screen-head h1 { flex: 1; min-width: 0; }
.sub { color: var(--ink-3); font-size: 13px; margin: -4px 0 12px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; margin: 0 0 10px; box-shadow: var(--shadow);
}
button.card { display: block; width: 100%; text-align: left; cursor: pointer; }
button.card:active { transform: scale(0.995); }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card-title { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.when { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.kv { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; margin-top: 8px; font-size: 14px; }
.kv .k { color: var(--ink-3); }
.kv .v { font-variant-numeric: tabular-nums; }
.kv .r { text-align: right; font-variant-numeric: tabular-nums; }
.lines { width: 100%; border-collapse: collapse; font-size: 14px; margin: 6px 0; }
.lines th { text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12px; padding: 4px 6px 4px 0; }
.lines td { padding: 6px 6px 6px 0; border-top: 1px solid var(--line); vertical-align: top; font-variant-numeric: tabular-nums; }
.lines td.l { color: var(--ink-2); }
.lines .note { display: block; font-size: 12px; color: var(--ink-3); }

.verdicts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 999px;
  padding: 2px 9px; font-size: 12px; font-weight: 600; border: 1px solid var(--line); color: var(--ink-2);
}
.pill.pick { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pill.pass { background: transparent; }
.pill.off { color: var(--ink-3); border-style: dashed; font-weight: 500; }
.pill.ok { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.broken { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.benched { background: var(--surface-2); color: var(--warn); border-color: transparent; }
.pill.active { background: var(--good-soft); color: var(--good); border-color: transparent; }

.verdict { padding: 9px 0; border-top: 1px solid var(--line); }
.verdict:first-child { border-top: 0; }
.verdict .head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.verdict .why { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.pick-line { font-weight: 600; margin-top: 3px; }

ul.plain { margin: 4px 0; padding-left: 18px; font-size: 14px; }
ul.plain li { margin: 3px 0; }
.section { margin-top: 14px; }
.section > h3 { margin-bottom: 4px; }
.notice {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: 9px 12px; border-radius: 8px; font-size: 13.5px; margin: 0 0 12px;
}
.notice.good { border-left-color: var(--good); background: var(--good-soft); }
a.btn { text-decoration: none; }
.error {
  border-left: 3px solid var(--bad); background: var(--bad-soft); color: var(--ink);
  padding: 10px 12px; border-radius: 8px; font-size: 14px; margin: 8px 0 12px;
}
.empty { color: var(--ink-3); text-align: center; padding: 26px 8px; font-size: 14px; }

/* numbers */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-width: 0; }
.stat .label { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.5px; }
.stat .value { font-family: var(--serif); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat.hero { grid-column: 1 / -1; }
.stat.hero .value { font-size: 34px; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

/* field and fight rows */
.runner { display: grid; grid-template-columns: 22px 1fr auto auto; gap: 4px 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.runner:first-of-type { border-top: 0; }
.runner .rank { color: var(--ink-3); font-size: 12px; text-align: right; }
.runner .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.runner .p { font-variant-numeric: tabular-nums; text-align: right; min-width: 52px; }
.runner .bar { grid-column: 2 / -1; height: 5px; background: var(--surface-2); border-radius: 4px; position: relative; overflow: hidden; }
.runner .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 4px; }
.runner .bar b { position: absolute; top: -1px; bottom: -1px; width: 2px; background: var(--ink); }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--ink-3); margin: 4px 0 2px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin-right: 4px; }
.sw.ours { background: var(--accent); }
.sw.mkt { background: var(--ink); width: 3px; }
.fighters { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 12px; margin-top: 8px; font-size: 14px; }
.fighters .h { font-size: 11.5px; color: var(--ink-3); text-align: right; }
.fighters .r { text-align: right; font-variant-numeric: tabular-nums; }
.group-head { font-family: var(--serif); font-size: 15px; color: var(--ink-2); margin: 16px 0 8px; }

/* forms */
label.f { display: block; font-size: 13px; color: var(--ink-2); margin: 10px 0 4px; }
input[type=text], input[type=url], input[type=password], input[type=number], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 11px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input[type=file] { width: 100%; font-size: 14px; padding: 8px 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--bg); font-weight: 600; cursor: pointer;
}
.btn svg { width: 18px; height: 18px; }
.btn.block { width: 100%; margin-top: 14px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13.5px; }
.btn[disabled] { opacity: 0.5; cursor: default; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none;
}
.icon-btn svg { width: 20px; height: 20px; }
.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; min-height: 38px; border: 0; background: transparent; border-radius: 8px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
details { margin-top: 8px; }
details > summary { cursor: pointer; color: var(--ink-2); font-size: 13.5px; min-height: 32px; display: flex; align-items: center; }
details > div { font-size: 13.5px; color: var(--ink-2); padding: 4px 0 2px; }
.csv { font-family: var(--mono); font-size: 12px; min-height: 120px; white-space: pre; }

/* player pool */
.pool-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 4px 8px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.pool-row .meta { font-size: 12px; color: var(--ink-3); }
.pool-row .tg { display: flex; gap: 4px; }
.tg button { min-height: 34px; min-width: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 12px; font-weight: 600; cursor: pointer; }
.tg button[aria-pressed="true"].lock { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tg button[aria-pressed="true"].excl { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.poschip { font-size: 11px; font-weight: 700; color: var(--ink-2); background: var(--surface-2); border-radius: 6px; text-align: center; padding: 2px 0; }
.lineup .pl { display: grid; grid-template-columns: 44px 1fr auto auto; gap: 8px; font-size: 13.5px; padding: 3px 0; }
.lineup .pl .s { color: var(--ink-3); font-size: 12px; }

/* status list */
.srow { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; align-items: center; }
.srow:first-child { border-top: 0; }
.srow .l { min-width: 0; overflow-wrap: anywhere; }
.meter { height: 8px; background: var(--surface-2); border-radius: 6px; overflow: hidden; margin: 8px 0 4px; }
.meter i { display: block; height: 100%; background: var(--accent); }
pre.lines-out { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 10px; border-radius: 8px; margin: 8px 0 0; }

/* detail sheet */
.back { margin-bottom: 8px; }

/* bottom tabs */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(6, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  height: var(--tabbar); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-3); text-decoration: none; font-size: 11px; font-weight: 600; min-width: 0;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar a[aria-current="page"] svg { stroke-width: 2.2; }

/* login */
.login { max-width: 380px; margin: 0 auto; padding: calc(48px + env(safe-area-inset-top)) 16px 40px; }
.login .mark { width: 64px; height: 64px; border-radius: 16px; display: block; margin-bottom: 14px; }
.login h1 { font-size: 28px; }
.login p { color: var(--ink-2); }

/* dialog */
dialog {
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink);
  padding: 18px 16px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
dialog::backdrop { background: rgba(10, 12, 15, 0.45); }
dialog h3 { margin-bottom: 6px; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabbar) + 14px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg); padding: 11px 14px; border-radius: 12px; z-index: 40;
  font-size: 14px; max-width: 688px; margin: 0 auto;
}
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp 0.8s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(4, 1fr); } .stat.hero { grid-column: span 2; } }

/* Trader Desk additions */
.chart { width: 100%; height: 120px; display: block; margin: 8px 0 2px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart .base { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.pill.warn { background: var(--surface-2); color: var(--warn); border-color: transparent; }
.acct-num { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.fresh { font-size: 12.5px; color: var(--ink-3); margin: 10px 0 0; }
.card .tagrow { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pill { white-space: nowrap; }
