/* ==========================================================================
   磁力播放器 — design tokens
   Palette grows out of the brand mark's coral gradient (#e94560 → #ff6b6b).
   Display type: Space Grotesk (geometric, technical).
   Body type: Inter. Data/hashes/speeds: JetBrains Mono — this is a torrent
   client, numbers and hashes are first-class content, not footnotes.

   Layout model: one DOM, two behaviours.
   - Desktop (>=860px): queue + stage side by side, both always visible.
   - Mobile (<860px): queue and stage become full-height "pages" switched
     by a top tab bar (workspace[data-view]) — no overlay/drawer needed.
   Secondary numbers (speed/peers/size) live in a collapsed <details> so
   the essentials (name, progress, controls) stay the focus everywhere.
   ========================================================================== */

:root {
  /* surfaces */
  --void: #0b0b0f;
  --panel: #131318;
  --panel-2: #191921;
  --elevated: #20202a;
  --line: #2a2a35;
  --line-soft: #1e1e27;

  /* text */
  --ink: #ededf0;
  --ink-dim: #9c9ca8;
  --ink-faint: #63636f;

  /* brand */
  --accent: #ff5468;
  --accent-2: #ff8659;
  --accent-soft: rgba(255, 84, 104, 0.14);
  --accent-line: rgba(255, 84, 104, 0.35);

  --gold: #ffb454;
  --good: #3ddc97;
  --good-soft: rgba(61, 220, 151, 0.14);
  --bad: #ff5468;
  --bad-soft: rgba(255, 84, 104, 0.14);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --topbar-h: 60px;
  --tabs-h: 44px;
  --inspector-h: 66px;

  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--void);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(1200px 600px at 15% -10%, rgba(255, 84, 104, 0.06), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(255, 134, 89, 0.05), transparent 55%);
  background-attachment: fixed;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

button { font-family: inherit; }
input, select { font-family: inherit; color: inherit; }

::selection { background: var(--accent-soft); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.is-hidden { display: none !important; }
.only-mobile { display: none; }

/* ==========================================================================
   App shell — plain flex column, no fixed-height tricks
   ========================================================================== */

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-shell:has(.queue-inspector:not(.is-empty)) {
  height: 100dvh;
  min-height: 0;
  padding-bottom: calc(var(--inspector-h) + env(safe-area-inset-bottom));
}

.app-shell:has(.queue-inspector:not(.is-empty)) .queue {
  max-height: calc(100vh - var(--topbar-h) - var(--inspector-h));
}

/* ==========================================================================
   Top bar
   ========================================================================== */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-icon { width: 30px; height: 30px; border-radius: 8px; box-shadow: 0 4px 14px -4px rgba(255, 84, 104, 0.5); flex-shrink: 0; }

.brand-text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-sub {
  margin: 1px 0 0;
  font-size: 10.5px;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.magnet-form {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 220px;
}

.magnet-input-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--void);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  height: 38px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.magnet-input-wrap:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.magnet-icon { color: var(--ink-faint); flex-shrink: 0; }

#magnetInput {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  color: var(--ink);
  font-size: 13px;
  height: 100%;
}
#magnetInput:focus { outline: none; }
#magnetInput::placeholder { color: var(--ink-faint); }

.btn-accent {
  flex-shrink: 0;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a0a0d;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: filter .15s ease, transform .1s ease;
}
.btn-accent:hover { filter: brightness(1.08); }
.btn-accent:active { transform: translateY(1px); }
.btn-accent:disabled { opacity: .5; cursor: default; }

.icon-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink-dim);
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-soft); background: var(--elevated); }
.icon-btn:disabled { opacity: .4; cursor: default; }

/* ---- overflow "more" menu ---- */

.more-wrap { position: relative; flex-shrink: 0; }

.more-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 168px;
  background: var(--elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity .12s ease, transform .12s ease, visibility .12s;
  z-index: 50;
}
.more-menu.is-open { opacity: 1; visibility: visible; transform: translateY(0); }

.more-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--ink-dim);
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
}
.more-menu button:hover { background: var(--panel-2); color: var(--ink); }
.more-menu button.danger:hover { background: var(--bad-soft); color: var(--bad); }
.more-menu button svg { flex-shrink: 0; }

