:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1a1f27;
  --text-muted: #6b7280;
  --accent: #1f6feb;
  --gloss: #c0392b;
  --border: #e2e6ec;
  --correct: #2fa84f;
  --wrong: #e5484d;
  font-size: calc(15px + 0.25vw);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1d2128;
    --text: #eef1f5;
    --text-muted: #9aa3af;
    --gloss: #ff7b6b;
    --border: #2c313a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Segoe UI", Roboto, sans-serif;
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 560px;
  padding-bottom: 3rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem 0.6rem;
  padding: 1.1rem 1.2rem 0.4rem;
}

header h1 { font-size: 1.15rem; margin: 0; }
#header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
#lesson-date { font-size: 0.9rem; color: var(--text-muted); }
#user-badge {
  flex: 0 0 auto;
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
#user-badge[hidden] { display: none; }

main { padding: 0 1.2rem; }

/* ── 3本柱のタブバー ── */
#tabbar {
  display: flex;
  gap: 0.4rem;
  padding: 0.3rem 1.2rem 0.6rem;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
#tabbar .tab {
  flex: 1;
  padding: 0.55rem 0.3rem;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
#tabbar .tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 700;
}

/* ── きほん表現ドリル ── */
#drill-intro {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 0.5rem;
  padding: 0.5rem 0.7rem;
  margin: 0.8rem 0 1rem;
  line-height: 1.7;
}
#drill-streak {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.2rem 0 0.6rem;
}
.srs-row-body { display: flex; flex-direction: column; flex: 1; gap: 0.15rem; min-width: 0; }
.srs-origin { font-size: 0.78rem; color: var(--text-muted); }
#drill-list .section-label { margin-top: 1.2rem; }
#drill-list details { margin-top: 1rem; }
.drill-cat-done { opacity: 0.55; cursor: default; }
#drill-list details summary { padding: 0.2rem 0; }
.drill-latest {
  border-width: 2px;
  border-color: var(--accent);
  font-weight: 700;
}
#drill-daily-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 0.5rem;
  padding: 0.5rem 0.7rem;
  margin: 0.4rem 0 0.8rem;
  line-height: 1.7;
}

#drill-browse-btn, #gloss-browse-btn {
  display: block;
  width: 100%;
  margin: 0 0 0.6rem;
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

#browse-filters, #news-browse-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.6rem 0 0.9rem;
}
.filter-chip {
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 700;
}

.browse-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  margin: 0.35rem 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.55;
  cursor: pointer;
}
.browse-flag { flex: 0 0 auto; }
.browse-sentence { flex: 1; }
.browse-type { flex: 0 0 auto; align-self: center; font-size: 0.8rem; color: var(--text-muted); }
#browse-list .section-label, #news-browse-list .section-label { margin-top: 1.1rem; }
#browse-empty, .browse-empty { color: var(--text-muted); margin-top: 1rem; line-height: 1.7; }

/* 「さらに表示」ボタン（問題一覧・表現まとめ一覧のページング・2026-07-24） */
.load-more-btn {
  display: block;
  width: 100%;
  margin: 0.9rem 0 0.4rem;
  padding: 0.6rem;
  font-size: 0.88rem;
  font-weight: 700;
  border: 1px dashed var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
}

/* 月別折りたたみ（ドリル・ニュースの過去アーカイブ共通・2026-07-24）：
   月見出しに▸/▾を自前で出すので、ブラウザ標準のディスクロージャー三角は消す */
.month-details > summary { list-style: none; }
.month-details > summary::-webkit-details-marker { display: none; }

/* 表現まとめ一覧（ニュースタブ内のサブ画面） */
#news-browse-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 0.5rem;
  padding: 0.5rem 0.7rem;
  margin: 0.6rem 0 0.9rem;
  line-height: 1.7;
}
#gloss-browse-section { margin-top: 1.2rem; }
#news-browse-types { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 0.9rem; }

#drill-back, #browse-back, #news-browse-back {
  margin: 0.8rem 0 0.4rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
