:root {
  --bg: #FDF6EC;
  --surface: #F5E9D7;
  --surface-hi: #EFDFC8;
  --accent: #E07A3F;
  --accent-deep: #B45F2B;
  --text: #3A2E26;
  --muted: #7A6A5C;
  --shadow: 0 -8px 30px rgba(58, 46, 38, .10);
  --radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1E1916;
    --surface: #2A231E;
    --surface-hi: #362D26;
    --accent: #F0A06A;
    --accent-deep: #E07A3F;
    --text: #F3E9DE;
    --muted: #A08D7C;
    --shadow: 0 -8px 30px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: max(28px, env(safe-area-inset-top)) 20px calc(150px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  max-width: 620px;
  margin-inline: auto;
}

/* ---- streak header ---- */

.streak { text-align: center; margin-bottom: 34px; }

.streak-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.flame { color: var(--accent); display: flex; }

.streak-count {
  font-size: 54px;
  font-weight: 300;
  letter-spacing: -.03em;
  line-height: 1;
}

.streak-label { color: var(--muted); font-size: 15px; align-self: flex-end; padding-bottom: 6px; }

.dots {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin-top: 18px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--surface-hi);
}

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

.dot.today { box-shadow: 0 0 0 3px var(--bg), 0 0 0 4.5px var(--accent); }

.stats { color: var(--muted); font-size: 13.5px; margin: 16px 0 0; }

/* ---- breadcrumb ---- */

/* display:flex would otherwise beat the UA's [hidden] { display: none } */
.crumb[hidden] { display: none; }

.crumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: -8px 0 14px;
}

.crumb button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: -10px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--accent-deep);
  cursor: pointer;
}

.crumb button:active { background: var(--surface); }

.crumb h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -.01em;
}

/* ---- track list ---- */

.tracks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.track {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 10px 8px 10px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  transition: background .18s ease;
}

.track.playing { background: var(--surface-hi); }

.track-open {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  background: none;
  border: 0;
  padding: 6px 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.track-title { font-size: 16.5px; }
.track.playing .track-title { color: var(--accent-deep); }
.track-meta { font-size: 13px; color: var(--muted); }

.pack-icon {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 21px;
  border-radius: 12px;
  background: var(--surface-hi);
}

.pack-chevron {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.dl {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.dl[data-state="saved"] { color: var(--accent); }
.dl[data-state="busy"] { color: var(--accent); }
.dl svg { display: block; }

.dl .spin { animation: spin 1.1s linear infinite; transform-origin: 50% 50%; }

@keyframes spin { to { transform: rotate(360deg); } }

.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 40px 10px; }
.empty code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 12.5px;
}

/* ---- footer tools ---- */

.tools { display: flex; gap: 10px; justify-content: center; margin-top: 34px; }

.tools button {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.tools button:active { background: var(--surface); }

/* ---- player ---- */

.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow);
  padding-bottom: env(safe-area-inset-bottom);
  max-width: 620px;
  margin-inline: auto;
}

.player-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px 18px;
  background: none;
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.player-title {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.chevron { color: var(--muted); display: flex; transition: transform .25s ease; }
.player.open .chevron { transform: rotate(180deg); }

/* breathing ring - runs only while playing */
.ring {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--accent);
}

.player.playing .ring { animation: breathe 10s ease-in-out infinite; }

@keyframes breathe {
  0%   { transform: scale(.8); opacity: .45; }
  40%  { transform: scale(1.3); opacity: 1; }   /* ~4s in  */
  100% { transform: scale(.8); opacity: .45; }  /* ~6s out */
}

.player-body {
  display: none;
  padding: 0 18px 22px;
}

.player.open .player-body { display: block; }

.scrub { margin-bottom: 6px; }

#seek {
  width: 100%;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  background: none;
  height: 26px;
}

#seek::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--p, 0%), var(--surface-hi) var(--p, 0%));
}

#seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: -5.5px;
}

#seek::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--p, 0%), var(--surface-hi) var(--p, 0%)); }
#seek::-moz-range-thumb { width: 15px; height: 15px; border: 0; border-radius: 50%; background: var(--accent); }

.times {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  margin-top: 14px;
}

.ctl {
  position: relative;
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 8px;
  display: grid;
  place-items: center;
}

.ctl span {
  position: absolute;
  font-size: 8.5px;
  font-weight: 600;
  top: 52%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.play {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.play svg { display: block; }

/* ---- toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(120px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 13.5px;
  padding: 10px 16px;
  border-radius: 12px;
  max-width: 80vw;
  text-align: center;
  z-index: 10;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