/* ==========================================================================
   Mobile view tabs (queue / player)
   ========================================================================== */

.view-tabs {
  display: none;
  gap: 6px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: var(--topbar-h);
  z-index: 35;
}
.view-tabs button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink-faint);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
}
.view-tabs button.is-active {
  color: var(--accent-2);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

/* ==========================================================================
   Workspace layout
   ========================================================================== */

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 0;
}

/* ---- Queue sidebar ---- */

.queue {
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - var(--topbar-h));
  position: sticky;
  top: var(--topbar-h);
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 16px 10px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-dim);
  flex-shrink: 0;
}

.panel-title strong {
  font-family: var(--font-mono);
  color: var(--accent-2);
  font-size: 13px;
}



.task-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px 16px;
}

.empty-list {
  padding: 24px 12px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 12.5px;
}

/* ---- Task item (generated by renderer.js) ---- */

.task-item {
  display: grid;
  grid-template-columns: 8px 1fr auto 14px;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s ease, border-color .12s ease;
}
.task-item:hover { background: var(--panel-2); }
.task-item.active { background: var(--accent-soft); border-color: var(--accent-line); }
.task-item.expanded { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }

.task-status {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-faint);
  box-shadow: 0 0 0 3px transparent;
}
.task-status.ready { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.task-status.pending { background: var(--gold); animation: pulse-dot 1.6s ease-in-out infinite; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.task-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.task-main strong {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-main span { font-size: 11px; color: var(--ink-faint); font-family: var(--font-mono); }

.task-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.task-side strong { font-size: 12px; font-family: var(--font-mono); color: var(--accent-2); }
.task-side span { font-size: 10.5px; color: var(--ink-faint); font-family: var(--font-mono); }

.task-toggle {
  width: 14px; height: 14px;
  position: relative;
}
.task-toggle::before {
  content: '';
  position: absolute; inset: 0; margin: auto;
  width: 8px; height: 8px;
  border-right: 1.5px solid var(--ink-faint);
  border-bottom: 1.5px solid var(--ink-faint);
  transform: rotate(45deg);
  transition: transform .15s ease;
}
.task-item.expanded .task-toggle::before { transform: rotate(-135deg); }

.task-files {
  padding: 6px 8px 10px;
  margin: -4px 0 6px;
  background: var(--panel-2);
  border: 1px solid var(--accent-line);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.file-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border-radius: 7px;
}
.file-item:hover { background: var(--elevated); }
.file-item.playing { background: var(--accent-soft); }

.file-check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.file-item > span:nth-child(2) { min-width: 0; }
.file-item strong {
  display: block;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-item strong b {
  font-size: 9px;
  font-weight: 700;
  color: var(--accent-2);
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  padding: 1px 4px;
  margin-right: 6px;
  vertical-align: middle;
  text-transform: uppercase;
}
.file-item small { font-size: 10.5px; color: var(--ink-faint); font-family: var(--font-mono); }

.file-meter {
  display: block;
  height: 3px;
  border-radius: 2px;
  background: var(--void);
  overflow: hidden;
  margin-top: 4px;
  font-style: normal;
}
.file-meter em {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.file-actions { flex-shrink: 0; }
.file-play {
  height: 26px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--accent-line);
  background: transparent;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.file-play:hover { background: var(--accent); color: #1a0a0d; }
.file-kind { font-size: 10.5px; color: var(--ink-faint); }

/* ==========================================================================
   Stage
   ========================================================================== */

.stage {
  padding: 20px 24px 26px;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Signature: a projector-frame around the player, referencing the
   sprocket holes of a film strip — this is a video player, after all. */
.player-frame {
  position: relative;
  padding: 0 14px;
  background: #000;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.player-frame::before,
.player-frame::after {
  content: '';
  position: absolute;
  left: 14px; right: 14px;
  height: 12px;
  background-image: radial-gradient(circle, var(--panel) 2.3px, transparent 2.4px);
  background-size: 18px 12px;
  background-repeat: repeat-x;
  background-position: 4px center;
  opacity: .9;
}
.player-frame::before { top: 0; }
.player-frame::after { bottom: 0; }

.player-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 4px;
  overflow: hidden;
  margin: 12px 0;
}

#videoPlayer {
  width: 100%;
  height: 100%;
  display: none;
  background: #000;
}
#videoPlayer.is-active { display: block; }

.player-state {
  position: absolute; inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink-faint);
  text-align: center;
  padding: 20px;
}
.player-state svg { color: var(--ink-faint); }
.player-state strong { color: var(--ink-dim); font-size: 14px; font-weight: 600; font-family: var(--font-display); }
.player-state span { font-size: 12px; max-width: 280px; }

/* ---- Seek panel ---- */

.seek-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 4px;
  flex-shrink: 0;
}
.seek-panel span { font-size: 11.5px; color: var(--ink-faint); width: 46px; flex-shrink: 0; }
.seek-panel span:last-child { text-align: right; }

#seekRange {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  cursor: pointer;
}
#seekRange:disabled { cursor: wait; opacity: .45; }
#seekRange::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--void);
  box-shadow: 0 0 0 2px var(--accent-line);
  margin-top: -4.5px;
}
#seekRange::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--line); }
#seekRange::-moz-range-thumb {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--void);
}
#seekRange::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }

/* ---- Subtitles ---- */

.subtitle-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
  padding: 0 4px;
}

