/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: #1e293b;
  background: #f8fafc;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: #0ea5e9; text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }

/* ===== Design Tokens ===== */
:root {
  --color-primary: #1e3a8a;
  --color-primary-light: #3b82f6;
  --color-secondary: #0ea5e9;
  --color-up: #16a34a;
  --color-down: #dc2626;
  --color-bg: #f8fafc;
  --color-card: #ffffff;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-accent: #fbbf24;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --max-width: 1100px;
}

/* ===== Header ===== */
.site-header {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: white;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-md);
}
.site-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.brand:hover { text-decoration: none; }
.brand-icon {
  width: 32px;
  height: 32px;
  background: white;
  color: var(--color-primary);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 1.1rem;
}

/* Desktop nav */
.nav-desktop {
  display: none;
  gap: 4px;
}
.nav-desktop a {
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s;
}
.nav-desktop a:hover {
  background: rgba(255,255,255,0.15);
  text-decoration: none;
}
.nav-desktop a.active {
  background: rgba(255,255,255,0.22);
}

/* Hamburger */
.hamburger {
  background: transparent;
  border: 0;
  color: white;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 1.4rem;
}
.hamburger:hover { background: rgba(255,255,255,0.15); }

/* Mobile menu */
.mobile-menu {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 80%;
  max-width: 320px;
  background: white;
  z-index: 100;
  padding: 16px;
  overflow-y: auto;
  box-shadow: -10px 0 30px rgba(0,0,0,0.2);
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.mobile-menu.open { display: block; transform: translateX(0); }
.mobile-menu-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 90;
}
.mobile-menu-backdrop.open { display: block; }
.mobile-menu-close {
  background: transparent;
  border: 0;
  font-size: 1.5rem;
  margin-bottom: 12px;
  color: var(--color-text-muted);
}
.mobile-menu h4 {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 18px 0 6px;
  padding: 0 8px;
}
.mobile-menu a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--color-text);
  font-weight: 500;
}
.mobile-menu a:hover { background: var(--color-bg); text-decoration: none; }
.mobile-menu a.active { background: #eff6ff; color: var(--color-primary); }

/* ===== Container ===== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 16px 100px;
}
.container-narrow {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 100px;
}

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #0ea5e9 100%);
  color: white;
  padding: 48px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 20% 30%, rgba(255,255,255,0.15) 0%, transparent 40%),
                    radial-gradient(circle at 80% 70%, rgba(255,255,255,0.1) 0%, transparent 40%);
  pointer-events: none;
}
.hero-inner { position: relative; max-width: var(--max-width); margin: 0 auto; }
.hero h1 {
  font-size: 1.8rem;
  margin: 0 0 12px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.hero p {
  margin: 0 auto;
  max-width: 600px;
  font-size: 1rem;
  opacity: 0.95;
}
.hero-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.hero-stat {
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.85rem;
}
.hero-stat strong { display: block; font-size: 1.4rem; font-weight: 800; }

/* ===== Section heading ===== */
.section-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 32px 0 16px;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 24px;
  background: var(--color-secondary);
  border-radius: 2px;
}
.section-subtitle {
  color: var(--color-text-muted);
  margin-top: -8px;
  margin-bottom: 16px;
  font-size: 0.95rem;
}

/* ===== Card grid ===== */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 600px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}

