@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700;12..96,800&family=Instrument+Sans:wght@400;500;600;700&display=swap');

:root {
  --ink: #1A2142;
  --ink-2: #4A5175;
  --ink-3: #7F86A6;
  --paper: #F5F6FA;
  --card: #FFFFFF;
  --line: #E1E4EF;
  --line-2: #CBD0E1;
  --brand: #2B59FF;
  --on-brand: #FFFFFF;
  --sun: #FFC531;
  --ok: #128a5b;
  --ok-bg: #E3F5EC;
  --warn: #9a5b00;
  --warn-bg: #FFF4D6;
  --bad: #C2283B;
  --bad-bg: #FDE8EB;
  --shadow: 0 1px 0 rgba(26, 33, 66, .04), 0 6px 24px -12px rgba(26, 33, 66, .25);
  --display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --body: 'Instrument Sans', 'Segoe UI', system-ui, sans-serif;
  --r-sm: 8px;
  --r: 14px;
  --r-lg: 22px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #EEF0FA; --ink-2: #B9BED6; --ink-3: #868DAD;
    --paper: #12162B; --card: #1C2140; --line: #2B3157; --line-2: #3A4170;
    --ok-bg: #12352a; --ok: #6fdcaa; --warn-bg: #3a2f10; --warn: #ffd57a; --bad-bg: #3d1820; --bad: #ff8b9a;
    --shadow: 0 6px 24px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.5 var(--body); }
h1, h2, h3 { font-family: var(--display); line-height: 1.1; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--brand); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── controls ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  border: 1.5px solid var(--line-2); background: var(--card); color: var(--ink);
  padding: .6em 1.05em; border-radius: 999px; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { border-color: var(--brand); filter: brightness(1.07); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-sm { padding: .35em .75em; font-size: .875rem; }
.btn-lg { padding: .85em 1.4em; font-size: 1.05rem; }
.btn-block { width: 100%; }

.field { display: grid; gap: .35rem; min-width: 0; }
.field > span { font-weight: 600; font-size: .9rem; }
.input, textarea.input, select.input {
  width: 100%; min-width: 0; border: 1.5px solid var(--line-2); background: var(--card); border-radius: var(--r-sm);
  padding: .65em .8em; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
textarea.input { resize: vertical; min-height: 5.5em; }

.switch { display: flex; align-items: flex-start; gap: .75rem; cursor: pointer; padding: .55rem 0; }
.switch input { appearance: none; flex: 0 0 auto; width: 40px; height: 24px; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(16px); }
.switch b { display: block; font-weight: 600; }
.switch small { color: var(--ink-3); }

.tabs { display: flex; gap: .25rem; border-bottom: 1.5px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; background: none; border: 0; padding: .7rem .9rem; font-weight: 600; color: var(--ink-3); cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::after { content: ''; position: absolute; left: .6rem; right: .6rem; bottom: -1.5px; height: 3px; border-radius: 3px 3px 0 0; background: var(--brand); }
.tab .count { font-size: .78rem; background: color-mix(in srgb, var(--ink) 9%, transparent); padding: .05rem .45rem; border-radius: 999px; margin-left: .3rem; }
.tab .live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); margin-left: .35rem; vertical-align: middle; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.pill { display: inline-flex; align-items: center; gap: .3em; font-size: .78rem; font-weight: 600; padding: .15em .6em; border-radius: 999px; background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink-2); }
.pill-live { background: var(--bad-bg); color: var(--bad); }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-brand { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--ink-3); }
.empty b { display: block; color: var(--ink); font-family: var(--display); font-size: 1.15rem; margin-bottom: .25rem; }

