/*
 * Lauchschranzler – redesign shell.
 * Provides the new TopBar + SideRail + theming layer.
 * Existing DaisyUI page content keeps working inside .app-content
 * during the migration; Sub-Phase 2/3 will replace those classes.
 */

:root {
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  /* British Racing Green base, brass accent (design defaults). */
  --bg: #030806;
  --surface: #06120c;
  --surface-2: #091a12;
  --surface-hover: #0d2419;
  --surface-header: #07150e;
  --border: #122a1f;
  --border-strong: #1c4030;
  --fg: #e6ede8;
  --fg-2: #8aa294;
  --fg-3: #4a6557;

  --accent: oklch(0.68 0.2 290);
  --accent-fg: #fff;
  --success: oklch(0.74 0.16 152);
  --warn: oklch(0.78 0.14 75);
  --danger: oklch(0.66 0.22 25);
  --info: oklch(0.72 0.13 230);

  --r-card: 12px;
  --r-btn: 8px;
}

*, *::before, *::after { box-sizing: border-box; }
button { font-family: inherit; }

::selection { background: color-mix(in oklch, var(--accent) 40%, transparent); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Base shell — overrides DaisyUI's body styling so the new theme shows through. */
html, body {
  background: var(--bg) !important;
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* === Layout shell ====================================================== */

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

.app-main-row {
  display: flex;
  flex: 1;
  min-height: 0;
}

.app-content {
  flex: 1;
  padding: 32px 40px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 900px) {
  .app-content { padding: 20px 16px; }
}

/* === TopBar ============================================================ */

.app-topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklch, var(--surface) 80%, transparent);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.app-logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklch, var(--accent) 50%, black));
  display: grid;
  place-items: center;
  color: var(--accent-fg);
  box-shadow: 0 0 12px color-mix(in oklch, var(--accent) 30%, transparent);
}

.app-logo-name {
  font: 600 14px/1 var(--sans);
  letter-spacing: 0.01em;
}

.app-nav {
  display: flex;
  gap: 2px;
  margin-left: 16px;
}

.app-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--fg-2);
  font: 500 13px/1 var(--sans);
  cursor: pointer;
  transition: all 120ms;
  text-decoration: none;
}

.app-nav-link:hover { color: var(--fg); }
.app-nav-link.is-active {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--fg);
}

.app-topbar-spacer { flex: 1; }

.app-user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font: 500 12px/1 var(--sans);
}

.app-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-2);
  cursor: pointer;
  transition: all 120ms;
}
.app-icon-btn:hover { color: var(--fg); background: var(--surface-2); border-color: var(--border); }

/* === SideRail ========================================================== */

.app-siderail {
  width: 240px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: color-mix(in oklch, var(--surface) 50%, var(--bg));
}

@media (max-width: 1100px) {
  .app-siderail { display: none; }
}

.app-siderail-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font: 500 11px/1 var(--sans);
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.app-siderail-divider {
  height: 1px;
  background: var(--border);
}

.app-online-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.app-online-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  transition: background 80ms;
}
.app-online-row:hover { background: var(--surface-2); }

.app-online-avatar {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: color-mix(in oklch, var(--accent) 24%, var(--surface-2));
  color: var(--fg);
  display: grid;
  place-items: center;
  font: 600 11px/1 var(--sans);
  flex-shrink: 0;
}
.app-online-avatar::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--success);
  border: 2px solid var(--bg);
}

