/* ════════════════════════════════════════════════
   GuitarLab — Animal Crossing Inspired Design
   Warm, cozy, paper-like with nature accents
   ════════════════════════════════════════════════ */

/* ── CSS Custom Properties (Animal Island Palette) ── */
:root {
  /* ── Core colors (warm cream, cozy light) ── */
  --bg-primary: #f8f8f0;
  --bg-secondary: #f0e8d8;
  --bg-card: #ffffff;
  --bg-surface: #f0ece2;
  --bg-elevated: #e8e2d6;
  --bg-input: #ffffff;

  /* ── Text (warm dark brown, high contrast on cream) ── */
  --text-primary: #3D2D24;
  --text-secondary: #7A6758;
  --text-tertiary: #A89484;
  --text-on-dark: #f8f8f0;
  --text-on-light: #3D2D24;

  /* ── Brand accent (warm woody tones, guitar-inspired) ── */
  --accent: #C49A6C;
  --accent-hover: #D4A574;
  --accent-active: #B8865C;
  --accent-bg: #F5EDE4;
  --accent-green: #6fba2c;
  --accent-green-hover: #85cc45;
  --accent-yellow: #f5c31c;
  --accent-dim: #A89484;

  /* ── Borders (warm, earthy) ── */
  --border-color: #C4B89E;
  --border-hover: #9F927D;
  --border-light: #E8E2D6;

  /* ── Shadows (warm brown tint) ── */
  --shadow-sm: 0 2px 4px rgba(61, 52, 40, 0.06);
  --shadow-base: 0 3px 10px rgba(61, 52, 40, 0.1);
  --shadow-lg: 0 8px 24px rgba(61, 52, 40, 0.14);

  /* ── CAGED shape colors (adjusted for light bg) ── */
  --caged-c: #C9604F;
  --caged-a: #4F96C4;
  --caged-g: #5FA05F;
  --caged-e: #C48F40;
  --caged-d: #8E70B0;

  /* ── Utility ── */
  --danger: #e05a5a;
  --danger-hover: #e87878;
  --success: #6fba2c;
  --info: #50B9AB;
  --warning: #f5c31c;

/* ── Typography scale ── */
  --text-display: 3rem;
  --text-h1: 2.5rem;
  --text-h2: 1.75rem;
  --text-h3: 1.5rem;
  --text-h4: 1.2rem;
  --text-body: 1.2rem;    /* 19.2px */
  --text-sm: 1.05rem;     /* ~17px */
  --text-xs: 0.9rem;      /* ~14px */

  /* ── Radius (big rounded = cozy) ── */
  --radius-sm: 16px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 28px;

  /* ── Fonts ── */
  --font-body: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;

  /* ── Layout ── */
  --nav-height: 56px;
  --max-width: 1100px;

  /* ── Spacing ── */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 60px;
}

/* ── Textbook / Reading variables ── */
:root {
  --reading-font-size: 1.25rem;
  --reading-line-height: 2.0;
  --reading-max-width: 700px;
  --chapter-gap: 56px;
}

/* ── Animal Crossing custom cursor ── */

/* ── Subtle wood-grain pattern overlay on body ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 2px,
    rgba(61, 52, 40, 0.012) 2px,
    rgba(61, 52, 40, 0.012) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ── Reset & Base ─────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;700;900&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 20px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-primary);
  background-image:
    url('../assets/img/ac-pattern.webp'),
    radial-gradient(ellipse at 20% 50%, rgba(196, 154, 108, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(111, 186, 44, 0.03) 0%, transparent 50%);
  line-height: 1.8;
  letter-spacing: 0.02em;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

a { color: var(--accent); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; }
svg { max-width: 100%; height: auto; display: block; }
svg[height="0"] { height: auto; }

/* ── Scrollbar (warm wood tones on light bg) ── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ════════════════════════════════════════════════
   Leaf SVG decoration (used via ::before / ::after)
   ════════════════════════════════════════════════ */
