/* Layout follows Kalshi: two-row top bar (nav + search, then categories), card grid with a
   sidebar of ranked lists, market page = chart column + sticky trade panel. */
:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F3F4F5;
  --raised: #FFFFFF;
  --ink: #0C0D0F;
  --muted: #6B6F76;
  --faint: #9A9EA5;
  --line: #E6E7E9;
  --line-strong: #D5D7DA;
  --green: #00A86B;
  --green-ink: #008556;
  --green-soft: #E5F6EF;
  --on-green: #FFFFFF;
  --no: #8A5CF5;
  --no-soft: #F1EBFE;
  --red: #E5484D;
  --red-soft: #FDECEC;
  --blue: #3E6FF5;
  --blue-soft: #EAF0FF;
  --warn: #B54708;
  --brand-tile: #0C0D0F;
  --font: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Archivo", "Figtree", ui-sans-serif, system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1012;
    --surface: #141518;
    --surface-2: #232428;
    --raised: #18191C;
    --ink: #F2F3F5;
    --muted: #9C9FA6;
    --faint: #6E7178;
    --line: #2A2B2F;
    --line-strong: #3A3C41;
    --green: #4FD69E;
    --green-ink: #4FD69E;
    --green-soft: #15291F;
    --on-green: #07140E;
    --no: #A68BFF;
    --no-soft: #221C38;
    --red: #F0525A;
    --red-soft: #2E1618;
    --blue: #4C7BFF;
    --blue-soft: #16203A;
    --warn: #F5A524;
    --brand-tile: #232428;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---- top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: 1320px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 32px; min-height: 72px;
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; flex: none; }
.brand span { font: 800 25px/1 var(--display); font-stretch: 78%; letter-spacing: -0.02em; color: var(--green); }
.brand-mark { width: 28px; height: 28px; }
.nav { display: flex; gap: 28px; }
.nav a {
  text-decoration: none; color: var(--ink); font-weight: 700; font-size: 14px;
  text-transform: uppercase; letter-spacing: 0.09em; white-space: nowrap;
}
.nav a:hover, .nav a.on { color: var(--green); }
.live-count { color: var(--red); margin-left: 4px; }
.search {
  flex: 1; max-width: 560px; margin-left: auto; display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border-radius: 999px; padding: 0 18px; height: 46px;
}
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; flex: none; }
.search input { border: 0; background: none; outline: none; flex: 1; min-width: 0; font-size: 16px; }
.search input::placeholder { color: var(--muted); }
.account { display: flex; align-items: center; gap: 10px; flex: none; }
.bal { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; text-decoration: none; }
.bal small { font-size: 12px; color: var(--muted); }
.bal b { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.who { font-weight: 600; font-size: 14px; background: none; border: 1px solid var(--line-strong); cursor: pointer; padding: 9px 16px; border-radius: 999px; }
.who:hover { border-color: var(--ink); }

.cats-wrap { max-width: 1320px; margin: 0 auto; padding: 0 24px; }
.cats { display: flex; gap: 24px; overflow-x: auto; scrollbar-width: none; padding: 4px 0 14px; }
.cats::-webkit-scrollbar { display: none; }
.cats a { text-decoration: none; color: var(--muted); font-weight: 500; font-size: 17px; white-space: nowrap; }
.cats a:hover { color: var(--ink); }
.cats a.on { color: var(--ink); font-weight: 700; }
.cats a:first-child { margin-right: 64px; }

.demo-banner { background: var(--green-soft); color: var(--green-ink); font-size: 13px; font-weight: 600; text-align: center; padding: 8px 16px; }

.page { max-width: 1320px; margin: 0 auto; padding: 32px 24px 56px; min-height: 70vh; }
.foot { max-width: 1320px; margin: 0 auto; padding: 24px 24px 40px; color: var(--faint); font-size: 13px; border-top: 1px solid var(--line); }
.foot a { color: var(--muted); }

/* ---- buttons */
.btn {
  border: 1px solid var(--line-strong); background: transparent; border-radius: 999px;
  padding: 10px 18px; font-weight: 600; font-size: 15px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--green); color: var(--on-green); border-color: var(--green); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.sm { padding: 7px 14px; font-size: 14px; }
.icon-btn { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line-strong); background: none; display: grid; place-items: center; cursor: pointer; }

