:root {
  color-scheme: light;
  --widget-bg: #fff;
  --deck-bg: #f7f3f8;
  --text: #251c32;
  --muted: #62566e;
  --border: #e1d7e5;
  --hover: #eee7f0;
  --selected: #f8e9ed;
  --accent: #b42349;
  --accent-hover: #982141;
  --accent-text: #ae2347;
  --rail: #daccdf;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --widget-bg: #1b1524;
  --deck-bg: #241b30;
  --text: #f5eef9;
  --muted: #c5b5cc;
  --border: #46374f;
  --hover: #35263f;
  --selected: #3e2337;
  --accent: #ba2e51;
  --accent-hover: #a52748;
  --accent-text: #ff97ad;
  --rail: #57415f;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--text);
  font: 14px/1.35 system-ui, sans-serif;
}

button, select, summary, input[type="range"] {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:where(button, a, select, summary, input):focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

button:disabled, input:disabled {
  cursor: default;
  opacity: .5;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover { text-decoration: underline; }

.widget {
  display: flex;
  flex-direction: column;
  height: 136px;
  max-height: 100dvh;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--widget-bg);
}

.widget--playlist { height: 298px; }

.widget-error {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--widget-bg);
}

.widget-error a {
  color: var(--accent-text);
  text-decoration: underline;
}

.deck {
  position: relative;
  display: grid;
  flex: 0 0 134px;
  grid-template-rows: minmax(54px, 1fr) 44px;
  gap: 6px;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 13px;
  background: var(--deck-bg);
}