.app-online-name {
  font: 500 12px/1 var(--sans);
  color: var(--fg);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-channel-card {
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: 400 12px/1.4 var(--mono);
  color: var(--fg-2);
}
.app-channel-card .name {
  color: var(--fg);
  font-weight: 500;
  margin-bottom: 4px;
}
.app-channel-card .addr { color: var(--fg-3); }
.app-channel-card .empty { color: var(--fg-3); font-style: italic; }

.app-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.app-stat-row .label { font: 400 12px/1 var(--sans); color: var(--fg-3); }
.app-stat-row .value { font: 500 13px/1 var(--mono); color: var(--fg); }

/* === Pill ============================================================== */

.app-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font: 500 11px/1.4 var(--mono);
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: color-mix(in oklch, var(--fg) 8%, transparent);
  color: var(--fg-2);
  border: 1px solid color-mix(in oklch, var(--fg) 12%, transparent);
}
.app-pill--accent {
  background: color-mix(in oklch, var(--accent) 14%, transparent);
  color: var(--accent);
  border-color: color-mix(in oklch, var(--accent) 28%, transparent);
}
.app-pill--success {
  background: color-mix(in oklch, var(--success) 14%, transparent);
  color: var(--success);
  border-color: color-mix(in oklch, var(--success) 28%, transparent);
}
.app-pill--warn {
  background: color-mix(in oklch, var(--warn) 14%, transparent);
  color: var(--warn);
  border-color: color-mix(in oklch, var(--warn) 30%, transparent);
}
.app-pill--danger {
  background: color-mix(in oklch, var(--danger) 14%, transparent);
  color: var(--danger);
  border-color: color-mix(in oklch, var(--danger) 28%, transparent);
}
.app-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

/* === Card =============================================================== */

.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  overflow: hidden;
  margin-bottom: 16px;
}

.app-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-header);
}

.app-card-header h2 {
  margin: 0;
  font: 600 13px/1 var(--sans);
  letter-spacing: 0.02em;
  color: var(--fg);
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.app-card-header h2 .icon { color: var(--fg-3); display: inline-flex; }

.app-card-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.app-card-body { padding: 18px; }
.app-card-body--flush { padding: 0; }

/* === Buttons ============================================================ */

.app-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--r-btn);
  font: 500 13px/1 var(--sans);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--fg);
  transition: background 120ms, border-color 120ms;
  white-space: nowrap;
}
.app-btn:hover { background: var(--surface-hover); }
.app-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.app-btn--sm { height: 28px; padding: 0 10px; font-size: 12px; gap: 6px; }
.app-btn--lg { height: 44px; padding: 0 18px; font-size: 14px; gap: 10px; }

.app-btn--primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: color-mix(in oklch, var(--accent) 60%, white 10%);
}
.app-btn--primary:hover { background: color-mix(in oklch, var(--accent) 90%, white 10%); }

.app-btn--danger {
  background: color-mix(in oklch, var(--danger) 12%, transparent);
  color: color-mix(in oklch, var(--danger) 90%, white);
  border-color: color-mix(in oklch, var(--danger) 30%, transparent);
}
.app-btn--danger:hover { background: color-mix(in oklch, var(--danger) 20%, transparent); }

.app-btn--success {
  background: color-mix(in oklch, var(--success) 14%, transparent);
  color: color-mix(in oklch, var(--success) 95%, white);
  border-color: color-mix(in oklch, var(--success) 32%, transparent);
}
.app-btn--success:hover {
  background: color-mix(in oklch, var(--success) 22%, transparent);
  border-color: color-mix(in oklch, var(--success) 45%, transparent);
}

.app-btn--warn {
  background: color-mix(in oklch, var(--warn) 14%, transparent);
  color: color-mix(in oklch, var(--warn) 95%, white);
  border-color: color-mix(in oklch, var(--warn) 32%, transparent);
}
.app-btn--warn:hover {
  background: color-mix(in oklch, var(--warn) 22%, transparent);
  border-color: color-mix(in oklch, var(--warn) 45%, transparent);
}

.app-btn--info {
  background: color-mix(in oklch, var(--info) 14%, transparent);
  color: color-mix(in oklch, var(--info) 95%, white);
  border-color: color-mix(in oklch, var(--info) 32%, transparent);
}
.app-btn--info:hover {
  background: color-mix(in oklch, var(--info) 22%, transparent);
  border-color: color-mix(in oklch, var(--info) 45%, transparent);
}

.app-btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--fg-2);
}
.app-btn--ghost:hover { background: var(--surface-2); border-color: var(--border); color: var(--fg); }