/* ---- headings & filters */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
h1, .h-display {
  font: 800 40px/1.05 var(--display); font-stretch: 72%; letter-spacing: -0.015em; margin: 0; text-wrap: balance;
}
h2 { font-size: 20px; letter-spacing: -0.01em; margin: 0 0 14px; font-weight: 700; }
.sub { color: var(--muted); margin: 6px 0 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink);
  border-radius: 999px; padding: 9px 16px; font-weight: 600; font-size: 14px; cursor: pointer;
  display: inline-flex; gap: 8px; align-items: center; text-decoration: none;
}
.chip:hover { border-color: var(--ink); }
.chip.on { border-color: var(--green); color: var(--green-ink); }
.chip .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.pill-select { position: relative; display: inline-flex; }
.pill-select select {
  appearance: none; border: 1px solid var(--line-strong); background: transparent; border-radius: 999px;
  padding: 11px 44px 11px 22px; font-weight: 600; font-size: 15px; cursor: pointer;
}
.pill-select select:hover { border-color: var(--ink); }
.pill-select::after {
  content: ""; position: absolute; right: 20px; top: 50%; width: 7px; height: 7px; margin-top: -6px;
  border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(45deg); pointer-events: none;
}
.pill-select option { background: var(--surface); color: var(--ink); }
.seg { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.seg button { border: 1px solid var(--line-strong); background: none; padding: 9px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; cursor: pointer; }
.seg button:hover { border-color: var(--ink); }
.seg button.on { border-color: var(--green); color: var(--green-ink); }

/* ---- market board */
.board { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; align-items: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 20px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 22px 22px 18px; display: flex; flex-direction: column; min-width: 0;
}
.card.live { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }
.card-head { display: flex; align-items: center; gap: 14px; min-width: 0; }
.tile-icon { width: 40px; height: 40px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--surface-2); }
.tile-icon svg { width: 24px; height: 24px; }
.kicker { font-size: 14px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { margin-left: auto; color: var(--faint); font-size: 15px; white-space: nowrap; }
.card-title { margin-top: 18px; font-weight: 700; font-size: 20px; line-height: 1.25; letter-spacing: -0.01em; text-decoration: none; color: var(--ink); }
.card-title:hover { text-decoration: underline; text-underline-offset: 3px; }
.when { margin-top: 4px; color: var(--muted); font-size: 15px; display: flex; align-items: center; gap: 8px; }
.live-tag { color: var(--red); font-weight: 600; letter-spacing: 0.04em; display: inline-flex; align-items: center; gap: 7px; }
.live-tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.outs { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.out { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; }
.out.plain { grid-template-columns: minmax(0, 1fr) auto auto; }
.out-icon { width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; }
.out-icon.red { background: var(--red); }
.out-icon.blue { background: var(--blue); }
.out-icon.opt { background: var(--surface-2); color: var(--muted); }
.out-name { min-width: 0; display: flex; flex-direction: column; gap: 7px; font-size: 17px; }
.out-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.out-name a { text-decoration: none; }
.out-name a:hover { text-decoration: underline; text-underline-offset: 3px; }
.bar { display: block; height: 3px; border-radius: 2px; min-width: 18px; max-width: 100%; }
.bar.red { background: var(--red); }
.bar.blue { background: var(--blue); }
.bar.green { background: var(--green); }
.bar.gray { background: var(--faint); }
.mult { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.odds-pill {
  min-width: 96px; height: 46px; border-radius: 999px; border: 1.5px solid var(--green);
  display: grid; place-items: center; font-weight: 700; font-size: 18px; text-decoration: none;
  color: var(--ink); font-variant-numeric: tabular-nums; background: none;
}
a.odds-pill:hover { background: var(--green); color: var(--on-green); }
.odds-pill.off { border-color: var(--line-strong); color: var(--muted); }
.odds-pill.won { border-color: var(--green); background: var(--green-soft); color: var(--green-ink); }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: auto; padding-top: 26px; font-size: 15px; color: var(--muted); }
.card-foot a { text-decoration: none; color: var(--ink); }
.card-foot a:hover { text-decoration: underline; text-underline-offset: 3px; }

.empty {
  border: 1px solid var(--line); border-radius: 18px;
  padding: 44px 20px; text-align: center; color: var(--muted);
}
.empty b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }

/* ---- sidebar lists (Kalshi "Trending" panels) */
.side-col { display: flex; flex-direction: column; gap: 32px; position: sticky; top: calc(150px + env(safe-area-inset-top, 0px)); }
.list-card { border: 1px solid var(--line); border-radius: 18px; padding: 8px 22px 12px; background: var(--surface); }
.list-card h3 { margin: 0; padding: 18px 0 16px; font-size: 20px; font-weight: 700; border-bottom: 1px solid var(--line); }
.list-card ol { list-style: none; margin: 0; padding: 0; }
.list-card li a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; padding: 18px 0 4px; text-decoration: none; }
.list-card .l-title { font-size: 16px; line-height: 1.35; }
.list-card .l-sub { color: var(--muted); font-size: 15px; }
.list-card .l-val { text-align: right; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.list-card .l-chg { display: block; font-size: 14px; font-weight: 600; }
.list-card p { color: var(--muted); font-size: 15px; margin: 16px 0 8px; }
.up { color: var(--green-ink); }
.down { color: var(--red); }

/* ---- market detail */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 48px; align-items: start; }
.detail .card-head { margin-bottom: 18px; }
.alliances { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0 4px; }
.alliance { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border-radius: 12px; font-size: 16px; font-weight: 600; border: 1px solid var(--line); }
.alliance .out-icon { width: 28px; height: 28px; border-radius: 7px; }
.alliance .pred { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.alliance a { text-decoration: none; }
.alliance a:hover { text-decoration: underline; }
.sibs { display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap; }

.headline { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-top: 26px; }
.big { font: 800 48px/1 var(--display); font-stretch: 75%; font-variant-numeric: tabular-nums; }
.big-label { font-weight: 600; color: var(--muted); font-size: 17px; }
.delta { font-weight: 600; }
.sbnote { color: var(--muted); font-size: 15px; margin-top: 6px; }
.status { color: var(--muted); font-size: 15px; }

.legend { display: flex; gap: 22px; font-size: 16px; color: var(--muted); flex-wrap: wrap; margin-top: 22px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend b { color: var(--ink); font-weight: 700; }
.legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.legend i.red { background: var(--red); }
.legend i.blue { background: var(--blue); }
.legend i.dash { width: 18px; height: 0; border-radius: 0; background: none; border-top: 2px dashed var(--faint); }
.chart { width: 100%; height: 300px; display: block; margin-top: 8px; }
.chart .grid-line { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 1 5; stroke-linecap: round; }
.chart .axis { fill: var(--muted); font: 13px var(--font); }
.chart .line { fill: none; stroke-width: 2.5; stroke-linejoin: round; }
.chart .line.green { stroke: var(--green); }
.chart .line.red { stroke: var(--red); }
.chart .line.blue { stroke: var(--blue); }
.chart .anchor { fill: none; stroke: var(--faint); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .end { stroke: var(--bg); stroke-width: 2; }
.chart .end.green { fill: var(--green); }
.chart .end.red { fill: var(--red); }
.chart .end.blue { fill: var(--blue); }

.section { margin-top: 40px; }
.rules { color: var(--muted); font-size: 16px; line-height: 1.55; }
.rules p { margin: 0 0 12px; max-width: 72ch; }
.rules p:last-child { margin: 0; }
.rules b { color: var(--ink); font-weight: 600; }

.result {
  border-radius: 14px; padding: 16px 20px; margin-top: 22px; font-weight: 600; border: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center;
}
.result.yes, .result.no { border-color: var(--green); }
.result .num { font-size: 18px; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-size: 14px; color: var(--muted); font-weight: 500; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
.table-wrap { border: 1px solid var(--line); border-radius: 18px; overflow-x: auto; background: var(--surface); }
.table-wrap td a { text-decoration: none; font-weight: 600; }
.table-wrap td a:hover { text-decoration: underline; }
.pos { color: var(--green-ink); }
.neg { color: var(--red); }
tr.you td { background: var(--green-soft); }
.rank { color: var(--muted); width: 3ch; font-variant-numeric: tabular-nums; }
.rank.top { color: var(--ink); font-weight: 700; }
.tag { font-weight: 600; font-size: 13px; padding: 2px 8px; border-radius: 6px; }
.tag.yes { background: var(--green-soft); color: var(--green-ink); }
.tag.no { background: var(--no-soft); color: var(--no); }

/* ---- trade panel */
.ticket {
  background: var(--raised); border: 1px solid var(--line); border-radius: 18px; padding: 22px;
  position: sticky; top: calc(150px + env(safe-area-inset-top, 0px)); display: flex; flex-direction: column; gap: 18px;
}
.ticket-q { font-weight: 700; font-size: 17px; line-height: 1.3; }
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 0 0 12px; font-weight: 600; font-size: 16px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--ink); border-color: var(--ink); }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.side {
  border: 1.5px solid var(--line-strong); background: transparent; border-radius: 999px; padding: 12px 10px;
  cursor: pointer; font-weight: 700; font-size: 16px; display: flex; justify-content: center; gap: 8px; align-items: baseline;
}
.side small { font-weight: 600; font-size: 15px; }
.side .num { font-size: 16px; }
.side.yes.on { border-color: var(--green); background: var(--green); color: var(--on-green); }
.side.no.on { border-color: var(--no); background: var(--no); color: #fff; }
.qty { display: flex; flex-direction: column; gap: 8px; }
.qty label { font-size: 15px; font-weight: 600; }
.qty-box { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; border: 1px solid var(--line-strong); border-radius: 14px; overflow: hidden; }
.qty-box button { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.qty-box button:hover { color: var(--ink); }
.qty-box input { border: 0; background: none; text-align: center; font-size: 20px; font-weight: 700; padding: 12px 0; min-width: 0; font-variant-numeric: tabular-nums; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.quick button { border: 1px solid var(--line-strong); background: none; border-radius: 999px; padding: 5px 14px; font-size: 14px; font-weight: 600; cursor: pointer; }
.quick button:hover { border-color: var(--ink); }
.summary { display: flex; flex-direction: column; gap: 9px; font-size: 15px; }
.summary div { display: flex; justify-content: space-between; gap: 10px; }
.summary span { color: var(--muted); }
.summary .win { color: var(--green-ink); }
.place { width: 100%; padding: 15px; border-radius: 999px; font-size: 16px; font-weight: 700; border: 0; cursor: pointer; background: var(--green); color: var(--on-green); }
.place.no { background: var(--no); color: #fff; }
.place:disabled { opacity: 0.45; cursor: not-allowed; }
.ticket .note { font-size: 15px; color: var(--muted); margin: 0; }
.ticket .err { color: var(--red); font-size: 14px; font-weight: 600; margin: 0; }
.ticket .err:empty { display: none; }
.holding { border-top: 1px solid var(--line); padding-top: 14px; font-size: 15px; display: flex; flex-direction: column; gap: 6px; }
.holding div { display: flex; justify-content: space-between; }

/* ---- portfolio tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 40px; }
.tile { border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; background: var(--surface); }
.tile small { display: block; font-size: 15px; color: var(--muted); }
.tile b { display: block; font-size: 26px; margin-top: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- admin */
.panel { border: 1px solid var(--line); border-radius: 18px; padding: 22px; margin-bottom: 24px; background: var(--surface); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input { border: 1px solid var(--line-strong); border-radius: 999px; padding: 10px 16px; background: transparent; min-width: 0; flex: 1 1 180px; }
.search-list { max-height: 380px; overflow: auto; margin-top: 12px; border-top: 1px solid var(--line); }
.search-list div { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.search-list code { color: var(--muted); font-size: 14px; }
.warn-text { color: var(--warn); font-size: 14px; }

/* ---- modal + toast */
.modal-back { position: fixed; inset: 0; background: rgb(0 0 0 / 0.55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--raised); border: 1px solid var(--line); border-radius: 20px; padding: 26px; width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; }
.modal-title { margin: 0; font: 800 30px/1.1 var(--display); font-stretch: 72%; }
.modal label { display: flex; flex-direction: column; gap: 8px; font-size: 14px; font-weight: 600; }
.modal input { border: 1px solid var(--line-strong); border-radius: 12px; padding: 12px 14px; background: transparent; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-error { color: var(--red); font-size: 14px; font-weight: 600; margin: 0; }
.form-error:empty { display: none; }
.form-note { color: var(--muted); font-size: 14px; margin: 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-weight: 600; font-size: 15px;
  z-index: 60; max-width: calc(100% - 32px);
}

/* ---- admin: create market form, question cards, users */
.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: flex; flex-direction: column; gap: 8px; font-size: 14px; font-weight: 600; }
.form .opt { font-weight: 400; color: var(--faint); }
.form input, .form textarea, .form select, .q-settle input {
  border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 14px; background: transparent;
  font: inherit; font-size: 15px; color: var(--ink); min-width: 0; width: 100%;
}
.form select option { background: var(--surface); }
.form textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.opt-head, .opt-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 40px; gap: 8px; align-items: center; }
.opt-head { font-size: 14px; color: var(--muted); }
.opt-row { margin-top: 8px; }
.opt-row .num { text-align: right; }
.opt-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.q-card { display: flex; flex-direction: column; gap: 14px; }
.q-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: start; }
.q-actions, .q-settle, .row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-actions { justify-content: flex-end; }
.q-opt { display: grid; grid-template-columns: minmax(0, 1fr) 70px auto auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.q-opt:first-child { border-top: 0; }
.q-opt .sub { margin: 0; font-size: 14px; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--green); }
.inline-label { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 600; flex-wrap: wrap; }
.q-settle input { width: auto; }
.badge { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); }
.badge.admin { border-color: var(--blue); color: var(--blue); }
.badge.owner { border-color: var(--green); color: var(--green-ink); }
.panel code { font-size: 14px; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }

/* ---- GP (play money) */
.gp { display: inline-flex; align-items: center; gap: 0.28em; white-space: nowrap; }
.gp-coin { width: 1.05em; height: 1.05em; flex: none; }
.gp-coin circle { fill: #E8B53A; }
.gp-coin .ring { fill: none; stroke: #9A6F0B; stroke-width: 1; }
.gp-coin text { font: 800 7px var(--font); fill: #5C4100; text-anchor: middle; letter-spacing: -0.2px; }

@media (max-width: 1100px) {
  .board, .detail { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .side-col, .ticket { position: static; }
  .nav { gap: 20px; }
}
/* ---- phones: Kalshi app layout. Top bar = logo + balance + account; sections move to a bottom
   tab bar with the search pill floating above it; market pages trade from a bottom sheet. */
.tabbar, .trade-bar, .sheet-close { display: none; }
@media (max-width: 860px) {
  body { padding-bottom: calc(146px + env(safe-area-inset-bottom, 0px)); }
  body.on-market { padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }
  .topbar-inner { flex-wrap: nowrap; gap: 12px; padding: 10px 16px; min-height: 58px; }
  .brand span { font-size: 23px; }
  .brand-mark { width: 30px; height: 30px; }
  .nav { display: none; }
  .account { margin-left: auto; gap: 8px; }
  .account .btn { padding: 8px 16px; font-size: 14px; }
  .acct-signup { display: none; }
  .acct-login { background: var(--green); color: var(--on-green); border-color: var(--green); }
  .who { padding: 8px 14px; }
  .bal.hide-sm { display: none; }
  .search {
    position: fixed; left: 16px; right: 16px; z-index: 31; margin: 0; max-width: none; height: 50px;
    bottom: calc(74px + env(safe-area-inset-bottom, 0px)); border: 1px solid var(--line-strong);
    box-shadow: 0 0 0 8px var(--bg);
  }
  body.on-market .search, body.on-market .tabbar { display: none; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--bg);
    border-top: 1px solid var(--line); padding: 6px 4px calc(4px + env(safe-area-inset-bottom, 0px));
  }
  .tabbar::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 72px; pointer-events: none;
    background: linear-gradient(to top, var(--bg) 75%, transparent); }
  .tabbar a { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600; }
  .tabbar a.on { color: var(--ink); }
  .tabbar svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .live-dot { position: absolute; top: 3px; left: calc(50% + 7px); width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

  .cats-wrap, .page, .foot { padding-left: 16px; padding-right: 16px; }
  .cats { gap: 26px; padding: 4px 0 12px; }
  .cats a { font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
  .cats a.on { font-weight: 700; }
  .cats a:first-child { margin-right: 0; }

  .page { padding-top: 18px; }
  .page-head { flex-wrap: nowrap; margin-bottom: 16px; }
  h1, .h-display { font-size: 30px; }
  .page-head h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .page-head:has(.chips) { flex-wrap: wrap; }
  .page-head .chips { width: 100%; flex-wrap: nowrap; }
  .page-head .chips .pill-select { flex: 1; min-width: 0; }
  .page-head .chips select { width: 100%; }
  .quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .quick button { padding: 7px 4px; }
  .pill-select select { padding: 9px 38px 9px 16px; font-size: 14px; }
  .pill-select::after { right: 16px; }
  .grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .card { padding: 18px 16px 16px; border-radius: 20px; }
  .card-head { gap: 12px; }
  .tile-icon { width: 44px; height: 44px; border-radius: 11px; }
  .kicker { font-size: 13px; }
  .card-title { margin-top: 14px; font: 800 28px/1.06 var(--display); font-stretch: 74%; letter-spacing: -0.01em; }
  .when { font-size: 14px; }
  .outs { gap: 12px; margin-top: 18px; }
  .out { grid-template-columns: 36px minmax(0, 1fr) auto auto; gap: 12px; }
  .out.plain { grid-template-columns: minmax(0, 1fr) auto auto; }
  .out-icon { width: 36px; height: 36px; border-radius: 8px; font-size: 12px; }
  .out-name { font-size: 17px; }
  .mult { font-size: 14px; }
  .odds-pill {
    min-width: 80px; height: 46px; font-size: 18px; color: var(--green);
    border-color: color-mix(in srgb, var(--green) 45%, transparent); background: color-mix(in srgb, var(--green) 7%, transparent);
  }
  .odds-pill.off { color: var(--muted); background: none; }
  .card-foot { padding-top: 20px; font-size: 14px; }
  .board { gap: 32px; }
  .side-col { gap: 20px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .foot { padding-bottom: 20px; }

  /* market page */
  .detail h1 { font-size: 34px; }
  .chart { height: 230px; }
  .trade-bar {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--bg); border-top: 1px solid var(--line);
  }
  .trade-bar button { height: 52px; border: 0; border-radius: 999px; font-weight: 700; font-size: 16px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 12px; }
  .trade-bar .yes { background: var(--green); color: var(--on-green); }
  .trade-bar .no { background: var(--no); color: #fff; }
  .ticket.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 46; max-height: 88vh; overflow-y: auto;
    border-radius: 22px 22px 0 0; border-bottom: 0; padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    transform: translateY(105%); transition: transform 0.22s ease; visibility: hidden;
  }
  .ticket.sheet.open { transform: none; visibility: visible; }
  .sheet-back { position: fixed; inset: 0; z-index: 45; background: rgb(0 0 0 / 0.55); }
  .ticket.sheet .sheet-close { display: block; }
  .ticket-top { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
  .sheet-close { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-strong); background: none; color: var(--muted); font-size: 14px; cursor: pointer; }
}
@media (max-width: 640px) {
  .big { font-size: 40px; }
  .hide-sm { display: none; }
  .q-opt { grid-template-columns: minmax(0, 1fr) 60px auto; }
  .q-opt .sub { display: none; }
  #q-kind { display: flex; overflow-x: auto; flex-wrap: nowrap; }
}
@media (max-width: 380px) {
  .out .mult { display: none; }
  .out { grid-template-columns: 36px minmax(0, 1fr) auto; }
  .out.plain { grid-template-columns: minmax(0, 1fr) auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---- account menu */
.acct { position: relative; }
.acct-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 180px; z-index: 30;
  background: var(--raised); border: 1px solid var(--line); border-radius: 14px; padding: 6px;
  display: flex; flex-direction: column;
}
.acct-menu a, .acct-menu button { text-align: left; padding: 10px 12px; border-radius: 9px; text-decoration: none; background: none; border: 0; cursor: pointer; font-size: 15px; }
.acct-menu a:hover, .acct-menu button:hover { background: var(--surface-2); }
.pill-plain { border: 1px solid var(--line-strong); border-radius: 999px; padding: 10px 16px; background: transparent; color: var(--ink); min-width: 0; flex: 1 1 220px; }
.pill-plain option { background: var(--surface); }
