/*
  PROJECT GRADE7 MISSION SYSTEM
  Screen Stylesheet — Version 3.0 "Neo Learning Mission UI"
  2026 Summer Grade 7 Preview
  Design: Clean white-surface app cards · Pastel subject accents · Warm cream base
*/

/* ════════════════════════════════════════
   CSS CUSTOM PROPERTIES
════════════════════════════════════════ */
:root {
  /* ── Neo Learning Mission UI Design Tokens ── */
  --bg:       #f6f4ef;
  --surface:  #ffffff;
  --ink:      #1f2933;
  --line:     #e2ddd6;
  --muted:    #6b7280;
  --yellow:   #ffe28a;
  --mint:     #9adbb5;
  --lavender: #c8c2ff;
  --coral:    #ff9b8a;
  --sky:      #8ed8f8;
  --cream:    #fff7df;

  /* ── Page Background (compat) ── */
  --bg-main:    var(--bg);
  --bg-surface: var(--surface);
  --bg-alt:     #eeeae3;
  --bg-nav:     var(--ink);

  /* ── Design Tokens ── */
  --color-bg:           var(--bg);
  --color-surface:      var(--surface);
  --color-surface-soft: #eeeae3;
  --color-primary:      var(--ink);
  --color-secondary:    #7c5ecf;
  --color-accent:       #c87828;
  --color-text:         var(--ink);
  --color-muted:        var(--muted);
  --color-border:       var(--line);
  --color-success:      #28a87c;
  --color-warning:      #d08030;
  --color-danger:       #cc4e52;

  --radius-card: 16px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 3px rgba(31,41,51,0.05), 0 4px 16px rgba(31,41,51,0.07);
  --shadow-soft: 0 1px 3px rgba(31,41,51,0.04);

  /* ── Brand ── */
  --brand-blue:    #2b8ec8;
  --brand-blue-dk: #1a6090;
  --brand-gold:    #c87828;
  --brand-gold-bg: var(--cream);

  /* ── Text ── */
  --text-primary: var(--ink);
  --text-muted:   var(--muted);
  --text-light:   #9ca3af;
  --text-on-dark: #f0ece6;

  /* ── Borders ── */
  --border:       var(--line);
  --border-light: #eae6de;

  /* ══════════════════════════════════════
     Subject Colors v3 — Neo Learning Mission UI
     目標：粉彩飽和、清爽但不幼稚
  ══════════════════════════════════════ */
  /* 數學：青藍 teal-blue */
  --subject-math:        #2b8ec8;
  --subject-math-bg:     #dff1fb;
  --subject-math-dk:     #17638f;
  /* 英文：淡紫 lavender */
  --subject-english:     #7c5ecf;
  --subject-english-bg:  #ece8ff;
  --subject-english-dk:  #4a3585;
  /* 國文：珊瑚紅 coral-red */
  --subject-chinese:     #cc4e52;
  --subject-chinese-bg:  #fde8e8;
  --subject-chinese-dk:  #882028;
  /* 生物：薄荷綠 mint-green */
  --subject-biology:     #28a87c;
  --subject-biology-bg:  #dff6ee;
  --subject-biology-dk:  #166048;
  /* 歷史：奶茶棕 milk-tea-brown */
  --subject-history:     #a07840;
  --subject-history-bg:  #f8edd8;
  --subject-history-dk:  #5c3e10;
  /* 地理：天空藍 sky-blue */
  --subject-geography:   #2090c0;
  --subject-geography-bg:#dcf1fa;
  --subject-geography-dk:#0e5878;
  /* 公民：橘黃 orange-yellow */
  --subject-civics:      #c87828;
  --subject-civics-bg:   #feecd8;
  --subject-civics-dk:   #7a3f08;

  /* backward compat shortcuts */
  --math:         var(--subject-math);
  --math-bg:      var(--subject-math-bg);
  --english:      var(--subject-english);
  --english-bg:   var(--subject-english-bg);
  --chinese:      var(--subject-chinese);
  --chinese-bg:   var(--subject-chinese-bg);
  --biology:      var(--subject-biology);
  --biology-bg:   var(--subject-biology-bg);
  --history:      var(--subject-history);
  --history-bg:   var(--subject-history-bg);
  --geography:    var(--subject-geography);
  --geography-bg: var(--subject-geography-bg);
  --civics:       var(--subject-civics);
  --civics-bg:    var(--subject-civics-bg);

  /* ── Active Subject Theme (overridden by body.subject-*) ── */
  --subject-color:    #2b8ec8;
  --subject-color-bg: #dff1fb;
  --subject-color-dk: #17638f;

  /* ── Typography ── */
  --font:      'Segoe UI', '微軟正黑體', 'Microsoft JhengHei', 'Noto Sans TC', system-ui, sans-serif;
  --font-mono: 'Consolas', 'Courier New', monospace;

  /* Font Sizes */
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-md:   1.0625rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --text-4xl:  2.25rem;

  /* Spacing */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;

  /* Border Radius */
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;
  --r-xl: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(31,41,51,0.05);
  --shadow:    0 1px 4px rgba(31,41,51,0.05), 0 4px 16px rgba(31,41,51,0.07);
  --shadow-lg: 0 4px 8px rgba(31,41,51,0.06), 0 8px 28px rgba(31,41,51,0.10);

  --transition: 0.2s ease;
}

