:root {
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --ink: #141a26;
  --muted: #5b6577;
  --faint: #8a93a3;
  --line: #dde2ea;
  --line-strong: #c6cdd8;
  --accent: #2440c8;
  --accent-ink: #ffffff;
  --accent-soft: #e6eafc;
  --yes: #1e9e63;
  --yes-soft: #dcf3e8;
  --maybe: #c98a0b;
  --maybe-soft: #fbf0d4;
  --no-soft: #eef0f4;
  --danger: #c43a3a;
  --danger-soft: #fbe5e5;
  --best: #e9f7ef;
  --shadow: 0 1px 2px rgba(20, 26, 38, .06), 0 6px 20px rgba(20, 26, 38, .06);
  --radius: 12px;
  --display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e121a;
    --surface: #161b25;
    --surface-2: #1b212d;
    --ink: #e7ebf2;
    --muted: #a0a9b9;
    --faint: #737d8f;
    --line: #283041;
    --line-strong: #394357;
    --accent: #7f94ff;
    --accent-ink: #0e121a;
    --accent-soft: #212a4d;
    --yes: #3cc486;
    --yes-soft: #173a2b;
    --maybe: #f0b83a;
    --maybe-soft: #3b3017;
    --no-soft: #1f2530;
    --danger: #ff7b7b;
    --danger-soft: #3d1e22;
    --best: #15291f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 8px 20px 96px; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1120px; margin: 0 auto; padding: 18px 20px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font: 800 20px/1 var(--display); letter-spacing: -.02em; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--accent); position: relative; overflow: hidden;
}
.brand-mark::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 8px; background: var(--ink); }
.brand-mark::after {
  content: ""; position: absolute; left: 8px; top: 11px; width: 8px; height: 5px;
  border: solid #fff; border-width: 0 0 2.5px 2.5px; transform: rotate(-45deg);
}
.topnav { display: flex; gap: 8px; align-items: center; }

/* Type */
h1, h2, h3 { font-family: var(--display); letter-spacing: -.02em; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(28px, 4.2vw, 44px); line-height: 1.05; font-weight: 800; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
.eyebrow { font: 600 12px/1 var(--body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
p { margin: 0; }

/* Layout helpers */
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--no-soft); color: var(--ink); }
.btn.danger { color: var(--danger); border-color: var(--danger-soft); }
.btn.danger.armed { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.lg { padding: 13px 22px; font-size: 16px; border-radius: 11px; }

/* Forms */
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
label.field .hint { font-weight: 400; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--surface); font-weight: 400; font-size: 15px;
}
textarea.input { resize: vertical; min-height: 72px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.sm { padding: 6px 8px; font-size: 14px; width: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-weight: 500; font-size: 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }

.seg { display: inline-flex; background: var(--no-soft); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--no-soft); color: var(--muted); }
.pill.open { background: var(--yes-soft); color: var(--yes); }
.pill.closed { background: var(--no-soft); color: var(--muted); }
.pill.final { background: var(--accent-soft); color: var(--accent); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* Home */
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 28px; align-items: end; padding: 28px 0 32px; }
.hero p.lede { font-size: 17px; color: var(--muted); max-width: 52ch; margin-top: 12px; }
.legend-demo { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.legend-demo span { aspect-ratio: 1.3; border-radius: 8px; display: grid; place-items: center; font-weight: 700; }
.poll-list { display: flex; flex-direction: column; }
.poll-item { display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.poll-item:last-child { border-bottom: 0; }
.poll-item:hover .poll-title { color: var(--accent); }
.poll-title { font-weight: 600; font-size: 16px; }
.empty { text-align: center; padding: 36px 12px; color: var(--muted); }

/* Create */
.create-layout { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.step-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 14px; }
.step-num { font: 700 13px/1 var(--mono); color: var(--accent); }
.cal { user-select: none; }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cal-head strong { font-family: var(--display); font-size: 17px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 4px 0; }
.cal-day {
  aspect-ratio: 1; border: 1px solid transparent; border-radius: 9px; background: transparent; cursor: pointer;
  font-variant-numeric: tabular-nums; font-weight: 500; position: relative;
}
.cal-day:hover:not(:disabled) { background: var(--accent-soft); }
.cal-day.today { border-color: var(--line-strong); }
.cal-day.sel { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.cal-day:disabled { color: var(--line-strong); cursor: default; }
.cal-day.pad { visibility: hidden; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.toolbar .group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.date-rows { display: flex; flex-direction: column; }
.date-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.date-row:last-child { border-bottom: 0; }
.date-label { font-weight: 600; padding-top: 5px; }
.date-label small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; border-radius: 8px;
  background: var(--accent-soft); color: var(--ink); font: 500 13px/1.4 var(--mono);
}
.chip button { border: 0; background: transparent; cursor: pointer; color: var(--muted); width: 22px; height: 22px; border-radius: 6px; font-size: 15px; line-height: 1; }
.chip button:hover { background: rgba(0,0,0,.08); color: var(--danger); }
.chip-add { display: inline-flex; gap: 4px; align-items: center; }
.chip-add input { width: 118px; padding: 4px 6px; font-size: 13px; border-radius: 7px; border: 1px dashed var(--line-strong); background: transparent; }

.bottom-bar {
  position: sticky; bottom: 0; margin-top: 20px; z-index: 5;
  padding: 14px 0 calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.bottom-bar .inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px 12px 18px; box-shadow: var(--shadow); }

/* Poll page */
.poll-head { display: grid; grid-template-columns: 1fr auto; gap: 20px; padding: 16px 0 22px; align-items: start; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 14px; margin-top: 10px; }
.meta b { color: var(--ink); font-weight: 600; }
.desc { margin-top: 12px; max-width: 70ch; white-space: pre-wrap; }

.banner {
  display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 18px 20px; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink); margin-bottom: 18px;
}
.banner h2 { font-size: 24px; }
.banner .btn { background: rgba(255,255,255,.14); color: inherit; border-color: rgba(255,255,255,.35); }
.banner .btn:hover { background: rgba(255,255,255,.24); }

.best-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 18px; }
.best-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.best-card.top { border-color: var(--yes); background: var(--best); }
.best-card .when { font: 700 17px/1.25 var(--display); margin: 4px 0 6px; }
.best-card .tally { display: flex; gap: 12px; font-size: 13px; color: var(--muted); }
.best-card .tally b { color: var(--ink); }

.grid-card { padding: 0; overflow: hidden; }
.grid-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); align-items: center; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 5px; }
.scroller { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.vote { border-collapse: separate; border-spacing: 0; min-width: 100%; font-variant-numeric: tabular-nums; }
table.vote th, table.vote td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; text-align: center; }
table.vote tr > :last-child { border-right: 0; }
table.vote .namecol {
  position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left;
  min-width: 190px; max-width: 220px; padding: 10px 14px; border-right: 1px solid var(--line-strong);
}
table.vote thead th { background: var(--surface-2); }
table.vote thead .namecol { background: var(--surface-2); vertical-align: bottom; }
th.day { padding: 10px 6px 6px; font-weight: 600; }
th.day .dow { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: block; }
th.day .dnum { font: 800 22px/1 var(--display); display: block; margin: 3px 0 1px; }
th.day .mon { font-size: 12px; color: var(--muted); }
th.time { padding: 7px 6px; min-width: 76px; font: 500 12px/1.3 var(--mono); color: var(--ink); }
th.time small { display: block; color: var(--faint); font-size: 11px; }
td.cell { height: 44px; min-width: 76px; }
td.cell.y { background: var(--yes-soft); color: var(--yes); }
td.cell.m { background: var(--maybe-soft); color: var(--maybe); }
td.cell svg { width: 18px; height: 18px; vertical-align: middle; }
.best-col { box-shadow: inset 0 0 0 9999px rgba(30, 158, 99, .06); }
th.time.best-col, th.day.best-col { color: var(--yes); }
.final-col { box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent); }

