/* ===== DESIGN TOKENS (light mode defaults) ===== */
:root {
  --color-bg: #f8fafc;
  --color-bg-end: #f1f5f9;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-primary: #4f46e5;
  --color-primary-dark: #3730a3;
  --color-notice-bg: #eff6ff;
  --color-notice-border: #bfdbfe;
  --color-notice-accent: #3b82f6;
  --color-notice-text: #1e40af;
  --color-notice-link: #1d4ed8;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
  --radius: 0.5rem;
  --radius-sm: 0.375rem;
  --radius-lg: 0.75rem;
  --radius-full: 9999px;
  color-scheme: light;
}

/* ===== DARK MODE TOKENS ===== */
/* Applied when: system is dark and toggle is not overriding to light */
@media (prefers-color-scheme: dark) {
  :root:not(:has(#theme-toggle:checked)) {
    --color-bg: #0f172a;
    --color-bg-end: #1e293b;
    --color-surface: #1e293b;
    --color-border: #334155;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-primary: #818cf8;
    --color-primary-dark: #a5b4fc;
    --color-notice-bg: #172554;
    --color-notice-border: #1e40af;
    --color-notice-accent: #60a5fa;
    --color-notice-text: #bfdbfe;
    --color-notice-link: #93c5fd;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

/* Applied when: system is light and toggle is overriding to dark */
@media (prefers-color-scheme: light) {
  :root:has(#theme-toggle:checked) {
    --color-bg: #0f172a;
    --color-bg-end: #1e293b;
    --color-surface: #1e293b;
    --color-border: #334155;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-primary: #818cf8;
    --color-primary-dark: #a5b4fc;
    --color-notice-bg: #172554;
    --color-notice-border: #1e40af;
    --color-notice-accent: #60a5fa;
    --color-notice-text: #bfdbfe;
    --color-notice-link: #93c5fd;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

/* ===== BASE ===== */
body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: linear-gradient(160deg, var(--color-bg) 0%, var(--color-bg-end) 100%);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
p + p { margin-top: 0.75rem; }

/* ===== SITE HEADER ===== */
.site-header {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4f46e5 100%);
  color: white;
  padding: 2.5rem 1.5rem;
  text-align: center;
}
.site-header h1 {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}
.site-header h2 {
  font-size: 1.0625rem;
  font-weight: 400;
  opacity: 0.8;
  margin-bottom: 1.5rem;
}

/* ===== NAVIGATION ===== */
.site-nav { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.site-nav a {
  color: rgba(255, 255, 255, 0.9);
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.site-nav a:hover {
  background-color: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
}

/* ===== DARK MODE TOGGLE ===== */
.theme-bar {
  display: flex;
  justify-content: center;
  padding: 2rem 1.5rem 3rem;
}
.theme-toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.theme-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.theme-label-light,
.theme-label-dark {
  font-size: 0.8125rem;
  font-weight: 500;
  transition: color 0.2s ease;
}

/* Track */
.theme-toggle-track {
  position: relative;
  width: 3rem;
  height: 1.625rem;
  background: #cbd5e1;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  transition: background 0.2s ease;
}
/* Thumb */
.theme-toggle-thumb {
  position: absolute;
  width: 1.25rem;
  height: 1.25rem;
  background: white;
  border-radius: 50%;
  top: 0.1875rem;
  left: 0.1875rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}

/* Light mode (default): ☀ is active, ☾ is muted, thumb left */
.theme-label-light { color: var(--color-text); }
.theme-label-dark  { color: var(--color-text-muted); }

/* Dark mode active: flip colors, slide thumb right, turn track indigo */
/* Case 1: system dark, toggle not overriding */
@media (prefers-color-scheme: dark) {
  :root:not(:has(#theme-toggle:checked)) .theme-label-light  { color: var(--color-text-muted); }
  :root:not(:has(#theme-toggle:checked)) .theme-label-dark   { color: var(--color-text); }
  :root:not(:has(#theme-toggle:checked)) .theme-toggle-track { background: #4f46e5; }
  :root:not(:has(#theme-toggle:checked)) .theme-toggle-thumb { transform: translateX(1.375rem); }
}
/* Case 2: system light, toggle overriding to dark */
@media (prefers-color-scheme: light) {
  :root:has(#theme-toggle:checked) .theme-label-light  { color: var(--color-text-muted); }
  :root:has(#theme-toggle:checked) .theme-label-dark   { color: var(--color-text); }
  :root:has(#theme-toggle:checked) .theme-toggle-track { background: #4f46e5; }
  :root:has(#theme-toggle:checked) .theme-toggle-thumb { transform: translateX(1.375rem); }
}

/* ===== MAIN ===== */
.main {
  max-width: 52rem;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ===== SECTION HEADING ===== */
.section-heading {
  font-size: 1.375rem;
  font-weight: 700;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--color-border);
}

/* ===== NOTICE ===== */
.notice {
  background: var(--color-notice-bg);
  border: 1px solid var(--color-notice-border);
  border-left: 3px solid var(--color-notice-accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  color: var(--color-notice-text);
}
.notice a { color: var(--color-notice-link); font-weight: 500; }

/* ===== CARD ===== */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 1rem; }
.card h3 { font-size: 1.0625rem; font-weight: 600; margin-bottom: 0.75rem; }

/* ===== EVENT MAP ===== */
.event-map {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  border: none;
  margin-top: 1rem;
  display: block;
}

/* ===== TABLE OF CONTENTS ===== */
.toc {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
}
.toc h3 { font-size: 1.0625rem; font-weight: 600; margin-bottom: 1rem; }
.toc ul { list-style: none; display: flex; flex-direction: column; gap: 0.375rem; }
.toc li a {
  font-size: 0.9375rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.toc li a::before { content: "♪"; font-size: 0.75rem; color: var(--color-text-muted); }

/* ===== SONG ARTICLE ===== */
.song-article {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.song-article h3 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

/* ===== PARTS SECTION ===== */
.parts-section { display: flex; flex-direction: column; gap: 0.75rem; }
.parts-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

/* ===== PART ITEM ===== */
.part-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}
.part-name { font-size: 0.875rem; font-weight: 600; color: var(--color-text-muted); }
audio { width: 100%; border-radius: var(--radius-sm); }

/* ===== DOWNLOAD LINK ===== */
.download-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-primary);
}
.download-link::before { content: "↓"; font-weight: 700; font-size: 0.875rem; }
.download-link:hover { color: var(--color-primary-dark); }

/* ===== BACK TO TOP ===== */
.back-to-top {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
}
.back-to-top::after { content: "↑"; font-size: 0.875rem; }
.back-to-top:hover { color: var(--color-text); text-decoration: none; }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .site-header { padding: 2rem 1rem; }
  .site-header h1 { font-size: 1.5rem; }
  .main { margin: 1.5rem auto; padding: 0 1rem; }
}
