:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  color: #f5f5f5;
  background: #030303;
  color-scheme: dark;
  --bg: #030303;
  --panel: #101010;
  --panel-2: #171717;
  --line: rgba(255,255,255,.10);
  --muted: #a8a8a8;
  --faint: #747474;
  --accent: #ffffff;
  --ok: #8ee8b5;
  --warn: #f0ca77;
  --bad: #ff9ca8;
}

* { box-sizing: border-box; }
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  padding: max(10px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

.app-shell {
  width: min(520px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 14px;
  min-width: 0;
}

.topbar {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}
.brand-copy { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  color: #050505;
  font-weight: 900;
  flex: 0 0 auto;
}
.eyebrow {
  color: #929292;
  font-size: 9px;
  line-height: 1;
  letter-spacing: .14em;
  font-weight: 800;
}
h1 { margin: 3px 0 0; font-size: 15px; line-height: 1.1; font-weight: 750; }
h2 { margin: 4px 0 0; font-size: 18px; line-height: 1.2; }

.badge {
  flex: 0 0 auto;
  max-width: 44vw;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  font-size: 10px;
  font-weight: 750;
}
.badge-ok { color: var(--ok); }
.badge-wait { color: var(--warn); }
.badge-bad { color: var(--bad); }
.badge-idle { color: #c8c8c8; }

.player-card {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 0;
  background: transparent;
}

.art-wrap {
  position: relative;
  width: min(78vw, 330px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 14px;
  background: linear-gradient(135deg, #242424, #101010);
  box-shadow: 0 10px 30px rgba(0,0,0,.28), inset 0 0 0 1px rgba(255,255,255,.05);
}
.artwork { width: 100%; height: 100%; object-fit: cover; display: block; }
.art-placeholder { position: absolute; inset: 0; display: grid; place-items: center; font-size: 64px; color: #666; }
.artwork:not([hidden]) + .art-placeholder { display: none; }

.track-copy { min-width: 0; padding: 0 2px; }
.track-title {
  font-size: 20px;
  line-height: 1.25;
  font-weight: 800;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.track-artist {
  margin-top: 5px;
  color: #d0d0d0;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.requester {
  min-height: 15px;
  margin-top: 4px;
  color: var(--faint);
  font-size: 10.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-wrap { padding: 2px 2px 0; }
.progress-track {
  width: 100%;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #343434;
}
.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #f5f5f5;
  transition: width .18s linear;
}
.time-row {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: #8e8e8e;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.main-actions {
  display: grid;
  grid-template-columns: 44px 64px 44px;
  align-items: center;
  justify-content: center;
  gap: clamp(22px, 9vw, 38px);
  padding: 0 4px;
}
button {
  border: 0;
  color: #f5f5f5;
  cursor: pointer;
}
button:active { transform: scale(.96); }
button:disabled { opacity: .35; cursor: default; }
.round-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  font-size: 21px;
}
.round-button.secondary { color: #dedede; }
.play-button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f5f5f5;
  color: #050505;
  font-size: 25px;
  font-weight: 900;
  box-shadow: 0 8px 22px rgba(0,0,0,.32);
}

.volume-row {
  display: grid;
  grid-template-columns: 20px auto minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0 4px 0 2px;
  color: #8b8b8b;
  font-size: 10px;
}
.volume-icon { font-size: 13px; opacity: .8; }
.volume-name { color: #b8b8b8; font-weight: 750; white-space: nowrap; }
.volume-row input {
  width: 100%;
  min-width: 0;
  min-height: 24px;
  accent-color: #f2f2f2;
}
.volume-row strong { text-align: right; color: #a9a9a9; font-variant-numeric: tabular-nums; }

.queue-card {
  min-width: 0;
  border-top: 1px solid var(--line);
  padding: 12px 0 0;
}
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px 8px;
}
.queue-count { color: #7f7f7f; font-size: 10.5px; white-space: nowrap; }
.queue-list {
  display: grid;
  max-height: min(31dvh, 280px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.queue-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  min-height: 54px;
  padding: 6px 2px;
  border-top: 1px solid rgba(255,255,255,.055);
}
.queue-row:first-child { border-top: 0; }
.queue-thumb {
  width: 42px;
  height: 42px;
  border-radius: 5px;
  object-fit: cover;
  background: #1e1e1e;
}
.queue-thumb-placeholder {
  width: 42px;
  height: 42px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  background: #1e1e1e;
  color: #777;
  font-size: 18px;
}
.queue-copy { min-width: 0; display: grid; gap: 3px; }
.queue-copy strong, .queue-copy span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-copy strong { color: #efefef; font-size: 12.5px; font-weight: 700; }
.queue-copy span { color: #8c8c8c; font-size: 10.5px; }
.empty-row, .more-row { padding: 14px 2px 8px; text-align: center; color: #777; font-size: 11px; }
.more-row { border-top: 1px solid rgba(255,255,255,.055); }

.footer-status {
  display: flex;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  padding: 1px 2px 0;
  color: #585858;
  font-size: 9.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-height: 760px) {
  .app-shell { gap: 10px; }
  .art-wrap { width: min(56vw, 230px); }
  .track-title { font-size: 18px; }
  .queue-list { max-height: min(25dvh, 190px); }
}

@media (max-width: 360px) {
  body { padding-left: 9px; padding-right: 9px; }
  .art-wrap { width: min(76vw, 270px); }
  .track-title { font-size: 18px; }
  .main-actions { grid-template-columns: 40px 58px 40px; gap: 22px; }
  .round-button { width: 40px; height: 40px; }
  .play-button { width: 58px; height: 58px; }
  .badge { max-width: 40vw; }
}

@media (min-width: 760px) {
  body { padding: 18px; }
  .app-shell {
    width: min(980px, 100%);
    grid-template-columns: minmax(300px, 420px) minmax(320px, 1fr);
    grid-template-areas:
      "topbar topbar"
      "player queue"
      "footer footer";
    column-gap: 28px;
    align-items: start;
  }
  .topbar { grid-area: topbar; }
  .player-card { grid-area: player; }
  .queue-card { grid-area: queue; border-top: 0; padding-top: 0; }
  .footer-status { grid-area: footer; }
  .art-wrap { width: min(34vw, 330px); }
  .queue-list { max-height: min(66dvh, 620px); }
  .player-card { gap: 9px; }
  .quick-actions { padding-top: 0; padding-bottom: 1px; }
  .quick-button { flex-basis: 52px; min-height: 46px; }
  .volume-row { margin-top: -2px; }
}

/* Activity shared-controls stage 2 */
:root {
  --sait: var(--discord-safe-area-inset-top, env(safe-area-inset-top));
  --saib: var(--discord-safe-area-inset-bottom, env(safe-area-inset-bottom));
  --sail: var(--discord-safe-area-inset-left, env(safe-area-inset-left));
  --sair: var(--discord-safe-area-inset-right, env(safe-area-inset-right));
}
body {
  padding-top: max(10px, var(--sait));
  padding-right: max(12px, var(--sair));
  padding-bottom: max(14px, var(--saib));
  padding-left: max(12px, var(--sail));
}

.main-actions {
  grid-template-columns: 42px 48px 64px 48px 42px;
  gap: clamp(7px, 4vw, 22px);
}
.transport-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: transparent;
  color: #f4f4f4;
  font-size: 20px;
  font-weight: 750;
}
.transport-button.side {
  width: 42px;
  height: 42px;
  color: #aaa;
  font-size: 19px;
}
.transport-button.active { color: #fff; background: rgba(255,255,255,.08); }

.quick-actions {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 4px;
  overflow: visible;
  padding: 2px 0 5px;
  margin: 0;
}
.quick-button {
  width: 100%;
  min-width: 0;
  min-height: 52px;
  padding: 5px 1px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  background: transparent;
  color: #d8d8d8;
}
.quick-button span { font-size: 18px; line-height: 1; }
.quick-button small { font-size: 9.5px; color: #999; white-space: nowrap; }
.quick-button:active { background: rgba(255,255,255,.08); }
.quick-button.danger span, .quick-button.danger small { color: #d8878f; }

.button-like {
  border: 0;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  color: #aaa;
}

.queue-row {
  grid-template-columns: 42px minmax(0, 1fr) 28px;
  cursor: pointer;
}
.queue-row.selected { background: rgba(255,255,255,.055); }
.queue-tail { color: #777; font-size: 11px; text-align: center; }
.queue-check { width: 18px; height: 18px; accent-color: #fff; justify-self: center; }
.more-row { cursor: pointer; }

.delete-toolbar {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 9px 2px 0;
  background: var(--bg);
  color: #aaa;
  font-size: 11px;
}
.delete-toolbar[hidden] { display: none !important; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 max(0px, var(--sair)) max(0px, var(--saib)) max(0px, var(--sail));
  background: rgba(0,0,0,.60);
  backdrop-filter: blur(3px);
}
.sheet-backdrop[hidden] { display: none !important; }
.sheet {
  width: min(560px, 100%);
  max-height: min(82dvh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.09);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  background: #181818;
  box-shadow: 0 -18px 60px rgba(0,0,0,.5);
}
.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: #5c5c5c;
  margin: 8px auto 2px;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px 9px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h3 { margin: 0; font-size: 17px; line-height: 1.2; }
.sheet-close {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  color: #aaa;
  font-size: 17px;
}
.sheet-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 14px max(14px, var(--saib));
}
.sheet-section, .sheet-form { display: grid; gap: 11px; min-width: 0; }
.sheet-note { color: #9e9e9e; font-size: 11.5px; line-height: 1.45; }
.sheet-input, .sheet-select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 10px;
  outline: none;
  background: #242424;
  color: #f5f5f5;
}
.sheet-input:focus, .sheet-select:focus { border-color: rgba(255,255,255,.42); }
.sheet-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.text-button, .solid-button {
  min-height: 40px;
  padding: 0 13px;
  border-radius: 999px;
  font-weight: 750;
  font-size: 12px;
}
.text-button { background: transparent; color: #d0d0d0; }
.solid-button { background: #f5f5f5; color: #111; }
.danger-solid { background: #d84f5f; color: #fff; }
.sheet-list { display: grid; min-width: 0; }
.sheet-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 10px 2px;
  border-top: 1px solid rgba(255,255,255,.06);
  min-width: 0;
}
.sheet-row:first-child { border-top: 0; }
.sheet-row-copy { display: grid; gap: 3px; min-width: 0; }
.sheet-row-copy strong, .sheet-row-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sheet-row-copy strong { font-size: 12.5px; color: #eee; }
.sheet-row-copy span { font-size: 10.5px; color: #8b8b8b; }
.sheet-row-actions { display: flex; align-items: center; gap: 6px; }
.sheet-check { width: 18px; height: 18px; accent-color: #fff; }
.disclosure {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  color: #aaa;
}
.playlist-tracks {
  grid-column: 1 / -1;
  display: grid;
  margin: 2px 0 0 9px;
  border-left: 2px solid rgba(255,255,255,.08);
  padding-left: 10px;
}
.playlist-tracks[hidden] { display: none !important; }
.playlist-track-row {
  min-height: 38px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  color: #c9c9c9;
  font-size: 11.5px;
}
.playlist-track-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.participant-list { display: grid; gap: 7px; }
.participant-button {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border-radius: 10px;
  text-align: left;
  background: #242424;
  color: #eee;
}

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: max(22px, calc(var(--saib) + 12px));
  transform: translateX(-50%);
  width: max-content;
  max-width: min(88vw, 480px);
  padding: 9px 13px;
  border-radius: 999px;
  background: rgba(245,245,245,.94);
  color: #111;
  font-size: 11.5px;
  font-weight: 700;
  box-shadow: 0 8px 30px rgba(0,0,0,.38);
  text-align: center;
}
.toast[hidden] { display: none !important; }

@media (max-width: 420px) {
  .main-actions { grid-template-columns: 38px 44px 60px 44px 38px; gap: clamp(4px, 3vw, 12px); }
  .transport-button { width: 44px; height: 44px; font-size: 18px; }
  .transport-button.side { width: 38px; height: 38px; font-size: 17px; }
  .play-button { width: 60px; height: 60px; }
  .quick-button { flex-basis: 54px; }
}

@media (max-height: 700px) and (max-width: 759px) {
  .topbar { min-height: 34px; }
  .brand-dot { width: 28px; height: 28px; }
  .art-wrap { width: min(48vw, 190px); }
  .player-card { gap: 8px; }
  .track-title { font-size: 17px; -webkit-line-clamp: 1; }
  .track-artist { margin-top: 3px; font-size: 12px; }
  .requester { margin-top: 2px; }
  .play-button { width: 56px; height: 56px; }
  .main-actions { grid-template-columns: 36px 42px 56px 42px 36px; }
  .quick-button { min-height: 46px; }
  .queue-list { max-height: 22dvh; }
}

/* Discord desktop Activity can reserve a large participant strip at the bottom.
   Keep every playback/action control above that strip on short windows. */
@media (min-width: 760px) and (max-height: 700px) {
  body { padding: 9px 12px; }
  .app-shell { row-gap: 6px; column-gap: 22px; }
  .topbar { min-height: 32px; }
  .brand-dot { width: 28px; height: 28px; }
  .player-card { gap: 5px; }
  .art-wrap { width: min(25vw, 200px); }
  .track-title { font-size: 16px; -webkit-line-clamp: 1; }
  .track-artist { margin-top: 2px; font-size: 11px; }
  .requester { min-height: 12px; margin-top: 1px; font-size: 9.5px; }
  .progress-wrap { padding-top: 0; }
  .time-row { margin-top: 3px; font-size: 9.5px; }
  .main-actions { grid-template-columns: 32px 36px 48px 36px 32px; gap: 8px; }
  .transport-button { width: 36px; height: 36px; font-size: 16px; }
  .transport-button.side { width: 32px; height: 32px; font-size: 15px; }
  .play-button { width: 48px; height: 48px; font-size: 21px; }
  .quick-actions { gap: 2px; padding: 0; }
  .quick-button { min-height: 38px; padding: 2px 1px; gap: 1px; }
  .quick-button span { font-size: 15px; }
  .quick-button small { font-size: 8.5px; }
  .volume-row { min-height: 22px; margin-top: -1px; }
  .volume-row input { min-height: 20px; }
  .queue-list { max-height: min(50dvh, 330px); }
}

/* Mobile Activity compatibility */
html.is-mobile, html.is-mobile body { min-height: 100%; }
html.is-mobile body {
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
html.is-mobile .queue-list,
html.is-mobile .sheet-body {
  -webkit-overflow-scrolling: touch;
}
html.is-mobile button,
html.is-mobile .button-like,
html.is-mobile input[type="range"] {
  min-height: 44px;
}
@media (max-width: 520px) {
  .quick-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 6px; }
  .quick-button { min-height: 48px; }
  .quick-button small { font-size: 10px; }
}
@media (max-width: 340px) {
  body { padding-left: 8px; padding-right: 8px; }
  .quick-actions { gap: 3px; }
  .quick-button small { font-size: 9px; }
}


/* Mobile vertical scrolling: let Discord Activity gestures pass through as page scroll. */
html.is-mobile, html.is-mobile body {
  overflow-y: auto;
  touch-action: pan-y pinch-zoom;
}
html.is-mobile body { overscroll-behavior-y: auto; }
html.is-mobile .app-shell,
html.is-mobile .player-card,
html.is-mobile .track-copy,
html.is-mobile .progress-wrap,
html.is-mobile .quick-actions,
html.is-mobile .queue-card { touch-action: pan-y pinch-zoom; }
html.is-mobile input[type="range"] { touch-action: pan-x; }

.history-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 3px;
  border-radius: 12px;
  background: rgba(255,255,255,.055);
}
.history-tab {
  min-height: 40px;
  border-radius: 9px;
  background: transparent;
  color: #9c9c9c;
  font-size: 12px;
  font-weight: 750;
}
.history-tab.active { background: #f2f2f2; color: #111; }