.lesson-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  color: var(--color-text);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  position: relative;
  overflow: hidden;
}
.lesson-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-secondary);
  text-decoration: none;
}
.lesson-card .level {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--color-primary);
  letter-spacing: 0.04em;
}
.lesson-card .level.intermediate { background: #fef3c7; color: #b45309; }
.lesson-card .level.advanced { background: #fee2e2; color: #b91c1c; }
.lesson-card h3 {
  margin: 4px 0 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.lesson-card p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.88rem;
  line-height: 1.55;
}
.lesson-card .card-meta {
  margin-top: auto;
  padding-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.lesson-card.completed::after {
  content: "✓";
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  background: var(--color-up);
  color: white;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
}

/* ===== Content page ===== */
.content {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px 18px;
  box-shadow: var(--shadow-sm);
}
.content .breadcrumb {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}
.content .breadcrumb a { color: var(--color-text-muted); }
.content h1 {
  font-size: 1.6rem;
  margin: 0 0 8px;
  color: var(--color-primary);
  font-weight: 800;
}
.content .lead {
  color: var(--color-text-muted);
  margin-bottom: 24px;
  font-size: 1rem;
}
.content h2 {
  font-size: 1.25rem;
  margin: 32px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--color-border);
  color: var(--color-primary);
}
.content h3 {
  font-size: 1.05rem;
  margin: 20px 0 8px;
  color: var(--color-text);
}
.content p { margin: 0 0 12px; }
.content ul, .content ol { margin: 0 0 12px; padding-left: 24px; }
.content li { margin-bottom: 4px; }
.content strong { color: var(--color-primary); font-weight: 700; }

.callout {
  border-left: 4px solid var(--color-secondary);
  background: #eff6ff;
  padding: 12px 14px;
  border-radius: 0 8px 8px 0;
  margin: 16px 0;
  font-size: 0.95rem;
}
.callout.warning { border-color: var(--color-down); background: #fef2f2; }
.callout.tip { border-color: var(--color-up); background: #f0fdf4; }
.callout-title { font-weight: 700; margin-bottom: 4px; display: block; }

.table-wrap { overflow-x: auto; margin: 16px 0; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 480px;
}
.data-table th, .data-table td {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  text-align: left;
}
.data-table th {
  background: #f1f5f9;
  font-weight: 700;
  color: var(--color-primary);
}
.data-table tr:nth-child(even) td { background: #f8fafc; }

.up { color: var(--color-up); font-weight: 700; }
.down { color: var(--color-down); font-weight: 700; }

/* Navigation pager (bottom of content) */
.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
  flex-wrap: wrap;
}
.pager a {
  flex: 1 1 200px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--color-text);
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pager a:hover { background: #eff6ff; border-color: var(--color-secondary); text-decoration: none; }
.pager .pager-label { font-size: 0.75rem; color: var(--color-text-muted); }
.pager .pager-next { text-align: right; align-items: flex-end; }

.complete-btn {
  margin-top: 20px;
  padding: 12px 20px;
  background: var(--color-primary);
  color: white;
  border: 0;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  width: 100%;
}
.complete-btn:hover { background: #1e40af; }
.complete-btn.completed { background: var(--color-up); }
.complete-btn.completed::before { content: "✓ "; }

/* ===== Quiz ===== */
.quiz-intro { text-align: center; padding: 20px 0; }
.quiz-category-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 20px;
}
@media (min-width: 600px) { .quiz-category-grid { grid-template-columns: repeat(2, 1fr); } }
.quiz-category {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text);
}
.quiz-category:hover { border-color: var(--color-secondary); box-shadow: var(--shadow-sm); text-decoration: none; }
.quiz-category-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #eff6ff;
  color: var(--color-primary);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.quiz-category-info { flex: 1; }
.quiz-category-info h4 { margin: 0 0 2px; font-size: 1rem; }
.quiz-category-info p { margin: 0; color: var(--color-text-muted); font-size: 0.85rem; }

.quiz-progress-bar {
  height: 8px;
  background: var(--color-border);
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 20px;
}
.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-secondary), var(--color-primary));
  width: 0%;
  transition: width 0.3s;
}
.quiz-question {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.quiz-question-num {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-bottom: 4px;
}
.quiz-question h3 {
  font-size: 1.1rem;
  margin: 0 0 16px;
  line-height: 1.5;
}
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
  background: white;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: left;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.15s;
}
.quiz-option:hover { border-color: var(--color-secondary); background: #f8fafc; }
.quiz-option.selected { border-color: var(--color-primary); background: #eff6ff; }
.quiz-option.correct { border-color: var(--color-up); background: #f0fdf4; }
.quiz-option.incorrect { border-color: var(--color-down); background: #fef2f2; }
.quiz-option.disabled { pointer-events: none; }
.option-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid currentColor;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
  font-size: 0.85rem;
}
.quiz-explanation {
  margin-top: 16px;
  padding: 12px 14px;
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.6;
  display: none;
}
.quiz-explanation.show { display: block; }
.quiz-explanation strong { color: var(--color-primary); }
.quiz-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.btn {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 0;
  font-weight: 700;
  font-size: 0.95rem;
  background: var(--color-primary);
  color: white;
  flex: 1;
}
.btn:hover { background: #1e40af; }
.btn:disabled { background: #cbd5e1; cursor: not-allowed; }
.btn-secondary { background: white; color: var(--color-primary); border: 2px solid var(--color-primary); }
.btn-secondary:hover { background: #eff6ff; }
.btn-danger { background: var(--color-down); }
.btn-danger:hover { background: #b91c1c; }

.quiz-result {
  text-align: center;
  padding: 32px 16px;
}
.quiz-result-score {
  font-size: 3rem;
  font-weight: 900;
  color: var(--color-primary);
  margin: 12px 0;
}
.quiz-result-message { color: var(--color-text-muted); margin-bottom: 20px; }

/* ===== Glossary ===== */
.glossary-search {
  position: sticky;
  top: 64px;
  background: var(--color-bg);
  padding: 12px 0;
  z-index: 10;
}
.glossary-search input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: white;
  font-family: inherit;
}
.glossary-search input:focus {
  outline: none;
  border-color: var(--color-secondary);
}
.glossary-filter {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.glossary-filter button {
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  background: white;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.glossary-filter button.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}
.glossary-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.glossary-item {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.glossary-item h4 {
  margin: 0 0 4px;
  font-size: 1rem;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.glossary-item .tag {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--color-primary);
  font-weight: 600;
}
.glossary-item p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--color-text);
  line-height: 1.6;
}
.glossary-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--color-text-muted);
}

/* ===== Simulator ===== */
.sim-header {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (min-width: 600px) { .sim-header { grid-template-columns: repeat(4, 1fr); } }
.sim-stat { text-align: center; }
.sim-stat-label { color: var(--color-text-muted); font-size: 0.75rem; }
.sim-stat-value { font-size: 1.1rem; font-weight: 800; margin-top: 2px; }

.sim-tabs {
  display: flex;
  gap: 4px;
  background: white;
  padding: 4px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  margin-bottom: 16px;
}
.sim-tab {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}
.sim-tab.active { background: var(--color-primary); color: white; }

.stock-list { display: flex; flex-direction: column; gap: 8px; }
.stock-row {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}
.stock-row:hover { border-color: var(--color-secondary); }
.stock-info { flex: 1; min-width: 0; }
.stock-name { font-weight: 700; font-size: 0.95rem; }
.stock-code { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 2px; }
.stock-price-block { text-align: right; }
.stock-price { font-weight: 800; font-size: 1.05rem; }
.stock-change { font-size: 0.85rem; font-weight: 700; }

.sim-detail {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px;
}
.sim-chart {
  width: 100%;
  height: 200px;
  background: #f8fafc;
  border-radius: var(--radius-sm);
  margin: 12px 0;
}
.sim-trade-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.sim-trade-form input {
  grid-column: span 2;
  padding: 10px 12px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
}
.sim-trade-form input:focus { outline: none; border-color: var(--color-secondary); }
.sim-trade-form .btn { font-size: 0.95rem; padding: 12px; }

.portfolio-empty, .history-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--color-text-muted);
}

.history-row {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  margin-bottom: 6px;
}
.history-side {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}
.history-side.buy { background: #dcfce7; color: var(--color-up); }
.history-side.sell { background: #fee2e2; color: var(--color-down); }

/* ===== Progress dashboard ===== */
.progress-overview {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}
.progress-overview h3 { margin: 0 0 12px; font-size: 1.1rem; color: var(--color-primary); }
.progress-bar {
  height: 12px;
  background: var(--color-border);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 6px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-secondary), var(--color-primary));
  transition: width 0.4s;
}
.progress-text { font-size: 0.85rem; color: var(--color-text-muted); }

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 28px 16px 60px;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  background: white;
  border-top: 1px solid var(--color-border);
}
.site-footer p { margin: 4px 0; }
.disclaimer {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px;
  background: #fef3c7;
  border-radius: var(--radius-sm);
  color: #92400e;
  font-size: 0.82rem;
  text-align: left;
  line-height: 1.6;
}

/* ===== Mobile bottom nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--color-border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0));
  z-index: 40;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  color: var(--color-text-muted);
  font-size: 0.68rem;
  border-radius: 6px;
  font-weight: 600;
}
.bottom-nav a.active { color: var(--color-primary); }
.bottom-nav a:hover { text-decoration: none; }
.bottom-nav-icon { font-size: 1.2rem; line-height: 1; }

/* ===== Responsive ===== */
@media (min-width: 768px) {
  body { font-size: 17px; }
  .hero { padding: 64px 16px; }
  .hero h1 { font-size: 2.4rem; }
  .hero p { font-size: 1.1rem; }
  .nav-desktop { display: flex; }
  .hamburger { display: none; }
  .bottom-nav { display: none; }
  .container { padding-bottom: 40px; }
  .container-narrow { padding-bottom: 40px; }
  .content { padding: 32px 36px; }
  .content h1 { font-size: 2rem; }
  .content h2 { font-size: 1.5rem; }
  .section-title { font-size: 1.6rem; }
}

@media (min-width: 1024px) {
  .hero h1 { font-size: 2.8rem; }
}

/* Print-friendly */
@media print {
  .site-header, .bottom-nav, .pager, .complete-btn, .mobile-menu, .mobile-menu-backdrop { display: none !important; }
  body { background: white; }
  .content { border: 0; box-shadow: none; padding: 0; }
}

/* ============================================== */
/* === Mobile-first refinements (v2) === */
/* ============================================== */

/* iOS-like safe-area & smooth tap */
html, body { overscroll-behavior-y: contain; }
body {
  padding-top: env(safe-area-inset-top, 0);
  -webkit-tap-highlight-color: rgba(30,58,138,0.08);
  text-rendering: optimizeLegibility;
}
button, a { -webkit-touch-callout: none; touch-action: manipulation; }

/* Bigger tap targets on phones (Apple HIG: min 44pt) */
@media (max-width: 767px) {
  .nav-desktop { display: none; }
  .bottom-nav a { min-height: 56px; }
  .bottom-nav a:active { background: #eff6ff; transform: scale(0.96); transition: transform 0.1s; }

  .lesson-card { padding: 16px; min-height: 100px; }
  .lesson-card:active { transform: scale(0.98); transition: transform 0.1s; }

  .btn, .complete-btn, .quiz-option, .sim-tab, .quiz-category {
    min-height: 48px;
  }
  .quiz-option { padding: 14px 14px; font-size: 1rem; }
  .quiz-option:active { transform: scale(0.99); }

  .btn { font-size: 1rem; padding: 14px 18px; }
  .btn:active { transform: scale(0.98); transition: transform 0.08s; }

  .hamburger { width: 48px; height: 48px; font-size: 1.6rem; }

  /* Sticky header smaller on mobile so more content visible */
  .site-header { padding: 10px 14px; }
  .brand { font-size: 1rem; }
  .brand-icon { width: 30px; height: 30px; font-size: 1.05rem; }

  /* Containers - tighter side padding to maximize space */
  .container, .container-narrow { padding: 16px 14px 110px; }
  .content { padding: 18px 16px; border-radius: 16px; }
  .content h1 { font-size: 1.45rem; line-height: 1.35; }
  .content h2 { font-size: 1.18rem; margin: 26px 0 10px; }
  .content h3 { font-size: 1.02rem; }
  .content .lead { font-size: 0.96rem; }
  .content p, .content li { font-size: 1rem; line-height: 1.75; }

  /* Hero — more compact on small screens */
  .hero { padding: 36px 16px 32px; }
  .hero h1 { font-size: 1.55rem; line-height: 1.35; }
  .hero p { font-size: 0.95rem; }
  .hero-stat { padding: 8px 14px; font-size: 0.78rem; }
  .hero-stat strong { font-size: 1.2rem; }

  /* Section headings */
  .section-title { font-size: 1.2rem; margin: 24px 0 12px; }
  .section-subtitle { font-size: 0.88rem; }

  /* Cards bigger on phone */
  .lesson-card h3 { font-size: 1rem; }
  .lesson-card p { font-size: 0.85rem; }

  /* Tables scrollable, hint visible */
  .table-wrap { position: relative; }
  .table-wrap::after {
    content: "← スワイプできます →";
    display: block;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.72rem;
    padding-top: 4px;
  }

  /* Stock rows: stack-friendly */
  .stock-row { padding: 14px 12px; min-height: 64px; }
  .stock-row:active { background: #f1f5f9; }

  /* Forms */
  input, select, textarea {
    font-size: 16px !important; /* avoid iOS auto-zoom */
  }
  .sim-trade-form input { padding: 14px 14px; min-height: 48px; }

  /* Footer */
  .site-footer { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0)); }

  /* Disclaimer */
  .disclaimer { padding: 12px; font-size: 0.8rem; }
}

/* ===== iPhone notch safe-area for the bottom-nav ===== */
.bottom-nav {
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0));
}

/* ===== Page transitions (smooth fade on navigate) ===== */
@media (prefers-reduced-motion: no-preference) {
  main { animation: fadeIn 0.22s ease-out; }
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

/* ===== Install button (PWA prompt) ===== */
.install-btn {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom, 0));
  right: 14px;
  background: var(--color-primary);
  color: white;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(30,58,138,0.35);
  z-index: 45;
  display: none;
  align-items: center;
  gap: 6px;
}
@media (min-width: 768px) {
  .install-btn { bottom: 24px; }
}

/* ===== Hero illustration ===== */
.hero-illust {
  display: block;
  max-width: 320px;
  width: 80%;
  margin: 16px auto 0;
  height: auto;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.18));
}
@media (min-width: 768px) {
  .hero-illust { max-width: 420px; }
}

/* ===== Lesson hero (top of each chapter page) ===== */
.lesson-hero {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-radius: 18px;
  padding: 18px 18px 0;
  margin: -8px 0 18px;
  color: white;
  position: relative;
  overflow: hidden;
  min-height: 130px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.lesson-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 20%, rgba(255,255,255,0.18), transparent 50%);
  pointer-events: none;
}
.lesson-hero-text { flex: 1; padding-bottom: 16px; position: relative; z-index: 1; }
.lesson-hero .chapter-num {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.lesson-hero h1.lesson-hero-title {
  margin: 8px 0 0;
  font-size: 1.3rem;
  color: white;
  font-weight: 800;
  line-height: 1.3;
}
.lesson-hero-illust {
  width: 90px;
  height: 90px;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  align-self: flex-end;
}
@media (min-width: 600px) {
  .lesson-hero { padding: 24px 26px 0; min-height: 160px; }
  .lesson-hero h1.lesson-hero-title { font-size: 1.6rem; }
  .lesson-hero-illust { width: 130px; height: 130px; }
}

/* Hide redundant h1 inside .content when we have lesson-hero */
.lesson-hero + .content h1 { display: none; }
.lesson-hero + .content .breadcrumb { margin-top: 0; }

/* ===== Sectioned chapter list (homepage) ===== */
.chapter-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  margin: 24px 0 8px;
}

