/* ============================================================
   CSS Variables & Reset
   ============================================================ */
:root {
  --primary: #1a73e8;
  --primary-dark: #1558b0;
  --surface: #ffffff;
  --surface2: #f8f9fa;
  --surface3: #e8eaed;
  --text: #202124;
  --text2: #5f6368;
  --text3: #9aa0a6;
  --border: #dadce0;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.06);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 56px;
  --bottom-nav-h: 60px;
  --sidebar-w: 256px;
  --transition: 200ms ease;

  /* Subject colors */
  --c-life: #34a853;
  --c-risk: #1a73e8;
  --c-fin: #fa7b17;
  --c-tax: #9334e6;
  --c-real: #e53935;
  --c-inh: #795548;
}

html.dark {
  --surface: #1e1e2e;
  --surface2: #16213e;
  --surface3: #0d1117;
  --text: #e8eaed;
  --text2: #9aa0a6;
  --text3: #5f6368;
  --border: #2d2d3a;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,.4);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: var(--surface2);
  color: var(--text);
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }

/* ============================================================
   Layout
   ============================================================ */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Header */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 4px;
  z-index: 200;
  box-shadow: var(--shadow-md);
}

#header-title {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

#header-actions { display: flex; gap: 4px; }

.icon-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 1.2rem;
  transition: background var(--transition);
}
.icon-btn:hover { background: rgba(255,255,255,.15); }

.hamburger {
  display: block;
  width: 20px; height: 2px;
  background: #fff;
  position: relative;
}
.hamburger::before, .hamburger::after {
  content: '';
  display: block;
  width: 20px; height: 2px;
  background: #fff;
  position: absolute;
}
.hamburger::before { top: -6px; }
.hamburger::after { top: 6px; }

/* Layout split */
#layout {
  display: flex;
  margin-top: var(--header-h);
  min-height: calc(100dvh - var(--header-h));
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}

#sidebar-inner {
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.sidebar-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 12px 16px 4px;
}

.sidebar-section { padding: 4px 0; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 8px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin: 2px 8px;
  color: var(--text);
  font-size: .9rem;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: var(--surface2); }
.nav-link.active { background: #e8f0fe; color: var(--primary); font-weight: 600; }
html.dark .nav-link.active { background: #1a3a6e; }

.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

/* Subject nav items */
.subject-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  margin: 2px 8px;
  color: var(--text);
  font-size: .875rem;
  cursor: pointer;
  transition: background var(--transition);
}
.subject-nav-item:hover { background: var(--surface2); }
.subject-nav-item.active { background: #e8f0fe; color: var(--primary); font-weight: 600; }
html.dark .subject-nav-item.active { background: #1a3a6e; }

.subject-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Sidebar overlay (mobile) */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

/* Main */
#main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 24px;
  min-height: calc(100dvh - var(--header-h) - var(--bottom-nav-h));
  overflow-y: auto;
  max-width: 900px;
}

/* Bottom nav */
#bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 200;
  box-shadow: 0 -2px 8px rgba(0,0,0,.08);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  color: var(--text2);
  font-size: .7rem;
  transition: color var(--transition);
}
.bottom-nav-item:hover, .bottom-nav-item.active { color: var(--primary); }
.bottom-nav-icon { font-size: 1.2rem; }

/* ============================================================
   Cards & Shared Components
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.progress-bar-wrap {
  height: 8px;
  background: var(--surface3);
  border-radius: 4px;
  overflow: hidden;
  margin: 6px 0;
}
.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width .4s ease;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: .8rem;
  font-weight: 600;
}
.badge-primary { background: #e8f0fe; color: var(--primary); }
.badge-success { background: #e6f4ea; color: #1e8e3e; }
.badge-warn { background: #fef7e0; color: #f29900; }
html.dark .badge-primary { background: #1a3a6e; }
html.dark .badge-success { background: #1a3a2e; color: #34a853; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  min-height: 44px;
  transition: background var(--transition), opacity var(--transition);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline {
  border: 1.5px solid var(--border);
  color: var(--text);
  background: transparent;
}
.btn-outline:hover { background: var(--surface2); }
.btn-success { background: #34a853; color: #fff; }
.btn-success:hover { background: #2d9249; }
.btn-sm { padding: 6px 14px; font-size: .825rem; min-height: 36px; }

/* ============================================================
   Loading & Toast
   ============================================================ */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 200px;
  color: var(--text2);
}
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--surface3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 12px);
  left: 50%; transform: translateX(-50%);
  background: #323232;
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 999;
  white-space: nowrap;
}
#toast.show { opacity: 1; }

/* ============================================================
   Dashboard
   ============================================================ */
.dashboard { display: flex; flex-direction: column; gap: 20px; }

