/* ============================================================================
   社労士 横断マスター — スタイル
   モバイルファースト。落ち着いた学習向けの配色。
   ============================================================================ */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #3b82f6;
  --brand-d: #2563eb;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .05);
  --maxw: 560px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN',
    'Noto Sans JP', Meiryo, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

/* ---- ヘッダー ---- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px 6px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; max-width: var(--maxw); margin: 0 auto; }
.logo {
  width: 40px; height: 40px; border-radius: 11px;
  object-fit: cover; display: block;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .18);
}
.app-header h1 { font-size: 17px; margin: 0; }
.tagline-sm { font-size: 11px; color: var(--muted); margin: 0; }

/* ---- レイアウト ---- */
.view { max-width: var(--maxw); margin: 0 auto; padding: 16px; }
.hero { padding: 8px 4px 16px; }
.hero h2 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
.hero.compact h2 { font-size: 19px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.note {
  margin: 12px 0 0; padding: 10px 12px; font-size: 13px;
  background: #f1f5fd; border-radius: 10px; color: #334155;
}

/* ---- 記憶の宮殿(要点の覚え方の一例) ---- */
.palace-tip {
  margin: 12px 0 0; padding: 12px 14px; border-radius: 12px;
  background: linear-gradient(135deg, #faf5ff, #eef2ff);
  border: 1px solid #e9d5ff;
}
.pt-head { font-weight: 800; font-size: 13.5px; color: #7c3aed; margin-bottom: 4px; }
.pt-intro { margin: 0 0 8px; font-size: 12.5px; color: #475569; line-height: 1.6; }
.pt-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: pt; }
.pt-steps li {
  position: relative; padding-left: 30px; counter-increment: pt;
  font-size: 13px; line-height: 1.6;
}
.pt-steps li::before {
  content: counter(pt); position: absolute; left: 0; top: 1px;
  width: 21px; height: 21px; border-radius: 50%;
  background: #a855f7; color: #fff; font-size: 11.5px; font-weight: 800;
  display: grid; place-items: center;
}
.pt-spot { display: inline-block; font-weight: 800; color: #6d28d9; margin-right: 6px; }
.pt-story { color: #334155; }
[data-theme="dark"] .palace-tip { background: linear-gradient(135deg, #271d3f, #1d2440); border-color: #4c1d95; }
[data-theme="dark"] .pt-intro { color: #cbd5e1; }
[data-theme="dark"] .pt-spot { color: #c4b5fd; }
[data-theme="dark"] .pt-story { color: #e2e8f0; }
[data-theme="dark"] .pt-head { color: #c4b5fd; }

/* ---- 制度のポイント解説(差分セリフ) ---- */
.voices { margin: 12px 0 0; padding: 12px 14px; border-radius: 12px; background: #f8fafc; border: 1px solid var(--line); }
.vc-head { font-weight: 800; font-size: 13.5px; color: #334155; margin-bottom: 8px; }
.vc-row { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: start; margin-bottom: 10px; }
.vc-who { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 56px; }
.vc-face {
  width: 44px; height: 44px; border-radius: 50%;
  object-fit: cover; object-position: center top;
  border: 2px solid var(--vc, #64748b); background: #fff;
}
/* 画像未作成のときの枠だけ確保するプレースホルダ(人物横断のイラスト用) */
.vc-face.vc-ph {
  border-style: dashed; border-color: var(--vc, #cbd5e1);
  background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 4px, #eef2f7 4px, #eef2f7 8px);
}
.vc-face.vc-ph::after { content: "人"; display: flex; align-items: center; justify-content: center; height: 100%; color: var(--vc, #94a3b8); font-size: 13px; font-weight: 800; }
.vc-name {
  text-align: center; font-size: 10.5px; font-weight: 800; color: #fff; line-height: 1.2;
  background: var(--vc, #64748b); border-radius: 8px; padding: 2px 6px;
}
.vc-line {
  font-size: 13.5px; line-height: 1.6; color: #1e293b;
  background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--vc, #64748b);
  border-radius: 8px; padding: 7px 10px;
}
[data-theme="dark"] .voices { background: #0f172a; }
[data-theme="dark"] .vc-head { color: #cbd5e1; }
[data-theme="dark"] .vc-line { background: #1e293b; color: #e2e8f0; }

/* ---- 覚え方ページ ---- */
.mg-text { font-size: 14px; line-height: 1.8; margin: 6px 0 0; }
.mg-steps { margin: 8px 0 0; padding-left: 22px; }
.mg-steps li { font-size: 14px; line-height: 1.7; margin-bottom: 6px; }
.mg-list { list-style: none; margin: 8px 0 0; padding: 0; }
.mg-list li { font-size: 14px; line-height: 1.7; margin-bottom: 8px; }
.mg-apply { border: 1px solid #e9d5ff; background: linear-gradient(135deg, #faf5ff, #eef2ff); }
[data-theme="dark"] .mg-apply { background: linear-gradient(135deg, #271d3f, #1d2440); border-color: #4c1d95; }

/* ---- 統計グリッド ---- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-grid.tight { grid-template-columns: repeat(3, 1fr); }
.stat {
  background: var(--surface); border-radius: var(--radius);
  padding: 14px; text-align: center; box-shadow: var(--shadow);
}
.stat-num { font-size: 28px; font-weight: 800; line-height: 1.1; color: var(--brand-d); }
.stat-num small { font-size: 14px; color: var(--muted); font-weight: 600; }
.stat-lbl { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---- ボタン ---- */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand); color: #fff; border: none;
  border-radius: 12px; padding: 12px 18px; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: transform .06s, background .2s;
  box-shadow: 0 6px 16px rgba(59, 130, 246, .3);
}
.btn-primary:active { transform: scale(.98); background: var(--brand-d); }
.btn-primary.big { width: 100%; padding: 16px; font-size: 16px; margin-bottom: 16px; }
.btn-ghost {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-ghost.danger { color: #dc2626; border-color: #fecaca; }
.btn-ghost.big { width: 100%; padding: 14px; font-size: 15px; }
.weak-btn { margin: -6px 0 16px; color: var(--brand-d); }
.imp-btn { margin: -6px 0 16px; color: #7c3aed; }
.mode-badge.imp { background: #8b5cf6; }
.mode-badge {
  font-size: 11px; font-weight: 700; color: #fff; background: #f59e0b;
  border-radius: 99px; padding: 3px 10px; white-space: nowrap;
}
.link-back { background: none; border: none; color: var(--brand-d); font-size: 14px; cursor: pointer; padding: 4px 0 10px; }

/* ---- カードボックス ---- */
.card-box {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-box h3 { margin: 0 0 2px; font-size: 15px; }
.chart { width: 100%; height: 180px; display: block; margin-top: 8px; }
.chart.tall { height: 220px; }

/* ---- チップ / 科目タグ ---- */
.topic-mini { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  background: #eef2ff; color: var(--brand-d); border: none;
  border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip:active { background: #e0e7ff; }
.subj-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.subj {
  font-size: 11px; font-weight: 700; color: #fff; background: var(--c, #888);
  border-radius: 6px; padding: 2px 7px;
}

/* ---- テーマ検索 ---- */
.theme-search {
  width: 100%; box-sizing: border-box;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 14px; font-size: 14px; color: var(--ink);
  margin-bottom: 10px; box-shadow: var(--shadow);
}
.theme-search:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.subj-filter.dim { opacity: .45; }

/* ---- 法令基準の表記 ---- */
.info-page { display: flex; flex-direction: column; gap: 12px; }
.info-h { font-size: 18px; margin: 4px 2px 0; }
.info-card { padding: 14px 16px; }
.info-card h3 { font-size: 15px; margin: 0 0 8px; }
.info-card p { font-size: 13.5px; line-height: 1.7; margin: 6px 0; }
.info-steps, .info-list { margin: 6px 0 0; padding-left: 1.25em; font-size: 13.5px; line-height: 1.8; }
.info-steps li, .info-list li { margin: 5px 0; }
.info-link { color: var(--brand-d); font-weight: 700; word-break: break-all; }
.info-small { font-size: 12px; }
.law-basis {
  text-align: center; font-size: 11px; color: var(--muted);
  margin: 18px 0 4px; letter-spacing: .02em;
}

/* ---- 横断テーマ一覧 ---- */
.topic-list { display: grid; gap: 12px; }
.palace-btn { margin-bottom: 16px; color: var(--brand-d); }

/* ---- 記憶の宮殿 ---- */
.palace { display: grid; gap: 10px; }
.palace-room {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); cursor: pointer;
}
.palace-room:active { transform: scale(.99); }
.palace-num {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 800; font-size: 13px;
  display: grid; place-items: center; margin-top: 2px;
}
.palace-body { display: flex; flex-direction: column; gap: 2px; }
.palace-place { font-weight: 800; font-size: 15.5px; }
.palace-hook { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.palace-topic { font-size: 12px; color: var(--brand-d); font-weight: 700; margin-top: 2px; }
.topic-card {
  background: var(--surface); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); cursor: pointer; transition: transform .06s;
  border: 1px solid transparent;
}
.topic-card:active { transform: scale(.99); border-color: var(--line); }
.topic-head { display: flex; align-items: center; justify-content: space-between; }
.topic-head h3 { margin: 0; font-size: 16px; }
.pill { background: #eef2ff; color: var(--brand-d); border-radius: 999px; font-size: 11px; font-weight: 700; padding: 2px 9px; white-space: nowrap; flex: none; }
.topic-prog { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.mini-track { flex: 1; height: 6px; background: #eef2f7; border-radius: 99px; overflow: hidden; }
.mini-fill { height: 100%; background: linear-gradient(90deg, var(--brand), #6366f1); }

/* ---- 横断テーマ 優先順位テーブル(ホーム) ---- */
.prio-box { padding: 12px 12px 6px; }
.prio-head { display: flex; align-items: baseline; justify-content: space-between; padding: 4px 4px 8px; }
.prio-head h3 { margin: 0; font-size: 15px; }
.prio-table { width: 100%; border-collapse: collapse; }
.prio-row { cursor: pointer; border-top: 1px solid var(--line); transition: background .06s; }
.prio-table tr:first-child { border-top: none; }
.prio-row:active { background: rgba(59,130,246,.06); }
.prio-row > td { padding: 11px 4px; vertical-align: middle; }
.prio-rank { width: 34px; text-align: center; }
.rank-no {
  display: inline-grid; place-items: center; width: 24px; height: 24px;
  border-radius: 50%; background: var(--rc, #cbd5e1); color: #fff;
  font-size: 12px; font-weight: 800;
}
.prio-main { width: 100%; }
.prio-title { font-size: 14.5px; font-weight: 700; line-height: 1.35; }
.prio-main .subj-tags { margin-top: 5px; }
.prio-stat { width: 96px; text-align: right; }
.prio-stat .mini-track { width: 88px; margin-left: auto; }
.prio-meta { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.prio-badge { font-size: 10.5px; font-weight: 800; border-radius: 6px; padding: 2px 6px; white-space: nowrap; }
.prio-badge.new { background: #f1f5f9; color: #94a3b8; }
.prio-badge.due { background: #fef3c7; color: #b45309; }
.prio-badge.ok  { background: #dcfce7; color: #15803d; }
.prio-empty { padding: 18px 4px; text-align: center; }
[data-theme="dark"] .prio-badge.new { background: #1e293b; color: #64748b; }
[data-theme="dark"] .prio-badge.due { background: #3b2f12; color: #fbbf24; }
[data-theme="dark"] .prio-badge.ok  { background: #14321f; color: #4ade80; }

/* ---- 科目フィルタ(ホーム) ---- */
.subj-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.sfchip {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.sfchip.on { background: var(--c, var(--brand)); border-color: var(--c, var(--brand)); color: #fff; }
.sfchip:first-child.on { background: var(--ink); border-color: var(--ink); }

/* ---- 比較テーブル ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.cmp { width: 100%; border-collapse: collapse; font-size: 13px; }
/* 多列(3列以上)の表は自然幅で横スクロール。狭い画面で各セルが潰れないように */
table.cmp.wide { width: auto; min-width: 100%; }
table.cmp.wide td, table.cmp.wide th { min-width: 6.5em; }
table.cmp.wide td.rowhdr { min-width: 5.5em; }
/* 横スクロール可能なことを示す右端フェード(スクロール領域に position 付与) */
.table-wrap { position: relative; }
.table-wrap::after {
  content: ""; position: absolute; top: 0; right: 0; width: 22px; height: 100%;
  background: linear-gradient(90deg, transparent, var(--surface));
  pointer-events: none; opacity: .9;
}
table.cmp th {
  background: #f1f5fd; color: #334155; font-weight: 700; text-align: left;
  padding: 9px 10px; white-space: normal; word-break: break-word; line-height: 1.4;
}
table.cmp td { padding: 9px 10px; border-top: 1px solid var(--line); vertical-align: top; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
table.cmp td.rowhdr { font-weight: 700; color: var(--ink); white-space: normal; word-break: break-word; }
table.cmp td.rowhdr.merged { vertical-align: middle; }
table.cmp tbody tr:nth-child(even) td { background: #fafbfe; }

/* ---- 法律ごとの色分け(行) ---- */
table.cmp tbody tr.lawrow td { background: color-mix(in srgb, var(--rowc) 13%, var(--surface)); }
table.cmp tbody tr.lawrow td.rowhdr { box-shadow: inset 4px 0 0 var(--rowc); }

/* ---- 答え列ごとの色分け(5年=青/2年=橙 等。行色より優先) ---- */
table.cmp th.colh { color: var(--colc); border-bottom: 2px solid var(--colc); }
table.cmp tbody tr td.ans.colc { background: color-mix(in srgb, var(--colc) 12%, var(--surface)); }
/* 短い答え(数字・割合・キーワード)は大きく太字・中央寄せで主役に */
table.cmp td.ans.short, table.cmp td.wordcloze.short { text-align: center; font-size: 1.18em; font-weight: 800; }
table.cmp td.ans.short .mask, table.cmp td.wordcloze.short .cloze { font-weight: 800; }
/* emCols: 指定列を全部太字＋センタリング（セルの長短に関わらず） */
table.cmp td.ans.em { text-align: center; font-weight: 800; }
table.cmp td.ans.em .mask, table.cmp td.ans.em .cloze { font-weight: 800; }

/* ---- 赤シート(答えを隠す) ---- */
.sheet-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.chip2 {
  background: #eef2ff; color: var(--brand-d); border: none; border-radius: 99px;
  padding: 7px 13px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.chip2:active { transform: scale(.96); }
.sheet-hint { margin-left: auto; }
table.cmp td.ans .mask {
  border-radius: 4px; padding: 0 2px; transition: background .12s, color .12s;
}
/* シートON時: 答えを赤ブロックで隠す。幅は答えの長さのまま(固定しない)。タップで表示 */
.sheet table.cmp td.ans .mask {
  display: inline;
  background: #e11d48; color: transparent; cursor: pointer;
  -webkit-user-select: none; user-select: none;
}
.sheet table.cmp td.ans .mask.revealed {
  background: transparent; color: inherit;
}
/* 語句単位の赤シート(太字だけ隠す。Anki方式) */
table.cmp td.wordcloze { white-space: normal; }
.nbr { white-space: nowrap; }
table.cmp td.wordcloze .cloze {
  border-radius: 3px; padding: 0 2px; font-weight: 700;
  transition: background .12s, color .12s;
}
.sheet table.cmp td.wordcloze .cloze {
  background: #e11d48; color: transparent; cursor: pointer;
  -webkit-user-select: none; user-select: none;
}
.sheet table.cmp td.wordcloze .cloze.revealed {
  background: transparent; color: #be123c;
}
/* 赤シートをめくった答えが長いとき、横に伸びず適切に折り返す */
table.cmp td.ans, table.cmp td.wordcloze {
  overflow-wrap: anywhere; word-break: break-word; line-height: 1.55;
}
.sheet table.cmp td.ans .mask.revealed {
  overflow-wrap: anywhere; word-break: break-word;
}
.row-x { color: #ef4444; font-weight: 800; margin-right: 5px; }

/* ---- スマホでは比較表を画面幅に収める(横スクロールを出さない) ---- */
@media (max-width: 600px) {
  table.cmp { font-size: 12px; }
  table.cmp.wide { width: 100%; min-width: 0; table-layout: fixed; }
  table.cmp.wide td, table.cmp.wide th { min-width: 0; }
  table.cmp.wide td.rowhdr { min-width: 0; }
  table.cmp th, table.cmp td { padding: 6px 5px; }
  .table-wrap::after { display: none; }
}

/* ---- 表テスト ---- */
.tt-prompt-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.tt-answers {
  margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line);
  opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s;
}
.tt-answers.show { opacity: 1; transform: none; }
.tt-ans-row { display: flex; gap: 10px; padding: 5px 0; }
.tt-ans-label { font-size: 12px; color: var(--muted); min-width: 84px; flex: none; }
.tt-ans-val { font-weight: 700; }
.tt-actions { margin-top: 16px; }
.tt-actions .btn-primary.big { margin-bottom: 0; }
.tt-actions.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-badge.tt { background: #3b82f6; }
.tt-wrong {
  text-align: left; background: var(--surface); border-radius: 12px;
  padding: 12px 16px; margin: 14px auto 0; max-width: 360px; box-shadow: var(--shadow);
}
.tt-wrong ul { margin: 6px 0 0; padding-left: 18px; }
.tt-wrong li { margin: 3px 0; }

/* ---- 復習(アクティブリコール) ---- */
.rv-top { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.rv-progress { flex: 1; height: 6px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.rv-fill { height: 100%; background: var(--brand); transition: width .25s; }

.recall {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; display: flex; flex-direction: column;
  /* 設問・解説の長さによらず白いカードの大きさを一定に見せる(短い問題でも縮まない) */
  min-height: 360px;
}
.recall-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.recall-meta .subj-line { display: inline-flex; gap: 4px; }
.topic-name { font-size: 12px; color: var(--muted); }
.src-badge {
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  background: var(--track, #eef2f7); border-radius: 6px; padding: 2px 7px;
}
.ret-badge {
  margin-left: auto; font-size: 11px; font-weight: 700; color: var(--brand-d);
  background: #eef2ff; border-radius: 99px; padding: 2px 9px;
}
.ret-badge.new { color: #16a34a; background: #dcfce7; }
.q { font-size: 19px; font-weight: 700; line-height: 1.5; }
.q-subj {
  display: inline-block; font-size: 12px; font-weight: 800; color: #fff;
  background: var(--c, #64748b); border-radius: 7px; padding: 2px 9px;
  margin-right: 8px; vertical-align: middle; letter-spacing: .02em;
}
.hint {
  margin-top: 14px; font-size: 13px; color: var(--brand-d); cursor: pointer;
  align-self: flex-start; border-bottom: 1px dashed var(--brand);
}
.hint.open { color: var(--muted); border: none; cursor: default; }
.a {
  margin-top: 0; max-height: 0; overflow: hidden; padding-top: 0; border-top: 0 solid var(--line);
  font-size: 20px; font-weight: 800; color: #0f172a;
  opacity: 0; transition: opacity .25s;
}
.a.show {
  margin-top: 16px; max-height: none; overflow: visible; padding-top: 16px; border-top-width: 1px;
  opacity: 1;
}

/* 復習の操作ボタン(○×/次へ/採点)は画面下部の固定バーに置き、設問の長さによらず常に同じ位置にする */
.rv-actions {
  position: fixed; left: 0; right: 0;
  bottom: calc(70px + env(safe-area-inset-bottom));
  z-index: 25; padding: 12px 16px;
  background: var(--bg); border-top: 1px solid var(--line);
}
@media (min-width: 600px) {
  .rv-actions { max-width: var(--maxw); margin: 0 auto; }
}
.rv-actions .btn-primary.big { margin-bottom: 0; }
.rv-actions:has(.grade) { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
/* 固定バーに隠れないよう、復習画面はコンテンツ下に余白を確保 */
.view:has(.recall) { padding-bottom: 202px; }
.grade {
  border: none; border-radius: 12px; padding: 14px 4px; cursor: pointer;
  background: color-mix(in srgb, var(--c) 14%, #fff);
  color: var(--c); font-weight: 700; font-size: 13px;
  border: 1.5px solid color-mix(in srgb, var(--c) 35%, #fff);
}
.grade:active { transform: scale(.96); }
.g-label { display: block; }

/* ---- 復習の ○×ボタン ---- */
.ox-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 0; }
.ox-btn {
  border-radius: 14px; padding: 22px 4px; cursor: pointer;
  background: var(--c);
  color: #fff; font-weight: 800; font-size: 20px;
  border: 1.5px solid var(--c);
}
.ox-btn:active { transform: scale(.96); }
[data-theme="dark"] .ox-btn {
  background: var(--c);
  border-color: var(--c);
  color: #fff;
}

/* ---- 完了画面 ---- */
.done { text-align: center; padding: 40px 16px; }
.done-emoji { font-size: 56px; }
.done h2 { margin: 10px 0 4px; }
.done-actions { display: flex; gap: 10px; justify-content: center; margin-top: 22px; }

/* ---- 成長度バー ---- */
.bars { margin-top: 10px; display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 1fr 90px 38px; align-items: center; gap: 8px; }
.bar-label { font-size: 12.5px; display: flex; flex-direction: column; }
.bar-count { font-size: 10.5px; color: var(--muted); }
.bar-track { height: 8px; background: #eef2f7; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; transition: width .4s; }
.bar-val { font-size: 12px; font-weight: 700; color: var(--muted); text-align: right; }

.data-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* ---- ボトムナビ ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(255, 255, 255, .9); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  background: none; border: none; cursor: pointer; padding: 9px 0 7px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 10.5px; font-weight: 600;
}
.nav-item .ni-ico { font-size: 20px; filter: grayscale(1) opacity(.6); transition: filter .2s; }
.nav-item.active { color: var(--brand-d); }
.nav-item.active .ni-ico { filter: none; }

@media (min-width: 600px) {
  .bottom-nav { max-width: var(--maxw); margin: 0 auto; border-radius: 16px 16px 0 0; }
}

/* ============================================================================
   ヘッダーのテーマ切替ボタン
   ============================================================================ */
.icon-btn {
  margin-left: auto; background: var(--surface); border: 1px solid var(--line);
  width: 38px; height: 38px; border-radius: 11px; font-size: 18px; cursor: pointer;
  display: grid; place-items: center; line-height: 1;
}
.icon-btn:active { transform: scale(.94); }

/* ============================================================================
   復習リマインドのバナー(ホーム)
   ============================================================================ */
.due-banner {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, #eef2ff, #faf5ff);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 16px;
}
.due-banner .db-ico { font-size: 22px; }
.due-banner .db-text { flex: 1; font-size: 13.5px; }
.due-banner .db-text b { color: var(--brand-d); }
.due-banner .db-go {
  background: var(--brand); color: #fff; border: none; border-radius: 10px;
  padding: 8px 12px; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
}

/* ============================================================================
   設定の行(成長ページ)
   ============================================================================ */
.setting-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.setting-row + .setting-row { border-top: 1px solid var(--line); }
.setting-row .sr-label { flex: 1; font-size: 14px; }
.setting-row .sr-sub { display: block; font-size: 11.5px; color: var(--muted); }
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--line); border-radius: 99px;
  transition: background .2s; cursor: pointer;
}
.switch .slider::before {
  content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ============================================================================
   インポート用モーダル
   ============================================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .5);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0; backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); width: 100%; max-width: var(--maxw);
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto; box-shadow: 0 -8px 32px rgba(0,0,0,.25);
}
@media (min-width: 600px) { .modal { border-radius: 18px; margin-bottom: 5vh; } .modal-overlay { align-items: center; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; }
.im-help { margin: 10px 0; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.im-help summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--brand-d); }
.im-pre {
  background: var(--bg); border-radius: 8px; padding: 10px; overflow-x: auto;
  font-size: 11.5px; line-height: 1.5; margin: 8px 0; white-space: pre;
}
code { background: var(--bg); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.im-text {
  width: 100%; min-height: 150px; resize: vertical; margin-top: 8px;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  background: var(--bg); color: var(--ink); box-sizing: border-box;
}
.im-row { margin-top: 10px; font-size: 13px; }
.im-modes { display: flex; gap: 16px; }
.im-modes label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.im-msg { margin-top: 10px; font-size: 13px; min-height: 1.2em; }
.im-msg.error { color: #dc2626; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ============================================================================
   ダークモード
   ============================================================================ */
:root[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --line: #334155;
  --brand: #60a5fa;
  --brand-d: #93c5fd;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}
[data-theme="dark"] .app-header,
[data-theme="dark"] .bottom-nav { background: rgba(15,23,42,.82); }
[data-theme="dark"] .mini-track,
[data-theme="dark"] .rv-progress,
[data-theme="dark"] .bar-track { background: #0b1220; }
[data-theme="dark"] table.cmp th { background: #0b1220; color: #cbd5e1; }
[data-theme="dark"] table.cmp tbody tr:nth-child(even) td { background: #243043; }
[data-theme="dark"] .note { background: #1d2a44; color: #cbd5e1; }
[data-theme="dark"] .chip,
[data-theme="dark"] .pill,
[data-theme="dark"] .ret-badge { background: #1d2a44; color: #93c5fd; }
[data-theme="dark"] .ret-badge.new { background: #14321f; color: #4ade80; }
[data-theme="dark"] .src-badge { background: #0b1220; color: #94a3b8; }
[data-theme="dark"] .due-banner { background: linear-gradient(135deg, #1d2a44, #271d3f); }
[data-theme="dark"] .btn-ghost.danger { color: #f87171; border-color: #7f1d1d; }
[data-theme="dark"] .grade {
  background: color-mix(in srgb, var(--c) 24%, #1e293b);
  border-color: color-mix(in srgb, var(--c) 45%, #1e293b);
  color: #fff;
}

/* ---- 回答時の正誤フラッシュ(画面上部) ---- */
.answer-flash {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  font-size: min(85vw, 520px); font-weight: 900; line-height: 1;
  pointer-events: none;
  animation: flashpop .9s ease-out forwards;
}
/* 正解(○)=赤、不正解(×)=青。○×ボタンと色を統一 */
.answer-flash.ok {
  color: #dc2626;
  text-shadow: 0 8px 30px rgba(220,38,38,.25);
}
.answer-flash.ng {
  color: #2563eb;
  text-shadow: 0 8px 30px rgba(37,99,235,.25);
}
@keyframes flashpop {
  0%   { opacity: 0; transform: scale(.5); }
  20%  { opacity: .95; transform: scale(1.08); }
  55%  { opacity: .92; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

/* ---- 列ヘッダーの法律キャラ顔 ---- */
table.cmp th .colface {
  display: block; width: 22px; height: 22px; margin: 0 auto 2px;
  border-radius: 50%; object-fit: cover; object-position: center top;
  border: 1.5px solid #cbd5e1; background: #fff;
}
table.cmp th { text-align: center; }
table.cmp th:first-child { text-align: left; }

/* ---- トップページのキャラ図鑑 ---- */
.char-gallery h3 { margin: 0 0 8px; font-size: 15px; }
.char-gallery-title { display: flex; align-items: baseline; gap: 8px; cursor: pointer; }
.char-gallery-title:hover .char-more { text-decoration: underline; }
.char-more { font-size: 11px; font-weight: 700; color: #2563eb; }
/* 2段グリッド(10人=5列×2段)・横スクロール(スライダー)なし */
.char-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px 6px; }
.char-item { text-align: center; min-width: 0; }
.char-item img {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover; object-position: center top; border: 1.5px solid #cbd5e1; background: #fff;
}
.char-law { display: block; font-size: 10px; font-weight: 800; color: #334155; margin-top: 2px; white-space: normal; }
.char-name { display: block; font-size: 9px; color: #64748b; line-height: 1.25; white-space: normal; }

/* ---- 別ページ: 全員のキャラ紹介 ---- */
.char-intro-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.ci-card { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.ci-card img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; object-position: center top; border: 2px solid #cbd5e1; background: #fff; flex: none; }
.ci-body { min-width: 0; }
.ci-name { font-weight: 800; font-size: 14px; color: var(--ink); }
.ci-law { font-size: 12px; color: #475569; }
.ci-sub-head { margin: 18px 0 8px; font-size: 13px; font-weight: 800; color: #475569; }
@media (max-width: 480px) { .char-intro-grid { grid-template-columns: 1fr; } }

/* ---- 解説: 📌ポイント・科目キャラ顔/名前・[[赤強調]] ---- */
.kai-point { background: #fff7e6; border: 1px solid #f0d28a; border-radius: 9px; padding: 8px 11px; font-size: 13px; margin-bottom: 10px; }
.kai-plbl { color: #9a6a00; font-weight: 800; margin-right: 5px; }
.kai-spk { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.kai-face { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; object-position: center top; border: 2.5px solid #cbd5e1; background: #fff; flex: none; }
.kai-name { font-weight: 800; font-size: 14px; }
.kai-text { font-size: 14px; line-height: 1.7; }
.a b.hot { color: #dc2626; font-weight: 800; }

/* ---- 復習中に開く「📊表」ボタン＋横断表オーバーレイ ---- */
.tbl-fab {
  position: fixed; right: 16px; bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 40;
  background: var(--brand); color: #fff; border: none; border-radius: 999px;
  padding: 11px 17px; font-size: 14px; font-weight: 800; cursor: pointer;
  box-shadow: 0 6px 18px rgba(59,130,246,.45);
}
.tbl-fab:active { transform: scale(.97); }
.tbl-ov {
  position: fixed; inset: 0; z-index: 80; background: rgba(15,23,42,.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 30px 10px; overflow-y: auto;
}
.tbl-ov[hidden] { display: none; }
.tbl-ov-card {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: var(--maxw);
  padding: 14px; box-shadow: var(--shadow);
}
.tbl-ov-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.tbl-ov-title { font-weight: 800; font-size: 15px; }
.tbl-ov-close {
  background: none; border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 13px; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--ink); white-space: nowrap;
}

/* ===== フリーミアム（ペイウォール） ===== */
.pill.lock{background:#eef1f7;color:#94a3b8}
.paywall{max-width:560px;margin:8px auto;padding:8px 16px 48px;text-align:center}
.pw-lock{font-size:44px;margin:8px 0 4px}
.pw-title{font-size:20px;margin:0 0 2px}
.pw-sub{color:#6b7a99;font-size:13px;margin:0 0 18px}
.pw-card{background:#fff;border:1px solid #dfe6f2;border-radius:16px;padding:20px 18px;box-shadow:0 6px 24px rgba(40,77,127,.08)}
.pw-headline{font-size:17px;font-weight:800;color:#1f2a44;margin-bottom:12px}
.pw-feat{list-style:none;padding:0;margin:0 0 18px;text-align:left}
.pw-feat li{position:relative;padding:7px 6px 7px 26px;font-size:14.5px;border-bottom:1px dashed #eef1f7}
.pw-feat li:last-child{border-bottom:0}
.pw-feat li::before{content:"✓";position:absolute;left:4px;color:#1f9d55;font-weight:800}
.pw-feat b{color:#284d7f}
.pw-card .btn-primary{width:100%;margin:4px 0}
.pw-card .btn-ghost{width:100%;margin-top:8px;color:#6b7a99}
.pw-free{margin-top:16px}
.info-actions{display:flex;flex-direction:column;gap:8px;margin-top:10px}

/* ============================================================================
   2026-06-23 ブラッシュアップ（青基調のまま・読みやすさ/タップ感の磨き込み）
   ============================================================================ */
:root{
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 6px 20px rgba(15,23,42,.06);
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
}
/* テーマ一覧：行をタップしやすく・ランクを上品に */
.prio-row > td{ padding: 13px 4px; }
.prio-row:active{ background: rgba(59,130,246,.07); }
.prio-title{ font-size: 15px; letter-spacing:-.01em; }
.rank-no{
  width:23px; height:23px; background: var(--rc, #eef2ff); color: var(--brand-d);
  font-size:12px; box-shadow: inset 0 0 0 1px rgba(59,130,246,.12);
}
.prio-box{ padding: 6px 12px 4px; }
.prio-head{ padding: 8px 4px 6px; }
.prio-head h3{ font-size: 13px; color: var(--muted); font-weight:800; letter-spacing:.04em; }
/* 科目タグ：少し丸く・余白を均す */
.subj{ border-radius:7px; padding:2px 8px; letter-spacing:.02em; }
.subj-tags{ gap:6px; }
/* 問数pill / ロック */
.pill{ background:#eef2ff; color:var(--brand-d); padding:3px 10px; }
.pill.lock{ background:#f1f5f9; color:#9aa7bd; }
/* 検索バー：丸み・フォーカスを上品に */
.theme-search{ border-radius:14px; padding:12px 15px; box-shadow: var(--shadow-sm); }
.theme-search:focus{ outline:none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
/* 科目フィルタ：タップ域を少し広げる */
.sfchip{ padding:6px 13px; }
.sfchip.on{ box-shadow: 0 2px 8px rgba(59,130,246,.25); }
/* カード：影をやわらかく */
.card-box{ box-shadow: var(--shadow); }
/* 主要ボタン：奥行きを少し */
.btn-primary{ box-shadow: 0 2px 10px rgba(37,99,235,.22); }
.btn-primary:active{ box-shadow: 0 1px 4px rgba(37,99,235,.22); }
/* ○×ボタン：丸みと影で押しやすく */
.ox-btn{ border-radius:16px; box-shadow: 0 3px 12px rgba(15,23,42,.12); }
.ox-btn:active{ box-shadow: 0 1px 4px rgba(15,23,42,.12); }
/* ボトムナビ：アクティブに上部アクセント＋アイコン拡大 */
.nav-item{ position:relative; padding:10px 0 8px; }
.nav-item.active::before{
  content:""; position:absolute; top:0; left:50%; transform:translateX(-50%);
  width:26px; height:3px; border-radius:0 0 3px 3px; background: var(--brand);
}
.nav-item.active .ni-ico{ transform: translateY(-1px) scale(1.06); }
.nav-item .ni-ico{ transition: filter .2s, transform .2s; }
/* ヘッダーロゴ：影をブランド色で締める */
.logo{ box-shadow: 0 4px 12px rgba(15,23,42,.18); }

/* ============================================================================
   アクセシビリティ・補助クラス（リリース前QAで追加）
   ============================================================================ */
/* スクリーンリーダー専用（視覚的に非表示・読み上げのみ） */
.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;
}
/* キーボード/スイッチ操作時のみフォーカスリングを表示（マウス・タップでは出ない） */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}
/* 初回起動スプラッシュ（JSが描画完了すると置き換わる） */
.boot-splash {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; min-height: 46vh; color: var(--muted);
}
.boot-splash img { border-radius: 14px; opacity: .92; }
.boot-splash p { margin: 0; font-size: 13px; }
/* 一問一答が無い（比較表のみ）テーマのピル */
.pill.pill-tbl { background: #eef2f7; color: var(--muted); }
[data-theme="dark"] .pill.pill-tbl { background: #1d2a44; color: #94a3b8; }