.leaf-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: var(--space-xl) 0;
  color: var(--accent-green);
  font-size: 0.85rem;
  opacity: 0.5;
}
.leaf-divider::before,
.leaf-divider::after {
  content: '';
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border-color), transparent);
  border-radius: 1px;
}
.leaf-divider svg {
  width: 20px;
  height: 20px;
  fill: var(--accent-green);
}

/* ── Navbar credit ── */
.navbar-credit {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: var(--space-sm);
  white-space: nowrap;
}

/* ── Navigation ── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-height);
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-light);
  display: flex; align-items: center;
  padding: 0 var(--space-lg);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  display: flex; align-items: center; gap: var(--space-sm);
}

.navbar-brand .brand-icon { 
  font-size: 1.4rem; 
  display: inline-flex;
  align-items: center;
}

.navbar-nav {
  display: flex; gap: var(--space-xs);
  margin-left: auto;
  align-items: center;
}

.nav-link {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all .2s;
  white-space: nowrap;
  position: relative;
}

.nav-link:hover { color: var(--text-primary); background: var(--bg-elevated); }

.nav-link.active {
  color: var(--accent);
  background: var(--accent-bg);
  border-bottom: 2px solid var(--accent);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

/* ── Nav dropdown ── */
.nav-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}
.dropdown-btn {
  cursor: pointer;
  background: none; border: none;
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all .2s;
  white-space: nowrap;
}
.dropdown-btn:hover { color: var(--text-primary); background: var(--bg-elevated); }
.nav-dropdown:hover .dropdown-btn { color: var(--accent); }
.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-xs);
  min-width: 160px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
}
.nav-dropdown:hover .dropdown-menu,
.dropdown-menu:hover { display: block; }
.dropdown-menu a {
  display: block;
  padding: var(--space-sm) var(--space-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  transition: all .15s;
}
.dropdown-menu a:hover {
  color: var(--accent);
  background: var(--accent-bg);
}

/* ── Dropdown with groups (課程 menu) ── */
.dropdown-menu.dropdown-wide {
  width: 420px; padding: var(--space-md);
  left: 50%; transform: translateX(-50%);
}
.nav-dropdown:hover .dropdown-menu.dropdown-wide,
.dropdown-menu.dropdown-wide:hover { display: flex; flex-wrap: wrap; gap: var(--space-md); }
.dropdown-menu.dropdown-wide .dropdown-group {
  flex: 1; min-width: 120px;
}
.dropdown-menu.dropdown-wide .dropdown-group-label {
  display: block; font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent); margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs); border-bottom: 1px solid var(--border-light);
}
.dropdown-menu.dropdown-wide a {
  font-size: 0.82rem; padding: var(--space-xs) 0;
}

@media (max-width: 768px) {
  .dropdown-menu.dropdown-wide {
    position: static; width: 100%; transform: none;
    flex-direction: column; gap: var(--space-sm); padding: var(--space-sm) var(--space-md);
    display: none;
  }
  .nav-dropdown.open .dropdown-menu.dropdown-wide { display: flex; }
  .dropdown-menu.dropdown-wide .dropdown-group {
    min-width: 100%;
  }
}

.chapter-toc a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius-sm); }

/* ── TOC groups ── */
.toc-group {
  margin-bottom: var(--space-md);
}
.toc-group + .toc-group {
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-light);
}
.toc-group-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-tertiary);
  margin-bottom: var(--space-xs);
  padding-left: var(--space-md);
  font-weight: 600;
  opacity: 0.8;
}
.toc-group a {
  display: block;
  padding: 6px 0 6px var(--space-md);
  border-left: 2px solid transparent;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s;
  line-height: 1.4;
}
.toc-group a:hover {
  color: var(--text-primary);
  border-left-color: var(--accent-green);
}
.toc-group a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.nav-toggle {
  display: none;
  background: none; border: none;
  color: var(--text-primary);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 10px;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: transform .25s ease, color .2s, background .2s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.nav-toggle:hover { background: var(--bg-elevated); }
.nav-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-toggle[aria-expanded="true"] {
  transform: rotate(90deg);
  color: var(--accent);
}

/* ── Layout ───────────────────────────────────── */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
  width: 100%;
}