.subtitle-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--elevated);
  color: var(--ink-dim);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .16s, color .16s;
}
.subtitle-trigger:hover { border-color: var(--accent-line); color: var(--ink); }
.subtitle-trigger.is-on { border-color: var(--accent-line); color: var(--ink); background: var(--accent-soft); }
.subtitle-trigger b {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-faint);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.subtitle-trigger.is-on b { color: var(--accent-2); }

.subtitle-delay {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.subtitle-delay button {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
}
.subtitle-delay button:hover { border-color: var(--accent-line); color: var(--ink); }
.subtitle-delay span { font-size: 11.5px; color: var(--ink-dim); min-width: 44px; text-align: center; }

.subtitle-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  flex-shrink: 0;
}
.subtitle-section { display: flex; flex-direction: column; gap: 8px; }
.subtitle-section h4 {
  margin: 0;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.subtitle-list { display: flex; flex-direction: column; gap: 5px; }
.subtitle-empty { font-size: 12px; color: var(--ink-faint); padding: 4px 2px; }

.subtitle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
  background: var(--elevated);
}
.subtitle-row.is-active { border-color: var(--accent-line); background: var(--accent-soft); }

.subtitle-pick, .subtitle-cand {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0;
  font-family: var(--font-body);
  cursor: pointer;
}
.subtitle-cand { cursor: default; }
.subtitle-pick strong, .subtitle-cand strong {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.subtitle-pick small, .subtitle-cand small { font-size: 10.5px; color: var(--ink-faint); }
.subtitle-cand em {
  font-style: normal;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  background: var(--good-soft);
  color: var(--good);
}

.subtitle-btn, .subtitle-drop {
  flex-shrink: 0;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-dim);
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.subtitle-btn:hover { border-color: var(--accent-line); color: var(--ink); }
.subtitle-btn:disabled { opacity: .5; cursor: wait; }
.subtitle-drop:hover { border-color: var(--bad); color: var(--bad); }

/* 不能提取的内嵌轨（图形字幕）占按钮的位置，说明为什么没有按钮。 */
.subtitle-note {
  flex-shrink: 0;
  padding: 5px 10px;
  font-size: 11px;
  color: var(--ink-faint);
}

.subtitle-download {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink-dim);
}
.subtitle-download:hover { border-color: var(--accent-line); color: var(--ink); }
.subtitle-archive-list { display: flex; flex-direction: column; gap: 7px; }
.subtitle-archive-option {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--elevated);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.subtitle-archive-option:hover { border-color: var(--accent-line); }
.subtitle-archive-option:disabled { opacity: .5; cursor: wait; }
.subtitle-archive-option strong { overflow-wrap: anywhere; }
.subtitle-archive-option small { color: var(--ink-faint); }

.subtitle-add { display: flex; flex-direction: column; gap: 7px; }
.subtitle-url-row { display: flex; gap: 7px; }
#subtitleUrlInput {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--void);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 12px;
}
#subtitleUrlInput:focus { outline: none; border-color: var(--accent-line); }
.subtitle-hint { margin: 0; font-size: 10.5px; color: var(--ink-faint); line-height: 1.5; }

