/* =========================================================
 * 運転免許 学科トレーニング — スタイル
 * スマートフォン優先（モバイルファースト）。白基調・カード型。
 * ========================================================= */

:root {
  color-scheme: light;

  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #18202f;
  --ink-2: #3d4757;
  --muted: #687385;
  --line: #e3e7ee;
  --line-strong: #cdd3dd;
  --chip: #eef1f6;

  --karimen: #0b7d71;
  --karimen-soft: #e3f4f1;
  --honmen: #2f5bd3;
  --honmen-soft: #e8eefc;
  --freq: #b45309;
  --freq-soft: #fdf1e2;
  --ichimon: #0e7490;
  --ichimon-soft: #e1f3f7;
  --mistake: #be2350;
  --mistake-soft: #fdebf0;
  --history: #4b5568;
  --history-soft: #eef1f5;

  --ok: #12804a;
  --ok-ink: #0b6239;
  --ok-soft: #e8f7ef;
  --ng: #cf2b2b;
  --ng-ink: #a61d1d;
  --ng-soft: #fdeeee;

  --o-mark: #2f5bd3;
  --x-mark: #be2350;

  --accent: var(--honmen);
  --accent-soft: var(--honmen-soft);

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .04);
  --gutter: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif;
}

.theme-karimen { --accent: var(--karimen); --accent-soft: var(--karimen-soft); }
.theme-honmen { --accent: var(--honmen); --accent-soft: var(--honmen-soft); }
.theme-freq { --accent: var(--freq); --accent-soft: var(--freq-soft); }
.theme-ichimon { --accent: var(--ichimon); --accent-soft: var(--ichimon-soft); }
.theme-mistake { --accent: var(--mistake); --accent-soft: var(--mistake-soft); }
.theme-history { --accent: var(--history); --accent-soft: var(--history-soft); }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