#drill-title { font-size: 1.1rem; font-weight: 700; margin: 0.5rem 0 0.2rem; }
#drill-progress { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.3rem; }
#drill-series-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: 2rem;
  padding: 0.25rem 0.7rem;
  margin-bottom: 0.4rem;
}

.drill-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  padding: 1rem 1.1rem;
  margin: 0.6rem 0 0.9rem;
}
#drill-sentence {
  font-size: 1.15rem;
  line-height: 1.85;
  margin: 0.2rem 0 0.8rem;
}
.drill-target {
  font-weight: 700;
  color: var(--gloss);
  border-bottom: 2px dotted var(--gloss);
}
#drill-question { font-weight: 600; line-height: 1.6; margin-bottom: 0.5rem; }
#drill-result { font-weight: 700; margin: 0.6rem 0 0.4rem; }
#drill-sentence-ja {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 0.5rem;
}
#drill-flag-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.flag-btn {
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
}
.flag-btn.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  color: var(--text);
  font-weight: 700;
}

#drill-next, .drill-nav-btn {
  width: 100%;
  margin-top: 1rem;
  padding: 0.7rem;
  font-size: 0.95rem;
  border: none;
  border-radius: 0.6rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
}
.drill-nav-btn { margin-top: 0.4rem; }
#drill-home-btn { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
#drill-error { margin-top: 2rem; text-align: center; color: var(--text-muted); line-height: 1.7; }

/* ── 発音タブ「音の地図」（pron.js描画・2026-07-24）── */
.pron-header { margin: 0.8rem 0 1rem; }
.pron-course-title { font-size: 1.3rem; margin: 0 0 0.6rem; }
.pron-rate-row {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
  /* スクロールしても速度切替に手が届くよう、タブバー（top:0・約3rem）の直下に貼り付く */
  position: sticky;
  top: 3rem;
  background: var(--bg);
  z-index: 4;
  padding: 0.3rem 0;
}

.pron-intro { margin: 0.8rem 0 1rem; }
.pron-intro-body p { font-size: 0.98rem; line-height: 1.85; margin: 0.7rem 0 0; }

.pron-units { margin-top: 0.4rem; }
.pron-unit { margin: 0.9rem 0; }
.pron-unit-title { display: block; font-size: 1.05rem; font-weight: 700; }
.pron-unit-tagline { display: block; font-size: 0.82rem; color: var(--text-muted); font-weight: 400; margin-top: 0.15rem; }
.pron-unit-body { margin-top: 0.8rem; }

.pron-sound-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  padding: 0.9rem 1rem;
  margin: 0.8rem 0;
}
.pron-sound-top { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.pron-ipa-badge {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 2px solid var(--accent);
  border-radius: 0.5rem;
  padding: 0.15rem 0.6rem;
}
.pron-nickname { font-size: 1.02rem; font-weight: 700; }
.pron-howto { font-size: 0.93rem; line-height: 1.8; margin: 0 0 0.7rem; }

.pron-kana-trap {
  background: color-mix(in srgb, var(--wrong) 10%, var(--surface));
  border-left: 3px solid var(--wrong);
  border-radius: 0.5rem;
  padding: 0.6rem 0.8rem;
  font-size: 0.88rem;
  line-height: 1.7;
  margin: 0 0 0.7rem;
}
.pron-kana-trap-label { font-weight: 700; color: var(--wrong); font-size: 0.78rem; margin-bottom: 0.25rem; }

.pron-words { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.2rem 0 0.7rem; }
.pron-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.05rem;
  padding: 0.4rem 0.7rem;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.pron-chip-ja { font-size: 0.72rem; color: var(--text-muted); }

.pron-trivia {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border-left: 3px solid var(--accent);
  border-radius: 0.5rem;
  padding: 0.6rem 0.8rem;
  font-size: 0.88rem;
  line-height: 1.7;
}
.pron-trivia-label { font-weight: 700; color: var(--accent); font-size: 0.78rem; margin-bottom: 0.25rem; }

.pron-contrast {
  background: color-mix(in srgb, var(--gloss) 8%, var(--surface));
  border-left: 3px solid var(--gloss);
  border-radius: 0.5rem;
  padding: 0.9rem 1rem;
  margin: 1rem 0 0.4rem;
}
.pron-contrast-label { font-weight: 700; color: var(--gloss); font-size: 0.82rem; margin-bottom: 0.4rem; }
.pron-contrast-note { font-size: 0.9rem; line-height: 1.8; margin: 0 0 0.7rem; }
.pron-contrast-words { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.7rem; }

.pron-check-link { text-align: center; margin: 2rem 0 0.5rem; }
.pron-check-link a { font-size: 0.8rem; color: var(--text-muted); }

.pron-error { margin-top: 2rem; text-align: center; color: var(--text-muted); line-height: 1.7; }

/* ── 発音タブ「👂聞き分けクイズ」（pron.js描画・2026-07-25）── */
.pron-quiz-entry-wrap { margin: 0.2rem 0 0.4rem; }
.pron-quiz-title { font-size: 1.05rem; margin: 0 0 0.4rem; }
.pron-quiz-desc { font-size: 0.9rem; line-height: 1.75; color: var(--text-muted); margin: 0 0 0.8rem; }
.pron-quiz-picks { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pron-quiz-pick {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.5rem 0.8rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.pron-quiz-pick-rate { font-size: 0.75rem; color: var(--text-muted); }

.pron-quiz-root { margin: 0.6rem 0; }
.pron-quiz-back {
  margin: 0.2rem 0 0.6rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.pron-quiz-progress { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.4rem; }

.pron-quiz-play {
  display: block;
  width: 100%;
  padding: 1rem;
  margin-bottom: 0.9rem;
  font-size: 1.15rem;
  font-weight: 700;
  border: none;
  border-radius: 0.6rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

.pron-quiz-options { display: flex; flex-direction: column; gap: 0.6rem; }
.pron-quiz-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  padding: 0.8rem 1rem;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.pron-quiz-option:active { filter: brightness(0.95); }
.pron-quiz-option:disabled { cursor: default; }
.pron-quiz-option-word { font-size: 1.1rem; font-weight: 700; }
.pron-quiz-option-ja { font-size: 0.8rem; color: var(--text-muted); }
.pron-quiz-option:disabled { opacity: 0.45; cursor: default; }
.pron-quiz-lockhint { font-size: 0.82rem; color: var(--text-muted); text-align: center; margin: 0.4rem 0; }
.pron-quiz-result-note { font-size: 0.85rem; color: var(--text-muted); line-height: 1.7; margin: 0.6rem 0; }
.pron-quiz-option-correct { border-color: var(--correct); background: color-mix(in srgb, var(--correct) 12%, var(--bg)); }
.pron-quiz-option-wrong { border-color: var(--wrong); background: color-mix(in srgb, var(--wrong) 12%, var(--bg)); }

.pron-quiz-feedback { margin-top: 0.9rem; }
.pron-quiz-feedback-result { font-weight: 700; font-size: 1.05rem; margin-bottom: 0.5rem; }
.pron-quiz-tip {
  background: color-mix(in srgb, var(--gloss) 8%, var(--surface));
  border-left: 3px solid var(--gloss);
  border-radius: 0.5rem;
  padding: 0.6rem 0.8rem;
  font-size: 0.88rem;
  line-height: 1.7;
  margin-bottom: 0.6rem;
}
.pron-quiz-map-link { display: inline-block; font-size: 0.85rem; color: var(--accent); margin-bottom: 0.6rem; }

/* 解答後の両選択肢くらべ（正誤にかかわらず2音を同等に解説する・2026-07-25オーナー要望） */
.pron-quiz-compare {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.6rem;
  background: var(--surface);
}
.pron-quiz-compare-label { font-weight: 700; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.pron-quiz-compare-row { display: flex; align-items: stretch; gap: 0.4rem; margin: 0.3rem 0; }
.pron-quiz-compare-play {
  flex: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem 0.6rem;
  text-align: left;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.pron-quiz-compare-map {
  flex: 0 0 auto;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  font-size: 1rem;
  cursor: pointer;
}
/* クイズから飛んできた音カードを一瞬ハイライト */
.pron-sound-flash { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 0.5rem; }

/* 📖ペア図鑑 */
.pron-zukan-legend { margin: 0.2rem 0 0.6rem; }
.pron-zukan-legend-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--accent);
  margin: 0.25rem 0;
}
.pron-zukan-row { display: flex; align-items: stretch; gap: 0.4rem; margin: 0.35rem 0; }
.pron-zukan-row .pron-chip { flex: 1; }
.pron-zukan-seq {
  flex: 0 0 auto;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}
.pron-zukan-quiz { color: var(--gloss); }
.pron-zukan-renshu { color: var(--wrong); }

/* ── 🎙️発音れんしゅう画面（P3・pron.js描画・2026-07-26）── */
.pron-renshu-root { margin: 0.6rem 0; }
.pron-renshu-title { font-size: 1.2rem; margin: 0 0 0.15rem; }
.pron-renshu-pair { font-size: 1rem; color: var(--text-muted); margin: 0 0 0.9rem; }

.pron-renshu-listen {
  background: color-mix(in srgb, var(--gloss) 8%, var(--surface));
  border-left: 3px solid var(--gloss);
  border-radius: 0.5rem;
  padding: 0.9rem 1rem;
  margin: 0 0 0.9rem;
}
.pron-renshu-listen-label { font-weight: 700; color: var(--gloss); font-size: 0.82rem; margin-bottom: 0.4rem; }
.pron-renshu-tip { font-size: 0.9rem; line-height: 1.75; margin: 0 0 0.6rem; }
.pron-renshu-listen-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; margin: 0.3rem 0; }

.pron-renshu-model { margin-bottom: 0.9rem; }
.pron-renshu-model-label { font-weight: 700; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.pron-renshu-model-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.pron-renshu-model-row .pron-chip { flex: 1; }

.pron-renshu-record {
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  padding: 0.9rem 1rem;
  margin-bottom: 0.9rem;
  background: var(--surface);
}
.pron-renshu-privacy { font-size: 0.8rem; color: var(--text-muted); line-height: 1.6; margin: 0 0 0.7rem; }
.pron-renshu-record-btn {
  display: block;
  width: 100%;
  padding: 1.1rem;
  font-size: 1.15rem;
  font-weight: 700;
  border: none;
  border-radius: 0.7rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.pron-renshu-record-btn-active { background: var(--wrong); }
.pron-renshu-mic-error { color: var(--wrong); font-size: 0.85rem; line-height: 1.6; margin-top: 0.6rem; }
.pron-renshu-player { margin-top: 0.8rem; }
.pron-renshu-player audio { width: 100%; margin-bottom: 0.6rem; }

.pron-renshu-recog { margin-bottom: 0.6rem; }
.pron-renshu-recog-body { padding-top: 0.6rem; }
.pron-renshu-recog-warn { font-size: 0.82rem; color: var(--wrong); font-weight: 700; line-height: 1.65; margin-bottom: 0.6rem; }
.pron-renshu-recog-unsupported { font-size: 0.85rem; color: var(--text-muted); }
.pron-renshu-pick { display: flex; gap: 0.4rem; margin-bottom: 0.6rem; }
.pron-renshu-pick-btn {
  flex: 1;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.pron-renshu-pick-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.pron-renshu-recog-result { font-size: 0.88rem; line-height: 1.7; margin-top: 0.6rem; }

/* 地図を覗いてる間の「クイズにもどる」浮遊ボタン */
.pron-quiz-return-float {
  position: fixed;
  bottom: 1.1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 2rem;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}
.pron-quiz-compare-word { font-weight: 700; font-size: 1rem; }
.pron-quiz-compare-ja { font-size: 0.82rem; color: var(--text-muted); }
.pron-quiz-compare-sound {
  flex-basis: 100%;
  font-size: 0.8rem;
  color: var(--accent);
}

.pron-quiz-result-title { font-size: 1.25rem; margin: 0 0 0.8rem; }
.pron-quiz-section-label { font-weight: 700; font-size: 0.85rem; color: var(--text-muted); margin: 0.9rem 0 0.4rem; }
.pron-quiz-missed-item, .pron-quiz-weak-item {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
  line-height: 1.6;
}
.pron-quiz-missed-words { font-weight: 700; margin-bottom: 0.2rem; }
.pron-quiz-missed-tip { color: var(--text-muted); }
.pron-quiz-weak-item { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.pron-quiz-choose { background: var(--surface); color: var(--text); border: 1px solid var(--border); }

/* ── レベル切替（3レベル）── */
#level-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.6rem 0 0.2rem;
}
#level-label { font-size: 0.8rem; color: var(--text-muted); flex: 0 0 auto; }
.level-chip {
  flex: 1;
  padding: 0.45rem 0.5rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}
.level-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 700;
}

#lesson-title {
  font-size: 1.35rem;
  line-height: 1.4;
  margin: 0.7rem 0 0.2rem;
}

#lesson-title-ja {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

#lesson-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 0.5rem;
  padding: 0.45rem 0.7rem;
  margin: 0.6rem 0 0.4rem;
}

#paragraphs p {
  font-size: 1.06rem;
  line-height: 1.85;
  margin: 0.9rem 0 0.3rem;
}

#toggle-ja {
  margin: 0.5rem 0 0.2rem;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.para-ja {
  display: none;
  font-size: 0.92rem;
  line-height: 1.75;
  color: var(--text-muted);
  background: var(--surface);
  border-left: 3px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.5rem 0.8rem;
  margin: 0 0 0.9rem;
}

#paragraphs.show-ja .para-ja { display: block; }

/* 本文中の注釈対象：太字＋赤字＋タップ可能の手がかり */
button.gloss {
  display: inline;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: 700;
  color: var(--gloss);
  border-bottom: 2px dotted var(--gloss);
  cursor: pointer;
}

/* 用語注（固有名詞・専門用語）：学習対象ではなく「読むための補助」＝控えめな青点線 */
button.term {
  display: inline;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--accent);
  border-bottom: 1px dotted var(--accent);
  cursor: pointer;
}

section { margin-top: 1.6rem; }

.section-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

#trivia-box {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border-left: 3px solid var(--accent);
  border-radius: 0.5rem;
  padding: 0.9rem 1rem;
}
#trivia-title { font-weight: 700; margin-bottom: 0.3rem; }
#trivia-text { font-size: 0.93rem; line-height: 1.7; }

.question {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  padding: 0.9rem 1rem;
  margin-bottom: 0.8rem;
}
.question-q { font-weight: 600; margin-bottom: 0.6rem; line-height: 1.6; }

.choice {
  display: block;
  width: 100%;
  text-align: left;
  margin: 0.4rem 0;
  padding: 0.65rem 0.8rem;
  font-size: 0.95rem;
  line-height: 1.5;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.choice:active { filter: brightness(0.95); }
.choice.correct { border-color: var(--correct); background: color-mix(in srgb, var(--correct) 12%, var(--bg)); }
.choice.wrong { border-color: var(--wrong); background: color-mix(in srgb, var(--wrong) 12%, var(--bg)); }
.choice.skip { color: var(--text-muted); border-style: dashed; }

.question-explain {
  margin-top: 0.5rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
}

details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  padding: 0.7rem 1rem;
}
details summary { cursor: pointer; font-weight: 600; }

.review-item { margin: 0.9rem 0; }
.review-phrase { font-weight: 700; color: var(--gloss); margin-bottom: 0.2rem; }
.review-why { font-size: 0.9rem; line-height: 1.7; color: var(--text); }

#sources-section { margin-top: 2rem; }
#sources-note { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.3rem; }
#sources-links a {
  font-size: 0.82rem;
  color: var(--accent);
  margin-right: 0.9rem;
}