/* Hover tones — apply to .app-btn--ghost (or any btn) to colorize on hover. */
.app-btn--hover-danger:hover {
  background: color-mix(in oklch, var(--danger) 16%, transparent);
  border-color: color-mix(in oklch, var(--danger) 32%, transparent);
  color: color-mix(in oklch, var(--danger) 95%, white);
}
.app-btn--hover-info:hover {
  background: color-mix(in oklch, var(--info) 16%, transparent);
  border-color: color-mix(in oklch, var(--info) 32%, transparent);
  color: color-mix(in oklch, var(--info) 95%, white);
}
.app-btn--hover-success:hover {
  background: color-mix(in oklch, var(--success) 16%, transparent);
  border-color: color-mix(in oklch, var(--success) 32%, transparent);
  color: color-mix(in oklch, var(--success) 95%, white);
}
.app-btn--hover-warn:hover {
  background: color-mix(in oklch, var(--warn) 16%, transparent);
  border-color: color-mix(in oklch, var(--warn) 32%, transparent);
  color: color-mix(in oklch, var(--warn) 95%, white);
}

.app-btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
}

/* Segmented transport (Play / Stop / Skip) */
.app-transport {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.app-transport > button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  background: transparent;
  border: none;
  color: var(--fg);
  font: 500 13px/1 var(--sans);
  cursor: pointer;
  transition: background 100ms;
}
.app-transport > button:hover { background: var(--surface-hover); }
.app-transport > button.is-primary {
  background: var(--accent);
  color: var(--accent-fg);
}
.app-transport > button.is-primary:hover { background: color-mix(in oklch, var(--accent) 90%, white 10%); }
.app-transport > .divider { width: 1px; background: var(--border); }

/* === Input ============================================================== */

.app-input {
  height: 38px;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font: 400 13px/1 var(--sans);
  outline: none;
  width: 100%;
  transition: border-color 120ms, box-shadow 120ms;
}
.app-input:focus {
  border-color: color-mix(in oklch, var(--accent) 60%, transparent);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--accent) 14%, transparent);
}

.app-input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.app-select {
  height: 38px;
  padding: 0 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font: 400 13px/1 var(--sans);
  outline: none;
  cursor: pointer;
}
.app-select:focus { border-color: color-mix(in oklch, var(--accent) 60%, transparent); }
.app-select--sm { height: 28px; font-size: 12px; }

.app-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.app-field-label {
  font: 500 11px/1 var(--sans);
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.app-form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.app-form-row > .app-btn { align-self: flex-end; }

.app-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.app-source-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.app-source-item .badge-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.app-source-item .badge-icon.is-active {
  background: color-mix(in oklch, var(--accent) 16%, transparent);
  color: var(--accent);
}
.app-source-item .badge-icon.is-inactive {
  background: color-mix(in oklch, var(--fg) 6%, transparent);
  color: var(--fg-3);
}
.app-source-item .meta { flex: 1; min-width: 0; }
.app-source-item .meta .name { font: 500 13px/1.2 var(--sans); color: var(--fg); }
.app-source-item .meta .desc { font: 400 11px/1.4 var(--mono); color: var(--fg-3); margin-top: 2px; }

.app-table {
  width: 100%;
  border-collapse: collapse;
  font: 400 13px/1.4 var(--sans);
}
.app-table th {
  text-align: left;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  font: 500 11px/1 var(--sans);
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-header);
}
.app-table td {
  padding: 10px 18px;
  border-bottom: 1px solid color-mix(in oklch, var(--border) 50%, transparent);
  color: var(--fg);
}
.app-table tr:last-child td { border-bottom: none; }
.app-table tr:hover td { background: var(--surface-hover); }
.app-table .muted { color: var(--fg-3); font-family: var(--mono); font-size: 12px; }

/* === Login layout ====================================================== */

.app-login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.app-login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 28px;
}
.app-login-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.app-login-header .logo {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), color-mix(in oklch, var(--accent) 50%, black));
  display: grid;
  place-items: center;
  color: var(--accent-fg);
  box-shadow: 0 0 20px color-mix(in oklch, var(--accent) 25%, transparent);
}
.app-login-header h1 { margin: 0; font: 600 18px/1 var(--sans); color: var(--fg); }