.welcome-card {
  background: linear-gradient(135deg, var(--primary), #4285f4);
  color: #fff;
}
.welcome-card .progress-bar-wrap { background: rgba(255,255,255,.3); }
.welcome-card .progress-bar-fill { background: #fff; }

.welcome-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.welcome-top h2 { font-size: 1.15rem; font-weight: 700; }

.streak-badge {
  background: rgba(255,255,255,.2);
  padding: 4px 12px;
  border-radius: 100px;
  font-size: .85rem;
  font-weight: 700;
  white-space: nowrap;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: .875rem;
  opacity: .9;
  margin-bottom: 2px;
}
.progress-detail { font-size: .8rem; opacity: .75; margin-top: 4px; }

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: -8px;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.subject-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  border-left: 4px solid;
}
.subject-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.subject-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.subject-card-icon { font-size: 1.5rem; }
.subject-card-name { font-size: .9rem; font-weight: 600; flex: 1; }
.subject-card-pct { font-size: .85rem; font-weight: 700; color: var(--text2); }

.share-card h3 { font-size: .95rem; font-weight: 700; margin-bottom: 6px; }
.share-card p { font-size: .85rem; color: var(--text2); margin-bottom: 12px; }
.share-url { display: flex; gap: 8px; }
.share-url input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  background: var(--surface2);
  color: var(--text);
  min-width: 0;
}

/* ============================================================
   Subject / Chapter Views
   ============================================================ */
.page-header {
  margin-bottom: 24px;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .8rem;
  color: var(--text2);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--primary); }
.breadcrumb-sep { color: var(--text3); }
.page-title { font-size: 1.4rem; font-weight: 700; }
.page-subtitle { font-size: .9rem; color: var(--text2); margin-top: 4px; }

.chapter-list { display: flex; flex-direction: column; gap: 12px; }

.chapter-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.chapter-card-header {
  padding: 16px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background var(--transition);
}
.chapter-card-header:hover { background: var(--surface2); }
.chapter-num {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  background: var(--surface3);
  color: var(--text2);
  flex-shrink: 0;
}
.chapter-info { flex: 1; min-width: 0; }
.chapter-title { font-size: .95rem; font-weight: 600; }
.chapter-progress { font-size: .8rem; color: var(--text2); margin-top: 2px; }
.chapter-chevron { color: var(--text3); transition: transform var(--transition); }

.section-list { border-top: 1px solid var(--border); }
.section-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
.section-item:last-child { border-bottom: none; }
.section-item:hover { background: var(--surface2); }
.section-check {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: .7rem;
  transition: background var(--transition), border-color var(--transition);
}
.section-check.done {
  background: #34a853;
  border-color: #34a853;
  color: #fff;
}
.section-name { flex: 1; font-size: .875rem; }
.section-arrow { color: var(--text3); font-size: .8rem; }

/* ============================================================
   Section Content View
   ============================================================ */
.section-view { display: flex; flex-direction: column; gap: 20px; }