/* ── question list ── */
.qlist { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.q { display: grid; grid-template-columns: 1fr auto; gap: .75rem; padding: .9rem 1rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.q.is-pinned { border-color: var(--brand); box-shadow: inset 4px 0 0 var(--brand); }
.q.is-answered { opacity: .72; }
.q-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.q-meta { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .4rem; font-size: .82rem; color: var(--ink-3); }
.q-reply { margin-top: .55rem; padding: .5rem .7rem; border-radius: var(--r-sm); background: color-mix(in srgb, var(--brand) 8%, transparent); font-size: .92rem; }
.q-reply b { color: var(--brand); }
.vote { align-self: start; display: grid; justify-items: center; align-content: start; gap: 0; min-width: 52px; padding: .35rem .5rem; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--card); cursor: pointer; font-weight: 700; }
.vote svg { width: 18px; height: 18px; }
.vote.on { background: var(--sun); border-color: var(--sun); color: #1A2142; }
.vote:disabled { cursor: default; }
.q-actions { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .5rem; }

/* ── results ── */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.bar-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; margin-bottom: .3rem; }
.bar-label { font-weight: 600; overflow-wrap: anywhere; }
.bar-num { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-num small { font-weight: 500; color: var(--ink-3); }
.bar-track { height: 12px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 8%, transparent); overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: var(--brand); transition: width .7s cubic-bezier(.2, .8, .2, 1); min-width: 0; }
.bar.is-lead .bar-fill { background: var(--sun); }
.bar.is-correct .bar-fill { background: var(--ok); }
.tick { color: var(--ok); }
.bars-big { gap: 1.6rem; }
.bars-big .bar-label { font-size: 1.9rem; font-family: var(--display); }
.bars-big .bar-num { font-size: 1.9rem; }
.bars-big .bar-track { height: 26px; }

.cloud { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .2rem .9rem; padding: 1rem 0; line-height: 1.15; font-family: var(--display); font-weight: 700; }
.cloud span { transition: font-size .5s; }
.cloud .w-top { color: var(--brand); font-weight: 800; }
.cloud .w-hi { color: var(--ink); }
.cloud .w-mid { color: var(--ink-2); }
.cloud .w-lo { color: var(--ink-3); font-weight: 500; }

.rating-res { display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: center; }
.rating-avg { display: grid; justify-items: center; }
.rating-avg strong { font-family: var(--display); font-size: 3.2rem; line-height: 1; }
.rating-avg span { color: var(--ink-3); font-size: .85rem; }
.stars { color: var(--line-2); letter-spacing: .05em; font-size: 1.1rem; }
.stars .on { color: var(--sun); font-style: normal; }
.stars i { font-style: normal; }
.dist { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.dist li { display: grid; grid-template-columns: 1.5rem 1fr 2rem; gap: .5rem; align-items: center; font-variant-numeric: tabular-nums; }
.dist small { color: var(--ink-3); text-align: right; }
.rating-big .rating-avg strong { font-size: 7rem; }
.rating-big .stars { font-size: 2.4rem; }
.rating-big .dist li { grid-template-columns: 2.5rem 1fr 3rem; font-size: 1.4rem; }
.rating-big .bar-track { height: 20px; }

.texts { list-style: none; margin: 0; padding: 0; columns: 2 220px; column-gap: .7rem; }
.texts li { break-inside: avoid; margin-bottom: .7rem; padding: .7rem .9rem; border-radius: var(--r); background: color-mix(in srgb, var(--brand) 7%, var(--card)); border: 1px solid var(--line); overflow-wrap: anywhere; }
.texts-big { columns: 3 320px; }
.texts-big li { font-size: 1.45rem; padding: 1rem 1.2rem; }

.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.rank li { display: grid; grid-template-columns: 2.2rem 1fr; gap: .7rem; align-items: center; }
.rank-pos { width: 2.2rem; height: 2.2rem; display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--ink) 8%, transparent); font-weight: 800; font-family: var(--display); }
.rank li:first-child .rank-pos { background: var(--sun); color: #1A2142; }
.rank-big li { grid-template-columns: 3.5rem 1fr; }
.rank-big .rank-pos { width: 3.5rem; height: 3.5rem; font-size: 1.6rem; }
.rank-big .bar-label, .rank-big .bar-num { font-size: 1.8rem; }
.rank-big .bar-track { height: 22px; }

/* ── reactions ── */
.react-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.float-emoji { position: absolute; bottom: -60px; font-size: 2.2rem; animation: rise var(--dur, 3s) ease-out forwards; }
@keyframes rise {
  0% { transform: translate(0, 0) scale(.6); opacity: 0; }
  12% { opacity: 1; transform: translate(0, -10vh) scale(1.1); }
  100% { transform: translate(var(--drift, 0), -95vh) scale(1); opacity: 0; }
}

/* ── toasts & dialog ── */
#toasts { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); display: grid; gap: .5rem; z-index: 100; width: min(92vw, 420px); }
.toast { background: var(--ink); color: var(--paper); padding: .75rem 1rem; border-radius: 12px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.4); font-weight: 500; transition: opacity .4s, transform .4s; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }

dialog { border: 0; padding: 0; border-radius: var(--r-lg); background: var(--card); color: var(--ink); width: min(94vw, 620px); max-height: 90vh; box-shadow: 0 30px 80px -20px rgba(10, 14, 40, .55); }
dialog::backdrop { background: rgba(14, 18, 40, .55); backdrop-filter: blur(2px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.1rem 1.3rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 1; }
.dlg-body { padding: 1.2rem 1.3rem; display: grid; gap: 1rem; }
.dlg-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: 1rem 1.3rem; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--card); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .float-emoji { display: none; }
}

/* ── site chrome shared by app pages ── */
.brandmark { font-family: var(--display); font-weight: 800; font-size: 1.1rem; display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--ink); }
.brandmark i { width: 22px; height: 22px; border-radius: 7px; background: var(--brand); display: inline-block; position: relative; flex: 0 0 auto; }
.brandmark i::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--sun); }
.container { max-width: 1180px; margin: 0 auto; padding: 0 1rem; }
.site-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0; flex-wrap: wrap; }
.site-nav nav { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.site-nav nav a:not(.btn) { color: var(--ink-2); text-decoration: none; font-weight: 600; padding: .4rem .7rem; border-radius: 8px; }
.site-nav nav a:not(.btn):hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.powered { text-align: center; font-size: .82rem; padding: 1.2rem 0 1.6rem; }
.powered a { color: var(--ink-3); text-decoration: none; }
.powered a:hover { color: var(--ink); text-decoration: underline; }
.upsell { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .75rem 1rem; border-radius: var(--r); background: color-mix(in srgb, var(--sun) 22%, var(--card)); border: 1px solid color-mix(in srgb, var(--sun) 60%, var(--line)); margin-bottom: 1rem; }
.upsell p { font-weight: 500; }
.logo-img { max-height: 44px; max-width: 180px; object-fit: contain; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-weight: 600; color: var(--ink-3); font-size: .82rem; }
.tbl-wrap { overflow-x: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }
