:root {
  --bg: #161513;
  --bg-2: #1c1a17;
  --surface: #211f1b;
  --surface-2: #28251f;
  --surface-hover: #2e2a23;
  --border: #322e28;
  --border-bright: #423c33;
  --text: #ece4d4;
  --text-2: #b8ad9b;
  --text-muted: #8c8275;
  --text-faint: #5c554c;
  --accent: #d4a574;
  --accent-bright: #e8b87a;
  --accent-dim: #8a6b48;
  --danger: #c97864;
  --success: #87a883;

  /* Ambient visual palette (warm default) */
  --ambient-bg-near: #221a12;
  --ambient-bg-far: #0f0d0a;
  --ambient-glow-1: #d4a574;
  --ambient-glow-2: #8a5d3a;
  --ambient-glow-3: #4a3826;
  --ambient-dust: rgba(245, 230, 200, 0.75);
  --ambient-dust-halo: rgba(245, 230, 200, 0.55);
  --ambient-dust-glow: rgba(212, 165, 116, 0.25);

  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Manrope", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;

  --radius: 4px;
  --radius-lg: 8px;

  --shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 8px 32px rgba(0, 0, 0, 0.3);
}

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

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(
      ellipse at top left,
      rgba(212, 165, 116, 0.04),
      transparent 50%
    ),
    radial-gradient(
      ellipse at bottom right,
      rgba(212, 165, 116, 0.03),
      transparent 50%
    ),
    var(--bg);
  background-attachment: fixed;
}

/* Subtle film grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

button,
input,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button {
  cursor: pointer;
}

/* ---------- LAYOUT ---------- */

.app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ---------- HEADER ---------- */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 32px;
  padding: 28px 0 24px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-mark {
  font-family: var(--serif);
  font-style: italic;
  font-size: 28px;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1;
}

.brand-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-bottom: 4px;
  box-shadow: 0 0 12px var(--accent);
}

.brand-tag {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-left: 6px;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* ---------- THEME PRESETS ---------- */
/* Only the accent family is overridden so backgrounds/text stay
   consistent across themes — keeps the "calm warm dark" identity. */
body[data-theme="forest"] {
  --accent: #87a883;
  --accent-bright: #9bbf96;
  --accent-dim: #5a7c58;
  --ambient-bg-near: #161e15;
  --ambient-bg-far: #0a0d0a;
  --ambient-glow-1: #87a883;
  --ambient-glow-2: #5a7c58;
  --ambient-glow-3: #2e3f2c;
  --ambient-dust: rgba(220, 235, 215, 0.75);
  --ambient-dust-halo: rgba(220, 235, 215, 0.55);
  --ambient-dust-glow: rgba(135, 168, 131, 0.25);
}
body[data-theme="ocean"] {
  --accent: #7ba9c4;
  --accent-bright: #9bc1d9;
  --accent-dim: #4f7a92;
  --ambient-bg-near: #131c22;
  --ambient-bg-far: #080b0e;
  --ambient-glow-1: #7ba9c4;
  --ambient-glow-2: #4f7a92;
  --ambient-glow-3: #2a4254;
  --ambient-dust: rgba(210, 230, 245, 0.75);
  --ambient-dust-halo: rgba(210, 230, 245, 0.55);
  --ambient-dust-glow: rgba(123, 169, 196, 0.25);
}
body[data-theme="sunset"] {
  --accent: #e07b6a;
  --accent-bright: #f0928a;
  --accent-dim: #a3554b;
  --ambient-bg-near: #221310;
  --ambient-bg-far: #0e0807;
  --ambient-glow-1: #e07b6a;
  --ambient-glow-2: #a3554b;
  --ambient-glow-3: #5a2c25;
  --ambient-dust: rgba(250, 220, 210, 0.75);
  --ambient-dust-halo: rgba(250, 220, 210, 0.55);
  --ambient-dust-glow: rgba(224, 123, 106, 0.25);
}
body[data-theme="mono"] {
  --accent: #c4b8a8;
  --accent-bright: #d6cdbf;
  --accent-dim: #8f8576;
  --ambient-bg-near: #1a1815;
  --ambient-bg-far: #0a0908;
  --ambient-glow-1: #c4b8a8;
  --ambient-glow-2: #8f8576;
  --ambient-glow-3: #4a4439;
  --ambient-dust: rgba(235, 230, 220, 0.75);
  --ambient-dust-halo: rgba(235, 230, 220, 0.55);
  --ambient-dust-glow: rgba(196, 184, 168, 0.25);
}

/* ---------- THEME PICKER ---------- */
.theme-control {
  position: relative;
}

.theme-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: none;
  gap: 8px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 50;
}
.theme-popover.show {
  display: flex;
}