/* ════════════════════════════════════════
   SUBJECT THEME CLASSES
   Add class to <body> for per-subject accent
════════════════════════════════════════ */
body.subject-math      { --subject-color: var(--subject-math);      --subject-color-bg: var(--subject-math-bg);      --subject-color-dk: var(--subject-math-dk); }
body.subject-english   { --subject-color: var(--subject-english);   --subject-color-bg: var(--subject-english-bg);   --subject-color-dk: var(--subject-english-dk); }
body.subject-chinese   { --subject-color: var(--subject-chinese);   --subject-color-bg: var(--subject-chinese-bg);   --subject-color-dk: var(--subject-chinese-dk); }
body.subject-biology   { --subject-color: var(--subject-biology);   --subject-color-bg: var(--subject-biology-bg);   --subject-color-dk: var(--subject-biology-dk); }
body.subject-history   { --subject-color: var(--subject-history);   --subject-color-bg: var(--subject-history-bg);   --subject-color-dk: var(--subject-history-dk); }
body.subject-geography { --subject-color: var(--subject-geography); --subject-color-bg: var(--subject-geography-bg); --subject-color-dk: var(--subject-geography-dk); }
body.subject-civics    { --subject-color: var(--subject-civics);    --subject-color-bg: var(--subject-civics-bg);    --subject-color-dk: var(--subject-civics-dk); }
body.subject-boss      { --subject-color: #7c5ecf;                  --subject-color-bg: #ece8ff;                     --subject-color-dk: #4a3585; }

/* ════════════════════════════════════════
   RESET & BASE
════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font);
  font-size: var(--text-md);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.75;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a {
  color: var(--subject-color, var(--brand-blue));
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

ul, ol { padding-left: var(--sp-6); }

table { border-collapse: collapse; width: 100%; }

h1, h2, h3, h4, h5, h6 {
  line-height: 1.4;
  font-weight: 700;
  color: var(--ink);
}
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p { margin-bottom: var(--sp-3); }
p:last-child { margin-bottom: 0; }

/* ════════════════════════════════════════
   NAVIGATION  ── App-style white topbar
════════════════════════════════════════ */
#main-nav {
  background: var(--surface);
  border-bottom: 1.5px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 8px rgba(31,41,51,0.07);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--sp-6);
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  min-height: 56px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  text-decoration: none;
  flex-shrink: 0;
}
.nav-brand:hover { text-decoration: none; }

.nav-brand-tag {
  background: var(--ink);
  color: white;
  font-size: 0.68rem;
  font-weight: 800;
  font-family: var(--font-mono);
  padding: 3px 8px;
  border-radius: var(--r-xl);
  letter-spacing: 0.06em;
}

.nav-brand-name {
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: var(--sp-1);
  margin: 0;
  padding: 0;
  align-items: center;
  flex: 1;
}

.nav-links li { position: relative; }

.nav-links > li > a {
  display: block;
  padding: var(--sp-2) var(--sp-3);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--r-xl);
  transition: all var(--transition);
  white-space: nowrap;
}
.nav-links > li > a:hover,
.nav-links > li > a.active {
  background: var(--bg-alt);
  color: var(--ink);
  text-decoration: none;
}

/* Dropdown */
.dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  min-width: 140px;
  list-style: none;
  padding: var(--sp-2);
  z-index: 200;
}