.app-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  font: 500 11px/1 var(--sans);
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.app-divider::before, .app-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.app-alert {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
  font: 400 13px/1.4 var(--sans);
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-alert--error {
  background: color-mix(in oklch, var(--danger) 14%, transparent);
  color: color-mix(in oklch, var(--danger) 90%, white);
  border: 1px solid color-mix(in oklch, var(--danger) 30%, transparent);
}
.app-alert--success {
  background: color-mix(in oklch, var(--success) 14%, transparent);
  color: color-mix(in oklch, var(--success) 90%, white);
  border: 1px solid color-mix(in oklch, var(--success) 30%, transparent);
}

.app-info-row {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: 400 12px/1.5 var(--sans);
  color: var(--fg-2);
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-info-row .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  flex-shrink: 0;
}
.app-info-row .strong { color: var(--fg); font: 500 12px/1 var(--mono); }
.app-info-row .muted { color: var(--fg-3); font: 400 12px/1 var(--mono); }

/* === Player Card ======================================================== */

.app-now-playing {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 20px 22px 8px;
}

.app-album-art {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 8px;
  background:
    repeating-linear-gradient(45deg, color-mix(in oklch, var(--fg) 5%, transparent) 0 6px, color-mix(in oklch, var(--fg) 8%, transparent) 6px 7px),
    var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--fg-3);
  font: 500 9px/1.2 var(--mono);
  text-align: center;
  letter-spacing: 0.04em;
  overflow: hidden;
}
.app-album-art--yt { background: #0a0a0a; }
.app-album-art--img { background: var(--surface-2); padding: 0; }
.app-album-art--img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.app-now-meta {
  flex: 1;
  min-width: 0;
}
.app-now-title {
  margin: 0;
  font: 600 18px/1.3 var(--sans);
  color: var(--fg);
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-now-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  font: 400 13px/1 var(--sans);
  color: var(--fg-2);
}
.app-now-sub .dotsep {
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: var(--fg-3);
}
.app-now-sub .bpm { font: 500 11px/1 var(--mono); color: var(--fg-3); }
.app-now-sub .by { color: var(--fg-2); }

.app-time-readout {
  text-align: right;
  flex-shrink: 0;
}
.app-time-readout .now {
  font: 500 22px/1 var(--mono);
  color: var(--fg);
  letter-spacing: -0.01em;
}
.app-time-readout .total {
  font: 400 12px/1 var(--mono);
  color: var(--fg-3);
  margin-top: 4px;
}

.app-waveform-wrap { padding: 14px 22px 16px; }
.app-waveform {
  position: relative;
  height: 64px;
  cursor: pointer;
  user-select: none;
}
.app-waveform .hover-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--fg);
  opacity: 0.35;
  pointer-events: none;
  display: none;
}
.app-waveform:hover .hover-line { display: block; }
.app-waveform .hover-tip {
  position: absolute;
  top: -22px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 2px 6px;
  font: 500 10px/1 var(--mono);
  color: var(--fg);
  pointer-events: none;
  white-space: nowrap;
  transform: translateX(-50%);
  display: none;
}
.app-waveform:hover .hover-tip { display: block; }
.app-waveform svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.app-controls-bar {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: color-mix(in oklch, black 18%, transparent);
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-auto-rows: 36px;
  align-items: center;
  gap: 14px;
}
.app-transport-row { display: flex; gap: 8px; }
.app-transport { line-height: 1; height: 36px; }
.app-transport > button { height: 36px; padding: 0 14px; font-size: 13px; line-height: 1; gap: 6px; }
.app-transport > button.is-primary { padding: 0 16px; }
.app-volume { height: 36px; }
.app-volume input[type="range"] { display: block; }

/* Volume */
.app-volume {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 200px;
}
.app-volume-track {
  flex: 1;
  height: 4px;
  background: color-mix(in oklch, var(--fg) 10%, transparent);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
}
.app-volume-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--fg-2);
  border-radius: 999px;
  pointer-events: none;
}
.app-volume input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 18px;
  margin: 0;
}
.app-volume input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: color-mix(in oklch, var(--fg) 10%, transparent);
  border-radius: 999px;
}
.app-volume input[type="range"]::-moz-range-track {
  height: 4px;
  background: color-mix(in oklch, var(--fg) 10%, transparent);
  border-radius: 999px;
}
.app-volume input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 999px;
  margin-top: -5px;
  cursor: pointer;
}
.app-volume input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 999px;
  border: none;
  cursor: pointer;
}
.app-volume .label {
  font: 500 11px/1 var(--mono);
  color: var(--fg-3);
  width: 32px;
  text-align: right;
}

