/* tokens: light by default, dark by OS setting or data-theme="dark" */
:root {
    color-scheme: light;
    --page: #f9f9f7;
    --surface: #fcfcfb;
    --ink: #0b0b0b;
    --ink-2: #52514e;
    --muted: #898781;
    --grid: #e1e0d9;
    --border: rgba(11, 11, 11, 0.10);
    --series-1: #2a78d6;
    --series-1-track: #b7d3f6;
    --good: #0ca30c;
    --good-text: #006300;
    --bad: #d03b3b;
    --bad-text: #d03b3b;
    --warn: #fab219;
}

@media (prefers-color-scheme: dark) {
    :root:where(:not([data-theme="light"])) {
        color-scheme: dark;
        --page: #0d0d0d;
        --surface: #1a1a19;
        --ink: #ffffff;
        --ink-2: #c3c2b7;
        --muted: #898781;
        --grid: #2c2c2a;
        --border: rgba(255, 255, 255, 0.10);
        --series-1: #3987e5;
        --series-1-track: #184f95;
        --good-text: #0ca30c;
        --bad-text: #e66767;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-1-track: #184f95;
    --good-text: #0ca30c;
    --bad-text: #e66767;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    background: var(--page);
    color: var(--ink);
    font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
    padding: 16px;
}

h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 15px; color: var(--ink); }
p { margin: 0; }

.muted { color: var(--muted); }
.hint { color: var(--ink-2); font-size: 13px; margin: 4px 0 12px; }
.empty { color: var(--muted); padding: 12px 0; }
.up { color: var(--good-text); }
.down { color: var(--bad-text); }
a { color: var(--series-1); }
/* a bucket links to its market; the text keeps its color */
a.pm-link { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--muted); }
a.pm-link:hover { border-bottom-color: var(--ink); }

/* header */
.topbar {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 24px;
    align-items: center;
    padding: 12px 16px 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.brand-sub { color: var(--ink-2); font-size: 13px; }
.hero { text-align: right; }
.hero-value { font-size: 48px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.hero-meta { color: var(--ink-2); font-size: 13px; margin-top: 4px; }
.topstats { display: flex; gap: 20px; margin: 0; }
.topstats div { min-width: 80px; }
.topstats dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.topstats dd { margin: 2px 0 0; font-size: 15px; font-variant-numeric: tabular-nums; }

.banner {
    background: var(--warn);
    color: #0b0b0b;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 13px;
}
.banner.info { background: var(--series-1); color: #fff; }

main { display: grid; gap: 16px; }
.events { display: grid; gap: 16px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }

/* event cards */
.event h2 { font-size: 16px; }
.event h2 a { color: inherit; text-decoration: none; }
.event h2 a:hover { text-decoration: underline; }
.event .hint { margin-bottom: 0; }
.counts { display: flex; align-items: center; gap: 8px; white-space: nowrap; }

.buckets { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 12px; }
.bucket {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 64px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--page);
    color: var(--ink-2);
    text-decoration: none;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.bucket.active { border-color: var(--series-1); background: color-mix(in srgb, var(--series-1) 10%, transparent); color: var(--ink); }
/* chips with rows are buttons that filter the table to their bucket */
button.bucket { font-family: inherit; cursor: pointer; }
button.bucket:hover { background: color-mix(in srgb, var(--series-1) 20%, transparent); }
.bucket.selected { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: color-mix(in srgb, var(--series-1) 24%, transparent); }
.bucket-title { font-weight: 600; }
.bucket-holders { display: flex; gap: 6px; font-size: 11px; font-weight: 600; }
.bucket-holders .yes { color: var(--good-text); }
.bucket-holders .no { color: var(--bad-text); }

/* tables */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
th.num, td.num { text-align: right; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--ink) 3%, transparent); }
tbody tr:hover { background: color-mix(in srgb, var(--series-1) 10%, transparent); }
tbody tr.exited td { color: var(--muted); }
td.empty { color: var(--muted); text-align: center; padding: 14px; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}
.badge.side.yes { background: var(--good); }
.badge.side.no { background: var(--bad); }
.badge.count { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.badge.count.hot { background: var(--series-1); color: #fff; }
.badge.decided { background: var(--warn); color: #0b0b0b; }
/* long usernames (some are a wallet address) must not stretch the tables */
td a[title^="0x"] { display: inline-block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
/* the expert's position in our list by week leaderboard pnl, before the name */
.rank { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.badge.status { color: var(--ink-2); background: color-mix(in srgb, var(--ink) 6%, transparent); font-weight: 500; }
.badge.status.holding { color: var(--good-text); background: color-mix(in srgb, var(--good) 14%, transparent); }
.badge.status.exited { color: var(--muted); }
.badge.source { color: var(--ink-2); background: color-mix(in srgb, var(--ink) 6%, transparent); font-weight: 500; font-size: 11px; }

/* long lists scroll inside their card instead of stretching the page */
.scroll { max-height: 520px; overflow: auto; }
.scroll table thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }

/* filters */
.filters { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filters-gap { width: 8px; }
.filters button {
    background: transparent;
    color: var(--ink-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px 12px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.filters button[aria-pressed="true"] { background: var(--series-1); border-color: var(--series-1); color: #fff; }

@media (max-width: 900px) {
    .topbar { grid-template-columns: 1fr; }
    .hero { text-align: left; }
    th, td { white-space: normal; }
}