.has-dropdown:hover .dropdown,
.has-dropdown:focus-within .dropdown {
  display: block;
}

.dropdown li a {
  display: block;
  padding: var(--sp-2) var(--sp-3);
  color: var(--ink) !important;
  font-size: var(--text-sm);
  border-radius: var(--r);
  border-left: 3px solid transparent;
  transition: all var(--transition);
}
.dropdown li a:hover {
  background: var(--bg-alt);
  text-decoration: none;
}

.dropdown .subject-math      a { border-left-color: var(--subject-math); }
.dropdown .subject-english   a { border-left-color: var(--subject-english); }
.dropdown .subject-chinese   a { border-left-color: var(--subject-chinese); }
.dropdown .subject-biology   a { border-left-color: var(--subject-biology); }
.dropdown .subject-history   a { border-left-color: var(--subject-history); }
.dropdown .subject-geography a { border-left-color: var(--subject-geography); }
.dropdown .subject-civics    a { border-left-color: var(--subject-civics); }

/* Mobile toggle button */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--sp-2);
  margin-left: auto;
  flex-direction: column;
  gap: 5px;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: all var(--transition);
}

@media (max-width: 780px) {
  .nav-inner {
    flex-wrap: wrap;
    padding: var(--sp-3) var(--sp-4);
  }
  .nav-toggle { display: flex; }
  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 0;
    padding-bottom: var(--sp-3);
  }
  .nav-links.open { display: flex; }
  .nav-links > li > a {
    padding: var(--sp-3) var(--sp-2);
    border-bottom: 1px solid var(--line);
    border-radius: 0;
  }
  .dropdown {
    position: static;
    box-shadow: none;
    border: none;
    border-left: 2px solid var(--line);
    background: var(--bg-alt);
    border-radius: 0;
    min-width: unset;
    padding: var(--sp-1) 0;
  }
  .dropdown li a { color: var(--muted) !important; }
  .has-dropdown:hover .dropdown { display: none; }
  .has-dropdown.open .dropdown { display: block; }
}

/* ════════════════════════════════════════
   LAYOUT
════════════════════════════════════════ */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

.page-content { padding: var(--sp-10) 0; }

.section { margin-bottom: var(--sp-12); }

.section-header {
  display: flex;
  align-items: baseline;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-3);
  border-bottom: 2px solid var(--line);
}

.section-title { font-size: var(--text-2xl); font-weight: 700; color: var(--ink); }

/* ════════════════════════════════════════
   HERO SECTION  ── App-card with dark ink
════════════════════════════════════════ */
.hero {
  background: var(--ink);
  color: white;
  padding: var(--sp-16) 0 var(--sp-12);
  position: relative;
  overflow: hidden;
  border-radius: 0 0 28px 28px;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 50%, rgba(142,216,248,0.10) 0%, transparent 50%),
    radial-gradient(circle at 85% 20%, rgba(200,194,255,0.10) 0%, transparent 50%);
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -40px;
  right: -40px;
  width: 300px;
  height: 300px;
  background: radial-gradient(ellipse, rgba(255,226,138,0.08) 0%, transparent 65%);
  pointer-events: none;
}

.hero-inner { position: relative; z-index: 1; }

.hero-eyebrow {
  display: inline-block;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.20);
  color: var(--sky);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  letter-spacing: 0.15em;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-xl);
  margin-bottom: var(--sp-4);
  text-transform: uppercase;
}

.hero-title {
  font-size: clamp(var(--text-3xl), 5vw, var(--text-4xl));
  font-weight: 900;
  line-height: 1.2;
  margin-bottom: var(--sp-4);
  color: white;
}
.hero-title span { color: var(--yellow); }

.hero-desc {
  font-size: var(--text-lg);
  color: rgba(255,255,255,0.60);
  max-width: 580px;
  margin-bottom: var(--sp-8);
  line-height: 1.9;
}

.hero-stats {
  display: flex;
  gap: var(--sp-8);
  flex-wrap: wrap;
}

.stat-item { text-align: center; }

.stat-value {
  font-size: var(--text-3xl);
  font-weight: 900;
  color: white;
  font-family: var(--font-mono);
  display: block;
}

.stat-label {
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: var(--sp-1);
  display: block;
}

.stat-gold { color: var(--yellow) !important; }