/* 字幕本体：默认的 ::cue 在深色片源上偏小、容易糊掉。 */
#videoPlayer::cue {
  background: rgba(0, 0, 0, .62);
  color: #fff;
  font-family: var(--font-body);
  font-size: 1.05em;
  line-height: 1.35;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
}


/* ---- Details card ---- */

.details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  flex-shrink: 0;
}
.details.is-empty { opacity: .55; }

.details-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.eyebrow {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 4px;
}

.details-title { min-width: 0; }
.details-title h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  word-break: break-word;
}
.details-title p {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--ink-faint);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.details-title p:hover { color: var(--accent-2); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink-dim);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
}
.actions button:hover:not(:disabled) { color: var(--ink); border-color: var(--line-soft); background: var(--elevated); }
.actions button:disabled { opacity: .35; cursor: default; }
.actions button.danger:hover:not(:disabled) { color: var(--bad); border-color: var(--bad-soft); background: var(--bad-soft); }

.meter-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.meter { flex: 1; height: 8px; border-radius: 5px; background: var(--void); overflow: hidden; }
#progressFill {
  height: 100%;
  width: 0%;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .4s ease;
}
#progressText { font-size: 12px; color: var(--accent-2); width: 46px; text-align: right; flex-shrink: 0; }

.task-status-message {
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-faint);
}

/* ---- Collapsible stats (secondary info, closed by default on mobile) ---- */

.stats-details {
  margin-top: 12px;
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
}

.stats-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  padding: 4px 2px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-dim);
  letter-spacing: .02em;
  user-select: none;
}
.stats-details summary::-webkit-details-marker { display: none; }
.stats-details summary:hover { color: var(--ink); }
.stats-details .chev { color: var(--ink-faint); transition: transform .15s ease; flex-shrink: 0; }
.stats-details[open] .chev { transform: rotate(180deg); }