.theme-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--swatch);
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease;
}
.theme-swatch:hover {
  transform: scale(1.12);
}
.theme-swatch.active {
  border-color: var(--text);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--surface);
  color: var(--accent);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

/* ---------- VOLUME CONTROL ---------- */

.volume-control {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 10px;
  margin-right: 4px;
  border-right: 1px solid var(--border);
}

.volume-icon {
  flex-shrink: 0;
}
.volume-icon .vol-off {
  display: none;
}
.volume-icon.muted .vol-on {
  display: none;
}
.volume-icon.muted .vol-off {
  display: block;
  color: var(--text-faint);
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.volume-slider:hover {
  background: var(--border-bright);
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  background: var(--accent);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 0 0 4px transparent;
  transition:
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.volume-slider:hover::-webkit-slider-thumb {
  background: var(--accent-bright);
  box-shadow: 0 0 0 4px rgba(212, 165, 116, 0.15);
}

.volume-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
}

.volume-slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: grab;
  transition: background 0.15s ease;
}

.volume-slider:hover::-moz-range-thumb {
  background: var(--accent-bright);
}

/* When muted, dim the slider */
.volume-control.is-muted .volume-slider::-webkit-slider-thumb {
  background: var(--text-faint);
}
.volume-control.is-muted .volume-slider::-moz-range-thumb {
  background: var(--text-faint);
}

@media (max-width: 720px) {
  .volume-slider {
    width: 60px;
  }
}

/* ---------- MAIN ---------- */

.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  padding: 24px 0;
  min-height: 0;
}

/* ---------- VIDEO PANEL ---------- */

.video-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.video-frame iframe,
.video-frame #player {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.video-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: var(--text-faint);
  pointer-events: none;
}

.video-empty.hidden {
  display: none;
}

/* ---------- VIEW MODES (overlay switcher) ---------- */

.view-modes {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 2px;
  padding: 3px;
  background: rgba(22, 21, 19, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(50, 46, 40, 0.6);
  border-radius: var(--radius);
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.video-frame:hover .view-modes,
.view-modes:hover,
.view-modes:focus-within {
  opacity: 1;
}

.video-frame.non-video-mode .view-modes {
  opacity: 1; /* always visible when overlay covers video */
}

.view-mode-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  color: var(--text-faint);
  transition: all 0.15s ease;
}

.view-mode-btn:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.05);
}

.view-mode-btn.active {
  color: var(--accent);
  background: rgba(212, 165, 116, 0.12);
}

.view-mode-btn svg {
  width: 15px;
  height: 15px;
}

.view-modes-divider {
  width: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 4px 3px;
  align-self: stretch;
}

/* Fullscreen icon swap */
.view-mode-btn .fs-exit {
  display: none;
}
.video-frame.is-fullscreen #fullscreenBtn .fs-enter {
  display: none;
}
.video-frame.is-fullscreen #fullscreenBtn .fs-exit {
  display: block;
}