.widget--playlist .deck {
  border-bottom: 1px solid var(--border);
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

.deck-header {
  display: grid;
  --cover-size: 54px;
  grid-template-columns: var(--cover-size) minmax(0, 1fr) auto;
  grid-template-rows: repeat(2, calc(var(--cover-size) / 2));
  align-content: center;
  grid-template-areas:
    "art meta brand"
    "art title title";
  column-gap: 10px;
  align-items: center;
  min-width: 0;
}

.artwork {
  grid-area: art;
  width: var(--cover-size);
  height: var(--cover-size);
  overflow: hidden;
  border-radius: 8px;
  background: var(--hover) url("/ss-logo.png") center / 60% no-repeat;
}

.cover {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.deck-header h1 {
  grid-area: title;
  min-width: 0;
  margin: 0;
  font-size: clamp(14px, 3.5vw, 16px);
  font-weight: 700;
  line-height: 1.25;
}

.title, .playlist-name, .track-title {
  min-width: 0;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist-name {
  grid-area: meta;
  color: var(--muted);
  font-size: 12px;
}

.notice, .queue-notice {
  margin: 0;
  color: var(--accent-text);
  font-size: 11px;
  line-height: 1.2;
}

.notice {
  grid-area: meta;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.deck-header:has(.notice:not(:empty)) .playlist-name,
.notice:empty, .queue-notice:empty { display: none; }

.brand {
  grid-area: brand;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: start;
  min-height: 26px;
  color: var(--text);
  font-size: 13px;
  line-height: 1;
  font-weight: 760;
  letter-spacing: -.15px;
  white-space: nowrap;
}

.brand img {
  display: block;
  flex: none;
}

.controls {
  display: grid;
  grid-template-columns: auto minmax(20px, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.transport, .options {
  display: flex;
  align-items: center;
  gap: 4px;
}

.play, .skip, .volume summary, .speed {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.play {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
}

.play:not(:disabled):hover { background: var(--accent-hover); }
.play svg { width: 25px; height: 25px; }

.play[data-state="loading"] svg { visibility: hidden; }
.play[data-state="loading"]::after {
  position: absolute;
  inset: 12px;
  border: 2px solid #fff7;
  border-top-color: white;
  border-radius: 50%;
  content: "";
  animation: loading .75s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .play[data-state="loading"]::after { animation: none; }
}

.skip, .volume summary {
  width: 30px;
  height: 32px;
}

.skip svg { display: block; width: 28px; max-width: 100%; height: 28px; }
.skip svg text { font: 700 8px Arial, sans-serif; }
.skip.forward svg g { transform: scaleX(-1); transform-origin: center; }

.skip:not(:disabled):hover, .volume summary:hover, .speed:hover { background: var(--hover); }

.timeline { min-width: 0; }

.seek-track {
  position: relative;
  display: grid;
  align-items: center;
  height: 20px;
}

.seek-track progress {
  position: absolute;
  width: 100%;
  height: 4px;
  overflow: hidden;
  appearance: none;
  border: 0;
  border-radius: 10px;
  background: var(--rail);
}

.seek-track progress::-webkit-progress-bar { background: var(--rail); }
.seek-track progress::-webkit-progress-value { background: var(--accent-text); }
.seek-track progress::-moz-progress-bar { background: var(--accent-text); }

.seek {
  position: relative;
  width: 100%;
  height: 20px;
  margin: 0;
  appearance: none;
  background: transparent;
}

.seek::-webkit-slider-runnable-track { background: transparent; }
.seek::-moz-range-track { background: transparent; }

.seek::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  appearance: none;
  border: 0;
  border-radius: 50%;
  background: var(--accent-text);
}

.seek::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-text);
}

.seek:disabled::-webkit-slider-thumb { visibility: hidden; }
.seek:disabled::-moz-range-thumb { visibility: hidden; }

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

.speed {
  width: 52px;
  height: 32px;
  padding: 0 3px;
  appearance: none;
  font-size: 12px;
  font-weight: 650;
  text-align: center;
}

.speed option { background: var(--widget-bg); }

.volume {
  position: relative;
}

.volume summary { list-style: none; }
.volume summary::-webkit-details-marker { display: none; }
.volume summary svg { width: 19px; height: 19px; }

.volume-panel {
  position: absolute;
  z-index: 1;
  right: 0;
  bottom: calc(100% + 4px);
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--widget-bg);
  box-shadow: 0 4px 12px #1710201c;
}

.volume-slider {
  display: block;
  width: 88px;
  height: 24px;
  margin: 0;
  accent-color: var(--accent-text);
}

.queue {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 4px 6px 6px;
  border-radius: 0 0 13px 13px;
}

.tracks {
  list-style: none;
  margin: 0;
  padding: 0;
}

.track {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 37px;
  padding: 3px 8px 3px 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: left;
}

.track:focus-visible { outline-offset: -2px; }
.track:hover { background: var(--hover); }
.track[aria-current="true"] { background: var(--selected); }

.track-icon {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: var(--hover);
  color: var(--muted);
}

.track[aria-current="true"] .track-icon {
  background: var(--accent);
  color: white;
}

.track-icon svg { width: 16px; height: 16px; }
.track-icon svg:nth-child(2), .track[data-playing="true"] svg:first-child { display: none; }
.track[data-playing="true"] svg:nth-child(2) { display: block; }

.track-title { font-size: 12px; }

.track[aria-current="true"] .track-title { font-weight: 650; }

.track-duration {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.queue-notice { padding: 7px 8px 2px; }

.more {
  display: block;
  width: calc(100% - 8px);
  min-height: 34px;
  margin: 4px;
  border: 0;
  border-radius: 7px;
  background: var(--hover);
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
}

.more:not(:disabled):hover { background: var(--selected); }

@media (max-width: 360px) {
  .deck-header:has(.notice:not(:empty)) .brand span { display: none; }
  .deck { padding-inline: 9px; }
  .deck-header { column-gap: 8px; }
  .controls { gap: 6px; }

  .transport, .options { gap: 1px; }
  .speed { width: 40px; }
}

@media (max-width: 300px) {
  .brand span { display: none; }
}

@media (max-width: 250px) {
  .deck { padding-inline: 6px; }
  .skip, .volume summary { width: 26px; }

  .times { font-size: 9px; }
}

@media (max-width: 230px) {
  .deck {
    grid-template-rows: 54px 1fr;
    gap: 3px;
    padding-block: 6px;
  }

  .controls {
    grid-template-columns: 1fr auto;
    grid-template-rows: 29px 34px;
    gap: 0;
  }

  .timeline {
    grid-row: 1;
    grid-column: 1 / -1;
  }

  .play {
    width: 34px;
    height: 34px;
  }

  .play[data-state="loading"]::after { inset: 9px; }
}