.page {
  flex: 1;
  padding: var(--space-xl) 0;
}

.page-header {
  margin-bottom: var(--space-xl);
  text-align: center;
}

.page-header h1 {
  font-size: var(--text-h1);
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.page-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: var(--space-sm);
  background: var(--accent-bg);
  border: 2px solid var(--border-light);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}

.page-header-icon svg {
  display: block;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 600px;
  margin: 0 auto;
}

/* ── Cards (paper-like with soft shadows) ─────── */
.card {
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-base);
  transition: box-shadow .2s, transform .2s;
}
.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-header {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--border-light);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
}

/* ── Feature Cards (homepage) ──────────────────── */
.feature-card {
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  transition: all .3s;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.curriculum-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.curriculum-card:hover .level-number {
  background: var(--accent);
  color: var(--bg-card);
  transform: scale(1.1);
}
.curriculum-card:hover h3 {
  color: var(--accent);
}
.curriculum-card:hover .topics span {
  background: var(--accent-bg);
  color: var(--accent);
}
.feature-card .icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-md);
}

.feature-card h3 {
  color: var(--text-primary);
  font-size: var(--text-h3);
  margin-bottom: var(--space-sm);
}

.feature-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.feature-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

/* ── Interactive tools ─────────────────────────── */
.tool-section {
  margin-bottom: var(--space-xl);
}

.tool-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  align-items: center;
}

.tool-controls label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

.tool-output {
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  min-height: 200px;
  box-shadow: var(--shadow-sm);
}

/* ── Page transitions ─────────────────────────── */
.page {
  flex: 1;
  padding: var(--space-xl) 0;
  animation: pageIn 0.4s ease-out;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Mobile nav slide-down ──────────────────── */
@keyframes navSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Scroll reveal animation ─────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }

/* ── SVG chord glow ──────────────────────────── */
.tool-output svg circle[fill="#D4A574"],
.tool-output svg circle[fill="#A1887F"] {
  transition: filter 0.3s, r 0.3s;
}
.tool-output svg:hover circle[fill="#D4A574"] {
  filter: drop-shadow(0 0 6px rgba(212,165,116,0.6));
}

/* ── Buttons (rounded, cozy) ──────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all .2s ease;
  background: var(--bg-card);
  color: var(--text-primary);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, transparent 50%);
  pointer-events: none;
}
.btn:hover { background: var(--bg-elevated); transform: translateY(-2px); box-shadow: var(--shadow-base); border-color: var(--border-hover); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-sm), inset 0 2px 6px rgba(61,52,40,0.08); border-color: var(--border-color); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: 0 0 0 4px var(--accent-bg); }
.btn-primary { background: var(--accent); color: var(--bg-card); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 2px 12px rgba(25, 200, 185, 0.35); }
.btn-primary:active { background: var(--accent-active); border-color: var(--accent-active); box-shadow: inset 0 2px 6px rgba(0,0,0,0.1); transform: translateY(0); }
.btn-sm { padding: var(--space-xs) var(--space-md); font-size: 0.8rem; }

/* ── Select / Input (rounded, light) ───────────── */
select, input, .input-like {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

select:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

select option { background: var(--bg-card); color: var(--text-primary); }

/* ── Tags / Badges ────────────────────────────── */
.tag {
  display: inline-block;
  padding: 2px var(--space-sm);
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.tag-root { background: var(--accent-bg); color: var(--accent); }

/* ── Table ────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th, .data-table td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.data-table th {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-secondary);
}

.data-table tr:hover td { background: var(--accent-bg); }

/* ── Theory Content ────────────────────────────── */
.prose {
  max-width: 720px;
  margin: 0 auto;
  line-height: 1.8;
}

.prose h2 {
  color: var(--text-primary);
  font-size: 1.4rem;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--border-light);
}

.prose h3 {
  color: var(--text-primary);
  font-size: 1.1rem;
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
}

.prose p { margin-bottom: var(--space-md); color: var(--text-primary); }
.prose ul, .prose ol { margin-bottom: var(--space-md); padding-left: var(--space-lg); }
.prose li { margin-bottom: var(--space-xs); color: var(--text-secondary); }
.prose strong { color: var(--text-primary); }

.prose .info-box {
  background: var(--accent-bg);
  border-left: 4px solid var(--accent);
  padding: var(--space-md) var(--space-lg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: var(--space-lg) 0;
}

/* ── Chord voicing selector ───────────────────── */
.voicing-selector {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin: var(--space-md) 0;
}

.voicing-option {
  padding: var(--space-xs) var(--space-md);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all .2s;
}

.voicing-option:hover { border-color: var(--accent); color: var(--text-primary); }
.voicing-option.active { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }

/* ── Difficulty dots ──────────────────────────── */
.difficulty {
  display: inline-flex;
  gap: 2px;
}
.difficulty-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-color); }
.difficulty-dot.fill { background: var(--accent-green); }

