:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #f2f2f7;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(60, 60, 67, .16);
  --primary: #0066cc;
  --primary-dark: #0057b3;
  --primary-soft: #e8f2ff;
  --correct: #248a3d;
  --correct-soft: #edf8ef;
  --wrong: #d70015;
  --wrong-soft: #fff0f1;
  --warning: #b25000;
  --shadow: 0 10px 35px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
  --radius: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-height: 100%; margin: 0; color: var(--text); background: var(--bg); -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; }
button { color: inherit; touch-action: manipulation; }
[hidden] { display: none !important; }
.skip-link { position: fixed; z-index: 99; top: 8px; left: 8px; transform: translateY(-150%); padding: 10px 14px; border-radius: 10px; color: #fff; background: var(--primary); }
.skip-link:focus { transform: none; }
.site-header { width: min(100% - 40px, 760px); height: 72px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.brand { min-height: 44px; display: inline-flex; align-items: center; gap: 10px; border: 0; padding: 4px; font-size: 17px; font-weight: 650; letter-spacing: -.02em; background: transparent; cursor: pointer; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: linear-gradient(145deg, #4da3ff, #0066cc); font-size: 15px; font-weight: 700; box-shadow: 0 5px 14px rgba(0, 102, 204, .22); }
.network-state { padding: 5px 9px; border-radius: 999px; color: var(--warning); background: #fff3d8; font-size: 12px; font-weight: 650; }
.app-shell { width: min(100% - 32px, 720px); margin: 0 auto; padding: 22px 0 calc(52px + env(safe-area-inset-bottom)); }
.view { animation: view-in .22s cubic-bezier(.25, .1, .25, 1) both; }
.hero { padding: 28px 4px 32px; }
.eyebrow { margin: 0 0 8px; color: var(--primary); font-size: 13px; font-weight: 650; letter-spacing: .01em; }
.hero h1, .library-hero h1, .complete-view h1 { margin: 0; font-size: clamp(32px, 8vw, 44px); line-height: 1.12; letter-spacing: -.045em; }
.hero > p:last-child, .library-hero p, .complete-view > p { max-width: 540px; margin: 11px 0 0; color: var(--muted); line-height: 1.65; }
.notice { margin-bottom: 16px; padding: 14px 16px; border: 1px solid #f0d0cc; border-radius: 14px; color: #8b3131; background: #fff6f4; line-height: 1.55; }
.library-list { display: grid; gap: 12px; }
.library-card { width: 100%; min-height: 136px; display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; border: 1px solid rgba(0, 0, 0, .055); border-radius: var(--radius); padding: 22px; text-align: left; background: rgba(255, 255, 255, .9); box-shadow: var(--shadow); cursor: pointer; transition: background .16s ease, transform .16s ease, box-shadow .16s ease; }
.library-card:hover { background: #fff; box-shadow: 0 14px 38px rgba(0, 0, 0, .08), 0 1px 2px rgba(0,0,0,.04); }
.library-card:active { transform: scale(.985); box-shadow: 0 5px 18px rgba(0, 0, 0, .06); }
.library-card h2 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.02em; }
.library-card p { margin: 7px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.card-meta { display: flex; flex-wrap: wrap; gap: 7px 13px; margin-top: 14px; color: var(--muted); font-size: 12px; }
.continue-label { color: var(--primary); font-weight: 650; }
.card-arrow { width: 19px; height: 19px; color: #8e8e93; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.empty-state { padding: 44px 20px; border: 1px dashed #ccd6ce; border-radius: var(--radius); text-align: center; color: var(--muted); background: rgba(255, 255, 255, .5); }
.skeleton-card { height: 145px; border-radius: var(--radius); background: linear-gradient(90deg, #ededf0 25%, #fafafa 45%, #ededf0 70%); background-size: 300% 100%; animation: shimmer 1.4s infinite; }
.back-button { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; border: 0; padding: 8px 2px; color: var(--muted); background: transparent; cursor: pointer; }
.back-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.back-button:hover { color: var(--text); }
.library-hero { padding: 30px 4px 24px; }
.soft-badge, .type-badge { display: inline-flex; margin-bottom: 12px; padding: 5px 10px; border-radius: 999px; color: var(--primary); background: var(--primary-soft); font-size: 12px; font-weight: 650; }
.history-strip { margin: 0 0 20px; padding: 13px 2px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.history-strip p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.mode-list { display: grid; gap: 12px; }
.mode-card { width: 100%; min-height: 78px; display: grid; grid-template-columns: 1fr 20px; gap: 14px; align-items: center; border: 1px solid rgba(0,0,0,.055); border-radius: 20px; padding: 16px 18px; text-align: left; background: rgba(255,255,255,.92); box-shadow: 0 5px 20px rgba(0,0,0,.035); cursor: pointer; transition: transform .14s ease, background .14s ease, box-shadow .14s ease; }
.mode-card:hover { background: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.055); }
.mode-card:active { transform: scale(.985); }
.mode-card:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.mode-card.primary { border-color: transparent; color: #fff; background: linear-gradient(180deg, #1384ed, #0066cc); box-shadow: 0 9px 24px rgba(0, 102, 204, .2); }
.mode-card.primary:hover { background: linear-gradient(180deg, #208bef, #086ed1); box-shadow: 0 11px 28px rgba(0, 102, 204, .24); }
.mode-card strong, .mode-card small { display: block; }
.mode-card strong { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.mode-card small { margin-top: 5px; color: var(--muted); line-height: 1.35; }
.mode-card.primary small { color: rgba(255,255,255,.76); }
.mode-card svg { width: 20px; height: 20px; color: #8e8e93; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mode-card.primary svg { color: rgba(255,255,255,.78); }
.type-hero { padding: 30px 4px 24px; }
.type-hero h1 { margin: 0; font-size: clamp(30px, 8vw, 42px); line-height: 1.15; letter-spacing: -.04em; }
.type-hero p { max-width: 540px; margin: 11px 0 0; color: var(--muted); line-height: 1.65; }
.type-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.type-card { min-width: 0; min-height: 108px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; border: 1px solid rgba(0,0,0,.055); border-radius: 20px; padding: 17px 16px; text-align: left; background: rgba(255,255,255,.92); box-shadow: 0 5px 20px rgba(0,0,0,.035); cursor: pointer; transition: transform .14s ease, background .14s ease, box-shadow .14s ease; }
.type-card:hover { background: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.055); }
.type-card:active { transform: scale(.985); }
.type-card:disabled { opacity: .48; cursor: not-allowed; transform: none; box-shadow: none; }
.type-card strong, .type-card small { display: block; }
.type-card strong { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.type-card small { margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.type-count { min-width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px; color: var(--primary); background: var(--primary-soft); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.type-card.all-types { grid-column: 1 / -1; min-height: 86px; }
.quiz-view { padding-bottom: 94px; }
.focus-session .site-header { display: none; }
.quiz-session { overscroll-behavior-y: contain; }
.quiz-session .app-shell { padding-top: 12px; }
.quiz-topbar { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; }
.quiz-topbar strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid rgba(0,0,0,.055); border-radius: 50%; background: rgba(255,255,255,.86); box-shadow: 0 3px 12px rgba(0,0,0,.05); cursor: pointer; transition: transform .14s ease, background .14s ease; }
.icon-button:active { transform: scale(.93); background: #fff; }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.position { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.question-card { margin-top: 16px; border: 1px solid rgba(0,0,0,.055); border-radius: 28px; padding: clamp(22px, 6vw, 30px); background: rgba(255,255,255,.94); box-shadow: var(--shadow); }
.question-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.question-meta .type-badge { margin: 0; }
.question-card h1 { margin: 18px 0 0; font-size: clamp(20px, 5.7vw, 25px); line-height: 1.55; letter-spacing: -.015em; white-space: pre-wrap; }
.question-hint { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.options { display: grid; gap: 11px; margin-top: 24px; }
.option { width: 100%; min-height: 60px; display: grid; grid-template-columns: 34px 1fr 22px; gap: 11px; align-items: center; border: 1.5px solid transparent; border-radius: 17px; padding: 11px 13px; text-align: left; background: var(--surface-soft); cursor: pointer; transition: border-color .13s ease, background .13s ease, transform .13s ease; }
.option:hover:not(:disabled) { background: #ebebf0; }
.option:active:not(:disabled) { transform: scale(.985); }
.option-key { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; color: #636366; background: rgba(118,118,128,.12); font-size: 13px; font-weight: 700; }
.option-text { line-height: 1.5; white-space: pre-wrap; }
.option-check { color: transparent; text-align: center; font-weight: 900; }
.option.selected { border-color: rgba(0,102,204,.7); background: var(--primary-soft); }
.option.selected .option-key { color: #fff; background: var(--primary); }
.option.selected .option-check { color: var(--primary); }
.option.correct { border-color: rgba(36,138,61,.55); background: var(--correct-soft); }
.option.correct .option-key { color: #fff; background: var(--correct); }
.option.correct .option-check { color: var(--correct); }
.option.wrong { border-color: rgba(215,0,21,.45); background: var(--wrong-soft); }
.option.wrong .option-key { color: #fff; background: var(--wrong); }
.option.wrong .option-check { color: var(--wrong); }
.option:disabled { color: var(--text); cursor: default; opacity: 1; }
.feedback { margin-top: 14px; border: 1px solid rgba(215,0,21,.14); border-radius: 20px; padding: 17px; background: var(--wrong-soft); }
.feedback.correct-feedback { border-color: rgba(36,138,61,.16); background: var(--correct-soft); }
.feedback.explanation-only { border-color: rgba(0,0,0,.055); background: rgba(255,255,255,.94); box-shadow: 0 5px 20px rgba(0,0,0,.035); }
.feedback.explanation-only #explanation-wrap { margin: 0; padding: 0; border: 0; }
.feedback-heading { display: flex; gap: 9px; align-items: center; }
.feedback-heading span { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--wrong); font-size: 13px; font-weight: 900; }
.correct-feedback .feedback-heading span { background: var(--correct); }
#explanation-wrap { margin-top: 13px; padding-top: 13px; border-top: 1px solid rgba(193, 60, 60, .14); }
#explanation-wrap p { margin: 0; color: #3a3a3c; line-height: 1.65; white-space: pre-wrap; }
.quiz-actions { position: fixed; z-index: 10; right: 0; bottom: 0; left: 0; display: flex; justify-content: center; gap: 10px; padding: 12px max(16px, env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(60,60,67,.12); background: rgba(245,245,247,.78); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); }
.quiz-actions .button { min-width: 0; max-width: 220px; flex: 1 1 0; }
.button { min-height: 50px; border: 0; border-radius: 15px; padding: 0 20px; font-weight: 650; cursor: pointer; transition: transform .13s ease, background .13s ease, opacity .13s ease; }
.button:active { transform: scale(.975); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button.primary { min-width: min(55vw, 310px); color: #fff; background: linear-gradient(180deg, #1384ed, #0066cc); box-shadow: 0 7px 20px rgba(0,102,204,.18); }
.quiz-actions .button.primary { min-width: 0; }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { color: var(--primary); background: var(--primary-soft); }
.button.ghost { border: 1px solid rgba(0,0,0,.06); color: #3a3a3c; background: rgba(255,255,255,.82); }
.complete-view { padding-top: 48px; text-align: center; }
.complete-mark { width: 68px; height: 68px; display: grid; place-items: center; margin: 0 auto 20px; border-radius: 22px; color: #fff; background: linear-gradient(145deg, #4da3ff, #0066cc); box-shadow: 0 10px 26px rgba(0,102,204,.2); }
.complete-mark svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.complete-view > p { margin-right: auto; margin-left: auto; }
.score-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; overflow: hidden; margin: 28px 0 22px; border: 1px solid rgba(0,0,0,.055); border-radius: 22px; background: var(--line); box-shadow: var(--shadow); }
.score-item { padding: 18px 10px; background: var(--surface); }
.score-item strong, .score-item span { display: block; }
.score-item strong { font-size: 25px; font-variant-numeric: tabular-nums; }
.score-item span { margin-top: 5px; color: var(--muted); font-size: 12px; }
.complete-actions { display: grid; gap: 10px; }
.complete-actions .button { width: 100%; }
.toast { position: fixed; z-index: 30; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; max-width: calc(100% - 32px); transform: translateX(-50%); border-radius: 14px; padding: 12px 16px; color: #fff; background: rgba(29,29,31,.88); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: var(--shadow); font-size: 13px; }
.noscript { margin: 20px; padding: 16px; text-align: center; color: #8b3131; background: #fff0ef; }

@keyframes view-in { from { opacity: 0; } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

@media (min-width: 700px) {
  .app-shell { padding-top: 34px; }
  .library-card { min-height: 146px; }
  .score-grid { grid-template-columns: repeat(4, 1fr); }
  .complete-actions { grid-template-columns: 1.3fr 1fr 1fr; }
}

@media (max-width: 380px) {
  .site-header, .app-shell { width: min(100% - 24px, 720px); }
  .question-card { padding: 18px 15px; }
  .quiz-actions { gap: 7px; padding-right: 12px; padding-left: 12px; }
  .button { padding-right: 15px; padding-left: 15px; }
  .type-list { grid-template-columns: 1fr; }
  .type-card.all-types { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

*:focus-visible { outline: 3px solid rgba(0, 102, 204, .46); outline-offset: 2px; }
