:root {
  --canvas: #edf2ed;
  --panel: #fffcf5;
  --text: #163e38;
  --muted: #465e53;
  --border: #c3d0c6;
  --accent: #205c4d;
  --accent-hover: #184b3e;
  --action-text: white;
  --focus: #8c5122;
  color-scheme: light;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--text);
  background: var(--canvas);
}

:root[data-theme="dark"] {
  --canvas: #10221e;
  --panel: #182e28;
  --text: #ecf5ef;
  --muted: #b5c9bf;
  --border: #476357;
  --accent: #a4dbba;
  --accent-hover: #bee9ce;
  --action-text: #10221e;
  --focus: #f5bd82;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --canvas: #10221e;
    --panel: #182e28;
    --text: #ecf5ef;
    --muted: #b5c9bf;
    --border: #476357;
    --accent: #a4dbba;
    --accent-hover: #bee9ce;
    --action-text: #10221e;
    --focus: #f5bd82;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  padding: calc(1rem + env(safe-area-inset-top))
    calc(1rem + env(safe-area-inset-right))
    calc(1rem + env(safe-area-inset-bottom))
    calc(1rem + env(safe-area-inset-left));
  place-items: center;
}

@media (max-width: 36rem) {
  body { padding-bottom: calc(4.75rem + env(safe-area-inset-bottom)); }
}

main {
  width: min(100%, 27rem);
  padding: clamp(1.5rem, 7vw, 3rem);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  box-shadow: 0 0.5rem 2rem #2346380c;
}

h1 {
  margin: 0;
  font: normal clamp(2.5rem, 10vw, 3.5rem)/1.05 "Instrument Serif", Georgia, serif;
  letter-spacing: -0.055em;
}

section {
  margin-block: 1.75rem 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  overflow-wrap: anywhere;
}

h2 {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

#track { margin: 0; font-weight: 650; font-size: 1.45rem; }
#artist { margin: 0.25rem 0 0; color: var(--muted); }
#artist:empty { display: none; }

#progress { width: 100%; accent-color: var(--accent); }
#progress[hidden] { display: inline-block; visibility: hidden; }
.song-time { margin: 0.25rem 0; font-variant-numeric: tabular-nums; }
#timing-label, .song-time { color: var(--muted); font-size: 0.875rem; }
#queue { margin: 0; padding-inline-start: 1.5rem; }
#queue li + li { margin-top: 0.4rem; }

.current-slot { position: relative; }
.current-song { position: relative; z-index: 1; background: var(--panel); pointer-events: none; }
.outgoing-mask { position: absolute; inset: 0 0 auto; overflow: hidden; pointer-events: none; }
.outgoing-mask strong { display: block; font-size: 1.45rem; font-weight: 650; }
.outgoing-mask small { display: block; margin-top: .25rem; color: var(--muted); font-size: 1rem; }
.queue-viewport { overflow: hidden; }
.queue-viewport #queue { padding: 0; list-style: none; }
.queue-viewport li { min-height: 3rem; padding-bottom: .45rem; border-bottom: 1px solid var(--border); }
.queue-viewport strong, .queue-viewport small { display: block; }
.queue-viewport small { color: var(--muted); font-size: .85rem; }

button {
  border-radius: 0.55rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

#listen {
  width: 100%;
  min-height: 3rem;
  padding: 0.75rem 1rem;
  border: 0;
  background: var(--accent);
  color: var(--action-text);
}

#theme {
  position: fixed;
  right: calc(1rem + env(safe-area-inset-right));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: var(--panel);
  color: var(--accent);
}

#theme:not([hidden]) {
  display: grid;
  place-items: center;
}

#theme[aria-pressed="false"] .theme-sun,
#theme[aria-pressed="true"] .theme-moon { display: none; }

#theme:hover, #theme[aria-pressed="true"] {
  background: var(--accent);
  color: var(--action-text);
}

#listen:hover, #theme[aria-pressed="true"]:hover { background: var(--accent-hover); }
button:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
#status { margin: 0.75rem 0 0; text-align: center; font-size: 0.875rem; color: var(--muted); }

#loading:not([hidden]) {
  display: block;
  width: 1rem;
  height: 1rem;
  margin: 0.75rem auto 0;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}

@media (prefers-reduced-motion: no-preference) {
  #loading:not([hidden]) { animation: loading-spin 0.8s linear infinite; }
}

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