:root {
  --bg: #0d1117;
  --surface: #1a2332;
  --surface-2: #0a0e14;
  --accent: #5a8dff;
  --text: #e6edf3;
  --text-dim: rgba(230, 237, 243, 0.5);
  --text-faint: rgba(230, 237, 243, 0.3);
  --border: #1a2332;
  --radius: 10px;
  --radius-pill: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 15px;
  min-height: 100vh;
}

body {
  padding-bottom: 76px; /* room for sticky mini-player */
  position: relative;
  overflow-x: hidden;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 18px;
  position: relative;
  z-index: 1;
}

/* ===== Ambient background ===== */
/* Registered <color> properties so the CSS transitions interpolate smoothly
   between palettes instead of snapping. Without @property, color values
   are treated as discrete strings and don't animate. */
@property --ambient-c1 {
  syntax: '<color>';
  inherits: true;
  initial-value: transparent;
}
@property --ambient-c2 {
  syntax: '<color>';
  inherits: true;
  initial-value: transparent;
}

.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--bg);
  opacity: var(--ambient-opacity, 0);
  transition: opacity var(--ambient-fade-duration, 3000ms) ease-in-out;
  overflow: hidden;
}

.ambient-bg::before,
.ambient-bg::after {
  content: '';
  position: absolute;
  width: 90vmax;
  height: 90vmax;
  border-radius: 50%;
  filter: blur(60px);
  will-change: transform;
  /* Without @property registration above, this transition would snap. */
  transition: background 3000ms ease-in-out;
}

.ambient-bg::before {
  top: -30vmax;
  left: -30vmax;
  background: radial-gradient(circle, var(--ambient-c1) 0%, transparent 65%);
  animation: ambient-drift-1 42s ease-in-out infinite alternate;
}

.ambient-bg::after {
  bottom: -30vmax;
  right: -30vmax;
  background: radial-gradient(circle, var(--ambient-c2) 0%, transparent 65%);
  animation: ambient-drift-2 38s ease-in-out infinite alternate;
}

.ambient-bg.ambient-paused::before,
.ambient-bg.ambient-paused::after {
  animation-play-state: paused;
}

.ambient-bg.ambient-paused {
  opacity: calc(var(--ambient-opacity, 0) * 0.5) !important;
}

@keyframes ambient-drift-1 {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(20vw, 12vh) scale(1.15); }
  100% { transform: translate(8vw, 24vh) scale(1.05); }
}

@keyframes ambient-drift-2 {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(-18vw, -10vh) scale(1.12); }
  100% { transform: translate(-6vw, -22vh) scale(1.08); }
}

/* Respect users who prefer reduced motion — keep the colors but stop the drift. */
@media (prefers-reduced-motion: reduce) {
  .ambient-bg::before,
  .ambient-bg::after {
    animation: none;
  }
}

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

.title {
  font-size: 18px;
  font-weight: 300;
}

.label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 18px 0 8px;
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  border: 0;
  font-size: 13px;
  cursor: pointer;
}

.chip.active {
  background: var(--accent);
  color: #fff;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.tile {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  border: 2px solid transparent;
  color: var(--text);
  font-size: 12px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 8px;
  cursor: pointer;
  position: relative;
  text-align: left;
}

.tile.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.tile-label {
  pointer-events: none;
}

.tile-fav {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 11px;
  color: var(--accent);
}

.miniplayer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 480px;
  margin: 0 auto;
}

/* Sleep-timer progress bar: fixed, sits flush above the mini-player */
.timer-progress {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(76px + env(safe-area-inset-bottom));   /* mini-player height */
  height: 18px;
  display: none;
  cursor: pointer;
  touch-action: none;
  z-index: 2;
  max-width: 480px;
  margin: 0 auto;
  --tp-fill-color: var(--accent);
}

.timer-progress.tp-visible {
  display: block;
}

/* The 18px height is the touch target; the visible track is centered inside */
.timer-progress::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 5px;
  margin-top: -2.5px;
  background: var(--surface);
  border-radius: 3px;
  transition: height 150ms ease, margin-top 150ms ease;
}

.timer-progress.tp-active::before {
  height: 8px;
  margin-top: -4px;
}

.tp-fill {
  position: absolute;
  left: 0;
  top: 50%;
  height: 5px;
  margin-top: -2.5px;
  background: var(--tp-fill-color);
  opacity: 1;
  border-radius: 3px;
  width: 0;
  transition: height 150ms ease, margin-top 150ms ease, background 800ms ease;
  pointer-events: none;
}

.timer-progress.tp-active .tp-fill {
  height: 8px;
  margin-top: -4px;
}

.tp-handle {
  position: absolute;
  top: 50%;
  margin-top: -7px;
  margin-left: -7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--tp-fill-color);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 150ms ease, transform 150ms ease, background 800ms ease;
  pointer-events: none;
  left: 0;
}

.timer-progress.tp-active .tp-handle {
  opacity: 1;
  transform: scale(1);
}

.mp-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 0;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.mp-info {
  flex: 1;
  min-width: 0;
}

.mp-title {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp-sub {
  font-size: 11px;
  color: var(--text-dim);
}

.mp-timer {
  background: transparent;
  color: var(--text-dim);
  border: 0;
  font-size: 13px;
  cursor: pointer;
}

.mp-volume {
  width: 90px;
  flex-shrink: 0;
}

.install-hint {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 12px;
  margin-bottom: 12px;
}

.install-hint button {
  background: transparent;
  color: var(--text-dim);
  border: 0;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}