h1, h2, h3, p, ul, ol, dl, dd, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[tabindex="-1"]:focus { outline: none; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.ic { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em; }
.muted { color: var(--muted); font-weight: 400; }
.center { text-align: center; }
.noscript { padding: 24px; text-align: center; }

/* ---------- レイアウト ---------- */
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.wrap.narrow { max-width: 760px; }
.page { display: flex; flex-direction: column; gap: 16px; padding-top: 16px; padding-bottom: 48px; }

/* ---------- 上部バー ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.appbar-inner {
  display: grid; grid-template-columns: 96px 1fr 96px; align-items: center;
  height: 56px; max-width: 1080px; margin: 0 auto; padding: 0 6px;
}
.appbar-title { font-size: 1.0625rem; font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-right { display: flex; justify-content: flex-end; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent;
  display: inline-grid; place-items: center; color: var(--ink); text-decoration: none;
}
.icon-btn:hover { background: var(--chip); }
.icon-btn .ic { width: 24px; height: 24px; }

/* ---------- カード・ボタン ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 14px; border: 1.5px solid transparent;
  font-weight: 700; font-size: 1rem; line-height: 1.3; text-decoration: none; text-align: center;
  transition: transform .08s ease, background-color .15s ease, box-shadow .15s ease;
  touch-action: manipulation;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-lg { min-height: 56px; font-size: 1.0625rem; border-radius: 16px; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: .9375rem; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 28%, transparent); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-soft:hover:not(:disabled) { background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 12%); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover:not(:disabled) { background: #f7f8fb; }
.btn-danger { background: var(--ng); color: #fff; }
.btn-danger-text { color: var(--ng-ink); }
.btn-link { background: none; border: 0; color: var(--muted); min-height: 44px; width: 100%; text-decoration: underline; text-underline-offset: 3px; }
.btn .ic { width: 1.2em; height: 1.2em; }

.link { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-weight: 700; text-decoration: none; font-size: .9375rem; }
.link:hover { text-decoration: underline; }

.chip {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  background: var(--chip); color: var(--ink-2); font-size: .8125rem; font-weight: 600; line-height: 1.5;
}
.chip-type { background: var(--accent-soft); color: var(--accent); }
.chip-law { background: #fff4d6; color: #7a4b00; }
.qid { font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.qid.strong { color: var(--ink); font-weight: 800; font-size: .9375rem; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 700; background: var(--chip); color: var(--ink-2); line-height: 1.6;
}
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-ok { background: var(--ok-soft); color: var(--ok-ink); }
.pill-ng { background: var(--ng-soft); color: var(--ng-ink); }
.pill.tiny { font-size: .6875rem; padding: 0 6px; margin-left: 6px; }

.eyebrow { font-size: .78rem; font-weight: 700; color: var(--accent); letter-spacing: .02em; }
.section-title { font-size: 1.0625rem; font-weight: 800; margin-bottom: 4px; }
.section-title.out { margin: 8px 4px 0; }
.section-sub { font-size: .875rem; color: var(--muted); margin-bottom: 14px; }
.mini-h { font-size: .875rem; color: var(--muted); font-weight: 700; margin: 18px 0 8px; }
.empty { color: var(--muted); font-size: .9375rem; padding: 8px 0; }

.note {
  display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; padding: 12px 14px;
  border-radius: var(--radius-sm); background: #f6f7fa; color: var(--ink-2); font-size: .875rem; line-height: 1.6;
}
.note .ic { color: var(--accent); margin-top: 2px; }
.note.small { margin: 0 0 12px; padding: 10px 12px; font-size: .8125rem; }

.mode-icon {
  width: 48px; height: 48px; border-radius: 14px; display: inline-grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent);
}
.mode-icon .ic { width: 26px; height: 26px; }
.mode-icon.sm { width: 40px; height: 40px; border-radius: 12px; }
.mode-icon.sm .ic { width: 22px; height: 22px; }

/* ---------- トップ画面 ---------- */
.hero {
  background:
    radial-gradient(1200px 300px at 10% -40%, rgba(47, 91, 211, .10), transparent 60%),
    radial-gradient(900px 260px at 100% 0%, rgba(11, 125, 113, .08), transparent 60%),
    var(--surface);
  border-bottom: 1px solid var(--line);
  padding: calc(28px + env(safe-area-inset-top)) 0 26px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--honmen); color: #fff;
}
.logo .ic { width: 24px; height: 24px; }
.brand-sub { font-size: .8125rem; font-weight: 700; color: var(--muted); }
.settings-link {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px;
  border-radius: 999px; border: 1.5px solid var(--line-strong); background: var(--surface);
  font-weight: 700; font-size: .875rem; text-decoration: none; color: var(--ink-2);
}
.settings-link .ic { width: 20px; height: 20px; }

/* 設定画面 */
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; }
.setting-title { font-weight: 800; font-size: 1.0625rem; }
.setting-desc { font-size: .875rem; color: var(--muted); margin-top: 2px; }
.setting-test { margin-top: 4px; }
.setting-sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0 8px; }
.switch {
  flex: none; position: relative; display: inline-flex; align-items: center; width: 92px; height: 44px; padding: 0 12px;
  border-radius: 999px; border: 0; background: #d5dae3; color: var(--ink-2); font-weight: 800; font-size: .875rem;
  justify-content: flex-end; transition: background .15s;
}
.switch-knob {
  position: absolute; left: 4px; top: 4px; width: 36px; height: 36px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .25); transition: left .15s;
}
.switch[aria-checked="true"] { background: var(--honmen); color: #fff; justify-content: flex-start; }
.switch[aria-checked="true"] .switch-knob { left: 52px; }
.switch:disabled { opacity: .45; }
.hero h1 { font-size: clamp(1.5rem, 5.6vw, 2.25rem); font-weight: 800; letter-spacing: .01em; line-height: 1.35; }
.lead { margin-top: 6px; font-size: clamp(.9375rem, 3.6vw, 1.125rem); color: var(--ink-2); }

.home-main { display: flex; flex-direction: column; gap: 16px; padding-top: 20px; padding-bottom: 40px; }
.grid-main, .grid-sub { display: grid; grid-template-columns: 1fr; gap: 16px; }

.mode-card { display: flex; flex-direction: column; gap: 12px; border-top: 5px solid var(--accent); }
.mode-head { display: flex; align-items: center; gap: 12px; }
.mode-card h2 { font-size: 1.375rem; font-weight: 800; line-height: 1.3; }
.mode-card .desc { color: var(--ink-2); }
.facts { display: flex; flex-wrap: wrap; gap: 8px; }
.facts li {
  padding: 6px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--ink);
  font-size: .875rem; font-weight: 600;
}
.facts b { font-size: 1.125rem; color: var(--accent); margin: 0 1px; }
.best { font-size: .875rem; color: var(--muted); }
.best b { color: var(--ink); font-size: 1rem; }
.mode-card .btn { margin-top: auto; }