.archive-item {
  display: block;
  width: 100%;
  text-align: left;
  margin: 0.4rem 0;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--text);
  font-size: 0.92rem;
  cursor: pointer;
}

#load-error {
  margin-top: 2rem;
  text-align: center;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ── 注釈パネル（ボトムシート）── */
#gloss-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
}
#gloss-overlay[hidden] { display: none; }

#gloss-panel {
  width: 100%;
  max-width: 560px;
  max-height: 78vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 1rem 1rem 0 0;
  padding: 1.2rem 1.2rem 1.4rem;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.25);
}

#gloss-phrase {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gloss);
  margin-bottom: 0.6rem;
}

#gloss-question { font-weight: 600; line-height: 1.6; margin-bottom: 0.5rem; }

#gloss-result { font-weight: 700; margin-bottom: 0.4rem; }
#gloss-ja { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.7rem; }

.gloss-block { margin-top: 0.7rem; }
.gloss-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
}
#gloss-why, #gloss-usage, #gloss-brdiff {
  font-size: 0.93rem;
  line-height: 1.75;
}

/* ── 下部バナー（アプリ更新／新レッスン通知）── */
#update-banner, #news-banner {
  position: fixed;
  bottom: 0.8rem;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 2rem);
  max-width: 528px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.7rem 1rem;
  background: var(--accent);
  color: white;
  border-radius: 0.8rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 20;
  font-size: 0.92rem;
}
#update-banner[hidden], #news-banner[hidden] { display: none; }
#news-banner { bottom: 4.6rem; } /* 更新バナーと同時表示でも重ならない */
#update-btn, #news-banner-btn {
  flex: 0 0 auto;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  border-radius: 0.5rem;
  background: white;
  color: var(--accent);
  cursor: pointer;
}