/* === Queue rows ========================================================= */

.app-queue-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid color-mix(in oklch, var(--border) 60%, transparent);
  cursor: grab;
  transition: background 80ms;
}
.app-queue-row:hover { background: var(--surface-hover); }
.app-queue-row:last-child { border-bottom: none; }
.app-queue-row .handle { color: var(--fg-3); display: inline-flex; flex-shrink: 0; }
.app-queue-row .num { width: 20px; text-align: center; font: 500 12px/1 var(--mono); color: var(--fg-3); }
.app-queue-row .title {
  flex: 1;
  min-width: 0;
  font: 500 13px/1.3 var(--sans);
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-queue-row .duration { font: 400 12px/1 var(--mono); color: var(--fg-3); width: 44px; text-align: right; }
.app-queue-row .pending { font: 400 11px/1 var(--sans); color: var(--fg-3); font-style: italic; }
.app-queue-row .by-tag { font: 400 11px/1 var(--sans); color: var(--fg-3); flex-shrink: 0; }

.app-empty {
  padding: 24px 18px;
  text-align: center;
  color: var(--fg-3);
  font: 400 13px/1.5 var(--sans);
}
.app-empty .icon { opacity: 0.4; margin-bottom: 8px; display: inline-block; }

/* === History table ====================================================== */

.app-history-table { display: flex; flex-direction: column; }
.app-history-head,
.app-history-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 110px 130px 120px 90px;
  gap: 12px;
  align-items: center;
  padding: 10px 18px;
}
.app-history-head {
  border-bottom: 1px solid var(--border);
  font: 500 11px/1 var(--sans);
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.app-history-row {
  border-bottom: 1px solid color-mix(in oklch, var(--border) 50%, transparent);
  transition: background 80ms;
}
.app-history-row:hover { background: var(--surface-hover); }
.app-history-row:last-child { border-bottom: none; }
.app-history-row .num { font: 500 11px/1 var(--mono); color: var(--fg-3); text-align: center; }
.app-history-row .title-cell {
  font: 400 13px/1.4 var(--sans);
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.app-history-row .by { font: 400 12px/1 var(--sans); color: var(--fg-2); }
.app-history-row .at { font: 400 12px/1 var(--mono); color: var(--fg-3); }
.app-history-row .actions { display: flex; gap: 4px; justify-content: flex-end; opacity: 0.4; transition: opacity 100ms; }
.app-history-row:hover .actions { opacity: 1; }

.app-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font: 400 12px/1 var(--mono);
  color: var(--fg-3);
}
.app-pagination .page-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-2);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}
.app-pagination .page-btn:hover { background: var(--surface-2); }
.app-pagination .page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* === Mobile (≤ 768px) =================================================== */

/* Default state: hide mobile-only chrome on desktop. */
.app-mobile-only { display: none; }
.app-bottom-nav { display: none; }
.app-mobile-drawer { display: none; }
.app-history-row .meta { display: none; }
.app-queue-row .meta { display: none; }