.sub-card { display: flex; flex-direction: column; gap: 10px; }
.sub-head { display: flex; align-items: center; gap: 12px; }
.sub-card h2 { font-size: 1.125rem; font-weight: 800; }
.sub-card .desc { color: var(--ink-2); font-size: .9375rem; }
.sub-meta { font-size: .8125rem; color: var(--muted); }
.sub-meta b { color: var(--accent); font-size: 1rem; }
.sub-card .btn { margin-top: auto; }

.resume { display: flex; flex-direction: column; gap: 12px; border-left: 5px solid var(--accent); }
.resume-title { font-weight: 800; }
.resume-sub { font-size: .875rem; color: var(--muted); }
.resume-actions { display: flex; gap: 8px; }
.resume-actions .btn { flex: 1; }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head h2 { font-size: 1.125rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.card-head h2 .ic { color: var(--accent); }

.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-row > div, .stat-grid > div { background: #f7f8fb; border-radius: var(--radius-sm); padding: 12px 14px; }
dt { font-size: .78rem; color: var(--muted); font-weight: 700; }
.stat-row dd, .stat-grid dd { font-size: 1.625rem; font-weight: 800; line-height: 1.25; font-variant-numeric: tabular-nums; }
dd small { font-size: .8125rem; font-weight: 700; color: var(--muted); margin-left: 2px; }

.test-list { display: flex; flex-direction: column; }
.test-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.test-list li:first-child { border-top: 0; }
.tl-main { display: flex; flex-direction: column; min-width: 0; }
.tl-title { font-weight: 700; font-size: .9375rem; }
.tl-date { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-score { display: flex; align-items: center; gap: 8px; font-size: .875rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl-score b { font-size: 1.0625rem; }

.site-foot { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 16px 0 8px; color: var(--muted); font-size: .8125rem; }
.foot-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 8px; }
.sound-btn[aria-pressed="false"], .speech-btn[aria-pressed="false"] { color: var(--muted); }
.head-btns { display: flex; }
.btn-line { background: #06c755; color: #fff; }
.btn-line:hover { filter: brightness(1.05); }
.btn-line .ic { fill: currentColor; stroke: none; }
.foot-note { max-width: 520px; text-align: left; margin: 0 0 4px; }
.read-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; min-height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1.5px solid var(--line-strong); background: var(--surface);
  font-size: .875rem; font-weight: 700; color: var(--ink-2);
}
.read-btn:hover { border-color: var(--accent); color: var(--accent); }
.site-foot .fine { max-width: 640px; font-size: .75rem; line-height: 1.7; }

/* ---------- 試験の説明・設定 ---------- */
.intro p { color: var(--ink-2); }
.intro-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.intro-title { font-size: 1.375rem; font-weight: 800; color: var(--ink) !important; line-height: 1.3; }
.intro .pills { margin-bottom: 8px; }
.intro .btn { margin-top: 16px; }
.rules { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px; }
.rules > div { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 10px 12px; }
.rules dd { font-weight: 800; font-size: 1rem; }

.seg-field { margin-bottom: 18px; }
.seg-field legend { font-size: .875rem; font-weight: 700; color: var(--ink-2); margin-bottom: 8px; padding: 0; }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.seg-opt { position: relative; display: block; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt > span {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  min-height: 56px; padding: 8px 10px; border-radius: 14px; border: 1.5px solid var(--line-strong);
  background: var(--surface); text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.seg-main { font-weight: 700; font-size: .9375rem; }
.seg-opt small { font-size: .72rem; color: var(--muted); font-weight: 600; }
.seg-opt input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.seg-opt input:checked + span .seg-main { color: var(--accent); }
.seg-opt input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.best-line { margin-bottom: 6px; color: var(--ink-2); }
.best-line b { font-size: 1.25rem; color: var(--accent); }

.cat-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.cat-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 60px; padding: 10px 14px;
  border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); text-align: left;
  transition: border-color .15s, background .15s;
}
.cat-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.cat-btn > .ic { color: var(--muted); margin-left: auto; }
.cat-text { display: flex; flex-direction: column; min-width: 0; }
.cat-name { font-weight: 700; }
.cat-meta { font-size: .78rem; color: var(--muted); }

.banner { display: flex; align-items: center; gap: 12px; text-decoration: none; border-left: 5px solid var(--accent); }
.banner:hover { background: #fffdf9; }
.banner > .ic { color: var(--muted); margin-left: auto; }
.banner-text { display: flex; flex-direction: column; gap: 4px; }
.banner-title { font-weight: 800; font-size: 1.0625rem; }
.banner-sub { font-size: .8125rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- 頻出テーマ ---------- */
.theme-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.theme-card { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; }
.theme-card h3 { font-size: 1.0625rem; font-weight: 800; }
.theme-desc { font-size: .875rem; color: var(--ink-2); }
.theme-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.theme-stat { font-size: .8125rem; color: var(--muted); }

/* ---------- 問題画面 ---------- */
.quiz { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.quiz-head {
  position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .96);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top);
}
.quiz-head-inner {
  display: grid; grid-template-columns: 48px 1fr auto auto; align-items: center; gap: 4px;
  max-width: 760px; margin: 0 auto; height: 52px; padding: 0 8px 0 6px;
}
.quiz-title { font-size: 1rem; font-weight: 800; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px;
  background: var(--chip); font-weight: 800; font-variant-numeric: tabular-nums; font-size: .9375rem;
}
.timer.is-warn { background: var(--ng-soft); color: var(--ng-ink); }
.timer-none { font-size: .72rem; font-weight: 700; color: var(--muted); background: transparent; }
.quiz-progress { max-width: 760px; margin: 0 auto; padding: 0 var(--gutter) 10px; }
.qcount { font-size: .875rem; color: var(--ink-2); margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.qcount b { font-size: 1.25rem; color: var(--ink); }
.progress { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .25s ease; }

.quiz-main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 16px var(--gutter) 8px; }
.qcard { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px 18px 22px; box-shadow: var(--shadow); }
.qmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.qmeta .qid { margin-left: auto; }
.qtext { font-size: clamp(1.125rem, 4.6vw, 1.375rem); line-height: 1.85; font-weight: 600; letter-spacing: .01em; overflow-wrap: anywhere; }
.quiz-hint { margin-top: 12px; text-align: center; font-size: .8125rem; color: var(--muted); }

.action-bar {
  position: sticky; bottom: 0; z-index: 10; width: 100%; max-width: 760px; margin: 0 auto;
  padding: 12px var(--gutter) calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 78%, rgba(244, 246, 250, 0));
}
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ans {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 104px; border-radius: 20px; border: 2px solid var(--line-strong); background: var(--surface);
  box-shadow: 0 2px 0 var(--line-strong); font-weight: 800; font-size: 1.0625rem;
  transition: transform .06s ease, border-color .15s, background .15s; touch-action: manipulation;
}
.ans .mark { width: 46px; height: 46px; stroke-width: 2.8; }
.ans-o .mark { color: var(--o-mark); }
.ans-x .mark { color: var(--x-mark); }
.ans:hover:not(:disabled) { border-color: var(--ink-2); }
.ans:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.ans.is-picked { border-color: var(--accent); background: var(--accent-soft); }
.ans:disabled { cursor: default; }
.answers.is-compact .ans { min-height: 76px; border-radius: 16px; }
.answers.is-compact .mark { width: 34px; height: 34px; }

.btn-next { min-height: 60px; font-size: 1.125rem; }

/* 正誤フィードバック（色＋文字＋アイコンで判別） */
.feedback { margin-top: 14px; border-radius: 20px; padding: 16px 18px 18px; border: 2px solid; background: var(--surface); }
.feedback.is-ok { border-color: var(--ok); background: var(--ok-soft); }
.feedback.is-ng { border-color: var(--ng); background: var(--ng-soft); }
.fb-head { display: flex; align-items: center; gap: 10px; }
.fb-icon { width: 36px; height: 36px; stroke-width: 2.4; }
.is-ok .fb-icon, .is-ok .fb-title { color: var(--ok-ink); }
.is-ng .fb-icon, .is-ng .fb-title { color: var(--ng-ink); }
.fb-title { font-size: 1.625rem; font-weight: 900; letter-spacing: .04em; }
.fb-answers { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: .9375rem; color: var(--ink-2); }
.fb-answers b { color: var(--ink); }
.expl { margin-top: 12px; padding-top: 12px; border-top: 1px dashed color-mix(in srgb, currentColor 25%, transparent); }
.expl-h { font-size: .8125rem; font-weight: 800; color: var(--muted); letter-spacing: .08em; margin-bottom: 4px; }
.expl p { line-height: 1.85; }
.ref { margin-top: 8px; font-size: .78rem; color: var(--muted); }

/* ---------- 一問一答 ---------- */
.filter-row {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; margin: 0 calc(var(--gutter) * -1);
  padding-left: var(--gutter); padding-right: var(--gutter); scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: none; min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--line-strong);
  background: var(--surface); font-weight: 700; font-size: .875rem; white-space: nowrap;
}
.filter-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.ichi-status { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 2px 2px 10px; }
.ichi-no { font-size: 1.375rem; font-weight: 900; color: var(--accent); }
.ichi-score { font-size: .875rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ichi-score b { font-size: 1.0625rem; color: var(--ink); }

/* ---------- 結果 ---------- */
.result-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px 20px; }
.result-mode { font-weight: 800; color: var(--accent); }
.timeup { display: inline-flex; gap: 6px; align-items: center; font-size: .875rem; color: var(--ng-ink); background: var(--ng-soft); padding: 4px 12px; border-radius: 999px; }
.verdict {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 20px; border-radius: 999px;
  font-size: 1.375rem; font-weight: 900; letter-spacing: .1em; border: 2px solid;
}
.verdict .ic { width: 28px; height: 28px; }
.verdict.is-pass { color: var(--ok-ink); background: var(--ok-soft); border-color: var(--ok); }
.verdict.is-fail { color: var(--ng-ink); background: var(--ng-soft); border-color: var(--ng); }
.score { display: flex; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
.score-num { font-size: 3.5rem; font-weight: 900; line-height: 1.1; }
.score-den { font-size: 1.0625rem; font-weight: 700; color: var(--ink-2); }
.rate { font-size: 1.0625rem; }
.rate b { font-size: 1.375rem; }
.meter { position: relative; width: 100%; max-width: 420px; margin: 18px 0 30px; }
.meter-track { height: 14px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px 4px 4px 999px; }
.meter-fill.is-pass { background: var(--ok); }
.meter-fill.is-fail { background: var(--ng); }
.meter-line { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--ink); transform: translateX(-1px); }
.meter-line span { position: absolute; top: calc(100% + 4px); right: -2px; white-space: nowrap; font-size: .75rem; font-weight: 700; color: var(--ink-2); }
.compare { font-size: 1rem; }
.compare b { font-size: 1.125rem; }
.result-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; margin-top: 10px; }
.result-facts > div { background: #f7f8fb; border-radius: var(--radius-sm); padding: 10px 8px; }
.result-facts dd { font-weight: 800; font-size: .9375rem; font-variant-numeric: tabular-nums; }
.result-actions { display: grid; grid-template-columns: 1fr; gap: 10px; }

.review-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.review-item { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: #fcfcfd; }
.ri-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.ri-head .qid { margin-left: auto; }
.ri-q { font-weight: 600; line-height: 1.75; }
.ri-ans { margin-top: 8px; font-size: .875rem; color: var(--ink-2); }
.ri-ans .sep { margin: 0 6px; color: var(--line-strong); }
.ri-expl, .ri-more { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #f3f5f9; font-size: .9375rem; line-height: 1.8; }
.ri-more summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.ri-more p:first-of-type { margin-top: 6px; }
.all-answers summary { cursor: pointer; font-weight: 800; min-height: 32px; display: list-item; }

/* ---------- 間違えた問題 ---------- */
.m-hero { display: flex; flex-direction: column; gap: 10px; }
.m-hero .section-sub { margin-bottom: 4px; }
.m-counts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.m-counts > div { display: flex; flex-direction: column; align-items: center; padding: 10px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.m-counts > div + div { background: var(--ok-soft); }
.m-counts b { font-size: 2rem; font-weight: 900; line-height: 1.2; font-variant-numeric: tabular-nums; }
.m-counts span { font-size: .8125rem; font-weight: 700; color: var(--ink-2); }

.toolbar { display: flex; flex-direction: column; gap: 10px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 14px; background: #e9ecf2; }
.tab { min-height: 44px; border: 0; border-radius: 10px; background: transparent; font-weight: 700; font-size: .9375rem; color: var(--ink-2); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }
.toolbar-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.select { display: flex; flex-direction: column; gap: 2px; }
.select-label { font-size: .72rem; font-weight: 700; color: var(--muted); padding-left: 4px; }
.select select {
  min-height: 44px; border-radius: 12px; border: 1.5px solid var(--line-strong); background: var(--surface);
  padding: 0 12px; font-weight: 600; appearance: auto;
}

.m-list { display: flex; flex-direction: column; gap: 12px; }
.m-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.m-card.is-open { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.m-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.m-q { font-weight: 600; line-height: 1.75; font-size: 1.0313rem; }
.m-facts { display: grid; grid-template-columns: 1fr 1.6fr; gap: 8px; }
.m-facts > div { background: #f7f8fb; border-radius: 10px; padding: 8px 10px; }
.m-facts dd { font-weight: 800; font-variant-numeric: tabular-nums; font-size: .9375rem; }
.m-progress { font-size: .8125rem; font-weight: 700; color: var(--accent); }
.m-progress.is-done { color: var(--ok-ink); display: flex; gap: 4px; align-items: center; }
.m-card .feedback { margin-top: 0; }
.m-after { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.empty-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--muted); }

/* ---------- 学習履歴 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px; }
.stat-grid.two { margin-top: 10px; }
.stat-grid > div[class^="theme-"] { background: var(--accent-soft); }
.stat-sub { font-size: .75rem; color: var(--muted); margin-top: 2px; }

.chart-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.cols {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; height: 200px; align-items: stretch;
  padding-top: 4px;
}
.col { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.col-val { font-size: .72rem; font-weight: 700; color: var(--ink-2); height: 18px; font-variant-numeric: tabular-nums; }
.col-bar-wrap {
  flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center;
  border-bottom: 1px solid var(--line-strong);
  background: linear-gradient(to top, transparent calc(50% - .5px), var(--line) calc(50% - .5px), var(--line) calc(50% + .5px), transparent calc(50% + .5px));
}
.col-bar { display: block; width: min(24px, 64%); background: var(--honmen); border-radius: 4px 4px 0 0; }
.col.is-today .col-bar { background: var(--honmen); }
.col-day { display: flex; flex-direction: column; align-items: center; margin-top: 6px; font-size: .72rem; color: var(--ink-2); line-height: 1.3; font-variant-numeric: tabular-nums; }
.col-day small { color: var(--muted); font-size: .68rem; }
.col.is-today .col-day { font-weight: 800; color: var(--ink); }

.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 8.5em 1fr 4.2em; align-items: center; gap: 10px; font-size: .8125rem; }
.hbar-label { font-weight: 700; color: var(--ink-2); display: flex; align-items: center; white-space: nowrap; }
.hbar-track { height: 12px; border-radius: 4px; background: #eef1f6; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--honmen); border-radius: 0 4px 4px 0; }
.hbar-val { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; display: flex; flex-direction: column; line-height: 1.2; }
.hbar-val small { font-size: .68rem; color: var(--muted); font-weight: 600; }
.hbar.is-empty .hbar-label { color: var(--muted); font-weight: 600; }

.danger-zone .btn { margin-top: 4px; }

/* ---------- モーダル・トースト ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: end center;
  background: rgba(16, 22, 34, .45); padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom));
  animation: fade .15s ease;
}
.modal {
  width: 100%; max-width: 440px; background: var(--surface); border-radius: 22px; padding: 22px 20px 18px;
  box-shadow: 0 20px 60px rgba(16, 24, 40, .25); animation: rise .18s ease;
}
.modal h2 { font-size: 1.1875rem; font-weight: 800; margin-bottom: 8px; }
.modal p { color: var(--ink-2); font-size: .9375rem; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 120;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px;
  background: #1d2433; color: #fff; font-weight: 700; font-size: .9375rem; text-align: center;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .25); transition: opacity .2s, transform .2s; overflow-wrap: anywhere;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- タブレット・PC ---------- */
@media (min-width: 640px) {
  :root { --gutter: 24px; }
  .grid-sub { grid-template-columns: repeat(2, 1fr); }
  .stat-row { grid-template-columns: repeat(4, 1fr); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .stat-grid.two { grid-template-columns: repeat(2, 1fr); }
  .rules { grid-template-columns: repeat(4, 1fr); }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .theme-grid { grid-template-columns: repeat(2, 1fr); }
  .result-actions { grid-template-columns: 1fr 1fr; }
  .resume { flex-direction: row; align-items: center; justify-content: space-between; }
  .resume-actions .btn { flex: none; }
  .modal-backdrop { place-items: center; }
  .card { padding: 24px; }
  .toolbar { flex-direction: row; align-items: end; justify-content: space-between; }
  .tabs { min-width: 300px; }
  .toolbar-row { min-width: 320px; }
}

@media (min-width: 900px) {
  .grid-main { grid-template-columns: 1fr 1fr; gap: 20px; }
  .grid-sub { grid-template-columns: repeat(3, 1fr); gap: 20px; }
  .home-main { gap: 20px; padding-top: 28px; }
  .theme-grid { grid-template-columns: repeat(3, 1fr); }
  .chart-grid { grid-template-columns: 1fr 1.2fr; }
  .mode-card { padding: 28px; }
  .ans { min-height: 120px; }
}

@media (hover: none) {
  .ans:hover:not(:disabled) { border-color: var(--line-strong); }
  .cat-btn:hover { border-color: var(--line); background: var(--surface); }
}

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