/* ════════════════════════════════════════
   CARDS
════════════════════════════════════════ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-5);
}

.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--subject-color, var(--line));
}

.card-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1.5px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.card-body {
  padding: var(--sp-5);
  flex: 1;
}

.card-footer {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1.5px solid var(--border-light);
  background: var(--bg-alt);
}

/* Subject Cards — colored left border */
.subject-card { border-left: 4px solid var(--line); }
.subject-card.math      { border-left-color: var(--subject-math); }
.subject-card.english   { border-left-color: var(--subject-english); }
.subject-card.chinese   { border-left-color: var(--subject-chinese); }
.subject-card.biology   { border-left-color: var(--subject-biology); }
.subject-card.history   { border-left-color: var(--subject-history); }
.subject-card.geography { border-left-color: var(--subject-geography); }
.subject-card.civics    { border-left-color: var(--subject-civics); }

.subject-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  font-weight: 900;
  color: white;
  flex-shrink: 0;
}
.math      .subject-icon { background: var(--subject-math); }
.english   .subject-icon { background: var(--subject-english); }
.chinese   .subject-icon { background: var(--subject-chinese); }
.biology   .subject-icon { background: var(--subject-biology); }
.history   .subject-icon { background: var(--subject-history); }
.geography .subject-icon { background: var(--subject-geography); }
.civics    .subject-icon { background: var(--subject-civics); }

.subject-name { font-size: var(--text-lg); font-weight: 700; line-height: 1.2; color: var(--ink); }
.subject-en   { font-size: var(--text-xs); color: var(--muted); font-family: var(--font-mono); letter-spacing: 0.05em; }
.subject-desc { font-size: var(--text-sm); color: var(--muted); margin-bottom: var(--sp-3); }

/* Week cards */
.week-card { border-top: 4px solid var(--ink); text-align: center; }
.week-card .card-body { padding: var(--sp-4); }
.week-num-label { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.week-num-big { font-size: var(--text-3xl); font-weight: 900; font-family: var(--font-mono); color: var(--ink); display: block; line-height: 1.1; }
.week-date-sm { font-size: var(--text-xs); color: var(--muted); font-family: var(--font-mono); margin-top: var(--sp-1); display: block; }
.week-boss-tag { margin-top: var(--sp-2); }

/* ════════════════════════════════════════
   MISSION ELEMENTS
════════════════════════════════════════ */
.mission-header {
  background: linear-gradient(145deg, #26333f 0%, #1f2933 100%);
  color: white;
  padding: var(--sp-10) 0 var(--sp-8);
  margin-bottom: var(--sp-8);
  position: relative;
  overflow: hidden;
  border-radius: 0 0 24px 24px;
}

.mission-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 90% 10%, rgba(255,226,138,0.07) 0%, transparent 55%);
  pointer-events: none;
}

.mission-header::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--subject-color);
}

.mission-meta {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: var(--sp-4);
}

.mission-code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  background: rgba(255,255,255,0.10);
  color: var(--sky);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-xl);
  border: 1px solid rgba(142,216,248,0.30);
}

.mission-title {
  font-size: clamp(var(--text-2xl), 4vw, var(--text-3xl));
  font-weight: 900;
  color: white;
  margin-bottom: var(--sp-2);
}

.mission-subtitle {
  font-size: var(--text-base);
  color: rgba(255,255,255,0.55);
}

/* XP Badge */
.xp-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  background: var(--cream);
  color: #7a4510;
  border: 1.5px solid var(--yellow);
  padding: 2px var(--sp-3);
  border-radius: var(--r-xl);
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: var(--font-mono);
}