/* ── Focus-visible ──────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Responsive ────────────────────────────────── */
@media (max-width: 768px) {
  .navbar-nav {
    display: none;
    position: absolute; top: var(--nav-height); left: 0; right: 0;
    z-index: 99;
    flex-direction: column;
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-light);
    padding: var(--space-sm);
    box-shadow: var(--shadow-lg);
  }
  .navbar-nav.open {
    display: flex;
    max-height: calc(100vh - var(--nav-height));
    overflow-y: auto;
    animation: navSlideDown .25s ease-out;
  }
  /* mobile nav backdrop overlay */
  .navbar-nav.open::before {
    content: '';
    position: fixed;
    inset: var(--nav-height) 0 0 0;
    background: rgba(0,0,0,0.3);
    z-index: -1;
  }
  .nav-toggle { display: flex; }
  .nav-link { padding: var(--space-sm) var(--space-md); }
  /* ── Mobile dropdown ── */
  .nav-dropdown { flex-direction: column; align-items: stretch; }
  .nav-dropdown .dropdown-btn { width: 100%; text-align: left; padding: var(--space-sm) var(--space-md); }
  .nav-dropdown .dropdown-menu {
    position: static;
    transform: none;
    display: none;
    box-shadow: none;
    border: none;
    background: rgba(61,52,40,0.03);
    padding: 0 0 0 var(--space-md);
  }
  .nav-dropdown:hover .dropdown-menu,
  .nav-dropdown .dropdown-menu:hover { display: none; }
  .nav-dropdown.open .dropdown-menu { display: block; }
  .nav-dropdown .dropdown-btn::after { content: ' ▾'; opacity: 0.5; }
  .card-grid { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 1.5rem; }
  .tool-controls { flex-direction: column; align-items: stretch; }
  .btn { width: 100%; justify-content: center; }
  .btn-sm { width: auto; }
  select, input, .input-like { font-size: 1rem; }
  .fretboard-wrap svg,
  .fretboard-wrap img,
  .caged-chart-wrap img,
  .notemap-wrap img {
    max-width: 100%;
    height: auto;
  }
  .fretboard-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .chord-diagram-wrap svg {
    max-width: 240px;
  }
  .key-chords-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
  .qc-selectors {
    gap: 6px;
  }
  .container {
    padding: 0 var(--space-md);
  }
  .page {
    padding: var(--space-lg) 0;
  }
  .page-header {
    margin-bottom: var(--space-lg);
  }
  .hero h1 {
    font-size: 1.5rem;
  }
  .quick-chord {
    padding: var(--space-md);
  }


/* ── Footer ────────────────────────────────────── */
.footer {
  text-align: center;
  padding: var(--space-lg);
  color: var(--text-secondary);
  font-size: 0.8rem;
  border-top: 2px solid var(--border-light);
  margin-top: var(--space-xl);
  background: var(--bg-secondary);
}

/* ── Loading ───────────────────────────────────── */
.loading {
  color: var(--text-secondary);
  text-align: center;
  padding: var(--space-xl);
}
.loading::after { content: '…'; animation: dots 1.5s infinite; }
@keyframes dots { 0%,20% { content: '.'; } 40% { content: '..'; } 60%,100% { content: '...'; } }

