:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1d1f1e;
  --muted: #646a67;
  --line: #dcdcd5;
  --accent: #1f5c4f;
  --accent-ink: #ffffff;
  --accent-soft: #e5efeb;
  --err: #b3261e;
  --err-soft: #fbeceb;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141615; --card: #1d201f; --ink: #ecedeb; --muted: #a2a8a5; --line: #343836;
    --accent: #7cc2ad; --accent-ink: #0f1a17; --accent-soft: #22322d; --err: #f2b8b5; --err-soft: #3a2322;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141615; --card: #1d201f; --ink: #ecedeb; --muted: #a2a8a5; --line: #343836;
  --accent: #7cc2ad; --accent-ink: #0f1a17; --accent-soft: #22322d; --err: #f2b8b5; --err-soft: #3a2322;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 720px; margin: 0 auto; padding: 32px 16px 80px; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 20px; }
h2 { font-size: 1.25rem; margin: 0 0 6px; }
h3 { font-size: 1.05rem; margin: 28px 0 4px; padding-top: 20px; border-top: 1px solid var(--line); }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.wide { max-width: 1100px; }

/* Progress */
.progress { display: flex; gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; }
.progress li { flex: 1; min-width: 0; }
.progress button {
  width: 100%; border: 0; background: none; padding: 0; text-align: left; font: inherit;
  color: var(--muted); font-size: 0.8rem; cursor: pointer;
}
.progress button::before {
  content: ""; display: block; height: 4px; border-radius: 2px; background: var(--line); margin-bottom: 6px;
}
.progress .done button::before, .progress .current button::before { background: var(--accent); }
.progress .current button { color: var(--ink); font-weight: 600; }
.progress button:disabled { cursor: not-allowed; opacity: 0.55; }
.progress .label { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) { .progress .label { display: none; } }
.step-count { font-size: 0.85rem; color: var(--muted); margin: 0 0 8px; }

/* Questions */
.q { padding: 18px 0; border-top: 1px solid var(--line); }
.q:first-of-type { border-top: 0; }
.q.heading-q { border-top: 0; }
.q[hidden] { display: none; }
.q-label, .q legend { font-weight: 600; display: block; padding: 0; margin-bottom: 4px; }
.qn { color: var(--muted); font-weight: 500; font-size: 0.85rem; margin-right: 6px; }
.opt-tag { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0 0 8px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.step-intro { background: var(--accent-soft); border-radius: 8px; padding: 12px 14px; margin: 12px 0 4px; }

input[type="text"], input[type="password"], textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-top: 4px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus-visible, textarea:focus-visible, button:focus-visible, .choice input:focus-visible + span {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.choices { display: grid; gap: 6px; margin-top: 6px; }
.choices.inline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice { display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: var(--bg); }
.choice:hover { border-color: var(--muted); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin: 4px 0 0; accent-color: var(--accent); flex: none; }
.choices.inline .choice { justify-content: center; align-items: center; }
.choices.inline .choice input { margin: 0; }
.other-input { margin-top: 6px; }
.other-input[hidden] { display: none; }

/* Sliders */
.slider { margin-top: 8px; }
.slider-item + .slider-item { margin-top: 18px; }
.slider-item > p { margin: 0 0 4px; }
.slider-row { display: flex; align-items: center; gap: 12px; }
.slider input[type="range"] { flex: 1; accent-color: var(--accent); height: 28px; margin: 0; }
.slider output { min-width: 4.5em; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.slider.unset output { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.slider.unset input[type="range"] { opacity: 0.45; }
.ticks { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--muted); padding: 0 2px; margin-right: calc(4.5em + 12px); }
.ends { display: flex; justify-content: space-between; gap: 12px; font-size: 0.8rem; color: var(--muted); margin-right: calc(4.5em + 12px); }
.ends span:last-child { text-align: right; }

.err { color: var(--err); font-size: 0.9rem; margin: 8px 0 0; }
.err:empty { display: none; }
.q.has-err { background: var(--err-soft); margin: 0 -12px; padding: 18px 12px; border-radius: 8px; }

/* Buttons */
.actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; }
button.btn {
  font: inherit; font-weight: 600; border-radius: 8px; padding: 10px 20px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
}
button.btn.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
button.btn:disabled { opacity: 0.6; cursor: progress; }
.banner { padding: 12px 14px; border-radius: 8px; background: var(--err-soft); color: var(--err); margin-top: 16px; }

/* Admin */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 8px 0 0; font-size: 0.9rem; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td button { font: inherit; font-size: 0.85rem; background: none; border: 0; color: var(--err); cursor: pointer; padding: 0; }
.code-input { max-width: 12em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.15rem; letter-spacing: 0.2em; text-transform: uppercase; }