.content-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.content-body {
  font-size: .95rem;
  line-height: 1.85;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.keyword {
  background: #fef9c3;
  color: #78350f;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
}
html.dark .keyword { background: #3d3000; color: #fde68a; }

.keypoints-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.keypoints-card h3 { font-size: .95rem; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.keypoint-list { display: flex; flex-direction: column; gap: 8px; }
.keypoint-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: .875rem;
  line-height: 1.5;
}
.keypoint-item::before {
  content: '✓';
  color: #34a853;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.action-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.nav-arrows {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* ============================================================
   Settings View
   ============================================================ */
.settings-view { display: flex; flex-direction: column; gap: 16px; }
.settings-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.settings-card h3 { font-size: .95rem; font-weight: 700; padding: 16px 20px 8px; border-bottom: 1px solid var(--border); }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.settings-row:last-child { border-bottom: none; }
.settings-row-label { font-size: .9rem; }
.settings-row-desc { font-size: .8rem; color: var(--text2); margin-top: 2px; }
.settings-row-left { flex: 1; }

/* Toggle switch */
.toggle {
  width: 48px; height: 26px;
  background: var(--surface3);
  border-radius: 13px;
  position: relative;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.toggle.on { background: var(--primary); }
.toggle.on::after { transform: translateX(22px); }

/* ============================================================
   Dashboard — Phase 5 強化
   ============================================================ */

/* 統計グリッド */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.stat-icon { font-size: 1.3rem; }
.stat-value { font-size: 1.4rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: .7rem; color: var(--text2); font-weight: 500; }
.stat-warn .stat-value { color: var(--c-real); }
.stat-good .stat-value { color: #34a853; }

/* 科目別進捗カード */
.subject-progress-list { display: flex; flex-direction: column; gap: 10px; }

.subject-progress-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  border-left: 4px solid;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.subject-progress-card:hover { box-shadow: var(--shadow-md); transform: translateX(2px); }

.spc-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.spc-icon { font-size: 1.1rem; flex-shrink: 0; }
.spc-name { font-size: .9rem; font-weight: 600; flex: 1; min-width: 0; }
.spc-stats { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; }

/* 苦手問題プレビュー */
.weak-preview-card { padding: 16px; display: flex; flex-direction: column; gap: 8px; }

.weak-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.weak-preview-item {
  font-size: .825rem;
  color: var(--text2);
  padding: 6px 10px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--c-real);
  line-height: 1.4;
}

/* 学習カレンダー */
.cal-card { padding: 16px; }
.cal-title { font-size: .9rem; font-weight: 700; margin-bottom: 10px; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--surface3);
  transition: background var(--transition);
}
.cal-cell.active {
  background: var(--primary);
  opacity: .85;
}
.cal-cell.today {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.cal-cell.active.today { opacity: 1; }

.cal-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: .75rem;
  color: var(--text2);
}

/* オフラインバナー */
#offline-banner {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  background: #f29900;
  color: #fff;
  text-align: center;
  padding: 6px 16px;
  font-size: .85rem;
  font-weight: 600;
  z-index: 150;
}

/* ============================================================
   Quiz
   ============================================================ */
.quiz-view { display: flex; flex-direction: column; gap: 16px; }

.quiz-header { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px; }

.quiz-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.quiz-count { font-size: .95rem; font-weight: 700; }
.quiz-mode-badge { font-size: .8rem; color: var(--text2); }

.quiz-card { display: flex; flex-direction: column; gap: 16px; }

.quiz-question {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.7;
  color: var(--text);
}

.quiz-options { display: flex; flex-direction: column; gap: 10px; }

.quiz-option {
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: .95rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform 80ms;
  line-height: 1.4;
}
.quiz-option:hover:not(:disabled) { background: #e8f0fe; border-color: var(--primary); }
html.dark .quiz-option:hover:not(:disabled) { background: #1a3a6e; }
.quiz-option:active:not(:disabled) { transform: scale(.98); }

.quiz-option.correct {
  background: #e6f4ea;
  border-color: #34a853;
  color: #1e8e3e;
  font-weight: 700;
}
html.dark .quiz-option.correct { background: #1a3a2e; color: #34a853; }

.quiz-option.wrong {
  background: #fce8e6;
  border-color: #e53935;
  color: #c62828;
  font-weight: 700;
}
html.dark .quiz-option.wrong { background: #3a1a1e; color: #ef5350; }

.quiz-option.disabled { opacity: .45; cursor: default; }

.quiz-feedback {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: .875rem;
  line-height: 1.6;
}
.quiz-feedback.correct { background: #e6f4ea; border-left: 4px solid #34a853; }
.quiz-feedback.wrong   { background: #fce8e6; border-left: 4px solid #e53935; }
html.dark .quiz-feedback.correct { background: #1a3a2e; }
html.dark .quiz-feedback.wrong   { background: #3a1a1e; }

.feedback-title { font-weight: 700; font-size: 1rem; margin-bottom: 6px; }
.feedback-correct { font-weight: 600; margin-bottom: 6px; color: #1e8e3e; }
html.dark .feedback-correct { color: #34a853; }
.feedback-explanation { color: var(--text); }

.quiz-next-btn { width: 100%; min-height: 52px; font-size: 1rem; }

/* Results */
.quiz-results { display: flex; flex-direction: column; gap: 16px; }

.results-header {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.score-circle {
  width: 100px; height: 100px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.score-circle.pass { background: linear-gradient(135deg, #34a853, #1e8e3e); }
.score-circle.fail { background: linear-gradient(135deg, #fa7b17, #e53935); }
.score-num { color: #fff; font-size: 1.8rem; font-weight: 800; }
.score-unit { font-size: 1rem; }

.results-score-text { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.results-grade { font-size: .95rem; color: var(--text2); margin-bottom: 4px; }
.results-time { font-size: .85rem; color: var(--text3); }

.results-wrong { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }

.wrong-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.wrong-item:last-child { border-bottom: none; padding-bottom: 0; }
.wrong-q { font-size: .9rem; font-weight: 600; margin-bottom: 4px; }
.wrong-ans { font-size: .825rem; color: #1e8e3e; font-weight: 600; margin-bottom: 4px; }
html.dark .wrong-ans { color: #34a853; }
.wrong-exp { font-size: .8rem; color: var(--text2); line-height: 1.5; }

.results-perfect { text-align: center; padding: 24px; font-size: 1.1rem; font-weight: 700; }

.results-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.results-actions .btn { flex: 1; min-width: 120px; }

/* ============================================================
   Responsive — Mobile
   ============================================================ */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }
  #sidebar-overlay.show { display: block; }

  #main {
    margin-left: 0;
    padding: 16px;
    padding-bottom: calc(var(--bottom-nav-h) + 16px);
  }

  #bottom-nav { display: flex; }

  #toast { bottom: calc(var(--bottom-nav-h) + 12px); }

  .subject-grid { grid-template-columns: 1fr; }

  .content-card { padding: 16px; }
  .page-title { font-size: 1.2rem; }

  .action-bar { justify-content: stretch; }
  .action-bar .btn { flex: 1; }
  .nav-arrows { margin-left: 0; width: 100%; }
  .nav-arrows .btn { flex: 1; }
}