/* ── Print styles ─────────────────────────────── */
@media print {
  body { background: #fff; color: #000; }
  .navbar, .footer, .tool-controls, .btn, .lottie-placeholder { display: none !important; }
  .card, .feature-card, .curriculum-card { background: #fff; border: 1px solid #ccc; box-shadow: none; }
  a { color: #000; text-decoration: underline; }
  .page { padding: 0; }
  .container { max-width: 100%; }
  .prose, .card, .tool-output { page-break-inside: avoid; }
  details > summary { list-style: none; }
  details[open] { page-break-inside: avoid; }
}

/* ── Transpose tool ───────────────────────────── */
.transpose-result {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  justify-content: center;
  padding: var(--space-lg) 0;
}

.transpose-chord {
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  min-width: 80px;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.transpose-chord .numeral {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: 400;
}

/* ── Scale highlight boxes ────────────────────── */
.scale-boxes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin: var(--space-md) 0;
}

.scale-note {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border-light);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.scale-note.root { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }

/* ════════════════════════════════════════════════
   Textbook Chapter Layout (for course content)
   ════════════════════════════════════════════════ */

/* ── Sidebar Table of Contents ── */
.chapter-toc {
  position: sticky;
  top: calc(var(--nav-height) + 24px);
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: var(--space-md) 0;
  z-index: 1;
}
.chapter-toc h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
  font-weight: 700;
  padding-left: var(--space-md);
}

/* Sidebar icons: small, muted — don't compete with content */
.chapter-toc .ac-icon {
  width: 24px;
  height: 24px;
  opacity: 0.65;
  filter: saturate(0.55);
  margin-right: 6px;
  vertical-align: middle;
}
.chapter-toc .toc-group-label .ac-icon {
  width: 20px;
  height: 20px;
  opacity: 0.5;
  filter: saturate(0.4);
}

/* ── Chapter Container ── */
.learning-chapter {
  margin: 0 auto;
  max-width: var(--reading-max-width);
}
.learning-chapter + .learning-chapter {
  margin-top: var(--chapter-gap);
  padding-top: var(--chapter-gap);
  border-top: 1px solid var(--border-light);
}

/* ── Chapter Header ── */
.chapter-header {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 2px solid var(--border-light);
}
.chapter-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 800;
  margin-bottom: var(--space-sm);
  font-family: var(--font-heading);
}
.chapter-header h2 {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: var(--space-xs) 0 var(--space-sm);
  line-height: 1.25;
  letter-spacing: -0.01em;
  font-family: var(--font-heading);
}
.chapter-header .chapter-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.03em;
}

/* ── Chapter Body (reading flow) ── */
.chapter-body {
  font-size: var(--reading-font-size);
  line-height: var(--reading-line-height);
  color: var(--text-primary);
}
.chapter-body p {
  margin: 0 0 1.2em;
}
.chapter-body h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 1.8em 0 0.6em;
  font-family: var(--font-heading);
}
.chapter-body h4 {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 1.4em 0 0.4em;
  font-family: var(--font-heading);
}
.chapter-body ul {
  margin: 0 0 1.2em;
  padding-left: 1.5em;
}
.chapter-body ul li {
  margin-bottom: 0.3em;
  list-style: disc;
}
.chapter-body ol {
  margin: 0 0 1.2em;
  padding-left: 1.5em;
}
.chapter-body ol li {
  margin-bottom: 0.5em;
  list-style: decimal;
}
.chapter-body strong {
  color: var(--text-primary);
  font-weight: 700;
}
.chapter-body .section-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  margin-right: var(--space-sm);
  font-family: var(--font-heading);
  vertical-align: middle;
}

