/* ===================================================
   NW試験対策学習サイト - メインスタイルシート
   スマホファースト / 読みやすさ最優先
=================================================== */

/* ---- リセット & ベース ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent; /* iOS タップハイライト除去 */
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary: #0ea5e9;
  --accent-green: #10b981;
  --accent-green-light: #d1fae5;
  --accent-amber: #f59e0b;
  --accent-amber-light: #fef3c7;
  --accent-red: #ef4444;
  --accent-red-light: #fee2e2;
  --accent-purple: #8b5cf6;
  --accent-purple-light: #ede9fe;
  --bg: #f1f5f9;
  --bg-subtle: #f8fafc;
  --card-bg: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.06);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --font-main: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Meiryo', sans-serif;
}

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

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ---- ヘッダー ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
.header-inner {
  max-width: 800px;
  margin: 0 auto;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.back-link {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  transition: background 0.15s;
  white-space: nowrap;
  min-height: 40px;
}
.back-link:hover { background: #bfdbfe; text-decoration: none; }
.back-link:active { background: #93c5fd; text-decoration: none; }
.header-progress-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---- サイトタイトルエリア（index用）---- */
.site-hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #0ea5e9 100%);
  color: white;
  padding: 36px 20px 32px;
  text-align: center;
}
.site-hero h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  line-height: 1.3;
}
.site-hero p {
  font-size: 0.9rem;
  opacity: 0.85;
  max-width: 440px;
  margin: 0 auto 20px;
}
.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 16px;
}

/* ---- 進捗バー（全体） ---- */
.progress-section {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
}
.progress-inner {
  max-width: 800px;
  margin: 0 auto;
}
.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.progress-title { font-size: 0.85rem; font-weight: 700; color: var(--text-secondary); }
.progress-count { font-size: 1.1rem; font-weight: 800; color: var(--primary); }
.progress-count span { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); }
.progress-bar-track {
  width: 100%;
  height: 10px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 99px;
  transition: width 0.5s ease;
  min-width: 0;
}
.progress-stats {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}
.progress-stat {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.progress-stat .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-done { background: var(--accent-green); }
.dot-todo { background: var(--border-strong); }

/* ---- 今日のおすすめ ---- */
.recommend-section {
  padding: 16px 16px 0;
  max-width: 800px;
  margin: 0 auto;
}
.section-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.recommend-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.recommend-card {
  background: linear-gradient(135deg, #eff6ff, #f0f9ff);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: block;
  color: var(--text-primary);
}
.recommend-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.rec-label { font-size: 0.65rem; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.rec-title { font-size: 0.8rem; font-weight: 700; line-height: 1.3; }
.rec-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }

/* ---- フィルターバー ---- */
.filter-section {
  padding: 12px 16px 0;
  max-width: 800px;
  margin: 0 auto;
}
.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex-wrap: nowrap;
  padding-bottom: 4px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border-strong);
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-main);
  min-height: 40px;
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn:active { transform: scale(0.96); }
.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ---- 学習テーマカテゴリ ---- */
.category-section {
  padding: 16px 16px 0;
  max-width: 800px;
  margin: 0 auto;
}
.category-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 4px 0;
  margin-top: 8px;
  margin-bottom: 8px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---- トピックカード（一覧） ---- */
