/* ============================================================
   応用情報技術者試験 学習サイト  スタイルシート
   ============================================================ */

/* ─── リセット ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
@media (max-width: 480px) { html { font-size: 15px; } }
body {
  margin: 0;
  font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Meiryo', 'Yu Gothic', 'Noto Sans JP', -apple-system, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
a { color: #4f46e5; text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3 { line-height: 1.3; }

/* ─── カテゴリ変数 ──────────────────────────────────── */
:root {
  --c-computer:   #3b82f6;
  --c-algorithm:  #7c3aed;
  --c-network:    #0891b2;
  --c-security:   #dc2626;
  --c-database:   #d97706;
  --c-software:   #059669;
  --c-management: #6366f1;
  --c-strategy:   #ea580c;
  --c-afternoon:  #be123c;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
}

/* ─── グローバルナビ ─────────────────────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #e2e8f0;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topnav-home {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: #1d4ed8;
  font-size: 0.95rem;
  white-space: nowrap;
}
.topnav-cat {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: #e0e7ff;
  color: #4338ca;
}

/* ─── ページヘッダー ─────────────────────────────────── */
.page-header {
  padding: 28px 20px 24px;
  background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.page-header::before {
  content: '';
  position: absolute;
  right: -30px;
  top: -30px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
}
.page-header.cat-computer   { background: linear-gradient(135deg,#2563eb,#3b82f6); }
.page-header.cat-algorithm  { background: linear-gradient(135deg,#6d28d9,#7c3aed); }
.page-header.cat-network    { background: linear-gradient(135deg,#0e7490,#0891b2); }
.page-header.cat-security   { background: linear-gradient(135deg,#b91c1c,#dc2626); }
.page-header.cat-database   { background: linear-gradient(135deg,#b45309,#d97706); }
.page-header.cat-software   { background: linear-gradient(135deg,#047857,#059669); }
.page-header.cat-management { background: linear-gradient(135deg,#4338ca,#6366f1); }
.page-header.cat-strategy   { background: linear-gradient(135deg,#c2410c,#ea580c); }
.page-header.cat-afternoon  { background: linear-gradient(135deg,#9f1239,#be123c); }

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
}
.badge-cat   { background: rgba(255,255,255,0.22); color: #fff; }
.badge-p3    { background: #fef3c7; color: #92400e; }
.badge-p2    { background: #dbeafe; color: #1e40af; }
.badge-p1    { background: #f1f5f9; color: #64748b; }
.badge-f3    { background: #fce7f3; color: #9d174d; }
.badge-f2    { background: #f3e8ff; color: #6b21a8; }
.badge-f1    { background: #f1f5f9; color: #64748b; }

.page-title {
  font-size: clamp(1.25rem, 5vw, 1.6rem);
  font-weight: 900;
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}
.page-meta-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  opacity: 0.9;
}
.done-mark {
  display: none;
  background: #22c55e;
  color: #fff;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.done-mark.visible { display: inline-block; }

/* ─── メインコンテンツ ───────────────────────────────── */
.content {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

/* ─── カード ─────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  border: 1px solid #e2e8f0;
}
.card h2 {
  font-size: 1rem;
  font-weight: 800;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card p { margin: 0 0 10px; font-size: 0.93rem; }
.card p:last-child { margin-bottom: 0; }

/* 結論カード */
.card-conclusion {
  border-left: 4px solid var(--primary);
  background: linear-gradient(135deg, #eef2ff, #fff);
}
.card-conclusion h2 { color: var(--primary); }
.conclusion-text {
  font-size: 0.97rem;
  font-weight: 600;
  line-height: 1.75;
}

/* 試験カード */
.card-exam {
  border-left: 4px solid #f59e0b;
  background: linear-gradient(135deg, #fffbeb, #fff);
}
.card-exam h2 { color: #b45309; }

/* 考え方カード */
.card-think {
  border-left: 4px solid #8b5cf6;
  background: linear-gradient(135deg, #f5f3ff, #fff);
}
.card-think h2 { color: #6d28d9; }

/* クイズカード */
.card-quiz {
  border-left: 4px solid #0891b2;
  background: linear-gradient(135deg, #ecfeff, #fff);
}
.card-quiz h2 { color: #0e7490; }

/* ─── 図 ─────────────────────────────────────────────── */
.fig {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  margin: 8px 0;
  overflow-x: auto;
}
.fig-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  text-align: center;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* パイプライン・フロー図 */
.pipe {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}
.pipe-step {
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 8px;
  text-align: center;
  min-width: 60px;
}
.pipe-arrow {
  color: #94a3b8;
  font-size: 1.1rem;
  font-weight: 700;
}
.pipe-step.s-fetch   { background: #3b82f6; }
.pipe-step.s-decode  { background: #8b5cf6; }
.pipe-step.s-exec    { background: #f59e0b; }
.pipe-step.s-write   { background: #10b981; }
.pipe-step.s-mem     { background: #ef4444; }

/* 積み上げ/層図 */
.layer-stack { display: flex; flex-direction: column; gap: 4px; }
.layer {
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  color: #fff;
}

/* テーブル */
.fig-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.fig-table th {
  background: #334155;
  color: #fff;
  padding: 7px 10px;
  font-weight: 700;
  text-align: left;
}
.fig-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #e2e8f0;
}
.fig-table tr:nth-child(even) td { background: #f8fafc; }

/* アルゴリズム可視化 */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 80px;
  padding: 0 8px;
}
.bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  background: var(--primary);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  transition: height 0.3s;
}
.bar.hi { background: #ef4444; }
.bar.ok { background: #22c55e; }

/* ツリー図 */
.tree-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.tree-row  { display: flex; gap: 16px; justify-content: center; }
.tree-node {
  background: var(--primary);
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  position: relative;
}
.tree-node::before {
  content: '';
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 14px;
  background: #94a3b8;
}
.tree-root::before { display: none; }

/* キュー・スタック（SVG diagram内 — CSSは使用しない） */

/* ─── コードブロック ─────────────────────────────────── */
.code {
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  font-family: 'Courier New', Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.7;
  overflow-x: auto;
  margin: 8px 0;
}
.code .kw  { color: #7dd3fc; }
.code .fn  { color: #a5b4fc; }
.code .cm  { color: #64748b; }
.code .st  { color: #86efac; }
.code .num { color: #fda4af; }

/* ─── リスト ─────────────────────────────────────────── */
.card ul, .card ol {
  padding-left: 20px;
  margin: 6px 0;
  font-size: 0.93rem;
}
.card li { margin-bottom: 5px; }

/* 強調 */
.hl { background: #fef9c3; padding: 0 3px; border-radius: 3px; font-weight: 700; }
.hl-red { background: #fee2e2; color: #991b1b; padding: 0 3px; border-radius: 3px; font-weight: 700; }
.hl-green { background: #dcfce7; color: #166534; padding: 0 3px; border-radius: 3px; font-weight: 700; }
.hl-blue { background: #dbeafe; color: #1e40af; padding: 0 3px; border-radius: 3px; font-weight: 700; }

/* 重要ボックス */
.important-box {
  background: #fffbeb;
  border: 1.5px solid #f59e0b;
  border-radius: 10px;
  padding: 13px 16px;
  margin: 12px 0;
  font-size: 0.9rem;
  line-height: 1.75;
  box-shadow: 0 1px 4px rgba(245,158,11,0.1);
}
.important-box strong { color: #92400e; }
.warn-box {
  background: #fff5f5;
  border: 1.5px solid #ef4444;
  border-radius: 10px;
  padding: 13px 16px;
  margin: 12px 0;
  font-size: 0.9rem;
  line-height: 1.75;
  box-shadow: 0 1px 4px rgba(239,68,68,0.1);
}
.tip-box {
  background: #f0fdf4;
  border: 1.5px solid #22c55e;
  border-radius: 10px;
  padding: 13px 16px;
  margin: 12px 0;
  font-size: 0.9rem;
  line-height: 1.75;
  box-shadow: 0 1px 4px rgba(34,197,94,0.1);
}

/* ─── クイズ ─────────────────────────────────────────── */
.quiz-q {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 14px;
  line-height: 1.65;
}
.btn-answer {
  appearance: none;
  background: #0891b2;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 20px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-answer:hover { background: #0e7490; }
.quiz-answer {
  margin-top: 14px;
  background: #f8fafc;
  border-radius: 10px;
  padding: 14px;
  font-size: 0.88rem;
  border-left: 3px solid #0891b2;
  line-height: 1.7;
}
.quiz-answer strong { color: #0e7490; }

/* ─── 読了ボタン ─────────────────────────────────────── */
.complete-area {
  text-align: center;
  padding: 20px 0 10px;
}
.btn-complete {
  appearance: none;
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 14px 40px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(79,70,229,0.3);
  transition: all 0.2s;
  letter-spacing: 0.02em;
}
.btn-complete:hover   { background: #3730a3; transform: translateY(-1px); }
.btn-complete.done    { background: #22c55e; box-shadow: 0 4px 12px rgba(34,197,94,0.3); }
.btn-complete.done:hover { background: #16a34a; }

/* ─── 前後ナビ ────────────────────────────────────────── */
.page-nav {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.nav-btn {
  flex: 1;
  min-width: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #475569;
  transition: all 0.15s;
  text-align: center;
}
.nav-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}
.nav-btn.prev { justify-content: flex-start; }
.nav-btn.next { justify-content: flex-end; }

/* ─── 一覧ページ ─────────────────────────────────────── */
.portal-hero {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
  color: #fff;
  padding: 40px 20px 36px;
  text-align: center;
}
.portal-hero h1 {
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 900;
  margin: 0 0 10px;
  letter-spacing: -0.03em;
}
.portal-hero p {
  color: #c7d2fe;
  font-size: 0.92rem;
  margin: 0;
  line-height: 1.65;
}
.portal-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* 進捗バー */
.progress-block {
  background: #fff;
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border: 1px solid #e2e8f0;
}
.progress-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: #334155;
}
.progress-bar-outer {
  background: #e2e8f0;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-bar-inner {
  background: linear-gradient(90deg, #4f46e5, #7c3aed);
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease;
  min-width: 0;
}
.progress-nums {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: #64748b;
}
.progress-nums strong { color: #1e293b; font-size: 1rem; }

/* 今日の3つ */
.today-block {
  background: linear-gradient(135deg, #f0f9ff, #fff);
  border: 2px solid #bae6fd;
  border-radius: 16px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.today-block h3 {
  font-size: 0.9rem;
  font-weight: 800;
  color: #0369a1;
  margin: 0 0 10px;
}
.today-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #e0f2fe;
  font-size: 0.87rem;
}
.today-item:last-child { border-bottom: none; }
.today-num {
  width: 22px; height: 22px;
  background: #0284c7;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* カテゴリヘッダー */
.cat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 24px 0 12px;
}
.cat-header-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
}
.cat-header-label {
  font-size: 1rem;
  font-weight: 800;
  color: #1e293b;
}
.cat-header-count {
  font-size: 0.75rem;
  color: #64748b;
}

/* トピックカードグリッド */
.topic-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 540px) {
  .topic-grid { grid-template-columns: 1fr 1fr; }
}

.topic-card {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}
.topic-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(79,70,229,0.1);
  transform: translateY(-1px);
  text-decoration: none;
}
.topic-card.completed { border-color: #22c55e; background: #f0fdf4; }
.topic-card.completed::after {
  content: '✅';
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 1rem;
}
.topic-num {
  font-size: 0.68rem;
  font-weight: 700;
  color: #94a3b8;
}
.topic-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.4;
}
.topic-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.topic-time { font-size: 0.72rem; color: #64748b; }
.topic-badge-p {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}
.topic-badge-p.p3 { background: #fef3c7; color: #92400e; }
.topic-badge-p.p2 { background: #dbeafe; color: #1e40af; }
.topic-badge-p.p1 { background: #f1f5f9; color: #64748b; }
.topic-badge-f {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}
.topic-badge-f.f3 { background: #fce7f3; color: #9d174d; }
.topic-badge-f.f2 { background: #f3e8ff; color: #6b21a8; }
.topic-badge-f.f1 { background: #f1f5f9; color: #64748b; }

/* ─── フッター ────────────────────────────────────────── */
.site-footer {
  padding: 40px 20px;
  border-top: 1px solid #e2e8f0;
  background: rgba(255,255,255,0.6);
  text-align: center;
}
.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 8px;
}
.site-footer-links a { color: inherit; text-decoration: none; }
.site-footer-links a:hover { color: #4f46e5; }
.site-footer-copy { font-size: 10px; color: #94a3b8; }

/* ─── 補完スタイル（ページテンプレート用） ──────────── */

/* topnav inner / back */
.topnav-inner {
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.topnav-back {
  font-size: 0.82rem;
  color: #64748b;
  font-weight: 700;
  text-decoration: none;
  padding: 5px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 20px;
  background: #fff;
  white-space: nowrap;
  transition: all 0.15s;
  min-height: 32px;
  display: flex;
  align-items: center;
}
.topnav-back:hover {
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}

/* page-header サブ要素 */
.page-header-cat {
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0.85;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
.page-header-title {
  font-size: clamp(1.2rem, 4.5vw, 1.55rem);
  font-weight: 900;
  margin: 0 0 10px;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.page-header-meta {
  font-size: 0.8rem;
  opacity: 0.8;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* page-main */
.page-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* section-title */
.section-title {
  font-size: 1rem;
  font-weight: 800;
  color: #1e293b;
  margin: 24px 0 10px;
  padding: 6px 4px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e2e8f0;
  border-radius: 4px 4px 0 0;
  transition: background 0.15s;
}
@media (max-width: 768px) {
  .section-title:active {
    background: rgba(79,70,229,0.06);
  }
}

/* card variants */
.card-conclusion,
.card-exam,
.card-think,
.card-quiz {
  border-radius: 12px;
  padding: 16px 18px;
  margin: 12px 0;
  font-size: 0.9rem;
  line-height: 1.8;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.card-conclusion {
  border-left: 4px solid var(--primary);
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  font-weight: 600;
  font-size: 0.95rem;
}
.card-exam {
  border-left: 4px solid #f59e0b;
  background: linear-gradient(135deg, #fffbeb 0%, #fff 100%);
}
.card-exam-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: #b45309;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.card-think {
  border-left: 4px solid #8b5cf6;
  background: linear-gradient(135deg, #f5f3ff 0%, #fff 100%);
}
.card-quiz {
  border-left: 4px solid #0891b2;
  background: linear-gradient(135deg, #ecfeff 0%, #f0f9ff 100%);
}

/* quiz-reveal-btn */
.quiz-reveal-btn {
  appearance: none;
  background: #0891b2;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
  transition: background 0.15s;
}
.quiz-reveal-btn:hover { background: #0e7490; }
.quiz-answer { display: none; }

/* pipe-stage */
.pipe-stage {
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 8px;
  text-align: center;
  min-width: 60px;
  line-height: 1.4;
}

/* layer-item */
.layer-item {
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  color: #334155;
  border: 1px solid #e2e8f0;
}

/* ─── box-row / box-item ─────────────────────────────── */
/* ページ内の比較・一覧カード。auto-fit で常に最大2列、スマホは1列 */
.box-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 10px;
  margin: 12px 0;
}
.box-item {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
  line-height: 1.7;
}
/* 奇数個の場合、最後のアイテムを全幅に */
.box-row > .box-item:last-child:nth-child(2n+1) {
  grid-column: 1 / -1;
}

/* bars / bar-item / bar-fill */
.bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}
.bar-item {
  background: #e2e8f0;
  border-radius: 4px;
  height: 22px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding-left: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  min-width: 60px;
}

/* tree overrides */
.root-node { background: #ef4444; }
.tree-node-empty { background: transparent; border: 2px dashed #e2e8f0; }

/* complete-wrap */
.complete-wrap {
  text-align: center;
  padding: 28px 0 10px;
}

/* page-nav (prev/home/next) */
.page-nav {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  align-items: center;
}
.nav-prev, .nav-next {
  flex: 1;
}
.nav-prev a, .nav-next a {
  display: block;
  padding: 10px 14px;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
  transition: all 0.15s;
  text-decoration: none;
}
.nav-prev a:hover, .nav-next a:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.nav-home {
  padding: 10px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s;
}
.nav-home:hover { background: var(--primary-dark); text-decoration: none; }

/* page-footer */
.page-footer {
  padding: 32px 20px;
  border-top: 1px solid #e2e8f0;
  background: rgba(255,255,255,0.6);
  text-align: center;
  margin-top: 24px;
}
.page-footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 8px;
}
.page-footer-nav a { color: inherit; text-decoration: none; }
.page-footer-nav a:hover { color: var(--primary); }
.page-footer p { font-size: 10px; color: #94a3b8; margin: 0; }

/* quiz-q inside card-quiz */
.card-quiz .quiz-q {
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.65;
  margin: 0 0 6px;
}

/* util */
ul, ol { padding-left: 20px; margin: 8px 0; }
li { margin-bottom: 5px; font-size: 0.9rem; }
p { margin: 0 0 10px; }
table { width: 100%; border-collapse: collapse; }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 0.85em; }

/* ============================================================
   スマホ UI 改善
   ============================================================ */

/* ─── 読書進捗バー ──────────────────────────────────────── */
#reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #4f46e5, #7c3aed, #0891b2);
  z-index: 9999;
  transition: width 0.12s linear;
  pointer-events: none;
  border-radius: 0 2px 2px 0;
}
/* topnav が sticky の場合、進捗バーが下に表示されないよう topnav も上に重ねる */
.topnav { z-index: 100; }

/* ─── ページナビ — モバイルで底部固定 ──────────────────── */
@media (max-width: 768px) {
  #page-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    margin: 0;
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid #e2e8f0;
    z-index: 200;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.07);
    display: flex;
    gap: 8px;
    align-items: stretch;
  }
  .nav-prev a, .nav-next a {
    min-height: 44px;
    display: flex;
    align-items: center;
    font-size: 0.78rem;
    padding: 0 10px;
  }
  .nav-home {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    font-size: 0.8rem;
  }
  .page-main {
    padding-bottom: 96px !important;
  }
}

/* ─── FAB（トップへ戻る）───────────────────────────────── */
#fab-top {
  position: fixed;
  bottom: 76px;
  right: 16px;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(79,70,229,0.88);
  color: #fff;
  border: none;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(79,70,229,0.35);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s;
  z-index: 190;
  display: flex;
  align-items: center;
  justify-content: center;
}
#fab-top.show { opacity: 1; transform: translateY(0); }
#fab-top:active { transform: scale(0.88); opacity: 0.75; }

/* ─── タッチターゲット改善 ──────────────────────────────── */
.quiz-reveal-btn {
  min-height: 44px;
  padding: 10px 20px;
  width: 100%;
  border-radius: 10px;
  font-size: 0.88rem;
  letter-spacing: 0.01em;
}
.btn-complete {
  min-height: 52px;
  max-width: 360px;
  width: 90%;
}
.topnav-back {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 4px 8px;
}

/* ─── テーブル (page-main 内) ────────────────────────────── */
.page-main table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  margin: 12px 0 16px;
  font-size: 0.875rem;
  line-height: 1.6;
  border-radius: 0; /* collapse 使用時は角丸なし */
}
.page-main thead th {
  background: #334155;
  color: #fff;
  padding: 9px 13px;
  font-weight: 700;
  text-align: left;
  border: 1px solid #475569;
  white-space: nowrap;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}
.page-main td {
  padding: 8px 13px;
  border: 1px solid #d1d5db;
  vertical-align: top;
  color: #1e293b;
}
.page-main tbody tr:nth-child(even) td {
  background: #f8fafc;
}
.page-main tbody tr:hover td {
  background: #eff6ff;
}

/* ─── SVG / 図 はみ出し防止 ─────────────────────────────── */
.page-main svg { max-width: 100%; height: auto; }
[style*="overflow-x:auto"] { -webkit-overflow-scrolling: touch; }

/* ─── スワイプヒント ────────────────────────────────────── */
.swipe-hint {
  text-align: center;
  font-size: 0.7rem;
  color: #94a3b8;
  padding: 4px 0;
  letter-spacing: 0.05em;
}
@media (min-width: 769px) { .swipe-hint { display: none; } }

/* ─── pre タグ ───────────────────────────────────────────── */
pre {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre;
  word-break: normal;
  max-width: 100%;
}

/* ─── テーブルスクロールインジケーター ─────────────────── */
.tbl-wrap {
  position: relative;
  margin: 12px 0 16px;
}
.tbl-wrap table {
  margin: 0 !important;
}
.tbl-wrap::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 44px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.93));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.tbl-wrap.has-overflow::after { opacity: 1; }

/* ─── 目次（TOC） ────────────────────────────────────────── */
.toc-block {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  margin: 0 0 16px;
  overflow: hidden;
}
.toc-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: none;
  border: none;
  font-size: 0.85rem;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  text-align: left;
  gap: 8px;
  min-height: 44px;
  font-family: inherit;
}
.toc-toggle:active { background: #f1f5f9; }
.toc-label { flex: 1; }
.toc-arr { font-size: 0.78rem; color: #94a3b8; transition: transform 0.2s; }
.toc-list {
  max-height: 0;
  overflow: hidden;
  list-style: none;
  padding: 0;
  margin: 0;
  transition: max-height 0.3s ease;
}
.toc-list.open { max-height: 800px; }
.toc-link {
  display: block;
  padding: 9px 16px;
  font-size: 0.82rem;
  color: #475569;
  border-top: 1px solid #e2e8f0;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
  line-height: 1.4;
}
.toc-link:hover, .toc-link:active {
  background: #e0e7ff;
  color: var(--primary);
  text-decoration: none;
}
.toc-link.active {
  background: #eef2ff;
  color: var(--primary);
  font-weight: 700;
}

/* ─── クイズジャンプボタン ──────────────────────────────── */
.quiz-jump-btn {
  position: fixed;
  bottom: 76px;
  left: 16px;
  background: rgba(8,145,178,0.9);
  color: #fff;
  border: none;
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(8,145,178,0.3);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  z-index: 190;
  white-space: nowrap;
  font-family: inherit;
}
.quiz-jump-btn.show { opacity: 1; transform: translateY(0); }
.quiz-jump-btn:active { transform: scale(0.91); }
@media (min-width: 769px) { .quiz-jump-btn { display: none; } }

/* ─── クイズ解答アニメーション ──────────────────────────── */
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.quiz-answer.open {
  display: block !important;
  animation: fadeSlideDown 0.22s ease;
}

/* ─── インデックス検索バー ──────────────────────────────── */
.search-section {
  padding: 14px 16px 0;
}
.search-wrap {
  position: relative;
}
.search-wrap::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") center/contain no-repeat;
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 11px 14px 11px 36px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.88rem;
  background: #fff;
  color: #1e293b;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
}
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.search-input::placeholder { color: #94a3b8; }
.search-empty {
  display: none;
  text-align: center;
  padding: 32px 16px;
  color: #94a3b8;
  font-size: 0.88rem;
}
.search-empty.visible { display: block; }

/* ─── topnav・ヘッダー スマホ最適化 ────────────────────── */
@media (max-width: 480px) {
  .topnav { padding: 10px 12px; }
  .topnav-home { font-size: 0.88rem; }
  .page-header { padding: 18px 14px 16px; }
  .page-header-title { font-size: clamp(1.2rem, 5.5vw, 1.55rem); }
}

/* ─── recommend-grid スマホ修正 ────────────────────────── */
@media (max-width: 540px) {
  .recommend-grid { grid-template-columns: 1fr !important; }
}