/* ── ユーザー選択（M2・2026-07-23導入。だれが使う？オーバーレイ）── */
#user-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 32;
  padding: 1.2rem;
}
#user-overlay[hidden] { display: none; }
#user-panel {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.4rem 1.3rem;
}
#user-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.6rem; text-align: center; }

/* 台帳ピッカー（M6・2026-07-24：起動時ワンクッション）。名前ボタン＋➕新規の一覧 */
#user-picker-buttons { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.6rem; }
.user-btn {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.user-btn:active { filter: brightness(0.95); }
#user-add-new { border-style: dashed; color: var(--text-muted); font-weight: 500; }

#user-note { font-size: 0.85rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 1rem; text-align: center; }
#user-input {
  width: 100%;
  padding: 0.7rem 0.8rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--bg);
  color: var(--text);
}
#user-error { font-size: 0.85rem; color: var(--wrong); margin-top: 0.6rem; line-height: 1.6; }
#user-submit {
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 0.6rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
}
#user-cancel {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.6rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}

/* ── 合言葉ゲート（データ層401時のオーバーレイ）── */
#gate-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 1.2rem;
}
#gate-overlay[hidden] { display: none; }
#gate-panel {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.4rem 1.3rem;
}
#gate-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.5rem; }
#gate-note { font-size: 0.88rem; color: var(--text-muted); line-height: 1.7; margin-bottom: 1rem; }
#gate-input {
  width: 100%;
  padding: 0.7rem 0.8rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--bg);
  color: var(--text);
}
#gate-error { font-size: 0.85rem; color: var(--wrong); margin-top: 0.6rem; line-height: 1.6; }
#gate-submit {
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 0.6rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
}
#gate-submit:disabled { opacity: 0.6; }

#gloss-close {
  width: 100%;
  margin-top: 1.1rem;
  padding: 0.75rem;
  font-size: 1rem;
  border: none;
  border-radius: 0.6rem;
  background: var(--accent);
  color: white;
  cursor: pointer;
}
