:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --text: #1f1e1c;
  --muted: #6b6862;
  --border: #dedad2;
  --accent: #2f5d50;
  --accent-text: #ffffff;
  --accent-soft: #e2ece8;
  --must: #b4441f;
  --must-soft: #f7e4dc;
  --danger: #a3262a;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --surface: #201f1d;
    --surface-2: #2a2926;
    --text: #ecebe7;
    --muted: #a3a09a;
    --border: #3a3834;
    --accent: #7fbfa9;
    --accent-text: #10201b;
    --accent-soft: #233630;
    --must: #f08a62;
    --must-soft: #3b2419;
    --danger: #f0787b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.container { max-width: 760px; margin: 0 auto; padding: 24px 16px 80px; }

h1 { font-size: 1.5rem; margin: 0; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; background: var(--surface-2); padding: 4px; border-radius: var(--radius); }
.tabs button { flex: 1; background: transparent; border: 0; color: var(--muted); }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.steps { display: flex; gap: 6px; margin-bottom: 20px; list-style: none; padding: 0; }
.steps li {
  flex: 1;
  font-size: .8rem;
  text-align: center;
  padding: 6px 4px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}
.steps li.current { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.steps li.past { background: var(--accent-soft); color: var(--accent); }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
input[type=text], input[type=password], textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
textarea { min-height: 64px; resize: vertical; }
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font: inherit;
  font-size: .95rem;
  cursor: pointer;
  border-radius: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.link { border: 0; background: none; padding: 4px 6px; color: var(--muted); text-decoration: underline; }
button.danger { color: var(--danger); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

.topic {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--surface);
}
.topic .title { font-weight: 600; }
.topic .details { color: var(--muted); font-size: .9rem; white-space: pre-wrap; margin-top: 2px; }
.topic.selected { border-color: var(--accent); background: var(--accent-soft); }
.topic.must { border-color: var(--must); }

.vote-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.vote-choices button { padding: 8px 4px; font-size: .875rem; }
.vote-choices button.on[data-level="0"] { background: var(--surface-2); border-color: var(--muted); font-weight: 600; }
.vote-choices button.on[data-level="1"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.vote-choices button.on[data-level="2"] { background: var(--must-soft); border-color: var(--must); color: var(--must); font-weight: 600; }

.badge {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge.must { background: var(--must-soft); color: var(--must); }
.badge.ok { background: var(--accent-soft); color: var(--accent); }

.result { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: start; }
.rank { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.counts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.bar span { display: block; height: 100%; background: var(--accent); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.merged-list { margin: 8px 0 0; padding-left: 16px; font-size: .85rem; color: var(--muted); }
.merged-list li { margin-bottom: 2px; }

.sticky-bar {
  position: sticky;
  bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.sticky-bar input { margin-bottom: 8px; }

.suggestion { border-left: 3px solid var(--accent); padding: 8px 12px; margin-bottom: 12px; background: var(--surface-2); border-radius: 0 8px 8px 0; }
.suggestion ul { margin: 6px 0; padding-left: 18px; font-size: .9rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: .9rem;
  max-width: calc(100% - 32px);
}

.login { max-width: 380px; margin: 10vh auto 0; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
details summary { cursor: pointer; color: var(--muted); font-size: .9rem; }

label.check { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 6px; cursor: pointer; }
label.check input { width: 18px; height: 18px; margin: 0; }

/* ---------- Guides ---------- */
.guide { max-width: 800px; }
.guide h1 { font-size: 1.75rem; margin-bottom: 8px; }
.guide h2 { font-size: 1.3rem; margin: 40px 0 12px; padding-top: 8px; border-top: 1px solid var(--border); }
.guide h3 { font-size: 1.05rem; margin: 24px 0 8px; }
.guide p, .guide li { line-height: 1.6; }
.guide ul, .guide ol { padding-left: 22px; margin: 0 0 12px; }
.guide li { margin-bottom: 4px; }
.guide figure { margin: 16px 0 24px; }
.guide figure img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
.guide figcaption { font-size: .85rem; color: var(--muted); margin-top: 8px; }
.guide nav.toc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 20px; margin: 20px 0; }
.guide nav.toc ol { margin: 0; }
.guide a { color: var(--accent); }
.guide .note { background: var(--accent-soft); border-radius: 8px; padding: 12px 16px; margin: 16px 0; }
.guide .warn { background: var(--must-soft); border-radius: 8px; padding: 12px 16px; margin: 16px 0; }
.guide table { margin: 12px 0 20px; background: var(--surface); }
.guide code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.guide pre { background: var(--surface-2); padding: 12px; border-radius: 8px; overflow-x: auto; font-size: .85rem; }
.guide .steps-list { counter-reset: s; list-style: none; padding: 0; }
.guide .steps-list li { counter-increment: s; padding-left: 36px; position: relative; margin-bottom: 10px; }
.guide .steps-list li::before {
  content: counter(s);
  position: absolute; left: 0; top: 1px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
  font-size: .8rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.help-link { font-size: .9rem; color: var(--muted); }
