:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --paper: #f8f7f3;
  --ink: #111216;
  --muted: #696b72;
  --line: #d8d8d5;
  --blue: #0b4ce6;
  --blue-soft: #edf2ff;
  --red: #e34d47;
  --green: #198754;
  --radius: 18px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
.loading { padding: 2rem; }

.shell { min-height: 100dvh; padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 20px clamp(18px, 4vw, 52px) 12px; }
.brand { margin: 0; font-size: clamp(1.65rem, 5vw, 2.35rem); letter-spacing: -.055em; }
.top-actions { display: flex; gap: 8px; }
.icon-btn, .ghost-btn, .primary-btn { min-height: 46px; border: 1px solid var(--line); border-radius: 13px; background: transparent; padding: 0 15px; cursor: pointer; font-weight: 700; }
.icon-btn:hover, .ghost-btn:hover { background: #fff; }
.primary-btn { background: var(--blue); border-color: var(--blue); color: #fff; }

main { width: min(780px, 100%); margin: 0 auto; padding: 8px clamp(16px, 4vw, 34px) 24px; }
.status-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin: 10px 0 9px; font-weight: 750; }
.saved { color: var(--green); font-size: .88rem; }
.progress { height: 7px; overflow: hidden; border-radius: 999px; background: #dedfdf; }
.progress > span { display: block; height: 100%; background: var(--blue); transition: width .25s ease; }
.context { margin: 22px 0 18px; }
.phase { margin: 0 0 7px; color: var(--muted); font-size: .82rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.section { margin: 0; font-size: clamp(1.4rem, 5.5vw, 2.25rem); line-height: 1.08; letter-spacing: -.035em; }

.question { background: rgba(255,255,255,.46); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(20px, 5vw, 34px); }
.qid { color: var(--blue); font-weight: 900; }
.feature { margin: 18px 0 10px; font-size: clamp(1.8rem, 7vw, 3.1rem); line-height: 1; letter-spacing: -.05em; }
.prompt { margin: 0 0 24px; color: #303136; font-size: clamp(1rem, 3.8vw, 1.2rem); line-height: 1.45; }
.recommendation { margin: -8px 0 18px; color: var(--muted); font-size: .88rem; }
.answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.answer { min-height: 78px; display: flex; gap: 12px; align-items: center; border: 1.5px solid #9bb6fa; border-radius: 15px; background: #fff; padding: 12px; cursor: pointer; text-align: left; }
.answer:hover, .answer:focus-visible { border-color: var(--blue); outline: 3px solid #dce6ff; }
.answer.selected { border: 2px solid var(--blue); background: var(--blue-soft); }
.answer.no { border-color: #f1a19d; }
.answer.no.selected { border-color: var(--red); background: #fff1f0; }
.code { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 42px; border-radius: 10px; background: var(--blue); color: #fff; font-size: 1.3rem; font-weight: 900; }
.no .code { background: var(--red); }
.answer-copy strong { display: block; line-height: 1.15; }
.answer-copy small { display: block; margin-top: 4px; color: var(--muted); line-height: 1.2; }
.secondary { margin-top: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.secondary .answer { min-height: 58px; justify-content: center; padding: 8px 4px; text-align: center; }
.secondary .code { width: 34px; height: 34px; flex-basis: 34px; font-size: 1rem; background: transparent; color: var(--blue); border: 1.5px solid var(--blue); }
.secondary .answer-copy small { display: none; }

details { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 15px; }
summary { cursor: pointer; color: var(--muted); font-weight: 750; }
textarea { width: 100%; min-height: 92px; resize: vertical; margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 12px; }
textarea:focus, input:focus, select:focus { outline: 3px solid #dce6ff; border-color: var(--blue); }

.pager { position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr 1fr 1.15fr; gap: 8px; width: min(780px, 100%); margin: 12px auto 0; padding: 10px clamp(16px, 4vw, 34px); background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(12px); }
.pager button { min-height: 52px; }
.bottom-nav { position: fixed; inset: auto 0 0; z-index: 10; display: grid; grid-template-columns: repeat(3, 1fr); min-height: calc(68px + env(safe-area-inset-bottom)); padding: 6px max(12px, env(safe-area-inset-left)) env(safe-area-inset-bottom) max(12px, env(safe-area-inset-right)); border-top: 1px solid var(--line); background: rgba(248,247,243,.96); backdrop-filter: blur(14px); }
.nav-btn { border: 0; background: transparent; min-height: 56px; color: var(--muted); font-size: .82rem; font-weight: 800; cursor: pointer; }
.nav-btn span { display: block; font-size: 1.15rem; margin-bottom: 2px; }
.nav-btn.active { color: var(--blue); }

.panel-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 16px 0; }
.panel-head h2 { margin: 0; font-size: clamp(1.8rem, 7vw, 2.8rem); letter-spacing: -.045em; }
.stats { color: var(--muted); }
.filter-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-bottom: 14px; }
input[type="search"], select { min-height: 48px; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 0 13px; }
.question-list { display: grid; gap: 8px; }
.question-row { width: 100%; display: grid; grid-template-columns: 54px 1fr auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.52); padding: 12px; text-align: left; cursor: pointer; }
.question-row:hover { border-color: #9bb6fa; }
.question-row strong { display: block; line-height: 1.25; }
.question-row small { color: var(--muted); }
.answer-mark { min-width: 36px; text-align: center; color: var(--blue); font-size: 1.1rem; font-weight: 900; }
.empty { color: var(--muted); padding: 28px 0; text-align: center; }

dialog { width: min(430px, calc(100% - 28px)); border: 1px solid var(--line); border-radius: 18px; background: var(--paper); padding: 22px; }
dialog::backdrop { background: rgba(10,10,15,.45); }
dialog h2 { margin-top: 0; }
.dialog-actions { display: grid; gap: 9px; }
.dialog-actions button { min-height: 48px; }
.danger { color: #b4231c; }

@media (max-width: 520px) {
  .topbar { padding-top: 14px; }
  .export-label { display: none; }
  .question { border-left: 0; border-right: 0; border-radius: 0; margin-inline: -16px; padding-inline: 16px; }
  .answer-copy small { display: none; }
  .secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pager .ghost-btn { font-size: .88rem; padding-inline: 6px; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
