:root {
  --bg: #f5f7fa; --card: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e3e7ee;
  --accent: #425ebb; --accent-ink: #ffffff; --accent-soft: #e6ebfa; --accent-strong: #334a9a;
  --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a111e; --card: #121b2d; --ink: #eef2f8; --muted: #94a3b8; --line: #233049;
    --accent: #7f9bf5; --accent-ink: #0a1230; --accent-soft: #1a2547; --accent-strong: #a9bcfa;
    --warn: #fbbf24; --warn-soft: #3a2c0b; --bad: #fca5a5; --bad-soft: #3b1414;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a111e; --card: #121b2d; --ink: #eef2f8; --muted: #94a3b8; --line: #233049;
  --accent: #7f9bf5; --accent-ink: #0a1230; --accent-soft: #1a2547; --accent-strong: #a9bcfa;
  --warn: #fbbf24; --warn-soft: #3a2c0b; --bad: #fca5a5; --bad-soft: #3b1414;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100dvh;
}
h1, h2, h3, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px 96px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 650; text-decoration: none; white-space: nowrap;
  transition: transform .12s ease, background .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.soft { background: var(--accent-soft); color: var(--accent-strong); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.sm { min-height: 38px; padding: 0 14px; border-radius: 11px; font-size: 14px; }
@media (hover: hover) {
  .btn:not([disabled]):hover { background: var(--accent-strong); }
  .btn.ghost:not([disabled]):hover { background: var(--accent-soft); }
  .btn.soft:not([disabled]):hover { background: var(--accent-soft); filter: brightness(.96); }
  .btn.danger:not([disabled]):hover { background: var(--bad-soft); filter: brightness(.96); }
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.field {
  width: 100%; border: 1.5px solid var(--line); background: var(--card); border-radius: 14px;
  padding: 13px 14px; outline: none; transition: border-color .15s ease;
}
.field:focus { border-color: var(--accent); }
textarea.field { resize: none; display: block; }
label.lab { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 650; background: var(--accent-soft); color: var(--accent-strong); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.plain { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.seg button { padding: 7px 14px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; z-index: 50;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 600;
  max-width: calc(100vw - 32px); text-align: center; pointer-events: none;
  transition: opacity .2s ease, transform .2s cubic-bezier(.2, .8, .2, 1);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }

/* questions */
.q { display: flex; gap: 12px; padding: 14px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); margin-top: 10px; }
.q.answered { opacity: .6; }
.q.pending { border-style: dashed; }
.q.onscreen { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.q .text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 17px; line-height: 1.4; }
.q .meta { font-size: 13px; color: var(--muted); margin-bottom: 4px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.up {
  flex: none; align-self: flex-start; width: 56px; min-height: 60px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-weight: 700;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.up:active { transform: scale(.94); }
.up svg { width: 20px; height: 20px; }
.up.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.up.static { cursor: default; background: var(--bg); }
.link { color: var(--accent-strong); font-weight: 600; font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }

/* polls */
.opt {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  min-height: 54px; padding: 12px 14px; margin-top: 8px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card);
  font-size: 17px; font-weight: 550; transition: border-color .15s ease, transform .12s ease;
}
button.opt:active { transform: scale(.985); }
.opt.on { border-color: var(--accent); }
.opt .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent-soft); transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.opt > span { position: relative; }
.opt .pct { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 650; font-size: 15px; }
.opt .tick { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; }
.opt.multi .tick { border-radius: 7px; }
.opt.on .tick { background: var(--accent); border-color: var(--accent); }
.opt.on .tick::after { content: ""; width: 10px; height: 6px; border: 2.5px solid var(--accent-ink); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.stars { display: flex; justify-content: center; gap: 6px; margin-top: 12px; }
.stars button { font-size: 44px; line-height: 1; color: var(--line); transition: transform .12s ease, color .15s ease; }
.stars button.on { color: #f59e0b; }
.stars button:active { transform: scale(.88); }
.cloud { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .15em .6em; line-height: 1.15; }
.cloud span { font-weight: 750; transition: font-size .5s cubic-bezier(.2, .8, .2, 1); }
.answers { display: grid; gap: 8px; margin-top: 12px; }
.answers div { background: var(--bg); border-radius: 12px; padding: 10px 12px; overflow-wrap: anywhere; }

dialog { border: 0; border-radius: 20px; padding: 22px; width: min(480px, calc(100vw - 24px)); background: var(--card); color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(8, 12, 22, .55); backdrop-filter: blur(3px); }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .3s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.shake { animation: shake .35s ease; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.brand { flex: none; width: 34px; height: 34px; border-radius: 10px; display: block; }