/* --- Share modal --- */
.share-modal {
  max-width: 480px;
}
.share-modal .modal-title {
  font-size: 24px;
  margin-bottom: 6px;
}
.share-subtitle {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  text-transform: uppercase;
  margin-bottom: 18px;
}
.share-url-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg);
}
.share-url-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  min-width: 0;
}
.share-url-copy {
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  padding: 0 16px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-transform: uppercase;
  transition: background 0.15s;
}
.share-url-copy:hover {
  background: rgba(212, 165, 116, 0.08);
}
.share-url-copy.copied {
  color: var(--text);
}

.share-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.share-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.share-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(212, 165, 116, 0.04);
}
.share-btn svg {
  width: 18px;
  height: 18px;
}
.share-btn.native {
  display: none;
}
.share-btn.native.available {
  display: flex;
}

.share-qr-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.share-qr {
  width: 120px;
  height: 120px;
  background: #ece4d4;
  border-radius: 3px;
  padding: 8px;
  flex-shrink: 0;
}
.share-qr svg {
  width: 100%;
  height: 100%;
  display: block;
}
.share-qr-text {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.share-qr-text strong {
  color: var(--text);
  font-weight: 500;
  display: block;
  margin-bottom: 4px;
}

/* Disabled state — share button before video is loaded */
.view-mode-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.view-mode-btn:disabled:hover {
  color: var(--text-faint);
  background: transparent;
}

/* Share button in playlist header */
.playlist-action.share-action {
  color: var(--text-muted);
}
.playlist-action.share-action:hover {
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 640px) {
  .share-buttons {
    grid-template-columns: repeat(2, 1fr);
  }
  .share-qr-wrap {
    flex-direction: column;
    text-align: center;
  }
}

/* Fullscreen frame */
.video-frame:fullscreen,
.video-frame:-webkit-full-screen,
.video-frame.is-fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  aspect-ratio: auto;
  border: none;
  border-radius: 0;
  background: var(--bg);
}

.video-frame:fullscreen .view-modes,
.video-frame:-webkit-full-screen .view-modes,
.video-frame.is-fullscreen .view-modes {
  opacity: 1;
  top: 24px;
  right: 24px;
}

.video-frame:fullscreen #player,
.video-frame:fullscreen iframe,
.video-frame:-webkit-full-screen #player,
.video-frame:-webkit-full-screen iframe,
.video-frame.is-fullscreen #player,
.video-frame.is-fullscreen iframe {
  width: 100%;
  height: 100%;
}

/* Bigger text in fullscreen for immersion */
.video-frame:fullscreen .clock-time,
.video-frame:-webkit-full-screen .clock-time,
.video-frame.is-fullscreen .clock-time,
.video-frame:fullscreen .big-timer-time,
.video-frame:-webkit-full-screen .big-timer-time,
.video-frame.is-fullscreen .big-timer-time {
  font-size: clamp(180px, 30vw, 640px);
}

.video-frame:fullscreen .clock-date,
.video-frame:-webkit-full-screen .clock-date,
.video-frame.is-fullscreen .clock-date {
  font-size: clamp(18px, 2.2vw, 32px);
  margin-top: 32px;
  letter-spacing: 0.35em;
}

.video-frame:fullscreen .big-timer-label,
.video-frame:-webkit-full-screen .big-timer-label,
.video-frame.is-fullscreen .big-timer-label {
  font-size: clamp(16px, 2vw, 28px);
  margin-bottom: 28px;
  letter-spacing: 0.35em;
}

.video-frame:fullscreen .big-timer-cycle,
.video-frame:-webkit-full-screen .big-timer-cycle,
.video-frame.is-fullscreen .big-timer-cycle {
  font-size: clamp(14px, 1.6vw, 22px);
  margin-top: 32px;
  letter-spacing: 0.3em;
}

.view-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: hidden;
  z-index: 5;
}

.view-overlay.active {
  display: flex;
}

/* ----- Visual mode: drifting ambient background ----- */

.visual-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 50% 100%,
    var(--ambient-bg-near) 0%,
    var(--ambient-bg-far) 80%
  );
  overflow: hidden;
}

.visual-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  will-change: transform;
}

.visual-glow-1 {
  width: 55%;
  height: 55%;
  top: -10%;
  left: -10%;
  background: radial-gradient(circle, var(--ambient-glow-1) 0%, transparent 70%);
  animation: drift-1 38s ease-in-out infinite alternate;
}

.visual-glow-2 {
  width: 50%;
  height: 50%;
  bottom: -15%;
  right: -10%;
  background: radial-gradient(circle, var(--ambient-glow-2) 0%, transparent 70%);
  animation: drift-2 46s ease-in-out infinite alternate;
}

.visual-glow-3 {
  width: 40%;
  height: 40%;
  top: 30%;
  right: 20%;
  background: radial-gradient(circle, var(--ambient-glow-3) 0%, transparent 70%);
  animation: drift-3 54s ease-in-out infinite alternate;
}

@keyframes drift-1 {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(30%, 20%) scale(1.2);
  }
}
@keyframes drift-2 {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(-25%, -30%) scale(1.3);
  }
}
@keyframes drift-3 {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(-20%, 25%) scale(0.8);
  }
}

.visual-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.dust {
  position: absolute;
  /* width/height are set per-particle via JS for varied sizes */
  background: var(--ambient-dust);
  border-radius: 50%;
  box-shadow:
    0 0 10px var(--ambient-dust-halo),
    0 0 18px var(--ambient-dust-glow);
  animation: dust-rise linear infinite;
  will-change: transform, opacity;
}

@keyframes dust-rise {
  0% {
    transform: translateY(0) translateX(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-120vh) translateX(40px);
    opacity: 0;
  }
}

/* ----- Clock mode ----- */

.clock-display {
  text-align: center;
  color: var(--text);
  padding: 24px;
}

.clock-time {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(80px, 18vw, 200px);
  line-height: 1;
  letter-spacing: -0.02em;
  font-feature-settings: "tnum" 1;
  color: var(--text);
}

.clock-date {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: clamp(12px, 1.6vw, 16px);
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--text-muted);
}

/* ----- Big timer mode ----- */

.big-timer-display {
  text-align: center;
  padding: 24px;
}

.big-timer-label {
  font-family: var(--mono);
  font-size: clamp(11px, 1.2vw, 14px);
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--accent);
  margin-bottom: 12px;
}

.big-timer-time {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(80px, 18vw, 200px);
  line-height: 1;
  letter-spacing: -0.02em;
  font-feature-settings: "tnum" 1;
  color: var(--text);
}

.big-timer-cycle {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: clamp(10px, 1.1vw, 12px);
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--text-faint);
}

.video-empty-mark {
  font-family: var(--serif);
  font-style: italic;
  font-size: 64px;
  color: var(--text-faint);
  line-height: 1;
  opacity: 0.5;
}

.video-empty-text {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--text-faint);
}

/* URL input */

.url-bar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.url-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.15s ease;
}

.url-input::placeholder {
  color: var(--text-faint);
  font-style: italic;
}

.url-input:focus {
  border-color: var(--accent-dim);
}

.btn-add-url {
  width: 48px;
  padding: 14px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  font-weight: 300;
  transition: all 0.15s ease;
}

.btn-add-url:hover {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--surface-hover);
}

.btn-primary {
  padding: 14px 22px;
  background: var(--accent);
  color: #1a1610;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: all 0.15s ease;
}

.btn-primary:hover {
  background: var(--accent-bright);
}

/* Loop controls */

.loop-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.loop-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.media-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--bg-2);
  transition: all 0.15s ease;
  position: relative;
  flex-shrink: 0;
}

.media-btn:hover {
  color: var(--accent);
  border-color: var(--border-bright);
  background: var(--surface-hover);
}

.media-btn.active {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: rgba(212, 165, 116, 0.08);
}

.media-btn svg {
  width: 16px;
  height: 16px;
}

.media-btn-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  color: #1a1610;
  background: var(--accent);
  width: 13px;
  height: 13px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 1.5px solid var(--surface);
}

.media-btn-badge.visible {
  display: flex;
}

.media-state {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  margin-left: 8px;
  white-space: nowrap;
}

.ab-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ab-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.ab-btn:hover {
  color: var(--accent);
  border-color: var(--border-bright);
}

.ab-btn.set {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: rgba(212, 165, 116, 0.05);
}

.ab-btn.danger {
  color: var(--text-faint);
}

.ab-btn.danger:hover {
  color: var(--danger);
}

/* ---------- PLAYLIST ---------- */

.playlist {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.playlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}

.playlist-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.playlist-icon {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--accent);
  line-height: 1;
}

.playlist-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 6px 26px 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  max-width: 200px;
  text-overflow: ellipsis;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2210%22%20height%3D%226%22%3E%3Cpath%20d%3D%22M0%200l5%206%205-6z%22%20fill%3D%22%238c8275%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.playlist-select:hover {
  border-color: var(--border-bright);
}
.playlist-select:focus {
  border-color: var(--accent-dim);
  outline: none;
}

.playlist-actions {
  display: flex;
  gap: 4px;
}

.playlist-action {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.playlist-action:hover {
  color: var(--accent);
  border-color: var(--border-bright);
  background: var(--surface-hover);
}

.playlist-action.primary {
  color: var(--accent);
  border-color: var(--accent-dim);
}

.playlist-action.primary:hover {
  background: rgba(212, 165, 116, 0.08);
}

.playlist-action.danger:hover {
  color: var(--danger);
}

.playlist-items {
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 140px;
  overflow-y: auto;
}

.playlist-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--text-faint);
  font-style: italic;
  font-family: var(--serif);
  font-size: 14px;
  width: 100%;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.15s ease;
  max-width: 100%;
  position: relative;
}

.playlist-item:hover {
  border-color: var(--border-bright);
  background: var(--surface-hover);
}

.playlist-item.active {
  border-color: var(--accent-dim);
  background: rgba(212, 165, 116, 0.06);
}

.playlist-item.active::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  flex-shrink: 0;
  animation: pulse 2s ease-in-out infinite;
}

.playlist-item.dragging {
  opacity: 0.35;
  border-style: dashed;
}

.playlist-item.drop-target {
  border-color: var(--accent);
  background: rgba(212, 165, 116, 0.12);
  box-shadow: inset 0 2px 0 var(--accent);
}

.playlist-item-grip {
  width: 14px;
  color: var(--text-faint);
  cursor: grab;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  touch-action: none; /* prevent page scroll while dragging the handle */
  transition:
    opacity 0.15s ease,
    color 0.15s ease;
}

.playlist-item:hover .playlist-item-grip {
  opacity: 1;
}

/* Touch devices have no hover — keep the grip visible and easier to tap */
@media (hover: none) {
  .playlist-item-grip {
    width: 22px;
    opacity: 1;
    color: var(--text-muted);
  }
  .playlist-item-grip svg {
    width: 16px;
    height: 16px;
  }
}

.playlist-item-grip:hover {
  color: var(--accent);
}
.playlist-item-grip:active {
  cursor: grabbing;
}
.playlist-item-grip svg {
  width: 12px;
  height: 12px;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.playlist-item-title {
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.playlist-item.active .playlist-item-title {
  color: var(--accent);
  font-weight: 500;
}

.playlist-item-remove {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  opacity: 0;
  flex-shrink: 0;
}

.playlist-item:hover .playlist-item-remove {
  opacity: 1;
}

.playlist-item-remove:hover {
  color: var(--danger);
  background: var(--surface);
}

.playlist-item-remove svg {
  width: 10px;
  height: 10px;
}

/* ---------- CURRENT TASK (pinned in timer) ---------- */

.current-task {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 14px;
  margin-bottom: 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
}

.current-task.visible {
  display: flex;
}

.current-task-check {
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--border-bright);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.current-task-check:hover {
  border-color: var(--accent);
  background: rgba(212, 165, 116, 0.08);
}

.current-task-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.current-task-label {
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-faint);
}

.current-task-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
  font-style: italic;
  font-family: var(--serif);
}