/* Difficulty badges */
.difficulty {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--sp-3);
  border-radius: var(--r-xl);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-mono);
}
.diff-1 { background: #d8f5e8; color: #176040; }
.diff-2 { background: #d8ecf8; color: #1a5f8a; }
.diff-3 { background: var(--cream); color: #7a4510; }
.diff-4 { background: #fde8e8; color: #8a1515; }
.diff-5 { background: var(--lavender); color: #4a2a8a; }

/* Boss badge */
.boss-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  background: #fde8e8;
  color: #8a1515;
  padding: 3px var(--sp-3);
  border-radius: var(--r-xl);
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  border: 1.5px solid #f5a5a5;
}

/* ════════════════════════════════════════
   LESSON CONTENT (Worksheet Style)
════════════════════════════════════════ */
.lesson-page { max-width: 820px; margin: 0 auto; }

.lesson-section {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1.5px solid var(--line);
  padding: var(--sp-6);
  margin-bottom: var(--sp-6);
  box-shadow: var(--shadow-sm);
}

.lesson-section-title {
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--ink);
}
.lesson-section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.1em;
  background: var(--subject-color);
  border-radius: 2px;
  flex-shrink: 0;
}

/* Key concept box */
.key-box {
  background: var(--subject-color-bg);
  border-left: 4px solid var(--subject-color);
  border-radius: 0 var(--r) var(--r) 0;
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-4);
}
.key-box ul { margin: var(--sp-2) 0 0; }
.key-box li { margin-bottom: var(--sp-2); }

/* Definition box */
.def-box {
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: var(--sp-4);
}
.def-box-header {
  background: var(--bg-alt);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
  border-bottom: 1.5px solid var(--line);
}
.def-box-body { padding: var(--sp-4); }
.def-term   { font-weight: 700; color: var(--subject-color); margin-bottom: var(--sp-1); font-size: var(--text-md); }
.def-meaning { color: var(--ink); padding-left: var(--sp-4); margin-bottom: var(--sp-3); line-height: 1.7; }
.def-meaning:last-child { margin-bottom: 0; }

/* Example box */
.example-box {
  background: #f0fdf8;
  border: 1.5px solid #a8e8c8;
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-4);
}
.example-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: #166048;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
  margin-bottom: var(--sp-2);
}

/* Exercise / Worksheet boxes */
.exercise-box {
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-5);
  break-inside: avoid;
}

.exercise-number {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--subject-color);
  font-size: var(--text-lg);
  margin-bottom: var(--sp-3);
}

.exercise-question {
  font-size: var(--text-base);
  line-height: 1.85;
  margin-bottom: var(--sp-4);
  color: var(--ink);
}

/* Handwriting space */
.answer-area {
  border: 1.5px dashed #c8c3ba;
  border-radius: var(--r);
  background: #faf9f6;
  min-height: 80px;
  padding: var(--sp-3);
  margin-top: var(--sp-2);
}

.answer-lines { margin-top: var(--sp-2); }
.answer-line {
  border-bottom: 1px solid #d8d3cc;
  height: 44px;
  margin-bottom: 4px;
}

/* ════════════════════════════════════════
   SCHEDULE TABLE
════════════════════════════════════════ */
.schedule-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  margin-bottom: var(--sp-8);
  border: 1.5px solid var(--line);
}

.schedule-table { font-size: var(--text-sm); background: var(--surface); }

.schedule-table th {
  background: var(--ink);
  color: var(--text-on-dark);
  padding: var(--sp-3) var(--sp-4);
  text-align: center;
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  border: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
}

.schedule-table td {
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line);
  vertical-align: top;
  font-size: var(--text-sm);
  min-width: 100px;
}

.schedule-table tr:nth-child(even) td { background: var(--bg-alt); }
.schedule-table tr:hover td { background: var(--subject-color-bg, var(--bg-alt)); }

.week-cell {
  white-space: nowrap;
  font-weight: 700;
  font-family: var(--font-mono);
  background: #ece9e2 !important;
  border-right: 2px solid var(--line) !important;
  min-width: 90px;
  text-align: center;
}
.week-cell-num  { font-size: var(--text-xs); color: var(--muted); display: block; }
.week-cell-date { font-size: var(--text-xs); color: var(--muted); font-weight: 400; margin-top: 2px; display: block; }

.cell-code  { font-size: var(--text-xs); font-family: var(--font-mono); color: var(--muted); display: block; }
.cell-title { font-size: var(--text-sm); display: block; color: var(--ink); }

.boss-cell { background: #fde8e8 !important; text-align: center; }
.boss-tag  {
  display: inline-block;
  background: #fde8e8;
  color: #8a1515;
  border: 1px solid #f5a5a5;
  font-size: var(--text-xs);
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: var(--r-xl);
  margin-bottom: var(--sp-1);
}
.boss-name { font-size: var(--text-xs); color: #7f1d1d; display: block; }

/* ════════════════════════════════════════
   LESSON LIST (Subject index pages)
════════════════════════════════════════ */
.lesson-list { list-style: none; padding: 0; margin: 0; }

.lesson-item {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
  flex-wrap: wrap;
}
.lesson-item:last-child { border-bottom: none; }
.lesson-item:hover { background: var(--subject-color-bg, var(--bg-alt)); }

.lesson-item-code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--muted);
  flex-shrink: 0;
  min-width: 90px;
}

