:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1d2330;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --bar: #c7d2fe;
  --bar-lead: #4f46e5;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: -.5px; cursor: pointer; }
.brand span { color: var(--brand); }
.spacer { flex: 1; }
.auth-area { display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: 13px; }
.who b { color: var(--ink); }

/* Layout */
.layout { display: grid; grid-template-columns: 220px 1fr; gap: 22px; max-width: 1040px; margin: 22px auto; padding: 0 18px; }
.sidebar h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 6px 0 10px; }
.topic-list { list-style: none; margin: 0; padding: 0; }
.topic-list li {
  padding: 7px 10px; border-radius: 8px; cursor: pointer; color: var(--ink); font-size: 14px;
}
.topic-list li:hover { background: #eef0f3; }
.topic-list li.active { background: var(--brand); color: var(--brand-ink); font-weight: 600; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px;
}
.card.clickable { cursor: pointer; transition: transform .05s ease, box-shadow .1s ease; }
.card.clickable:hover { box-shadow: 0 2px 6px rgba(0,0,0,.08), 0 12px 28px rgba(0,0,0,.06); }
.card h2 { margin: 0 0 6px; font-size: 17px; line-height: 1.35; }
.meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 10px; flex-wrap: wrap; }
.pill { background: #eef2ff; color: var(--brand); border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; }

/* Result bars */
.option { margin: 9px 0; }
.option .row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.option .track { background: #eef0f3; border-radius: 8px; height: 10px; overflow: hidden; }
.option .fill { background: var(--bar); height: 100%; border-radius: 8px; transition: width .4s ease; }
.option.mine .fill { background: var(--bar-lead); }
.option.mine .row b::after { content: " ✓ your vote"; color: var(--brand); font-weight: 600; font-size: 12px; }

/* Voting buttons */
.vote-opt {
  display: block; width: 100%; text-align: left; padding: 11px 14px; margin: 7px 0;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-size: 14px;
}
.vote-opt:hover { border-color: var(--brand); background: #f5f3ff; }

/* Buttons */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.btn:hover { background: #f1f2f5; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { border: none; background: none; color: var(--brand); padding: 6px; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.link { border: none; background: none; color: var(--brand); padding: 0; font-weight: 600; }

/* Comments */
.comments { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.comment { padding: 10px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: none; }
.comment .chead { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 3px; }
.avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--bar); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--brand); }
.anon-note { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; padding: 10px 12px; border-radius: 10px; font-size: 13px; margin: 10px 0; }

/* Forms */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font: inherit;
}
.field textarea { resize: vertical; min-height: 70px; }
.row-opts { display: flex; gap: 8px; margin-bottom: 7px; }
.row-opts input { flex: 1; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,18,28,.45); display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 50; }
.modal-backdrop[hidden] { display: none; }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; padding: 22px; }
.modal h2 { margin: 0 0 14px; }
.modal .tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.modal .tabs button { flex: 1; }
.social { display: grid; gap: 8px; margin-top: 12px; }
.divider { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0; }

.error { color: var(--danger); font-size: 13px; margin: 6px 0; }
.loading { color: var(--muted); padding: 30px; text-align: center; }
.back { color: var(--brand); cursor: pointer; font-weight: 600; margin-bottom: 12px; display: inline-block; }

/* Toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100; font-size: 14px; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
}