.stats {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.stat {
  background: var(--panel-2);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat span { font-size: 10px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .04em; }
.stat strong { font-size: 13px; color: var(--ink); }


/* ==========================================================================
   Login overlay
   ========================================================================== */

.login-overlay {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--void);
  overflow: hidden;
  padding: 20px;
}

.login-atmosphere { position: absolute; inset: 0; pointer-events: none; }
.login-atmosphere span {
  position: absolute;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .5;
  filter: blur(1px);
  animation: drift 14s ease-in-out infinite;
}
.login-atmosphere span:nth-child(1) { top: 20%; left: 12%; animation-delay: 0s; }
.login-atmosphere span:nth-child(2) { top: 65%; left: 22%; animation-delay: -3s; background: var(--accent-2); }
.login-atmosphere span:nth-child(3) { top: 30%; left: 80%; animation-delay: -6s; }
.login-atmosphere span:nth-child(4) { top: 75%; left: 70%; animation-delay: -9s; background: var(--accent-2); }
.login-atmosphere span:nth-child(5) { top: 10%; left: 55%; animation-delay: -2s; }
.login-atmosphere span:nth-child(6) { top: 85%; left: 40%; animation-delay: -11s; background: var(--accent-2); }

@keyframes drift {
  0%, 100% { transform: translate(0, 0); opacity: .35; }
  50% { transform: translate(20px, -30px); opacity: .7; }
}

.login-panel {
  position: relative;
  width: min(360px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px 28px 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.login-icon { width: 52px; height: 52px; border-radius: 14px; margin-bottom: 14px; box-shadow: 0 8px 24px -8px rgba(255, 84, 104, 0.55); }

.login-panel h2 { margin: 0 0 6px; font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.login-panel p { margin: 0 0 20px; font-size: 12.5px; color: var(--ink-faint); }
.login-panel p[data-type="error"] { color: var(--bad); }
.login-panel p[data-type="warning"] { color: var(--gold); }

.login-panel .field {
  width: 100%;
  text-align: left;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.login-panel .field span { font-size: 11px; color: var(--ink-faint); }
.login-panel input {
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--void);
  color: var(--ink);
  padding: 0 12px;
  font-size: 13px;
  width: 100%;
}
.login-panel input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }

.login-panel button {
  width: 100%;
  height: 42px;
  margin-top: 8px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a0a0d;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.login-panel button:hover { filter: brightness(1.08); }
.login-panel button:disabled { opacity: .6; cursor: default; }

/* ==========================================================================
   Toasts
   ========================================================================== */

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  max-width: min(320px, calc(100vw - 32px));
}

.app-shell:has(.queue-inspector:not(.is-empty)) ~ .toast-stack {
  bottom: calc(16px + var(--inspector-h) + env(safe-area-inset-bottom));
}

.toast {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--elevated);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink-faint);
  font-size: 12.5px;
  color: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.warning { border-left-color: var(--gold); }
.toast.error { border-left-color: var(--bad); }

/* ==========================================================================
   Modal / drawer (settings, diagnostics)
   ========================================================================== */

.drawer-overlay {
  position: fixed; inset: 0;
  z-index: 150;
  background: rgba(6, 6, 8, 0.7);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: flex-end;
}

.drawer-panel {
  width: min(440px, 100vw);
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slide-in .2s ease;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.drawer-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.drawer-panel h2 { margin: 0; font-family: var(--font-display); font-size: 16px; }
.drawer-panel header button {
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-dim);
  font-size: 12px;
  cursor: pointer;
}
.drawer-panel header button:hover { color: var(--ink); border-color: var(--line-soft); }

.modal-body { padding: 18px; overflow-y: auto; flex: 1; }

.modal-form { display: flex; flex-direction: column; gap: 10px; }
.modal-form label { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; color: var(--ink-faint); }
.modal-form input, .modal-form select {
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--void);
  color: var(--ink);
  padding: 0 10px;
  font-size: 12.5px;
  font-family: var(--font-mono);
}
.modal-form input:focus, .modal-form select:focus { outline: none; border-color: var(--accent-line); }
.modal-form label.check-row { flex-direction: row; align-items: flex-start; gap: 9px; }
.modal-form label.check-row input[type="checkbox"] {
  height: auto;
  width: 15px;
  flex-shrink: 0;
  margin-top: 1px;
  padding: 0;
  accent-color: var(--accent);
}
.modal-form label.check-row span { display: flex; flex-direction: column; gap: 3px; color: var(--ink-dim); font-size: 12px; }
.modal-form label.check-row small { color: var(--ink-faint); font-size: 10.5px; line-height: 1.5; }
.modal-form.compact { flex-direction: row; flex-wrap: wrap; align-items: center; }
.modal-form.compact input, .modal-form.compact select { flex: 1; min-width: 100px; }

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--ink-faint);
  flex-wrap: wrap;
}
.modal-actions button,
.modal-form button {
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a0a0d;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  flex-shrink: 0;
}
.modal-form button:hover, .modal-actions button:hover { filter: brightness(1.08); }

.modal-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.modal-section h3 { margin: 0 0 12px; font-size: 13px; font-family: var(--font-display); color: var(--ink-dim); }

.modal-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  flex-wrap: wrap;
}
.user-actions { display: flex; gap: 6px; flex-shrink: 0; }
.user-actions button {
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-faint);
  font-size: 10.5px;
  cursor: pointer;
}
.user-actions button:hover:not(:disabled) { color: var(--bad); border-color: var(--bad-soft); }
.user-actions button:disabled { opacity: .35; cursor: default; }

.diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}
.diagnostics-grid span {
  background: var(--panel-2);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10.5px;
  color: var(--ink-faint);
}
.diagnostics-grid strong { font-size: 14px; color: var(--ink); font-family: var(--font-mono); }

.diagnostics-box {
  background: var(--void);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-dim);
  overflow-x: auto;
  white-space: pre;
  margin: 0 0 16px;
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.log-list span {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-faint);
  padding: 4px 8px;
  border-radius: 5px;
  background: var(--panel-2);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==========================================================================
   Scrollbars
   ========================================================================== */

* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--line-soft); }

/* ==========================================================================
   Responsive — tablet
   ========================================================================== */

@media (max-width: 1080px) {
  .workspace { grid-template-columns: 280px 1fr; }
}

/* ==========================================================================
   Responsive — mobile: workspace becomes a single tab-switched pane
   ========================================================================== */