.current-task-unpin {
  width: 22px;
  height: 22px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.current-task-unpin:hover {
  color: var(--danger);
  background: var(--surface);
}

.current-task-unpin svg {
  width: 12px;
  height: 12px;
}

/* ---------- TODO ---------- */

.todo-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  margin: 14px 0 18px;
}

.todo-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.15s ease;
}

.todo-input:focus {
  border-color: var(--accent-dim);
}

.todo-input::placeholder {
  color: var(--text-faint);
  font-style: italic;
}

.todo-add-btn {
  padding: 0 14px;
  background: var(--accent);
  color: #1a1610;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 18px;
  line-height: 1;
  transition: background 0.15s ease;
}

.todo-add-btn:hover {
  background: var(--accent-bright);
}

.todo-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.todo-section-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-faint);
  margin: 14px 0 6px;
}

.todo-section-label:first-child {
  margin-top: 0;
}

.todo-item {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}

/* Completed rows reuse the same 4-column grid as active rows; their grip
   slot is just an empty placeholder so check/text/actions stay aligned. */
.todo-grip-placeholder {
  pointer-events: none;
  opacity: 0;
}

.todo-item:hover {
  background: var(--bg-2);
}

.todo-item.dragging {
  opacity: 0.35;
  border-style: dashed;
}

.todo-item.drop-target {
  border-color: var(--accent);
  background: rgba(212, 165, 116, 0.12);
  box-shadow: inset 0 2px 0 var(--accent);
}

.todo-grip {
  width: 14px;
  color: var(--text-faint);
  cursor: grab;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  touch-action: none; /* prevent page scroll while dragging the handle */
  transition:
    opacity 0.15s ease,
    color 0.15s ease;
}

.todo-item:hover .todo-grip {
  opacity: 1;
}

/* Touch devices have no hover — keep the grip visible and easier to tap */
@media (hover: none) {
  .todo-grip {
    width: 22px;
    opacity: 1;
    color: var(--text-muted);
  }
  .todo-grip svg {
    width: 16px;
    height: 16px;
  }
}

.todo-grip:hover {
  color: var(--accent);
}
.todo-grip:active {
  cursor: grabbing;
}
.todo-grip svg {
  width: 12px;
  height: 12px;
}

.todo-check {
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-bright);
  border-radius: 3px;
  background: var(--bg-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.todo-check:hover {
  border-color: var(--accent);
}

.todo-check.done {
  background: var(--accent);
  border-color: var(--accent);
}

.todo-check.done::after {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 1.5px solid #1a1610;
  border-bottom: 1.5px solid #1a1610;
  transform: rotate(-45deg) translate(1px, -1px);
}

.todo-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
  cursor: pointer;
}

.todo-item.done .todo-text {
  color: var(--text-faint);
  text-decoration: line-through;
  text-decoration-color: var(--text-faint);
}

