/* Palette: 深夜电台 — near-black studio, warm paper text, one amber "on air" lamp. */
:root {
  --bg: #0e0e10;
  --card: #1a1a1e;
  --card-edge: #2a2a2e;
  --line: #2a2a2e;
  --text: #ede6d6;
  --muted: #8a847a;
  --accent: #ff9f1c;
  --accent-ink: #0e0e10;
  --ok: #8fd694;
  --bad: #ff6b5e;
  --field: #0e0e10;
  /* System monospace only: no font files are shipped. CJK falls through to the UI font. */
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 500px at 50% -180px, #241a0c 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
}

[hidden] { display: none !important; }

/* Labels, clocks and counters read like studio equipment; titles and prose stay in the UI font. */
.badge, .eyebrow, .times, .count, .volume output, .queue li::before { font-family: var(--mono); }

.app {
  max-width: 600px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
}

h1, h2, p { margin: 0; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-bottom: 16px;
}

.brand { display: flex; flex: 1; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { font-size: 20px; letter-spacing: 0.04em; white-space: nowrap; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.dot[data-state="online"] { background: var(--ok); box-shadow: 0 0 10px #8fd69480; }
.dot[data-state="offline"] { background: var(--bad); }

.status { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.who { display: flex; flex: none; align-items: center; gap: 8px; max-width: 60%; }
.who .quiet { flex: none; padding: 0 4px 0 8px; white-space: nowrap; }
.who-name { max-width: 7em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

.badge {
  flex: none;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}
.badge[data-role="admin"] { border-color: var(--accent); color: var(--accent); }

.card {
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--card-edge);
  border-radius: 18px;
  background: var(--card);
}

.section-title { display: block; margin-bottom: 10px; font-size: 15px; font-weight: 600; }
.count { color: var(--muted); font-weight: 400; }

.hint { margin-top: 10px; color: var(--muted); font-size: 13px; }
.hint code { padding: 1px 5px; border-radius: 5px; background: var(--field); font: 12px ui-monospace, Menlo, monospace; }

button, input { font: inherit; color: inherit; }

button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.primary { padding: 0 20px; background: var(--accent); color: var(--accent-ink); font-weight: 700; white-space: nowrap; }
.primary:not(:disabled):active { filter: brightness(0.9); }

.secondary { padding: 0 18px; border: 1px solid var(--line); background: var(--field); color: var(--text); white-space: nowrap; }
.secondary:not(:disabled):active { background: var(--line); }

.quiet { padding: 0 12px; background: transparent; color: var(--muted); font-size: 14px; }
.quiet:not(:disabled):hover { color: var(--text); }

input:not([type="range"]) {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field);
}
input::placeholder { color: #5f5b54; }

/* ── login ── */
.login h2 { font-size: 20px; }
.login form { display: grid; gap: 8px; margin-top: 16px; }
.login label { margin-top: 6px; color: var(--muted); font-size: 13px; }
.login .primary { margin-top: 12px; }

.error, .note { min-height: 1.5em; font-size: 14px; }
.error { color: var(--bad); }
.note { margin-top: 8px; color: var(--muted); }
.note[data-kind="error"] { color: var(--bad); }
.note[data-kind="ok"] { color: var(--ok); }

/* ── deck ── */
.deck {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 14px 16px;
  align-items: center;
}

.disc {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle at 50% 50%, #0000 0 3px, #ffffff0d 3px 4px),
    conic-gradient(from 20deg, #17171a, #34343a 12%, #17171a 25%, #2a2a2e 50%, #17171a 62%, #34343a 75%, #17171a);
  box-shadow: 0 0 0 2px #000, 0 10px 26px #0009;
  animation: spin 3.6s linear infinite;
  animation-play-state: paused;
}
.disc-label {
  position: absolute;
  inset: 32%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--bg) 0 14%, var(--accent) 15% 100%);
}
.deck[data-state="playing"] .disc { animation-play-state: running; }
.deck[data-state="idle"] .disc { opacity: 0.45; }
.deck[data-state="idle"] .disc-label { background: radial-gradient(circle, var(--bg) 0 14%, #4a4741 15% 100%); }

@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .disc { animation: none; } }

.deck-info { min-width: 0; }

.eyebrow { color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; }
.deck[data-state="idle"] .eyebrow { color: var(--muted); }
.deck[data-state="paused"] .eyebrow { color: var(--text); }

.now-title { font-size: 19px; line-height: 1.3; overflow-wrap: anywhere; }
.now-title a { color: inherit; text-decoration: none; }
.now-title a[href]:hover { text-decoration: underline; }
.now-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.by { margin-top: 2px; color: var(--muted); font-size: 13px; }

.progress {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}
.progress-fill {
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.5s linear;
}
.times {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  margin-top: -8px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.controls {
  grid-column: 1 / -1;
  display: grid;
  gap: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.transport { display: flex; align-items: center; justify-content: center; gap: 22px; }

.round {
  display: grid;
  place-items: center;
  gap: 2px;
  width: 60px;
  height: 60px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--field);
  color: var(--text);
  font-size: 11px;
}
.round svg { width: 20px; height: 20px; fill: currentColor; }
.round span { margin-top: -6px; color: var(--muted); }
.round:not(:disabled):active { background: var(--line); }

.round.main { width: 72px; height: 72px; border: 0; background: var(--accent); color: var(--accent-ink); }
.round.main svg { width: 30px; height: 30px; }
.round.main:not(:disabled):active { background: var(--accent); filter: brightness(0.9); }
.round.main .icon-play { display: none; }
.round.main[data-mode="play"] .icon-play { display: block; }
.round.main[data-mode="play"] .icon-pause { display: none; }

.volume { display: grid; grid-template-columns: auto minmax(0, 1fr) 2.2em; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.volume output { color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; height: 44px; margin: 0; accent-color: var(--accent); background: transparent; }

/* ── request ── */
.row { display: flex; gap: 10px; }

/* ── upload (DJ only) ── */
.upload { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.upload-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--muted); font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.upload-progress { margin-top: 12px; }
.upload-progress .progress-fill { transition: transform 0.2s linear; }

/* ── library (collapsed until asked for) ── */
.library-card summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  list-style: none;
  cursor: pointer;
}
.library-card summary::-webkit-details-marker { display: none; }
.library-card summary::after { content: "▾"; margin-left: auto; color: var(--muted); transition: transform 0.15s; }
.library-card[open] summary::after { transform: rotate(180deg); }
.library-card summary .section-title { margin: 0; }
.library-card summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.summary-hint { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-card[open] .summary-hint { display: none; }

.tracks { margin: 12px 0 0; padding: 0; list-style: none; }
.tracks li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.tracks .title { overflow-wrap: anywhere; }
.tracks .title:only-of-type { grid-row: 1 / span 2; }
.tracks .meta { grid-column: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tracks .secondary { grid-column: 2; grid-row: 1 / span 2; min-height: 40px; padding: 0 14px; font-size: 14px; }

.pager { display: flex; justify-content: space-between; margin-top: 4px; border-top: 1px solid var(--line); }

/* ── queue ── */
.queue { margin: 0; padding: 0; list-style: none; counter-reset: track; }
.queue li {
  display: grid;
  grid-template-columns: 1.8em minmax(0, 1fr);
  gap: 2px 8px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
  counter-increment: track;
}
.queue li::before { content: counter(track); grid-row: span 2; color: var(--muted); font-variant-numeric: tabular-nums; }
.queue .title { overflow-wrap: anywhere; }
.queue .title a { color: inherit; text-decoration: none; }
.queue .title a:hover { text-decoration: underline; }
.queue .meta { grid-column: 2; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.queue li.pending::before { content: "…"; }
.queue li.pending .title { color: var(--muted); }
.queue li.failed::before { content: "!"; color: var(--bad); }
.queue li.failed .meta { color: var(--bad); white-space: normal; }

.empty { padding: 14px 0 4px; color: var(--muted); font-size: 14px; }

.notice { min-height: 1.5em; margin-top: 4px; color: var(--muted); font-size: 14px; text-align: center; }
.notice[data-kind="error"] { color: var(--bad); }

@media (max-width: 380px) {
  .deck { grid-template-columns: 76px minmax(0, 1fr); }
  .disc { width: 76px; height: 76px; }
  .transport { gap: 16px; }
}

/* ── desktop: the deck and the request box on the left, the queue beside them ── */
@media (min-width: 900px) {
  .app { max-width: 1160px; padding: 28px 32px 40px; }

  .top { margin-bottom: 24px; }
  .brand h1 { font-size: 24px; }
  .status { font-size: 14px; }
  .who { gap: 12px; }
  .who-name { max-width: 16em; font-size: 15px; }

  .login { max-width: 420px; margin: 9vh auto 0; padding: 28px; }

  .desk {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(320px, 5fr);
    gap: 20px;
  }
  .desk-main { display: grid; gap: 20px; align-content: start; min-width: 0; }
  .desk .card { margin-bottom: 0; padding: 24px; }

  .deck { grid-template-columns: 172px minmax(0, 1fr); gap: 22px 28px; }
  .desk .deck { padding: 28px; }
  .disc { width: 172px; height: 172px; }
  .eyebrow { font-size: 13px; }
  .now-title { margin-top: 4px; font-size: 30px; line-height: 1.25; }
  .now-sub { margin-top: 4px; font-size: 15px; }
  .by { margin-top: 6px; font-size: 14px; }
  .progress { height: 8px; border-radius: 4px; }
  .times { margin-top: -12px; font-size: 13px; }

  .controls { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 40px; padding-top: 22px; }
  .transport { justify-content: flex-start; gap: 18px; }
  .volume { max-width: 360px; justify-self: end; width: 100%; font-size: 14px; }

  .request-card .section-title, .queue-card .section-title { font-size: 16px; }
  .request-card input { min-height: 50px; }
  .request-card .primary { padding: 0 28px; }

  /* The queue keeps to the window: a long list scrolls inside its card. */
  .queue-card {
    position: sticky;
    top: 20px;
    display: flex;
    flex-direction: column;
    min-height: 320px;
    max-height: calc(100vh - 136px);
  }
  .queue { flex: 1; min-height: 0; margin: 0 -10px; padding: 0 10px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
  .queue li { padding: 12px 0; }

  /* A full library page would push everything else far down: scroll it in place. */
  .tracks { max-height: 440px; margin-right: -10px; padding-right: 10px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
}

/* Narrow desktop windows: the same two columns with a smaller deck. */
@media (min-width: 900px) and (max-width: 1099px) {
  .deck { grid-template-columns: 132px minmax(0, 1fr); gap: 20px 22px; }
  .disc { width: 132px; height: 132px; }
  .now-title { font-size: 24px; }
  .controls { gap: 24px; }
}

@media (hover: hover) {
  .primary:not(:disabled):hover { filter: brightness(1.08); }
  .round:not(:disabled):hover { border-color: var(--accent); }
  .secondary:not(:disabled):hover { border-color: var(--accent); }
  .round.main:not(:disabled):hover { filter: brightness(1.08); }
  input:not([type="range"]):hover { border-color: #3d3d43; }
}