/* ===== Card with illustration ===== */
.lesson-card-illust {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.lesson-card-illust-img {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 12px;
  background: #eff6ff;
  display: grid;
  place-items: center;
  font-size: 1.7rem;
}
.lesson-card-illust .lesson-card-body { flex: 1; min-width: 0; }
.lesson-card-illust h3 { margin: 0 0 4px; }
.lesson-card-illust p { margin: 0; }

/* ===== Pill chip ===== */
.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  background: #eff6ff;
  color: var(--color-primary);
  margin-right: 4px;
}
.chip.jp { background: #fef2f2; color: #b91c1c; }
.chip.us { background: #f0fdf4; color: #15803d; }

/* ===== Floating quick-actions for content pages ===== */
.quick-actions {
  display: flex;
  gap: 8px;
  margin: 16px 0 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 4px;
}
.quick-actions::-webkit-scrollbar { display: none; }
.quick-actions a {
  flex-shrink: 0;
  background: white;
  border: 1px solid var(--color-border);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}
.quick-actions a:hover { border-color: var(--color-secondary); text-decoration: none; }

/* ===== Better scrollbar on desktop ===== */
@media (min-width: 768px) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; }
  ::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
}

/* ===== Skeleton (loading) ===== */
.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Big bottom CTA on chapter pages ===== */
.next-cta {
  margin-top: 24px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-radius: 16px;
  padding: 18px 20px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(30,58,138,0.2);
}
.next-cta:hover { text-decoration: none; }
.next-cta-text { flex: 1; }
.next-cta-label { font-size: 0.75rem; opacity: 0.9; letter-spacing: 0.05em; }
.next-cta-title { font-size: 1.05rem; font-weight: 800; margin-top: 2px; color: white; }
.next-cta-arrow { font-size: 1.4rem; margin-left: 12px; }