.todo-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.todo-pin {
  width: 24px;
  height: 24px;
  color: var(--text-faint);
  opacity: 0;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.todo-item:hover .todo-pin {
  opacity: 1;
}

.todo-pin:hover {
  color: var(--accent);
  background: var(--surface-hover);
}

.todo-pin.pinned {
  color: var(--accent);
  opacity: 1;
}

.todo-pin svg {
  width: 12px;
  height: 12px;
}

.todo-delete {
  width: 24px;
  height: 24px;
  color: var(--text-faint);
  opacity: 0;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.todo-item:hover .todo-delete {
  opacity: 1;
}

.todo-delete:hover {
  color: var(--danger);
  background: var(--surface-hover);
}

.todo-delete svg {
  width: 12px;
  height: 12px;
}

.todo-empty {
  text-align: center;
  color: var(--text-faint);
  font-style: italic;
  padding: 30px 20px;
  font-family: var(--serif);
  font-size: 16px;
}

.todo-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.todo-footer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.todo-clear-done {
  color: var(--text-faint);
  transition: color 0.15s ease;
}

.todo-clear-done:hover {
  color: var(--danger);
}

.todo-clear-done:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.todo-clear-done:disabled:hover {
  color: var(--text-faint);
}

.todo-show-completed {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-faint);
  transition: color 0.15s ease;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.todo-show-completed:hover {
  color: var(--text);
}

.todo-show-completed.is-on {
  color: var(--accent);
}

.todo-show-completed svg {
  width: 12px;
  height: 12px;
}

.todo-show-completed .icon-eye-off {
  display: inline-block;
}

.todo-show-completed .icon-eye-on {
  display: none;
}

.todo-show-completed.is-on .icon-eye-off {
  display: none;
}

.todo-show-completed.is-on .icon-eye-on {
  display: inline-block;
}

/* ---------- SIDEBAR ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}

.tab {
  padding: 14px 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid transparent;
  transition: all 0.15s ease;
  position: relative;
}

.tab:hover {
  color: var(--accent);
  background: var(--surface);
}

.tab.active {
  color: var(--accent);
}

.tab.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 20%;
  right: 20%;
  height: 1px;
  background: var(--accent);
}

.tab-panel {
  display: none;
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
}

/* ---------- TIMER ---------- */

.timer-mode {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--text-faint);
  text-align: center;
  margin-bottom: 8px;
}

.timer-mode-current {
  color: var(--accent);
}

.timer-display {
  font-family: var(--serif);
  font-style: italic;
  font-size: 88px;
  text-align: center;
  line-height: 1;
  color: var(--text);
  letter-spacing: -0.02em;
  font-feature-settings: "tnum" 1;
  margin: 12px 0;
}

.timer-cycle {
  text-align: center;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 24px;
}

.cycle-dots {
  display: inline-flex;
  gap: 5px;
  margin-left: 10px;
  vertical-align: middle;
}

.cycle-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border-bright);
}

.cycle-dot.complete {
  background: var(--accent);
}

.timer-controls {
  display: flex;
  gap: 8px;
}

.timer-btn {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
  font-weight: 600;
  transition: all 0.15s ease;
}

.timer-btn:hover {
  background: var(--surface-hover);
  color: var(--accent);
  border-color: var(--border-bright);
}

.timer-btn.primary {
  background: var(--accent);
  color: #1a1610;
  border-color: var(--accent);
}

.timer-btn.primary:hover {
  background: var(--accent-bright);
  border-color: var(--accent-bright);
}

.timer-settings {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.timer-settings-title {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-faint);
  margin-bottom: 14px;
}

.timer-setting {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-2);
}

.number-input {
  width: 60px;
  padding: 4px 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  text-align: center;
}

.number-input:focus {
  border-color: var(--accent-dim);
}

/* ---------- NOTES ---------- */

.notes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.panel-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--text);
}

.notes-status {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.notes-status.saved {
  color: var(--success);
}

/* ---------- HISTORY ---------- */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 16px;
}

.history-empty {
  text-align: center;
  color: var(--text-faint);
  font-style: italic;
  padding: 40px 20px;
  font-family: var(--serif);
  font-size: 16px;
}

.history-item {
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  cursor: pointer;
  transition: background 0.15s ease;
  border-radius: 2px;
}

.history-item:hover {
  background: var(--bg-2);
}

.history-item:last-child {
  border-bottom: none;
}