/* ── Info & Tip Boxes ── */
.chapter-body .info-box {
  background: var(--accent-bg);
  border: 2px solid rgba(25, 200, 185, 0.15);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-lg);
  margin: 1.5em 0;
  font-size: 0.95rem;
  line-height: 1.7;
}
.chapter-body .info-box strong {
  color: var(--accent);
}
.chapter-body .tip-box {
  background: var(--bg-secondary);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  margin: 1.2em 0;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-secondary);
}
.chapter-body .tip-box strong {
  color: var(--text-primary);
}

/* ── Chapter Divider (leaf motif) ── */
.chapter-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: var(--chapter-gap);
  color: var(--accent-green);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  opacity: 0.4;
}
.chapter-divider::before,
.chapter-divider::after {
  content: '';
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border-color), transparent);
  border-radius: 1px;
}
.chapter-divider svg {
  width: 18px;
  height: 18px;
  fill: var(--accent-green);
}
.chapter-divider::after {
  content: '✦';
  flex: none;
  height: auto;
  background: none;
  font-size: 0.75rem;
  color: var(--accent-green);
}
.chapter-divider::before {
  content: '';
}

/* ── Two-column chapter layout with TOC sidebar ── */
.chapter-layout {
  display: flex;
  gap: 48px;
  align-items: flex-start;
  max-width: 1020px;
  margin: 0 auto;
}
.chapter-main {
  flex: 1;
  min-width: 0;
}



/* ── Course breadcrumb ── */
.course-breadcrumb {
  max-width: var(--reading-max-width);
  margin: 0 auto var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.85rem;
  flex-wrap: wrap;
}
.course-breadcrumb a {
  color: var(--text-tertiary);
  text-decoration: none;
  transition: color .2s;
}
.course-breadcrumb a:hover { color: var(--accent); }
.course-breadcrumb .sep {
  color: var(--border-color);
  font-size: 1.1rem;
}
.course-breadcrumb .current {
  color: var(--text-secondary);
  font-weight: 500;
}
.course-breadcrumb .progress {
  margin-left: auto;
  color: var(--text-tertiary);
  font-size: 0.78rem;
  background: var(--accent-bg);
  padding: 2px 10px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-light);
}

/* ── Back-to-top button ── */
.back-to-top {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  z-index: 90;
  box-shadow: var(--shadow-base);
}
.back-to-top:hover {
  background: var(--accent);
  color: var(--bg-card);
  border-color: var(--accent);
  transform: translateY(-2px);
}
.back-to-top.visible { display: flex; }

/* ── Drawer menu (mobile) ── */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(61, 52, 40, 0.5);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.25s;
}
.drawer-overlay.open {
  display: block;
  opacity: 1;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 80vw;
  background: var(--bg-card);
  border-right: 2px solid var(--border-light);
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  padding: var(--space-lg);
}
.drawer.open {
  transform: translateX(0);
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 2px solid var(--border-light);
}
.drawer-header h4 {
  font-size: 1rem;
  color: var(--text-primary);
  margin: 0;
}
.drawer-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all .2s;
}
.drawer-close:hover {
  color: var(--accent);
  background: var(--accent-bg);
}
.drawer-toc .toc-group { margin-bottom: var(--space-md); }
.drawer-toc .toc-group + .toc-group {
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-light);
}
.drawer-toc .toc-group-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-tertiary);
  margin-bottom: var(--space-xs);
  padding-left: var(--space-md);
  font-weight: 600;
  opacity: 0.8;
}
.drawer-toc a {
  display: block;
  padding: 8px 0 8px var(--space-md);
  border-left: 2px solid transparent;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s;
}
.drawer-toc a:hover {
  color: var(--text-primary);
  border-left-color: var(--accent-green);
}
.drawer-toc a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-bg);
}

@media (min-width: 901px) {
  .drawer { display: none; }
  .drawer-overlay { display: none !important; }
}
.mobile-chapter-select { display: none; }
.mobile-chapter-select select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  margin-bottom: var(--space-lg);
  cursor: pointer;
}

@media (max-width: 900px) {
  .chapter-layout { flex-direction: column; }
  .chapter-toc { display: none; }
  .mobile-chapter-select { display: block; }
}