.topic-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.topic-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: var(--text-primary);
}
.topic-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
  text-decoration: none;
}
.topic-card:active {
  transform: scale(0.99);
  box-shadow: none;
  text-decoration: none;
}
.topic-card.completed {
  background: #f0fdf4;
  border-color: #86efac;
}
.topic-card.completed::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent-green);
}
.topic-card-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  transition: all 0.15s;
  font-size: 0.85rem;
}
.topic-card.completed .topic-card-check {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: white;
}
.topic-card-body { flex: 1; min-width: 0; }
.topic-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 4px;
}
.topic-card-summary {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 6px;
}
.topic-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.4;
}
.badge-time { background: #f1f5f9; color: var(--text-secondary); }
.badge-freq-high { background: #fee2e2; color: #dc2626; }
.badge-freq-medium { background: #fef3c7; color: #d97706; }
.badge-freq-low { background: #f1f5f9; color: var(--text-muted); }
.badge-imp { background: var(--primary-light); color: var(--primary-dark); }
.badge-done { background: var(--accent-green-light); color: #059669; }

/* ---- 学習ページ ---- */
.page-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px 16px 40px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(40px, calc(env(safe-area-inset-bottom) + 24px));
}

/* パンくず */
.breadcrumb {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep { color: var(--border-strong); }

/* ページタイトル */
.page-header { margin-bottom: 20px; }
.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 10px;
}
.page-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.meta-time {
  background: #f1f5f9;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}
.meta-importance {
  color: var(--accent-amber);
  font-size: 0.9rem;
  font-weight: 700;
}
.meta-freq {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
}
.meta-freq.high { background: #fee2e2; color: #dc2626; }
.meta-freq.medium { background: #fef3c7; color: #d97706; }
.meta-freq.low { background: #f1f5f9; color: var(--text-muted); }

/* カード */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.conclusion-card {
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
  border-color: #93c5fd;
}
.exam-card {
  background: linear-gradient(135deg, #fefce8 0%, #fffbeb 100%);
  border-color: #fcd34d;
}
.warning-card {
  background: linear-gradient(135deg, #fff7ed 0%, #fff1f2 100%);
  border-color: #fca5a5;
}
.quiz-card {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border-color: #86efac;
}
.point-card {
  background: linear-gradient(135deg, #faf5ff 0%, #f5f3ff 100%);
  border-color: #c4b5fd;
}

/* セクションタイトル */
.section-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* テキスト */
.lead-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 12px;
}
p { margin-bottom: 10px; font-size: 0.95rem; line-height: 1.75; }
p:last-child { margin-bottom: 0; }

.highlight { background: #fef9c3; padding: 1px 4px; border-radius: 3px; font-weight: 700; }
.keyword { color: var(--primary); font-weight: 700; }
.caution { color: var(--accent-red); font-weight: 700; }
.tip { color: var(--accent-green); font-weight: 700; }

/* ハイライトボックス */
.highlight-box {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px;
  margin: 12px 0;
  font-size: 0.9rem;
}
.highlight-box.amber {
  background: var(--accent-amber-light);
  border-color: var(--accent-amber);
}
.highlight-box.green {
  background: var(--accent-green-light);
  border-color: var(--accent-green);
}
.highlight-box.red {
  background: var(--accent-red-light);
  border-color: var(--accent-red);
}
.highlight-box.purple {
  background: var(--accent-purple-light);
  border-color: var(--accent-purple);
}

/* ---- 図・ダイアグラム ---- */
.diagram-wrap {
  overflow-x: auto;
  margin: 12px 0;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.diagram-box {
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  min-width: 280px;
}
.diagram-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

/* OSI層モデル */
.osi-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 320px;
  margin: 0 auto;
}
.osi-layer {
  display: grid;
  grid-template-columns: 36px 1fr 1fr;
  align-items: center;
  gap: 0;
  border-radius: 6px;
  overflow: hidden;
  font-size: 0.82rem;
  font-weight: 700;
}
.osi-num {
  background: #334155;
  color: white;
  padding: 8px 0;
  text-align: center;
  font-size: 0.75rem;
}
.osi-name {
  padding: 8px 10px;
  color: white;
}
.osi-example {
  padding: 8px 10px;
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.85;
  color: white;
  border-left: 1px solid rgba(255,255,255,0.2);
}
.osi-l7 .osi-name, .osi-l7 .osi-num ~ * { background: #1d4ed8; }
.osi-l6 .osi-name, .osi-l6 .osi-num ~ * { background: #2563eb; }
.osi-l5 .osi-name, .osi-l5 .osi-num ~ * { background: #3b82f6; }
.osi-l4 .osi-name, .osi-l4 .osi-num ~ * { background: #0ea5e9; }
.osi-l3 .osi-name, .osi-l3 .osi-num ~ * { background: #06b6d4; }
.osi-l2 .osi-name, .osi-l2 .osi-num ~ * { background: #0891b2; }
.osi-l1 .osi-name, .osi-l1 .osi-num ~ * { background: #0e7490; }
.osi-l7 .osi-num { background: #1e3a8a; }
.osi-l6 .osi-num { background: #1d4ed8; }
.osi-l5 .osi-num { background: #2563eb; }
.osi-l4 .osi-num { background: #0284c7; }
.osi-l3 .osi-num { background: #0369a1; }
.osi-l2 .osi-num { background: #0e7490; }
.osi-l1 .osi-num { background: #164e63; }

/* フローダイアグラム */
.flow-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.flow-box {
  background: var(--primary-light);
  border: 2px solid var(--primary);
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-dark);
  min-width: 160px;
  text-align: center;
}
.flow-arrow {
  font-size: 1.2rem;
  color: var(--text-muted);
  line-height: 1.2;
  padding: 2px 0;
}
.flow-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 140px;
}

/* シーケンス図 */
.sequence-diagram {
  font-size: 0.82rem;
  max-width: 400px;
  margin: 0 auto;
}
.seq-header {
  display: flex;
  justify-content: space-around;
  margin-bottom: 8px;
}
.seq-actor {
  background: var(--primary);
  color: white;
  padding: 6px 16px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.8rem;
  min-width: 80px;
  text-align: center;
}
.seq-lines {
  position: relative;
  padding: 4px 0;
}
.seq-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  position: relative;
}
.seq-line {
  display: flex;
  align-items: center;
  width: 100%;
  position: relative;
  padding: 6px 0;
}
.seq-msg {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  z-index: 1;
  color: var(--primary-dark);
}
.seq-arrow-right, .seq-arrow-left {
  width: 100%;
  height: 28px;
  display: flex;
  align-items: center;
  position: relative;
}
.seq-arrow-right::after {
  content: '';
  position: absolute;
  left: 10%; right: 10%;
  height: 2px;
  background: var(--primary);
}
.seq-arrow-right::before {
  content: '▶';
  position: absolute;
  right: 8%;
  color: var(--primary);
  font-size: 0.7rem;
}
.seq-arrow-left::after {
  content: '';
  position: absolute;
  left: 10%; right: 10%;
  height: 2px;
  background: var(--secondary);
}
.seq-arrow-left::before {
  content: '◀';
  position: absolute;
  left: 8%;
  color: var(--secondary);
  font-size: 0.7rem;
}
.seq-step-label {
  font-size: 0.7rem;
  background: var(--accent-amber-light);
  color: #92400e;
  border-radius: 10px;
  padding: 1px 6px;
  font-weight: 700;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

/* ネットワーク構成図 */
.net-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px;
}
.net-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.net-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
}
.net-label { font-size: 0.7rem; font-weight: 700; color: var(--text-secondary); }
.net-line {
  height: 3px;
  width: 40px;
  background: var(--border-strong);
  border-radius: 2px;
  align-self: center;
  margin-top: -20px;
}
.net-line-v {
  width: 3px;
  height: 30px;
  background: var(--border-strong);
  border-radius: 2px;
}

/* アイコン色 */
.icon-pc { background: #dbeafe; }
.icon-router { background: #d1fae5; }
.icon-sw { background: #fef3c7; }
.icon-fw { background: #fee2e2; }
.icon-server { background: #ede9fe; }
.icon-cloud { background: #e0f2fe; }
.icon-internet { background: #f1f5f9; }

/* パケット変換図 */
.packet-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
}
.packet-row {
  display: flex;
  align-items: stretch;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.packet-layer {
  padding: 6px 10px;
  font-weight: 700;
  white-space: nowrap;
  display: flex;
  align-items: center;
}
.pkt-l7 { background: #dbeafe; color: #1d4ed8; min-width: 60px; justify-content: center; }
.pkt-l4 { background: #d1fae5; color: #065f46; min-width: 60px; justify-content: center; }
.pkt-l3 { background: #fef3c7; color: #92400e; min-width: 60px; justify-content: center; }
.pkt-l2 { background: #ede9fe; color: #5b21b6; min-width: 60px; justify-content: center; }
.pkt-data { background: var(--bg-subtle); color: var(--text-secondary); flex: 1; font-weight: 500; }

/* ---- テーブル ---- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 10px 0;
}
th {
  background: var(--primary);
  color: white;
  padding: 8px 12px;
  text-align: left;
  font-weight: 700;
  font-size: 0.8rem;
}
th:first-child { border-radius: 8px 0 0 0; }
th:last-child { border-radius: 0 8px 0 0; }
td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}
tr:nth-child(even) td { background: var(--bg-subtle); }
tr:hover td { background: var(--primary-light); }
.table-wrap {
  overflow-x: auto;
  margin: 10px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.table-wrap table { margin: 0; }

/* ---- ステップリスト ---- */
.step-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0;
}
.step-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-weight: 800;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.step-content { flex: 1; }
.step-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 2px; }
.step-desc { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }

/* チェックリスト */
.check-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0;
}
.check-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
}
.check-list li::before {
  content: '✓';
  color: var(--accent-green);
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
}
.check-list li.caution::before { content: '✗'; color: var(--accent-red); }
.check-list li.note::before { content: '→'; color: var(--primary); }

/* 比較表 */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0;
}
.compare-card {
  border-radius: var(--radius-sm);
  padding: 12px;
  border: 2px solid var(--border);
}
.compare-card.left { border-color: #93c5fd; background: #eff6ff; }
.compare-card.right { border-color: #86efac; background: #f0fdf4; }
.compare-head { font-weight: 800; font-size: 0.9rem; margin-bottom: 8px; }
.compare-head.blue { color: var(--primary-dark); }
.compare-head.green { color: #065f46; }
.compare-item { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 4px; }

/* ---- 試験バッジ ---- */
.exam-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fef9c3;
  border: 1px solid #fcd34d;
  color: #92400e;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  margin: 2px;
}
.exam-badge.red {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}
.exam-badge.blue {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1d4ed8;
}

/* ---- クイズ ---- */
.quiz-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.quiz-item { }
.quiz-q {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  gap: 8px;
}
.quiz-q-num {
  background: var(--primary);
  color: white;
  border-radius: 50%;
  width: 22px; height: 22px;
  font-size: 0.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.quiz-options {
  user-select: none;
  -webkit-user-select: none;
}
.quiz-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  cursor: pointer;
  font-size: 0.88rem;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  font-family: var(--font-main);
  text-align: left;
  width: 100%;
  min-height: 48px;
  line-height: 1.4;
}
.quiz-option:hover { border-color: var(--primary); background: var(--primary-light); }
.quiz-option:active:not(:disabled) { transform: scale(0.98); background: var(--primary-light); }
.quiz-option.correct { border-color: var(--accent-green); background: var(--accent-green-light); }
.quiz-option.wrong { border-color: var(--accent-red); background: var(--accent-red-light); }
.quiz-answer {
  display: none;
  padding: 12px 16px;
  background: var(--accent-green-light);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-green);
  font-size: 0.86rem;
  line-height: 1.65;
}
.quiz-answer.show {
  display: block;
  animation: slideDown 0.25s ease both;
}

/* ---- 読了ボタン ---- */
.completion-area {
  text-align: center;
  padding: 24px 0 10px;
}
.btn-complete {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  font-family: var(--font-main);
  box-shadow: 0 4px 14px rgba(37,99,235,0.35);
  transition: all 0.2s;
  min-width: 200px;
  justify-content: center;
}
.btn-complete:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37,99,235,0.4);
}
.btn-complete:active { transform: scale(0.97); box-shadow: none; }
.btn-complete.done {
  background: linear-gradient(135deg, var(--accent-green), #059669);
  box-shadow: 0 4px 14px rgba(16,185,129,0.35);
}
.btn-complete:hover.done { box-shadow: 0 6px 20px rgba(16,185,129,0.4); }

/* ---- 前へ/次へナビゲーション ---- */
.page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0 20px;
}
.nav-btn {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  transition: all 0.15s;
  line-height: 1.3;
}
.nav-btn:hover { border-color: var(--primary); background: var(--primary-light); text-decoration: none; }
.nav-btn:active { background: var(--primary-light); transform: scale(0.98); }
.nav-btn.nav-prev { justify-content: flex-start; }
.nav-btn.nav-next { justify-content: flex-end; text-align: right; }
.nav-btn-sub { font-size: 0.7rem; font-weight: 500; color: var(--text-muted); display: block; }
.nav-btn.disabled { opacity: 0.4; pointer-events: none; }

/* ---- スポンサーエリア ---- */
.sponsor-area {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.sponsor-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}
.sponsor-inner {
  background: var(--card-bg);
  padding: 4px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

/* ---- 試験対策ポータル ---- */
.portal-hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #312e81 100%);
  color: white;
  padding: 40px 20px 36px;
  text-align: center;
}
.portal-hero h1 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}
.portal-hero p {
  font-size: 0.95rem;
  opacity: 0.8;
  max-width: 480px;
  margin: 0 auto;
}
.exam-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 20px 16px;
  max-width: 800px;
  margin: 0 auto;
}
.exam-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  cursor: pointer;
  transition: all 0.15s;
  display: block;
  text-decoration: none;
  color: var(--text-primary);
  position: relative;
  overflow: hidden;
}
.exam-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  text-decoration: none;
}
.exam-card.available::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
}
.exam-card.coming-soon {
  opacity: 0.6;
  cursor: default;
}
.exam-card.coming-soon:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border);
}
.exam-icon { font-size: 2rem; margin-bottom: 8px; }
.exam-name { font-size: 0.9rem; font-weight: 800; margin-bottom: 4px; color: var(--text-primary); }
.exam-name-en { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 8px; }
.exam-desc { font-size: 0.78rem; color: var(--text-secondary); line-height: 1.5; margin-bottom: 10px; }
.exam-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
}
.status-available { background: #d1fae5; color: #065f46; }
.status-soon { background: #f1f5f9; color: var(--text-muted); }
.status-progress {
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ---- おすすめ学習順 ---- */
.order-section {
  padding: 16px;
  max-width: 800px;
  margin: 0 auto;
}
.order-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.order-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
}
.order-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.order-item a {
  flex: 1;
  font-weight: 600;
  color: var(--primary);
}
.order-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 10px;
}

/* ---- フッター ---- */
.site-footer {
  background: #1e293b;
  color: #94a3b8;
  text-align: center;
  padding: 24px 16px;
  font-size: 0.8rem;
  margin-top: 40px;
}
.site-footer a { color: #60a5fa; }

/* ---- レスポンシブ ---- */
@media (max-width: 480px) {
  .site-hero h1 { font-size: 1.35rem; }
  .page-title { font-size: 1.25rem; }
  .recommend-grid { grid-template-columns: 1fr; }
  .compare-grid { grid-template-columns: 1fr; }
  .exam-grid { grid-template-columns: 1fr; }
  .page-nav { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .osi-layer { font-size: 0.75rem; }

  /* タッチ向けレイアウト改善 */
  .btn-complete { width: 100%; min-width: 0; }
  .nav-btn { font-size: 0.82rem; padding: 12px 12px; }
  .highlight-box { font-size: 0.88rem; padding: 10px 14px; }
  .check-list li { font-size: 0.88rem; line-height: 1.55; }
  .compare-card { padding: 10px 12px; }
  .compare-item { font-size: 0.8rem; }
  td { padding: 7px 10px; font-size: 0.82rem; }
  th { padding: 7px 10px; font-size: 0.78rem; }
  .step-desc { font-size: 0.84rem; }
  .topic-card { padding: 12px 14px; }
  .filter-bar { gap: 6px; }
  p { font-size: 0.93rem; }

  /* セーフエリア（インデックスページ） */
  .category-section, .recommend-section, .filter-section, .order-section {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}

/* 320px以下の極小画面 */
@media (max-width: 360px) {
  .page-title { font-size: 1.15rem; }
  .card { padding: 14px; }
  .section-title { font-size: 0.95rem; }
  .back-link { font-size: 0.82rem; padding: 7px 10px; }
  .filter-btn { font-size: 0.74rem; padding: 7px 12px; }
}

@media (min-width: 600px) {
  .recommend-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 768px) {
  .site-hero h1 { font-size: 2rem; }
  .page-title { font-size: 1.75rem; }
  .card { padding: 24px; }
  .exam-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---- ユーティリティ ---- */
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.text-center { text-align: center; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.flex-wrap { flex-wrap: wrap; }

/* ---- アニメーション ---- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* カードのフェードイン（スタガー） */
.card { animation: fadeIn 0.3s ease both; }
.card:nth-child(1) { animation-delay: 0.04s; }
.card:nth-child(2) { animation-delay: 0.08s; }
.card:nth-child(3) { animation-delay: 0.12s; }
.card:nth-child(4) { animation-delay: 0.16s; }
.card:nth-child(5) { animation-delay: 0.20s; }
.card:nth-child(6) { animation-delay: 0.24s; }
.card:nth-child(n+7) { animation-delay: 0.28s; }

/* ---- スクロールトップボタン ---- */
.scroll-top-btn {
  position: fixed;
  right: 16px;
  bottom: 24px;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px));
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37,99,235,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.9);
  transition: opacity 0.25s, transform 0.25s;
  z-index: 80;
  font-family: var(--font-main);
}
.scroll-top-btn.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.scroll-top-btn:active { transform: scale(0.92); }

/* ---- 読書進捗バー ---- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  z-index: 200;
  transition: width 0.1s linear;
  pointer-events: none;
}

/* ---- モーション削減（アクセシビリティ） ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reading-progress { transition: none; }
}