.history-completed-line {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-completed-mark {
  color: var(--accent);
  font-size: 10px;
  flex-shrink: 0;
}

.history-completed-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.history-more {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.1em;
  margin-top: 2px;
}

/* ---------- HISTORY DETAIL MODAL ---------- */

.history-modal-name {
  width: 100%;
  padding: 8px 12px;
  margin: -4px 0 16px -12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--serif);
  font-style: italic;
  font-size: 28px;
  line-height: 1.1;
  transition: all 0.15s ease;
}

.history-modal-name:hover {
  border-color: var(--border);
}

.history-modal-name:focus {
  border-color: var(--accent-dim);
  background: var(--bg-2);
  outline: none;
}

.history-modal-name::placeholder {
  color: var(--text-faint);
}

.history-modal-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.history-modal-meta-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 13px;
}

.history-modal-meta-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  min-width: 70px;
}

.history-modal-meta-value {
  color: var(--text-2);
  flex: 1;
  word-break: break-word;
}

.history-modal-section {
  margin-bottom: 18px;
}

.history-modal-section-title {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.history-modal-task {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

.history-modal-task::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  position: relative;
}

.history-modal-task::after {
  content: "";
  position: absolute;
  margin-left: 3px;
  margin-top: 6px;
  width: 7px;
  height: 4px;
  border-left: 1.5px solid #1a1610;
  border-bottom: 1.5px solid #1a1610;
  transform: rotate(-45deg);
  flex-shrink: 0;
}

.history-modal-empty {
  color: var(--text-faint);
  font-style: italic;
  font-size: 13px;
}

.history-modal-loop-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}

.history-modal-loop-index {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  flex-shrink: 0;
  min-width: 18px;
}

.timer-btn.danger {
  color: var(--danger);
  border-color: var(--border);
}

.timer-btn.danger:hover {
  color: var(--danger);
  background: rgba(201, 120, 100, 0.08);
  border-color: var(--danger);
}

.history-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.history-template {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.history-detail {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.05em;
}

.history-duration {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.05em;
}

/* ---------- STATS ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.stat-card {
  padding: 20px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-value {
  font-family: var(--serif);
  font-style: italic;
  font-size: 36px;
  line-height: 1;
  color: var(--text);
  font-feature-settings: "tnum" 1;
}

.stat-unit {
  font-size: 20px;
  color: var(--text-faint);
  margin-left: 0.5em;
  margin-right: 0.5em;
  font-style: normal;
  letter-spacing: 0.02em;
}

.stat-label {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-faint);
}

.stat-card.wide {
  grid-column: span 2;
}

/* ---------- FOOTER ---------- */

.footer {
  padding: 24px 0;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer a {
  color: var(--text-faint);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer a:hover {
  color: var(--accent);
}

/* ---------- TOAST ---------- */

.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 14px 24px;
  background: var(--surface-2);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 2000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-mark {
  font-family: var(--serif);
  font-style: italic;
  color: var(--accent);
  margin-right: 8px;
}

/* ---------- MODAL ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 480px;
  width: calc(100% - 40px);
  box-shadow: var(--shadow);
}

.modal-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 28px;
  margin-bottom: 8px;
}

.modal-text {
  color: var(--text-2);
  margin-bottom: 24px;
  line-height: 1.7;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ---------- RESPONSIVE ---------- */

@media (max-width: 1080px) {
  .main {
    grid-template-columns: 1fr;
  }
  .sidebar {
    min-height: 600px;
  }
}

@media (max-width: 720px) {
  .app {
    padding: 0 16px;
  }
  .header {
    gap: 16px;
  }
  .timer-display {
    font-size: 64px;
  }
  .loop-bar {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  /* Stack the playlist header so the select doesn't collide with action
     buttons on narrow screens. */
  .playlist-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .playlist-selector {
    width: 100%;
  }
  .playlist-select {
    max-width: 100%;
    width: 100%;
  }
  .playlist-actions {
    flex-wrap: wrap;
    gap: 6px;
  }
}

/* ---------- Screen-reader / SEO-only content ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
