:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --surface: #fff;
  --text: #202326;
  --muted: #596168;
  --line: #dce0e3;
  --accent: #b91c1c;
  --accent-2: #991b1b;
  --accent-soft: #fff1f1;
  --ok: #166534;
  --ok-bg: #edf8f0;
  --warn: #854d0e;
  --warn-bg: #fff9e6;
  --bad: #991b1b;
  --bad-bg: #fff1f1;
  --shadow: 0 2px 8px rgb(20 30 40 / 4%);
}
:root.dark-mode {
  color-scheme: dark;
  --bg: #17191b;
  --surface: #222629;
  --text: #f3f5f6;
  --muted: #b8c0c6;
  --line: #41494f;
  --accent-soft: #3a2022;
  --ok: #86d39b;
  --ok-bg: #193326;
  --warn: #f0c66b;
  --warn-bg: #3b301b;
  --bad: #ff9b9b;
  --bad-bg: #3a2022;
  --shadow: 0 2px 8px rgb(0 0 0 / 20%);
}
* { box-sizing: border-box; letter-spacing: 0; }
html { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
body { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { touch-action: manipulation; cursor: pointer; }
button:disabled { cursor: not-allowed; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #006b80; outline-offset: 3px; }
button { transition: background-color .15s, border-color .15s; }
.app-shell { max-width: 1008px; margin: 0 auto; padding: 0 max(20px, env(safe-area-inset-left)) max(32px, env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bg); padding: 16px 0; border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.brand > div:last-child { min-width: 0; }
.flagmark { width: 40px; height: 40px; flex: 0 0 40px; display: block; border-radius: 8px; }
.brand-title { font-size: 1rem; font-weight: 750; line-height: 1.3; overflow-wrap: anywhere; }
.brand-sub { font-size: .875rem; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.icon-btn, .share-icon, .bookmark-icon { width: 44px; height: 44px; flex: 0 0 44px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--accent); display: grid; place-items: center; font-size: 1.25rem; line-height: 1; }
main { padding-top: 24px; }
.hero { padding: 8px 0 24px; }
.eyebrow { font-size: .8125rem; color: var(--accent); font-weight: 700; text-transform: uppercase; }
.hero h1 { font-size: 2rem; line-height: 1.2; margin: 8px 0 12px; max-width: 700px; font-weight: 750; }
.hero p { margin: 0; color: var(--muted); max-width: 720px; line-height: 1.65; }
.grid { display: grid; gap: 16px; }
.grid.actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 20px; box-shadow: var(--shadow); }
.action-card { display: flex; flex-direction: column; gap: 8px; text-align: left; min-height: 168px; }
.action-card strong { font-size: 1.0625rem; }
.action-card span { color: var(--muted); font-size: .9375rem; line-height: 1.5; }
.action-card .action-icon { font-size: 1.25rem; color: var(--accent); height: 28px; }
.action-card.primary { background: var(--accent); border-color: var(--accent); color: white; }
.action-card.primary span { color: white; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 24px 0; padding: 20px 0; border-block: 1px solid var(--line); }
.stat { min-width: 0; padding: 0 8px; }
.stat b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .875rem; color: var(--muted); }
.section-title { display: flex; justify-content: space-between; gap: 16px; margin: 24px 0 12px; }
.section-title h2 { font-size: 1.125rem; margin: 0; }
.section-title small { color: var(--muted); }
.list { display: grid; gap: 12px; }
.list-btn { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 16px 20px; text-align: left; display: flex; gap: 16px; align-items: center; min-height: 80px; }
.list-btn .grow { flex: 1; min-width: 0; }
.list-btn strong { display: block; font-size: 1rem; overflow-wrap: anywhere; }
.list-btn small { display: block; color: var(--muted); margin-top: 4px; line-height: 1.5; font-size: .875rem; }
.list-btn:disabled, .list-btn.disabled { background: #eef0f2; color: var(--muted); }
:root.dark-mode .list-btn:disabled, :root.dark-mode .list-btn.disabled { background: #2b3034; }
.pill { font-size: .8125rem; padding: 4px 10px; border-radius: 6px; background: #edf0f2; color: #495158; overflow-wrap: anywhere; }
.pill.muted { background: #e5e7eb; color: var(--muted); }
:root.dark-mode .pill { background: #30373b; color: #dce2e6; }
:root.dark-mode .pill.muted { background: #343b40; }
.chev { font-size: 1.5rem; color: var(--muted); }
.list-share-row { display: flex; align-items: center; gap: 12px; }
.list-share-row > .list-btn { flex: 1; min-width: 0; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; min-height: 48px; padding: 12px 16px; font-weight: 650; overflow-wrap: anywhere; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.ghost { background: transparent; }
.btn.good { background: var(--ok-bg); border-color: #8dbb99; color: var(--ok); }
.btn.bad { background: var(--bad-bg); border-color: #eab7b7; color: var(--bad); }
.btn:disabled { background: #edf0f2; color: #657078; border-color: var(--line); }
:root.dark-mode .btn:disabled { background: #30363a; color: #9da7ad; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.btn-row .btn { flex: 1; min-width: 120px; }
.form-card, .settings-group { display: grid; gap: 20px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; max-width: 760px; margin-inline: auto; }
.field label { font-size: .9375rem; font-weight: 650; display: block; margin-bottom: 8px; }
.select, .input { width: 100%; border: 1px solid #929ba3; background: var(--surface); border-radius: 8px; min-height: 48px; padding: 10px 12px; font-size: 1rem; }
.hint, .notice { font-size: .9375rem; line-height: 1.6; }
.hint { color: var(--muted); }
.notice { border-left: 3px solid #b38226; background: var(--warn-bg); color: #71430c; padding: 16px; border-radius: 4px; }
.quiz-head { display: grid; gap: 12px; margin-bottom: 20px; }
.quiz-meta { display: flex; justify-content: space-between; gap: 16px; font-size: .9375rem; color: var(--muted); flex-wrap: wrap; }
.progress-track { height: 6px; background: #dce0e3; border-radius: 3px; overflow: hidden; }
:root.dark-mode .progress-track { background: #3d454a; }
.progress-fill { height: 100%; background: var(--accent); transition: width .2s; }
.question-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 24px; box-shadow: var(--shadow); }
.q-kicker { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.q-kicker .pill { background: var(--accent-soft); color: var(--accent-2); }
.bookmark-icon { margin-left: auto; }
.question { font-size: 1.375rem; line-height: 1.5; font-weight: 700; margin: 0 0 16px; overflow-wrap: anywhere; }
.options { display: grid; gap: 8px; }
.option { border: 1px solid #9aa3ab; background: var(--surface); border-radius: 8px; min-height: 56px; padding: 12px 16px; display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; color: var(--text); line-height: 1.5; }
.option > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.option .letter { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 4px; background: #edf0f2; display: grid; place-items: center; font-weight: 700; font-size: .875rem; }
:root.dark-mode .option .letter { background: #343b40; }
.option.selected { border-color: var(--accent); background: var(--accent-soft); }
.option.selected .letter { background: var(--accent); color: white; }
.option.correct { border-color: var(--ok); background: var(--ok-bg); }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }
.option:disabled { opacity: 1; -webkit-text-fill-color: currentColor; }
.quiz-actions { display: flex; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.quiz-actions .btn { flex: 1; min-width: 100px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 750; color: var(--text); }
.answer-status { margin-top: 12px; border-radius: 6px; padding: 12px 16px; font-size: .9375rem; line-height: 1.6; border-left: 3px solid currentColor; }
.answer-status.unkeyed { background: #edf0f2; color: var(--muted); }
.answer-status.correct { background: var(--ok-bg); color: var(--ok); }
.answer-status.wrong { background: var(--bad-bg); color: var(--bad); }
.study-list { display: grid; gap: 12px; margin-top: 16px; }
.study-line { padding: 12px; background: var(--surface); border-bottom: 1px solid var(--line); white-space: pre-wrap; }
.result-score { text-align: center; border: 0; background: transparent; box-shadow: none; padding: 24px 0; }
.result-score .big { font-size: 3rem; font-weight: 800; }
.result-score p { color: var(--muted); margin: 8px 0; }
.result-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 24px 0; padding: 20px 0; border-block: 1px solid var(--line); }
.pass { color: var(--ok); }.fail { color: var(--bad); }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px; }
.tab { white-space: nowrap; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; min-height: 44px; padding: 8px 12px; }
.tab.active { background: var(--accent); color: white; }
.searchbar { display: flex; gap: 12px; margin: 12px 0; flex-wrap: wrap; }
.searchbar .input { flex: 1; min-width: 180px; }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 24px; border-bottom: 1px solid var(--line); padding: 8px 0 24px; }
.setting-row > div:first-child { flex: 1; min-width: 0; }
.setting-row small { color: var(--muted); display: block; margin-top: 6px; font-size: .9375rem; line-height: 1.6; }
.compact-select { max-width: 180px; flex: 0 0 auto; }
.toggle { width: 56px; height: 44px; flex: 0 0 56px; border: 0; padding: 10px 4px; border-radius: 22px; background: linear-gradient(#747e86, #747e86) center / 56px 32px no-repeat; }
.toggle i { display: block; width: 24px; height: 24px; background: white; border-radius: 50%; box-shadow: 0 1px 3px #0003; transition: transform .15s; }
.toggle.on { background-image: linear-gradient(var(--accent), var(--accent)); }
.toggle.on i { transform: translateX(24px); }
.footer-note, .site-credits { color: var(--muted); font-size: .875rem; line-height: 1.6; text-align: center; }
.footer-note { margin: 24px 0; }
.site-credits { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line); }
.site-credits p { margin: 4px 0; }
.teacher-thanks { margin-top: 16px; }
.site-credits strong { color: var(--text); }
.site-credits a { color: var(--accent); text-underline-offset: 3px; overflow-wrap: anywhere; }
.empty, .loading-state { text-align: center; padding: 32px 20px; color: var(--muted); }
.loading-state { min-height: 70vh; display: grid; place-items: center; }
.loading-state.error { color: var(--bad); }
.ad-slot { min-height: 56px; margin-top: 16px; display: grid; place-items: center; color: var(--muted); position: relative; overflow: hidden; }
.ad-slot .adsbygoogle { display: block; width: 100%; min-height: 56px; }
.ad-slot span { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; font-size: .8125rem; }
.install-backdrop { position: fixed; inset: 0; z-index: 50; background: rgb(24 24 27 / 42%); display: grid; place-items: end center; padding: 16px 16px max(16px, env(safe-area-inset-bottom)); overflow: auto; }
.install-dialog { width: min(100%, 440px); max-height: calc(100dvh - 48px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 24px; box-shadow: 0 12px 40px #0002; }
.install-dialog h2 { margin: 16px 0 12px; font-size: 1.25rem; line-height: 1.4; }
.install-dialog p { margin: 0 0 12px; color: var(--muted); line-height: 1.6; }
.install-icon { width: 48px; height: 48px; border-radius: 8px; display: block; }
@media (hover: hover) {
  .btn:hover:not(:disabled), .list-btn:hover:not(:disabled), .option:hover:not(:disabled), .icon-btn:hover, .share-icon:hover, .bookmark-icon:hover, .action-card:hover { border-color: var(--accent); background: var(--accent-soft); }
  .btn.primary:hover:not(:disabled), .action-card.primary:hover { background: var(--accent-2); color: white; }
}
@media (max-width: 640px) {
  .app-shell { padding-inline: max(16px, env(safe-area-inset-left)); }
  .topbar { padding-block: 12px; }
  .topbar-inner, .brand { gap: 8px; }
  .brand-sub { display: none; }
  .flagmark { width: 32px; height: 32px; flex-basis: 32px; }
  main { padding-top: 20px; }
  .hero { padding: 4px 0 20px; }
  .hero h1 { font-size: 1.5rem; }
  .grid.actions { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .action-card { min-height: 0; padding: 16px; gap: 6px; }
  .stats, .result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .question-card { padding: 14px; }
  .question { font-size: 1.1875rem; margin-bottom: 14px; }
  .option { padding: 10px 12px; gap: 10px; }
  .quiz-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quiz-actions .btn { min-width: 0; }
  .quiz-actions .btn.bad { grid-column: 1 / -1; }
  .setting-row { gap: 16px; }
  .setting-row:has(select) { flex-wrap: wrap; }
  .setting-row:has(select) > div:first-child { flex-basis: 100%; }
  .setting-row .compact-select { max-width: none; width: 100%; }
  .list-btn { padding: 14px; }
  .install-dialog { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