.person { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.person .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; font: 700 12px/1 var(--body); color: #fff; }
.person .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .acts { display: flex; gap: 2px; flex: none; margin-left: 34px; }
.person .acts .btn { padding: 3px 7px; font-size: 12px; }

tr.me-row td, tr.me-row .namecol { background: var(--accent-soft); }
tr.me-row .namecol { font-weight: 700; }
button.vote-btn {
  width: 100%; height: 48px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center;
  border-radius: 0; transition: background .1s;
}
button.vote-btn .box { width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; }
button.vote-btn:hover .box { border-color: var(--accent); }
button.vote-btn.y .box { background: var(--yes); border-color: var(--yes); color: #fff; }
button.vote-btn.m .box { background: var(--maybe); border-color: var(--maybe); color: #fff; }
button.vote-btn svg { width: 17px; height: 17px; }

tfoot td, tfoot th { background: var(--surface-2); }
.total { padding: 8px 4px; }
.total b { font: 800 18px/1 var(--display); display: block; }
.total small { color: var(--maybe); font-weight: 600; font-size: 11px; }
.bar { height: 4px; border-radius: 4px; background: var(--line); margin: 6px 8px 0; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--yes); }
.pick-btn { margin: 6px 4px; }

.respond-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; padding: 16px 18px; border-top: 1px solid var(--line); background: var(--surface); }
.respond-bar .field { flex: 1 1 200px; }
.respond-bar .field.wide { flex: 2 1 260px; }

.comments { display: flex; flex-direction: column; gap: 12px; }
.comment { display: flex; gap: 10px; }
.comment .body { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }

.side-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 18px; margin-top: 18px; align-items: start; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px; }
.note { padding: 10px 12px; border-radius: 9px; background: var(--maybe-soft); color: var(--ink); font-size: 13px; }
.err { padding: 10px 12px; border-radius: 9px; background: var(--danger-soft); color: var(--danger); font-size: 14px; font-weight: 500; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); z-index: 50; max-width: calc(100vw - 32px);
}

@media (max-width: 860px) {
  .create-layout, .hero, .side-grid, .poll-head { grid-template-columns: 1fr; }
  .hero { padding-top: 12px; }
}
@media (max-width: 560px) {
  .wrap { padding: 4px 16px 96px; }
  .topbar { padding: 14px 16px; }
  .card { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .date-row { grid-template-columns: 1fr auto; }
  .date-row .chips { grid-column: 1 / -1; }
  table.vote .namecol { min-width: 120px; max-width: 140px; padding: 8px 10px; }
  .avatar { display: none; }
  .person .acts { margin-left: 0; }
  .poll-item { grid-template-columns: 1fr auto; }
  .poll-item .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
