*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Theme tokens ─────────────────────────────────────────── */

[data-theme="light"] {
  --bg: #e8e8e8;
  --fg: #1a1a1a;
  --fg-muted: #666;
  --surface: #d4d4d4;
  --surface-hover: #ccc;
  --control-track: #c0c0c0;
  --control-thumb: #1a1a1a;
  --control-fill: #1a1a1a;
  --accent: #8b1a1a;
  --menu-bg: #f0f0f0;
  --border: #bbb;
}

[data-theme="dark"] {
  --bg: #111;
  --fg: #e8e8e8;
  --fg-muted: #888;
  --surface: #222;
  --surface-hover: #333;
  --control-track: #444;
  --control-thumb: #e8e8e8;
  --control-fill: #e8e8e8;
  --accent: #b22222;
  --menu-bg: #1a1a1a;
  --border: #333;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 540px;
  margin: 0 auto;
}

.hidden { display: none !important; }

/* ── Header ───────────────────────────────────────────────── */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--fg);
  cursor: pointer;
  padding: 4px;
  -webkit-tap-highlight-color: transparent;
}

/* ── Side menu ────────────────────────────────────────────── */

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 90;
}

.menu-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 80vw;
  background: var(--menu-bg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

.menu-panel.open {
  transform: translateX(0);
}

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1rem;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
}

.menu-body {
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  font-size: 0.9rem;
}

.menu-section {
  padding: 0.75rem 0;
}

.menu-section h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-bottom: 0.5rem;
}

.menu-section p {
  font-size: 0.8rem;
  color: var(--fg-muted);
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.menu-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.5rem 0;
}

/* ── Toggle switch ────────────────────────────────────────── */

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--control-track);
  border-radius: 24px;
  transition: background 0.2s;
}

.switch .slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--bg);
  border-radius: 50%;
  transition: transform 0.2s;
}

.switch input:checked + .slider {
  background: var(--control-fill);
}

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

/* ── Main ─────────────────────────────────────────────────── */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0 1.5rem 2rem;
  gap: 0;
}

.player-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  justify-content: center;
}

.content-title {
  font-family: "Georgia", "Times New Roman", Times, serif;
  font-weight: 700;
  font-size: 1.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
  margin-bottom: 0.25rem;
}

.message {
  font-size: 0.8rem;
  color: var(--accent);
  text-align: center;
  min-height: 1.25rem;
  margin-bottom: 2rem;
}

/* ── Progress bar ─────────────────────────────────────────── */

.progress-container {
  width: 100%;
  margin-bottom: 1.5rem;
}

.progress-bar {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--control-track);
  outline: none;
  pointer-events: none;
  cursor: default;
}

.progress-bar:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 0;
  height: 0;
  background: transparent;
  cursor: default;
  margin-top: 0;
}

.progress-bar::-moz-range-thumb {
  width: 0;
  height: 0;
  background: transparent;
  border: none;
  cursor: default;
}

.progress-bar::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
}

.progress-bar::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--control-track);
}

.time-display {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-top: 0.4rem;
  font-variant-numeric: tabular-nums;
}

/* ── Play/Pause button ────────────────────────────────────── */

.controls {
  margin-bottom: 1.5rem;
}

.play-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--fg);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.play-btn:disabled {
  border-color: var(--control-track);
  color: var(--control-track);
  cursor: not-allowed;
}

.play-btn:not(:disabled):active {
  transform: scale(0.92);
  background: var(--fg);
  color: var(--bg);
}

/* ── Volume slider ────────────────────────────────────────── */

.volume-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 240px;
  color: var(--fg-muted);
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--control-track);
  outline: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--control-thumb);
  cursor: pointer;
}

.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--control-thumb);
  border: none;
  cursor: pointer;
}

/* ── Headphones ───────────────────────────────────────────── */

.headphones {
  text-align: center;
  color: var(--fg-muted);
  margin-top: auto;
  padding: 2rem 0 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.headphones p {
  font-size: 0.8rem;
  line-height: 1.5;
}

/* ── Debug ────────────────────────────────────────────────── */

.debug {
  width: 100%;
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: 8px;
  font-size: 0.625rem;
  overflow-x: auto;
}

.debug h3 {
  font-size: 0.7rem;
  margin-bottom: 0.5rem;
  color: var(--fg-muted);
  text-transform: uppercase;
}

.debug pre {
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--fg-muted);
  max-height: 200px;
  overflow-y: auto;
}