/* ── Responsive: mobile reading ── */
@media (max-width: 640px) {
  .learning-chapter { padding: 0 var(--space-md); }
  .chapter-header h2 { font-size: 1.3rem; }
  .chapter-body { font-size: 1.063rem; line-height: 2.0; }
  .chapter-divider { margin-top: 32px; }
}

/* ── Chapter Nav (kept for backward compat) ── */
.course-level { /* keep for pages that still reference it */ }

/* ════════════════════════════════════════════════
   Animal Crossing Style Icons (auto-cropped)
   Each icon is an individually cropped WebP from
   the sprite sheet, with transparent background.
   ════════════════════════════════════════════════ */

[class^="ac-icon-"], [class*=" ac-icon-"] {
  display: inline-block;
  width: 56px;
  height: 56px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Row 1 — music & nature */
.ac-icon-guitar    { background-image: url('../assets/img/icons/guitar.webp'); }
.ac-icon-note      { background-image: url('../assets/img/icons/note.webp'); }
.ac-icon-leaf      { background-image: url('../assets/img/icons/leaf.webp'); }
.ac-icon-book      { background-image: url('../assets/img/icons/book.webp'); }

/* Row 2 — tools */
.ac-icon-tuner     { background-image: url('../assets/img/icons/tuner.webp'); }
.ac-icon-brush     { background-image: url('../assets/img/icons/brush.webp'); }
.ac-icon-trophy    { background-image: url('../assets/img/icons/trophy.webp'); }
.ac-icon-bell      { background-image: url('../assets/img/icons/bell.webp'); }

/* Row 3 — decorative */
.ac-icon-flower      { background-image: url('../assets/img/icons/flower.webp'); }
.ac-icon-pick        { background-image: url('../assets/img/icons/pick.webp'); }
.ac-icon-metronome   { background-image: url('../assets/img/icons/metronome.webp'); }
.ac-icon-star        { background-image: url('../assets/img/icons/star.webp'); }

/* 2nd sheet — section labels */
.ac-icon-pin       { background-image: url('../assets/img/icons/pin.webp'); }
.ac-icon-brain     { background-image: url('../assets/img/icons/brain.webp'); }
.ac-icon-target    { background-image: url('../assets/img/icons/target.webp'); }
.ac-icon-books     { background-image: url('../assets/img/icons/books.webp'); }
.ac-icon-chart     { background-image: url('../assets/img/icons/chart.webp'); }
.ac-icon-bookmark  { background-image: url('../assets/img/icons/bookmark.webp'); }
.ac-icon-thought   { background-image: url('../assets/img/icons/thought.webp'); }
.ac-icon-bolt      { background-image: url('../assets/img/icons/bolt.webp'); }
.ac-icon-bulb      { background-image: url('../assets/img/icons/bulb.webp'); }

/* Small variant */
.ac-icon-sm {
  width: 32px;
  height: 32px;
}

/* ── TOC checkbox toggle (CSS-only, no JS needed) ── */
.toc-checkbox {
  display: none;
}
.toc-checkbox:not(:checked) ~ .chapter-toc {
  width: 0;
  overflow: hidden;
  padding: 0;
  margin: 0;
  opacity: 0;
  border: none;
}
.toc-checkbox:checked ~ .chapter-toc {
  width: 220px;
  overflow: visible;
  opacity: 1;
}
.chapter-layout .toc-toggle-btn {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 99;
  width: 36px;
  height: 48px;
  border: none;
  border-radius: 0 12px 12px 0;
  background: var(--accent);
  color: var(--wood-darkest);
  cursor: pointer;
  opacity: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.08);
}
.chapter-layout .toc-toggle-btn::after {
  content: "目錄";
  writing-mode: vertical-rl;
  font-size: 0.65rem;
  letter-spacing: 2px;
  font-weight: 700;
}
.chapter-layout .toc-toggle-btn:hover {
  opacity: 1;
  width: 40px;
}
.toc-checkbox:checked ~ .toc-toggle-btn::after {
  content: "✕";
  writing-mode: initial;
  font-size: 1.1rem;
}

