:root {
  color-scheme: dark;
  --bg: #0e1116; --surface: #161b22; --surface2: #1d242e; --line: #2a323d;
  --text: #eef2f7; --muted: #8b96a5; --accent: #4f8cff;
  --yes: #27ae60; --yes-soft: #173a28; --no: #e0474c; --no-soft: #3d1c1f;
  --radius: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 Inter, "Segoe UI", system-ui, Arial, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: var(--accent); }
h1 { font-size: 24px; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 24px 0 10px; }
.card h2 { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
code { background: var(--surface2); border-radius: 5px; padding: 1px 5px; font-size: 12px; }

/* top bar and tabs */
.topbar { position: sticky; top: 0; z-index: 5; background: rgba(14,17,22,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-inner, .tabs, .page { max-width: 1100px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 900; }
.brand strong { display: block; font-size: 16px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.controls { display: flex; align-items: center; gap: 10px; }
.mode-switch { display: flex; background: var(--surface2); border-radius: 999px; padding: 3px; }
.mode-switch button { border: 0; background: transparent; border-radius: 999px; padding: 6px 13px; font-size: 13px; font-weight: 700; color: var(--muted); }
.mode-switch button.active { background: var(--text); color: var(--bg); }
.mode-switch button.active[data-mode="live"] { background: var(--no); color: #fff; }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; color: var(--muted); font-weight: 700; padding: 11px 12px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--text); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

/* page */
.page { padding-top: 16px; padding-bottom: 40px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 16px; }
.status-bar { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.status-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status-bar.running .dot { background: var(--yes); box-shadow: 0 0 0 4px var(--yes-soft); }
.status-bar.paused .dot { background: var(--no); }
.status-bar.paused { color: #ffb4b7; }
.notice { background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.notice.error { background: var(--no-soft); border-color: #6b2a2e; color: #ffd9db; }
.notice[hidden] { display: none; }
.notice button { margin-left: 8px; border: 0; background: transparent; color: #fff; text-decoration: underline; font-weight: 700; }
footer { margin-top: 36px; }

/* buttons */
.btn { border: 1px solid transparent; border-radius: 10px; padding: 9px 15px; font-weight: 700; white-space: nowrap; text-decoration: none; display: inline-block; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary.stop { background: var(--surface2); border-color: var(--line); color: var(--text); }
.btn-secondary { background: var(--surface2); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { background: transparent; border-color: #6b2a2e; color: var(--no); }
.link { border: 0; background: transparent; color: var(--accent); font-weight: 700; padding: 0; }
.icon-btn { border: 0; background: var(--surface2); border-radius: 50%; width: 32px; height: 32px; flex: none; }
.row { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }

/* market cards */
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.mcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.mcard-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.mcard-title small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.mcard-title strong { display: block; font-size: 15px; line-height: 1.3; }
.chance { text-align: right; flex: none; }
.chance b { display: block; font-size: 22px; line-height: 1; }
.chance small { color: var(--muted); font-size: 11px; }
.mcard-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.outcome { border: 0; border-radius: 10px; padding: 11px 8px; font-weight: 800; font-size: 15px; }
.outcome.yes { background: var(--yes-soft); color: #6fe0a0; }
.outcome.no { background: var(--no-soft); color: #ff8e92; }
.outcome.yes:hover:not(:disabled), .outcome.yes.selected { background: var(--yes); color: #fff; }
.outcome.no:hover:not(:disabled), .outcome.no.selected { background: var(--no); color: #fff; }
.mcard-foot { display: flex; justify-content: space-between; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }
.tag { border-radius: 6px; padding: 2px 7px; font-size: 11px; font-weight: 800; }
.tag.auto { background: #1f2d4a; color: #9dbcff; }
.tag.yes { background: var(--yes-soft); color: #6fe0a0; }
.tag.no { background: var(--no-soft); color: #ff8e92; }
.tag.stale { background: #3a321c; color: #ffd27a; }
.empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }

/* lists */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.item-main { min-width: 0; }
.item-main strong { display: block; font-size: 14px; overflow-wrap: anywhere; }
.item-main small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.item-side { display: flex; align-items: center; gap: 12px; flex: none; text-align: right; }
.item-side b { display: block; }
.list.compact .item { padding: 9px 12px; font-size: 13px; }
.search-result { width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface2); }
.search-result:hover { border-color: var(--muted); }
.positive { color: #6fe0a0; }
.negative { color: #ff8e92; }

/* summary tiles and cards */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.summary.six { grid-template-columns: repeat(4, 1fr); }
.summary div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.summary small { display: block; color: var(--muted); font-size: 12px; }
.summary strong { display: block; font-size: 20px; margin-top: 2px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.pill { border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; background: var(--surface2); color: var(--muted); }
.pill.good { background: var(--yes-soft); color: #6fe0a0; }

/* forms */
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields label, #thesis-field { display: block; font-size: 12px; font-weight: 700; color: var(--muted); }
input:not([type="checkbox"]), select { display: block; width: 100%; margin-top: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; outline: none; }
input:focus, select:focus { border-color: var(--accent); }
.more { margin-top: 14px; }
.more summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 700; }
.switch { display: flex; align-items: center; gap: 10px; margin: 16px 0 6px; font-weight: 700; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

/* sheets (dialogs) */
.sheet { border: 0; padding: 0; background: transparent; color: var(--text); width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
.sheet::backdrop { background: rgba(0,0,0,.6); }
.sheet-body { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.sheet-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.sheet-head strong { display: block; font-size: 16px; line-height: 1.3; }
.sheet-head small { display: block; font-size: 12px; }
.outcome-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.outcome-toggle.small .outcome { padding: 8px; font-size: 14px; }
.amount { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-weight: 700; }
.amount-input { display: flex; align-items: center; gap: 4px; font-size: 30px; font-weight: 800; }
.amount-input input { margin: 0; width: 150px; text-align: right; font-size: 30px; font-weight: 800; background: transparent; border: 0; padding: 0; }
.chips { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: var(--surface2); border-radius: 8px; padding: 5px 10px; font-size: 13px; font-weight: 700; }
.receipt { margin: 0; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 12px; }
.receipt div { display: flex; justify-content: space-between; font-size: 14px; }
.receipt dt { color: var(--muted); }
.receipt dd { margin: 0; font-weight: 700; }
.receipt .win dd { color: #6fe0a0; font-size: 20px; }
.receipt .win dt { align-self: center; }
.autosell { display: flex; gap: 8px; align-items: baseline; background: var(--surface2); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.autosell span { color: var(--muted); }
.autosell strong { flex: 1; }
.btn-buy { width: 100%; border: 0; border-radius: 12px; padding: 14px; font-size: 16px; font-weight: 800; color: #fff; }
.btn-buy.yes { background: var(--yes); }
.btn-buy.no { background: var(--no); }
.search { display: flex; gap: 8px; }
.search input { margin: 0; }
.picked strong { display: block; }
.picked small { display: block; font-size: 12px; }
#search-results { max-height: 50vh; overflow: auto; margin-top: 10px; }

/* home feed */
.page > .panel > .search { margin: 4px 0 10px; }
.chips-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; scrollbar-width: none; }
.chips-row button { flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 6px 13px; font-size: 13px; font-weight: 700; }
.chips-row button.active { background: var(--text); color: var(--bg); border-color: var(--text); }
#feed:empty, #market-grid:empty { display: none; }
#feed { margin-top: 0; }
.ecard-head { display: flex; gap: 10px; align-items: flex-start; }
.ecard-head img { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface2); }
.ecard-head .mcard-title { flex: 1; min-width: 0; }
.orow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 6px; align-items: center; font-size: 13px; }
.orow-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orow-chance { font-weight: 800; min-width: 38px; text-align: right; }
.orow .outcome { padding: 6px 8px; font-size: 12px; min-width: 64px; }
.orows { display: flex; flex-direction: column; gap: 8px; }
.show-all { align-self: flex-start; }
#more-btn { margin-top: 16px; }

/* sections, carousels, and event cards */
.section { margin-bottom: 26px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-head button { border: 0; background: transparent; font-size: 18px; font-weight: 800; padding: 0; }
.section-head button::after { content: " ›"; color: var(--muted); }
.carousel { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(290px, calc((100% - 28px) / 3)); gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; scrollbar-width: thin; }
.carousel > * { scroll-snap-align: start; }
.ecard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ecard-top { display: flex; gap: 10px; align-items: flex-start; }
.ecard-top img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface2); }
.ecard-title { min-width: 0; flex: 1; }
.ecard-title strong { display: block; font-size: 15px; line-height: 1.25; }
.ecard-title small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ecard-title small .live { color: var(--no); font-weight: 800; }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--no); margin-right: 6px; vertical-align: 1px; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.orow2 { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; font-size: 14px; }
.orow2 .logo { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; background: var(--surface2); }
.orow2 .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.orow2 .mult { color: var(--muted); font-size: 13px; }
.pill-btn { border: 1px solid var(--line); background: var(--surface2); border-radius: 10px; min-width: 60px; padding: 6px 10px; font-weight: 800; }
.pill-btn:hover { border-color: var(--text); }
.pill-btn.no:hover { border-color: var(--no); }
.ecard-foot { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; margin-top: auto; }
.score { color: var(--text); font-weight: 700; font-size: 12px; }

.focus-toggle .outcome { background: var(--surface2); color: var(--muted); }
.focus-toggle .outcome.selected, .focus-toggle .outcome:hover:not(:disabled) { background: var(--text); color: var(--bg); }

/* chart */
.chart-box { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.chart-head { display: flex; align-items: baseline; gap: 8px; }
.chart-head strong { font-size: 22px; }
#chart { width: 100%; height: 120px; display: block; margin-top: 6px; }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.range-chips { display: flex; gap: 6px; margin-top: 8px; }
.range-chips button { border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 800; padding: 3px 7px; border-radius: 6px; }
.range-chips button.active { background: var(--surface2); color: var(--text); }
.switch.big span { font-size: 14px; }
.switch.big input { width: 22px; height: 22px; }

/* Polymarket-style cards */
.team-buttons { display: grid; gap: 8px; }
.team-btn { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; width: 100%; text-align: left;
  border: 1px solid var(--line); background: var(--surface2); border-radius: 10px; padding: 9px 10px; font-weight: 700; }
.team-btn .logo { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; }
.team-btn .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-btn .team-chance { color: var(--muted); font-size: 13px; }
.team-btn [data-price] { border-radius: 7px; padding: 3px 8px; font-size: 13px; min-width: 50px; text-align: center; }
.team-btn.yes [data-price] { background: var(--yes-soft); color: #6fe0a0; }
.team-btn.no [data-price] { background: var(--no-soft); color: #ff8e92; }
.team-btn:hover:not(:disabled) { border-color: var(--muted); }
/* Head-to-head: each team is its own neutral button in its team color, not a green "Yes" and a red "No". */
.team-btn.team { grid-template-columns: 22px minmax(0, 1fr) auto auto; border-left: 4px solid var(--team, var(--accent)); }
.team-btn.team .team-chance { display: none; }   /* the price already is the chance */
.team-btn.team [data-price] { background: color-mix(in srgb, var(--team, var(--accent)) 28%, var(--bg)); color: var(--text); font-weight: 600; }
.team-btn.team:hover:not(:disabled) { border-color: var(--team, var(--muted)); border-left-color: var(--team, var(--accent)); }
.team-btn .name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.team-btn .team-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-btn .team-score { font-weight: 700; font-size: 15px; min-width: 1ch; text-align: right; }
.team-btn .team-score:empty { display: none; }
.turn { flex: none; font-size: 12px; line-height: 1; }
.team-btn.has-turn .team-name { font-weight: 700; }
.game-detail { margin-top: 6px; font-size: 12px; color: var(--muted); }
.game-detail:empty { display: none; }
/* Buy sheet with two teams: team-colored choices. */
.outcome-toggle.teams .outcome { background: var(--surface2); color: var(--text); border: 2px solid transparent; border-left: 5px solid var(--team, var(--accent)); }
.outcome-toggle.teams .outcome:hover:not(:disabled) { background: color-mix(in srgb, var(--team, var(--accent)) 20%, var(--bg)); color: var(--text); }
.outcome-toggle.teams .outcome.selected { background: color-mix(in srgb, var(--team, var(--accent)) 35%, var(--bg)); color: #fff; border-color: var(--team, var(--accent)); }
.big-chance b { font-size: 26px; }
.big-chance small { color: var(--muted); }
.orow { grid-template-columns: minmax(0, 1fr) auto auto auto; }
.mini { border: 0; border-radius: 7px; padding: 5px 6px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.orow { gap: 5px; }
.orow-chance { min-width: 30px; }
.mini.yes { background: var(--yes-soft); color: #6fe0a0; }
.mini.no { background: var(--no-soft); color: #ff8e92; }
.mini.yes:hover:not(:disabled) { background: var(--yes); color: #fff; }
.mini.no:hover:not(:disabled) { background: var(--no); color: #fff; }
.tick { animation: tick .8s ease-out; }
@keyframes tick { from { background: rgba(79, 140, 255, .45); } }
.exit-pick { display: grid; gap: 8px; font-size: 13px; }
.exit-pick > div { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.exit-pick span { color: var(--muted); }
.chips.left { justify-content: flex-start; }
.pgroup { margin-top: 18px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; }
.pgroup.live { border-color: color-mix(in srgb, var(--no) 45%, var(--line)); }
.pgroup.paper { border-style: dashed; }
.pgroup-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 14px; margin-bottom: 8px; }
.pgroup-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 17px; }
.pgroup-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.pgroup-stats b { font-weight: 700; }
.mode-badge { font-size: 10px; font-weight: 800; letter-spacing: .06em; padding: 3px 7px; border-radius: 6px; }
.mode-badge.live { background: var(--no); color: #fff; }
.mode-badge.paper { background: var(--surface2); color: var(--muted); border: 1px solid var(--line); }
.item .src { color: var(--text); font-weight: 600; }
.tag.team { background: color-mix(in srgb, var(--team, var(--accent)) 30%, var(--bg)); color: var(--text); border-left: 3px solid var(--team, var(--accent)); }
.lot-rules { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.lot-rules b { color: var(--accent); font-weight: 600; }
.lot-editor { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface2); }
.lot-editor .chips { flex-wrap: wrap; gap: 6px; }
.lot-editor input[type=number] { width: 64px; padding: 4px 6px; font-size: 13px; }
.lot-editor small { margin-top: -4px; }
.lot-editor > div:not(.row) { flex-direction: column; align-items: flex-start; }
.chips button.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.chart-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.legend { border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; padding: 0; display: flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.legend.yes i { background: var(--yes); }
.legend.no i { background: var(--no); }
.legend.on { color: var(--text); }
.legend b { color: var(--text); }

.score-line { display: block; color: var(--no); font-weight: 800; font-size: 13px; margin-top: 3px; }
.ecard-title small.score { font-size: 13px; }

.receipt .loss dd { color: #ff8e92; }

@media (max-width: 700px) {
  .carousel { grid-auto-columns: 86%; }
  .topbar-inner, .tabs, .page { padding-left: 16px; padding-right: 16px; }
  .brand small { display: none; }
  .fields, .fields.two { grid-template-columns: 1fr; }
  .summary.six { grid-template-columns: repeat(2, 1fr); }
  .summary strong { font-size: 17px; }
  .sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; max-height: 92vh; }
  .sheet-body { border-radius: 18px 18px 0 0; }
  .item { flex-wrap: wrap; }
}

/* sign-in page (hosted mode) */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-box { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 24px; display: grid; gap: 14px; }
.auth-box h1 { font-size: 20px; }
.auth-box form { display: grid; gap: 12px; }
.auth-box label { font-size: 12px; font-weight: 700; color: var(--muted); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface2); border-radius: 10px; padding: 3px; }
.auth-tabs button { border: 0; background: transparent; color: var(--muted); border-radius: 8px; padding: 8px; font-weight: 700; }
.auth-tabs button.active { background: var(--text); color: var(--bg); }