@media (max-width: 768px) {
  /* Show mobile chrome, hide desktop nav. */
  .app-mobile-only { display: inline-flex; }
  .app-nav { display: none; }
  .app-user-pill { display: none; }

  /* Compact topbar — leaves room for logo + status + trigger + logout. */
  .app-topbar { padding: 0 12px; gap: 12px; }
  .app-logo-name { font-size: 13px; }
  .app-pill { font-size: 10px; padding: 2px 6px; }

  .app-content { padding: 14px 12px; padding-bottom: 80px; }
  .app-card-body { padding: 14px; }
  .app-card-header { padding: 10px 14px; }

  /* Section visibility: only the active tab's content shows. */
  body[data-tab="queue"] #player-section,
  body[data-tab="queue"] #add-section,
  body[data-tab="queue"] #history-section { display: none; }

  body[data-tab="history"] #player-section,
  body[data-tab="history"] #add-section,
  body[data-tab="history"] #queue-section { display: none; }

  /* Player tab: full player + add + queue (matches mockup). History hidden. */
  body[data-tab="player"] #history-section { display: none; }

  /* Transport buttons → circular icon-only on mobile. */
  .app-transport-row { gap: 12px; justify-content: center; }
  .app-transport-row .app-btn {
    width: 44px; height: 44px;
    padding: 0;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .app-transport-row .app-btn .label { display: none; }
  .app-transport-row #player-toggle {
    width: 56px; height: 56px;
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-fg);
  }
  /* Speed selector hidden on mobile — keeps the transport row clean. */
  .app-transport-row label[title="Playback speed"] { display: none; }

  /* Controls bar: stack volume below transport on mobile. */
  .app-controls-bar {
    grid-template-columns: 1fr !important;
    grid-auto-rows: auto !important;
    gap: 12px;
    padding: 16px 14px;
  }
  .app-volume { width: 100%; justify-content: center; }
  .app-volume input[type="range"] { flex: 1; }

  /* Bottom nav. */
  .app-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 64px;
    background: color-mix(in oklch, var(--surface) 90%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    z-index: 20;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .app-bottom-nav .bn-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--fg-3);
    text-decoration: none;
    font: 500 11px/1 var(--sans);
    padding: 8px 0;
    border-top: 2px solid transparent;
  }
  .app-bottom-nav .bn-link .material-symbols-outlined { font-size: 22px; }
  .app-bottom-nav .bn-link.is-active {
    color: var(--accent);
    border-top-color: var(--accent);
  }

  /* Online-users drawer. */
  .app-mobile-drawer { display: block; position: fixed; inset: 0; z-index: 30; pointer-events: none; }
  .app-mobile-drawer.is-open { pointer-events: auto; }
  .app-mobile-drawer-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 180ms;
  }
  .app-mobile-drawer.is-open .app-mobile-drawer-backdrop { opacity: 1; }
  .app-mobile-drawer-panel {
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: min(82vw, 320px);
    background: var(--surface);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 200ms ease-out;
    display: flex; flex-direction: column;
  }
  .app-mobile-drawer.is-open .app-mobile-drawer-panel { transform: translateX(0); }
  .app-mobile-drawer-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font: 600 14px/1 var(--sans);
  }
  .app-mobile-drawer-body { flex: 1; overflow-y: auto; padding: 12px; }

  /* Queue rows on mobile: hide drag handle + by-tag + pill + duration,
     render them as meta inside the title cell instead. */
  .app-queue-row {
    padding: 10px 12px;
    gap: 10px;
  }
  .app-queue-row .handle,
  .app-queue-row .by-tag,
  .app-queue-row .app-pill,
  .app-queue-row .duration { display: none; }
  .app-queue-row .title { white-space: normal; overflow: visible; text-overflow: clip; }
  .app-queue-row .title .title-text {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .app-queue-row .meta {
    display: block;
    font: 400 11px/1.3 var(--mono);
    color: var(--fg-3);
    margin-top: 2px;
  }

  /* History rows collapse to: num | title+meta | actions on mobile. */
  .app-history-head { display: none; }
  .app-history-row {
    grid-template-columns: 24px minmax(0, 1fr) auto;
    padding: 10px 12px;
    gap: 10px;
  }
  /* Hide separate Source/By/At cells — render them inline via ::after. */
  .app-history-row > span:nth-child(3),
  .app-history-row > span:nth-child(4),
  .app-history-row > span:nth-child(5) { display: none; }
  .app-history-row .title-cell { white-space: normal; }
  /* The title cell already contains the title text; inject source + date as sub via JS-free trick.
     We add an extra <span class="meta"> in mobile pass — see partials/history.html update. */
  .app-history-row .meta {
    display: block;
    font: 400 11px/1.3 var(--mono);
    color: var(--fg-3);
    margin-top: 2px;
  }
}
