:root {
  color-scheme: light dark;
  --bg: #f8f7f8;
  --surface: #ffffff;
  --soft: #f8edf1;
  --text: #262124;
  --muted: #70676b;
  --line: #e8e1e4;
  --accent: #f2c6d4;
  --accent-strong: #a34869;
  --accent-text: #48212f;
  --correct: #e5f3e9;
  --wrong: #f8e7e7;
  --focus: #a34869;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); }
button, input { font: inherit; }
button { color: inherit; min-height: 44px; min-width: 44px; touch-action: manipulation; }
button:not(:disabled) { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
button:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.skip-link { position: fixed; left: 16px; top: -60px; z-index: 20; padding: 10px 14px; color: var(--accent-text); background: var(--accent); border-radius: 12px; }
.skip-link:focus { top: 12px; }
.topbar { height: 66px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 22px; padding: 0 34px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; min-height: 44px; gap: 10px; color: var(--text); text-decoration: none; font-size: 15px; font-weight: 650; }
.brand-mark { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 10px; color: var(--accent-text); background: var(--accent); }
.nav { display: flex; align-self: stretch; gap: 30px; }
.nav button { position: relative; min-width: 66px; padding: 0; border: 0; color: var(--muted); background: transparent; font-size: 14px; }
.nav button[aria-current="page"] { color: var(--text); font-weight: 650; }
.nav button[aria-current="page"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--accent-strong); }
.nav-count { display: inline-grid; min-width: 18px; height: 18px; place-items: center; padding: 0 5px; margin-left: 3px; border-radius: 999px; background: var(--soft); font-size: 10px; }
.header-actions { justify-self: end; display: flex; align-items: center; gap: 8px; }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: var(--soft); color: var(--muted); font-size: 17px; }
.storage-bar { width: min(800px, calc(100% - 40px)); margin: 12px auto 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
#save-status[data-error="true"] { color: var(--accent-strong); font-weight: 650; }
#workspace { width: min(800px, calc(100% - 40px)); margin: 0 auto; padding: 72px 0 74px; }
.screen-start { width: min(600px, 100%); margin: 0 auto; padding-top: 40px; text-align: center; }
.eyebrow { margin: 0 0 14px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 14px; font-size: clamp(34px, 6vw, 54px); line-height: 1.07; letter-spacing: -.045em; font-weight: 680; }
h2 { margin-bottom: 16px; font-size: clamp(24px, 3.6vw, 34px); line-height: 1.28; letter-spacing: -.028em; font-weight: 640; }
h3 { font-size: 16px; font-weight: 650; }
.lead { max-width: 560px; margin: 0 auto 28px; color: var(--muted); font-size: 16px; line-height: 1.65; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 20px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--text); font-weight: 650; }
.button.primary { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.button.quiet { color: var(--muted); }
.start-button { min-width: 210px; }
.status-line { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 22px; margin-top: 26px; color: var(--muted); font-size: 13px; }
.status-line strong { color: var(--text); }
.practice-modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 30px; text-align: left; }
.practice-mode { min-height: 158px; display: flex; flex-direction: column; align-items: start; justify-content: space-between; gap: 18px; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.practice-mode h2 { margin-bottom: 7px; font-size: 18px; letter-spacing: -.015em; }
.practice-mode p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.practice-mode .button { padding-inline: 16px; font-size: 13px; }
.quality-note { max-width: 560px; margin: 26px auto 0; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.6; }
.session-meta, .screen-header, .question-actions, .row-main, .history-main { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.session-meta { margin-bottom: 26px; color: var(--muted); font-size: 13px; }
.session-meta strong { color: var(--text); }
.question-card { padding: 36px; border: 1px solid var(--line); border-radius: 26px; background: var(--surface); }
.question-index { margin-bottom: 17px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.question-card h2 { font-size: clamp(21px, 3.2vw, 31px); }
.options { display: grid; gap: 10px; }
.option { width: 100%; display: grid; grid-template-columns: 27px 1fr; align-items: start; gap: 12px; padding: 15px 17px; border: 1px solid var(--line); border-radius: 18px; background: transparent; text-align: left; line-height: 1.48; }
.option > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.option.is-selected { border-color: var(--accent-strong); background: var(--soft); }
.option.is-correct { border-color: #68a77a; background: var(--correct); }
.option.is-wrong { border-color: #c7767a; background: var(--wrong); }
.letter { width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); font-size: 12px; font-weight: 700; }
.option.is-selected .letter { border-color: var(--accent-strong); background: var(--accent); color: var(--accent-text); }
.question-actions { margin-top: 20px; }
.answer-feedback { margin-top: 18px; padding: 21px; border-radius: 18px; background: var(--correct); line-height: 1.6; }
.answer-feedback.is-wrong { background: var(--wrong); }
.answer-feedback h3 { margin: 0 0 8px; }
.answer-feedback p { margin-bottom: 12px; }
.answer-feedback p:last-child { margin-bottom: 0; }
.rationales { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.rationales summary { cursor: pointer; font-weight: 650; min-height: 44px; padding-block: 8px; }
.rationales summary span { margin-left: 6px; color: var(--muted); font-size: 11px; font-weight: 500; }
.rationale-list { display: grid; gap: 9px; margin-top: 12px; }
.rationale-item { padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.rationale-item.is-correct { border-color: #68a77a; }
.rationale-item strong { font-size: 12px; }
.rationale-item p { margin: 4px 0 0; }
.source-status { margin-top: 13px; color: var(--muted); font-size: 11px; }
.screen-header { align-items: end; margin-bottom: 26px; }
.screen-header h2 { margin-bottom: 5px; }
.screen-header p { margin: 0; color: var(--muted); }
.segments { width: fit-content; display: flex; gap: 5px; margin-bottom: 22px; padding: 4px; border-radius: 999px; background: var(--soft); }
.segments button { padding: 9px 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 13px; }
.segments button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px #00000012; }
.review-list, .history-list { border-top: 1px solid var(--line); }
.review-row, .history-row { padding: 18px 2px; border-bottom: 1px solid var(--line); }
.row-title, .history-title { margin-bottom: 5px; font-weight: 650; }
.row-sub, .history-sub { color: var(--muted); font-size: 13px; }
.status { flex: none; padding: 5px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 12px; font-weight: 650; }
.row-action { flex: none; border: 0; background: transparent; color: var(--accent-strong); font-weight: 650; }
.history-date { margin: 27px 0 9px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.history-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.show-more { margin-top: 20px; text-align: center; }
.empty { padding: 54px 20px; border: 1px dashed var(--line); border-radius: 22px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); }
.loading { padding-top: 15vh; text-align: center; color: var(--muted); }
#notice { position: fixed; left: 50%; bottom: 22px; z-index: 10; width: min(560px, calc(100% - 32px)); transform: translateX(-50%); padding: 13px 18px; border: 1px solid #d6bfa6; border-radius: 14px; background: #fff6ea; box-shadow: 0 8px 30px #0002; font-size: 13px; }
dialog { width: min(440px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow-y: auto; padding: 0; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); color: var(--text); box-shadow: 0 20px 80px #0004; }
dialog::backdrop { background: #20171c66; backdrop-filter: blur(3px); }
dialog form, .dialog-body { padding: 26px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; margin-bottom: 25px; }
.dialog-heading h2 { margin: 0; font-size: 25px; }
dialog label { display: flex; justify-content: space-between; margin-bottom: 8px; font-weight: 650; }
dialog label span, .field-note { color: var(--muted); font-size: 12px; font-weight: 400; }
dialog input { width: 100%; height: 45px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text); }
.field-note { margin: 9px 0 24px; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
#backup-dialog { width: min(520px, calc(100% - 32px)); }
#download-prepared-backup { margin-top: 10px; text-decoration: none; }
.backup-import { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 22px; }
.file-label { font-size: 14px; }
dialog input[type="file"] { height: auto; min-height: 44px; padding: 9px; font-size: 13px; }
dialog input[type="file"]::file-selector-button { min-height: 44px; margin-right: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); color: var(--text); }
#backup-preview { margin-top: 18px; border: 1px solid var(--line); border-radius: 12px; padding: 15px; background: var(--soft); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
#backup-preview dl { margin: 0 0 14px; }
#backup-preview dl div { display: flex; justify-content: space-between; gap: 16px; }
#backup-preview dd { margin: 0; text-align: right; }
#backup-preview p:last-child { margin-bottom: 0; }
dialog .confirm-label { min-height: 44px; align-items: center; justify-content: start; gap: 12px; margin: 18px 0; font-size: 13px; line-height: 1.5; }
dialog .confirm-label input { flex: none; width: 22px; height: 22px; padding: 0; accent-color: var(--accent-strong); }
#backup-message:not(:empty) { margin: 18px 0 0; }
.review-nav { display: flex; gap: 10px; }
@media (max-width: 640px) {
  .topbar { height: auto; grid-template-columns: 1fr auto; padding: 13px 18px 0; gap: 9px; }
  .nav { grid-column: 1 / -1; grid-row: 2; height: 49px; width: 100%; justify-content: space-around; gap: 8px; }
  .header-actions { grid-column: 2; grid-row: 1; }
  #workspace { width: min(100% - 28px, 800px); padding: 42px 0 52px; }
  .screen-start { padding-top: 25px; }
  .question-card { padding: 22px 18px; border-radius: 17px; }
  .question-actions { align-items: stretch; flex-direction: column-reverse; }
  .question-actions .button { width: 100%; }
  .screen-header { align-items: start; flex-direction: column; }
  .segments { width: 100%; }
  .segments button { flex: 1; padding-inline: 8px; }
  .row-main, .history-main { align-items: start; }
  .status-line { gap: 8px 14px; }
  .practice-modes { grid-template-columns: 1fr; }
  .storage-bar { width: calc(100% - 28px); align-items: start; }
  .storage-bar .row-action { margin-top: -10px; text-align: right; }
  .dialog-actions { flex-wrap: wrap; }
  .session-meta { flex-wrap: wrap; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { --bg: #171517; --surface: #242124; --soft: #352a30; --text: #f7f2f4; --muted: #c8bec2; --line: #4a4145; --accent: #efb4c7; --accent-strong: #ffb4cd; --accent-text: #431a29; --correct: #234333; --wrong: #492b2d; }
  :root:not([data-theme]) #notice { background: #4a3827; }
}
:root[data-theme="dark"] { --bg: #171517; --surface: #242124; --soft: #352a30; --text: #f7f2f4; --muted: #c8bec2; --line: #4a4145; --accent: #efb4c7; --accent-strong: #ffb4cd; --accent-text: #431a29; --correct: #234333; --wrong: #492b2d; }
:root[data-theme="dark"] #notice { background: #4a3827; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
