:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1b1f24;
  --muted: #5b6470;
  --line: #d9d6cc;
  --accent: #0d6b6b;
  --accent-ink: #ffffff;
  --accent-soft: #dcefee;
  --star: #b7791f;
  --danger: #a4262c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181c;
    --card: #1d2329;
    --ink: #eef1f4;
    --muted: #a3adb8;
    --line: #333c45;
    --accent: #5cc4c0;
    --accent-ink: #0b1f1f;
    --accent-soft: #1c3a3a;
    --star: #f0b84f;
    --danger: #ff8a8f;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}
#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
h1 { font-size: 1.7rem; line-height: 1.15; margin: 8px 0 12px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }

.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 4px 0 10px; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .25s; }
.topline { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; color: var(--muted); }
.chip { display: inline-block; font-size: .8rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--accent); }
.back { background: none; border: 0; color: var(--muted); font: inherit; font-size: .95rem; padding: 8px 4px; cursor: pointer; }
.back[disabled] { visibility: hidden; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 16px 16px; margin-top: 8px; }
.card h2 { font-size: 1.35rem; line-height: 1.25; margin: 6px 0 4px; }
.card .hint { color: var(--muted); font-size: .95rem; margin: 0 0 4px; }
.card .prompt { color: var(--muted); font-size: .95rem; margin: 10px 0 12px; }

.opts { display: grid; gap: 10px; margin-top: 14px; }
.opt {
  font: inherit; text-align: left; color: var(--ink);
  background: var(--bg); border: 2px solid var(--line); border-radius: 12px;
  padding: 14px 14px; min-height: 52px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.opt:active { transform: scale(.99); }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.opt:focus-visible, .star:focus-visible, .btn:focus-visible, .back:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 16px; }
.scale .opt { text-align: center; padding: 14px 0; font-size: 1.3rem; font-weight: 600; }
.scale-legend { display: flex; justify-content: space-between; gap: 12px; font-size: .85rem; color: var(--muted); margin-top: 8px; }

.opt .t { display: block; }
.opt .h { display: block; font-weight: 400; font-size: .85rem; color: var(--muted); margin-top: 2px; }
.opt[aria-pressed="true"] .h { color: var(--ink); }
.opt[disabled] { opacity: .45; cursor: not-allowed; }
.opts.multi .opt { position: relative; padding-left: 48px; }
.opts.multi .opt::before {
  content: ""; position: absolute; left: 14px; top: 50%; width: 22px; height: 22px; margin-top: -11px;
  border: 2px solid var(--muted); border-radius: 6px; background: var(--card);
}
.opts.multi .opt[aria-pressed="true"]::before { background: var(--accent); border-color: var(--accent); }
.opts.multi .opt[aria-pressed="true"]::after {
  content: ""; position: absolute; left: 21px; top: 50%; width: 7px; height: 12px; margin-top: -9px;
  border: solid var(--accent-ink); border-width: 0 3px 3px 0; transform: rotate(45deg);
}
.grp { font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.grp:first-child { margin-top: 0; }
.actions {
  position: sticky; bottom: 0; display: flex; gap: 12px; align-items: center;
  background: var(--card); margin: 14px -16px -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); border-radius: 0 0 14px 14px;
}
.actions .btn { flex: none; min-width: 120px; margin-left: auto; }
.actions .btn:only-child { flex: 1; margin-left: 0; }
.count { color: var(--muted); font-size: .95rem; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

input[type=text] {
  width: 100%; font: inherit; font-size: 1.2rem; padding: 14px; margin-top: 14px;
  border: 2px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink);
}
.row { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  flex: 1; font: inherit; font-weight: 600; border-radius: 12px; padding: 14px; min-height: 52px; cursor: pointer;
  border: 2px solid var(--accent); background: var(--accent); color: var(--accent-ink);
}
.btn.ghost { background: none; color: var(--accent); }

.center { margin: auto 0; text-align: center; }
.big { font-size: 3rem; line-height: 1; margin-bottom: 12px; }
#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 528px; margin: 0 auto; background: var(--danger); color: #fff;
  padding: 12px 14px; border-radius: 12px; font-size: .95rem; z-index: 10;
}
@media (prefers-reduced-motion: reduce) { .progress > i { transition: none; } }