@media (max-width: 860px) {
  :root { --topbar-h: 56px; }

  .only-mobile { display: flex; }
  .view-tabs { display: flex; }

  .topbar { padding: 8px 12px; gap: 10px; }
  .brand-sub { display: none; }
  .magnet-form { min-width: 0; }
  #magnetInput { font-size: 13px; }
  .btn-accent { padding: 0 12px; font-size: 12.5px; }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  .queue,
  .stage {
    max-height: none;
    height: 100%;
    position: static;
  }

  /* only one pane visible at a time, controlled by workspace[data-view] */
  .workspace[data-view="queue"] .stage { display: none; }
  .workspace[data-view="player"] .queue { display: none; }

  .stage { padding: 14px; }

  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 420px) {
  .brand-text h1 { font-size: 13.5px; }
  .toast-stack { left: 12px; right: 12px; max-width: none; }
}

/* ==========================================================================
   Queue-owned task controls and inspector
   ========================================================================== */

.task-item {
  grid-template-columns: 8px minmax(0, 1fr) auto 28px 14px;
}

.task-menu-trigger {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  opacity: .45;
}
.task-item:hover .task-menu-trigger,
.task-item.active .task-menu-trigger,
.task-menu-trigger:focus-visible { opacity: 1; }
.task-menu-trigger:hover { color: var(--ink); background: var(--elevated); }
.task-menu-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.queue-inspector {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 70;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  box-shadow: 0 -10px 24px rgba(0, 0, 0, .12);
}
.queue-inspector.is-empty { display: none; }
.queue-inspector-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.queue-inspector .details-title h2 { font-size: 13px; }
.inspector-progress { color: var(--accent-2); font-size: 12px; flex-shrink: 0; }
.queue-inspector .meter-row { margin-top: 12px; }
.queue-inspector .task-status-message { margin-top: 8px; }
.stats-heading {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  color: var(--ink-dim);
  font-size: 10.5px;
  font-weight: 600;
}
.queue-inspector .stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 8px;
}
.queue-inspector .stat {
  padding: 8px 10px;
  background: var(--panel);
}

.task-context-menu {
  position: fixed;
  z-index: 240;
  display: none;
  min-width: 176px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--elevated);
  box-shadow: var(--shadow);
}
.task-context-menu.is-open { display: block; }
.task-context-menu button {
  width: 100%;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-dim);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}
.task-context-menu button:hover:not(:disabled),
.task-context-menu button:focus-visible:not(:disabled) {
  color: var(--ink);
  background: var(--panel-2);
  outline: none;
}
.task-context-menu button:disabled { opacity: .35; cursor: default; }
.task-context-menu button.danger { color: var(--bad); }
.task-context-menu button.danger:hover,
.task-context-menu button.danger:focus-visible { background: var(--bad-soft); }
.menu-separator { height: 1px; margin: 5px 4px; background: var(--line); }

@media (hover: none), (pointer: coarse) {
  .task-menu-trigger { opacity: 1; }
}

@media (max-width: 860px) {
  .queue-inspector { max-height: none; }
}
/* Compact queue inspector */
.queue-inspector {
  overflow: hidden;
  padding: 8px 10px calc(9px + env(safe-area-inset-bottom));
}
.queue-inspector-head {
  align-items: center;
  gap: 10px;
}
.queue-inspector .task-status-message {
  min-width: 0;
  max-width: 42%;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inspector-meter {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}
.inspector-meter .meter { min-width: 0; }
.inspector-progress { width: auto; }
.queue-inspector .stats {
  display: flex;
  flex-wrap: nowrap;
  gap: 1px;
  margin: 7px -10px -9px;
  overflow-x: auto;
  border: 0;
  border-radius: 0;
  scrollbar-width: none;
}
.queue-inspector .stats::-webkit-scrollbar { display: none; }
.queue-inspector .stat {
  flex: 0 0 auto;
  min-width: max-content;
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
  padding: 7px 10px;
  white-space: nowrap;
}
.queue-inspector .stat span { font-size: 9.5px; }
.queue-inspector .stat strong { font-size: 12px; }
@media (max-width: 860px) {
  .queue-inspector { max-height: none; }
}
/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .login-atmosphere span { animation: none; opacity: .35; }
  .task-status.pending { animation: none; }
  .drawer-panel { animation: none; }
  #progressFill { transition: none; }
}