.lesson-item-name {
  flex: 1;
  font-weight: 600;
  color: var(--ink);
  font-size: var(--text-base);
}

.lesson-item-badges {
  display: flex;
  gap: var(--sp-2);
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
}

.week-group-header {
  background: var(--bg-alt);
  padding: var(--sp-3) var(--sp-5);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  border-bottom: 1.5px solid var(--line);
  text-transform: uppercase;
}

/* ════════════════════════════════════════
   SUBJECT PAGE HEADER  ── Lighter, pastel gradients
════════════════════════════════════════ */
.subject-hero {
  padding: var(--sp-10) 0 var(--sp-8);
  color: white;
  position: relative;
  border-radius: 0 0 24px 24px;
}
.subject-hero::before { content: none; }

/* Pastel-bright gradients (lighter than original) */
.subject-hero.math      { background: linear-gradient(135deg, #17638f 0%, #2b8ec8 70%, #4ab0e0 100%); }
.subject-hero.english   { background: linear-gradient(135deg, #4a3585 0%, #7c5ecf 70%, #9878e0 100%); }
.subject-hero.chinese   { background: linear-gradient(135deg, #882028 0%, #cc4e52 70%, #e06878 100%); }
.subject-hero.biology   { background: linear-gradient(135deg, #166048 0%, #28a87c 70%, #40c895 100%); }
.subject-hero.history   { background: linear-gradient(135deg, #5c3e10 0%, #a07840 70%, #c89858 100%); }
.subject-hero.geography { background: linear-gradient(135deg, #0e5878 0%, #2090c0 70%, #38b0d8 100%); }
.subject-hero.civics    { background: linear-gradient(135deg, #7a3f08 0%, #c87828 70%, #e09840 100%); }

.subject-hero-title {
  font-size: var(--text-4xl);
  font-weight: 900;
  margin-bottom: var(--sp-2);
  color: white;
}
.subject-hero-sub {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.1em;
}

/* ════════════════════════════════════════
   WEEKLY REVIEW  ── Warm cream header
════════════════════════════════════════ */
.week-header {
  background: var(--cream);
  border-bottom: 2.5px solid var(--yellow);
  color: var(--ink);
  padding: var(--sp-10) 0 var(--sp-8);
}
.week-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: var(--sp-3);
}
.week-title { font-size: var(--text-3xl); font-weight: 900; color: var(--ink); margin-bottom: var(--sp-2); }
.week-dates { font-family: var(--font-mono); color: var(--muted); font-size: var(--text-base); }

.mission-checklist { list-style: none; padding: 0; margin: 0; }
.mission-check-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}
.mission-check-item:last-child { border-bottom: none; }
.check-box {
  width: 22px;
  height: 22px;
  border: 2px solid var(--subject-color, var(--line));
  border-radius: 5px;
  flex-shrink: 0;
}
.check-code { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--muted); flex-shrink: 0; min-width: 80px; }
.check-name { flex: 1; font-weight: 500; color: var(--ink); }
.check-xp   { flex-shrink: 0; }

/* ════════════════════════════════════════
   ALERTS & INFO BOXES
════════════════════════════════════════ */
.alert {
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-4);
  border-left: 4px solid;
  font-size: var(--text-base);
}
.alert-info    { background: #e8f3fd; border-color: #2b8ec8; color: #17638f; }
.alert-warning { background: var(--cream); border-color: var(--yellow); color: #7a4510; }
.alert-success { background: #dff6ee; border-color: #28a87c; color: #166048; }
.alert-danger  { background: #fde8e8; border-color: #cc4e52; color: #7f1520; }

/* ════════════════════════════════════════
   BUTTONS  ── Pill-shaped, ink-colored
════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--r-xl);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  border: 2px solid transparent;
  font-family: var(--font);
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
.btn-primary:hover {
  background: #2d3f50;
  border-color: #2d3f50;
  color: white;
}

.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}
.btn-outline:hover {
  background: var(--ink);
  color: white;
}

.btn-sm { padding: var(--sp-1) var(--sp-3); font-size: var(--text-sm); }

/* ════════════════════════════════════════
   TAGS
════════════════════════════════════════ */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--sp-2);
  border-radius: var(--r-xl);
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: var(--font-mono);
}
.tag-blue   { background: #d8ecf8; color: #17638f; }
.tag-green  { background: #d8f5e8; color: #176040; }
.tag-purple { background: var(--lavender); color: #4a2a8a; }
.tag-amber  { background: var(--cream); color: #7a4510; }
.tag-red    { background: #fde8e8; color: #8a1515; }
.tag-teal   { background: #d0f0f8; color: #0e5878; }
.tag-pink   { background: #fde8f0; color: #8a1548; }

/* ════════════════════════════════════════
   SITE FOOTER  ── Light cream
════════════════════════════════════════ */
.site-footer {
  background: var(--bg-alt);
  color: var(--muted);
  text-align: center;
  padding: var(--sp-8) var(--sp-6);
  margin-top: auto;
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  border-top: 1.5px solid var(--line);
}
.site-footer p { margin-bottom: var(--sp-1); }

/* ════════════════════════════════════════
   UTILITIES
════════════════════════════════════════ */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--muted); }
.text-sm     { font-size: var(--text-sm); }
.text-mono   { font-family: var(--font-mono); }
.fw-bold     { font-weight: 700; }
.d-flex      { display: flex; }
.align-center { align-items: center; }
.gap-3       { gap: var(--sp-3); }
.flex-wrap   { flex-wrap: wrap; }
.mt-4        { margin-top: var(--sp-4); }
.mt-6        { margin-top: var(--sp-6); }
.mb-4        { margin-bottom: var(--sp-4); }
.mb-6        { margin-bottom: var(--sp-6); }

.print-only  { display: none; }
.no-print    { }

/* ════════════════════════════════════════
   SCHEDULE / SESSION INDICATORS
════════════════════════════════════════ */
.session-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-3);
  border-radius: var(--r-xl);
  font-size: var(--text-xs);
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.session-morning {
  background: var(--cream);
  color: #7a4510;
  border: 1px solid var(--yellow);
}
.session-evening {
  background: var(--lavender);
  color: #4a2a8a;
  border: 1px solid #a898f8;
}
.session-weekend {
  background: #fde8e8;
  color: #8a1515;
  border: 1px solid var(--coral);
}

/* Light review section (evening) */
.light-review {
  border-left: 4px solid #8b5cf6;
  background: #faf9ff;
}
.light-review .lesson-section-title::before {
  background: #8b5cf6 !important;
}

/* Daily schedule strip */
.daily-schedule-strip {
  display: flex;
  gap: var(--sp-4);
  flex-wrap: wrap;
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-5);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-sm);
}
.dss-slot {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.dss-time {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--muted);
  white-space: nowrap;
}

/* ════════════════════════════════════════
   LESSON TEMPLATE v2 :: NEW ELEMENTS
════════════════════════════════════════ */

/* Source type tags */
.source-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--sp-3);
  border-radius: var(--r-xl);
  font-size: var(--text-xs);
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.source-online     { background: #d8ecf8; color: #17638f; border: 1px solid #a8cce8; }
.source-curriculum { background: #d8f5e8; color: #176040; border: 1px solid #a0d8b8; }

/* Supply card (補給卡) */
.supply-card {
  background: var(--cream);
  border: 1.5px solid var(--yellow);
  border-left: 4px solid var(--brand-gold);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-4);
  break-inside: avoid;
}
.supply-card-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  color: #7a4510;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--yellow);
}

/* Section number prefix */
.section-num {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-light);
  letter-spacing: 0.08em;
  margin-right: var(--sp-1);
}

/* Beginner training ground (新手訓練場) */
.training-section {
  border-left: 4px solid var(--subject-biology) !important;
  background: #f0fdf8 !important;
}
.training-section .lesson-section-title::before { background: var(--subject-biology) !important; }

/* Boss challenge section */
.boss-section {
  border: 2px solid #cc4e52 !important;
  background: #fdf4f4 !important;
}
.boss-section .lesson-section-title { color: #8a1515; }
.boss-section .lesson-section-title::before { background: #cc4e52 !important; }

/* Error recycling table (錯題回收) */
.error-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin-top: var(--sp-3);
}
.error-table th {
  background: var(--bg-alt);
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1.5px solid var(--line);
}
.error-table td {
  border: 1.5px solid var(--line);
  padding: var(--sp-2) var(--sp-3);
  height: 52px;
  vertical-align: top;
  background: white;
}
.error-table .col-num {
  width: 52px;
  text-align: center;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* Mission tally (任務結算) */
.tally-card {
  background: var(--bg-alt);
  border-radius: var(--r-lg);
  border: 1.5px solid var(--line);
  overflow: hidden;
  break-inside: avoid;
}
.tally-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border-light);
  font-size: var(--text-sm);
  gap: var(--sp-3);
}
.tally-row .tally-check {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-radius: 4px;
  flex-shrink: 0;
  display: inline-block;
}

/* Interactive checkbox upgrade */
label.tally-row {
  cursor: pointer;
  user-select: none;
}
label.tally-row:hover {
  background: var(--surface);
}
.tally-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 2px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  position: relative;
  background: white;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}
.tally-checkbox:hover {
  border-color: var(--subject-color);
}
.tally-checkbox:focus-visible {
  outline: 2px solid var(--subject-color);
  outline-offset: 2px;
}
.tally-checkbox:checked {
  background: var(--subject-color);
  border-color: var(--subject-color);
}
.tally-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}
.tally-label {
  flex: 1;
  min-width: 0;
  transition: color 0.2s, text-decoration 0.2s;
  color: var(--ink);
}
.tally-row--done .tally-label {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--muted);
}
.tally-total {
  background: var(--cream);
  border-top: 1.5px solid var(--yellow);
  padding: var(--sp-3) var(--sp-5);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: var(--text-base);
}

/* Operator tag */
.operator-tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.12em;
}

/* ════════════════════════════════════════
   PRINT BUTTON
════════════════════════════════════════ */
.btn-print {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--ink);
  color: var(--text-on-dark);
  border: none;
  border-radius: var(--r-xl);
  padding: 0.5rem 1.1rem;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(31,41,51,0.28);
  z-index: 900;
  transition: background var(--transition), transform var(--transition);
}
.btn-print:hover  { background: #2d3f50; transform: translateY(-1px); }
.btn-print:active { transform: translateY(0); }

/* ════════════════════════════════════════
   IMAGE PLACEHOLDER
════════════════════════════════════════ */
.image-placeholder {
  background: var(--bg-alt);
  border: 2px dashed var(--line);
  border-radius: var(--r-lg);
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  margin: var(--sp-3) 0;
}

/* ════════════════════════════════════════
   ANSWER SPACE UTILITIES
════════════════════════════════════════ */
.answer-space-sm,
.answer-space-md,
.answer-space-lg,
.calculation-space,
.note-space {
  display: block;
  background: #faf9f6;
  border: 1.5px dashed #c8c3ba;
  border-radius: var(--r);
  margin: var(--sp-2) 0 var(--sp-3);
}
.answer-space-sm   { min-height: 52px; }
.answer-space-md   { min-height: 100px; }
.answer-space-lg   { min-height: 150px; }
.calculation-space { min-height: 88px; background: var(--surface); border-style: solid; border-color: var(--line); }
.note-space        { min-height: 70px; background: var(--cream); border-color: var(--yellow); }

/* ════════════════════════════════════════
   XP DASHBOARD :: SUBJECT COLOR BARS
════════════════════════════════════════ */
.subject-bar-math      { background: var(--subject-math); }
.subject-bar-english   { background: var(--subject-english); }
.subject-bar-chinese   { background: var(--subject-chinese); }
.subject-bar-biology   { background: var(--subject-biology); }
.subject-bar-history   { background: var(--subject-history); }
.subject-bar-geography { background: var(--subject-geography); }
.subject-bar-civics    { background: var(--subject-civics); }
.subject-bar-boss      { background: #7c5ecf; }

/* ════════════════════════════════════════
   LESSON-SECTION :: INTERACTIVE STATES
════════════════════════════════════════ */
.lesson-section:focus-within {
  border-color: var(--subject-color);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.03), var(--shadow);
}

/* ════════════════════════════════════════
   CHECK-BOX :: SUBJECT COLOR
════════════════════════════════════════ */
.check-box {
  border-color: var(--subject-color, var(--line));
}

/* review-missions card inner */
.review-missions { padding: 0; }
