/* The DJ page wears the music catalog's (Chocobox's) iTunes-era layout: a
   transport bar over a source list, a column browser and a track table.
   Colors are tokens, so the dark theme changes surfaces, not rules. */

:root {
  --row-h: 20px;
  --sidebar-w: 210px;
  --browser-h: 170px;
  --w-num: 38px;
  --w-name: 340px;
  --w-time: 56px;
  --w-artist: 210px;
  --w-album: 230px;

  color-scheme: light dark;
  --s-white: #fff;          --s-page: #f0f0f0;
  --s-chrome-hi: #fbfbfb;   --s-chrome-lo: #d8d8d8;
  --s-raised-hi: #fdfdfd;   --s-raised-lo: #e4e4e4;
  --s-pressed-hi: #d0d0d0;  --s-pressed-lo: #bcbcbc;
  --s-head-hi: #f7f9fb;     --s-head-lo: #dfe4ea;
  --s-panel: #eef1f5;       --s-sidebar: #d6dde7;
  --s-lcd-hi: #e9eef5;      --s-lcd-lo: #dfe6ef;
  --s-slot: #d2d9e2;        --stripe: #f2f6fd;

  --line: #c8c8c8;          --line-soft: #c9ced4;
  --line-faint: #e3e7ec;    --line-strong: #a2a2a2;

  --text: #1a1a1a;          --text-panel: #33393f;
  --text-2: #4a5561;        --text-3: #6b7480;
  --text-4: #78818d;

  --sel: #3875d7;           --sel-text: #fff;
  --accent: #1a5fb4;        --bad: #a01b1b;         --good: #2f7d4f;
  --on-air: #c0392b;

  --chrome: linear-gradient(var(--s-chrome-hi), var(--s-chrome-lo));
}

@media (prefers-color-scheme: dark) {
  :root {
    --s-white: #23262b;       --s-page: #1c1f23;
    --s-chrome-hi: #35393f;   --s-chrome-lo: #24272c;
    --s-raised-hi: #3a3e45;   --s-raised-lo: #2a2e33;
    --s-pressed-hi: #22252a;  --s-pressed-lo: #1a1d21;
    --s-head-hi: #33373d;     --s-head-lo: #24282d;
    --s-panel: #26292e;       --s-sidebar: #22262c;
    --s-lcd-hi: #2b3037;      --s-lcd-lo: #23272d;
    --s-slot: #31363d;        --stripe: #23282f;
    --line: #3a3f45;          --line-soft: #333940;
    --line-faint: #2b2f35;    --line-strong: #4a5058;
    --text: #e6e8ea;          --text-panel: #dcdfe3;
    --text-2: #b6bcc4;        --text-3: #949ba4;
    --text-4: #7f868f;
    --sel: #3b6fc4;           --sel-text: #fff;
    --accent: #6ea8f0;        --bad: #e06b6b;         --good: #61c489;
    --on-air: #ff6b5b;
  }
}

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

html, body {
  margin: 0; height: 100%;
  font: 12px/1.35 "Lucida Grande", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--s-white);
  overflow: hidden;
  user-select: none;
}

body { display: flex; flex-direction: column; }

button { font: inherit; color: inherit; }

/* ---------- transport ---------- */

#transport {
  display: flex; align-items: center; gap: 14px;
  padding: 7px 12px;
  background: var(--chrome);
  border-bottom: 1px solid var(--line-strong);
  flex: 0 0 auto;
}

.transport-deck { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.controls { display: flex; align-items: center; gap: 6px; }

/* Aqua transport: round buttons, the main one raised and larger. */
.controls button {
  border-radius: 50%; border: 1px solid var(--text-4);
  background: linear-gradient(var(--s-raised-hi) 0%, var(--s-panel) 48%, var(--line-soft) 52%, var(--s-panel) 100%);
  box-shadow: 0 1px 2px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.9);
  color: var(--text-2); cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.controls button:active:not(:disabled) {
  background: linear-gradient(var(--line-soft) 0%, var(--line-faint) 100%);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.3);
}
.controls button:disabled { opacity: .4; cursor: default; }
#preview-prev, #preview-next { width: 30px; height: 30px; font-size: 9px; }
#play.primary { width: 44px; height: 44px; font-size: 15px; }
/* A mode that is on is lit, the way iTunes lit its shuffle and repeat. */
#shuffle[aria-pressed="true"], #repeat[aria-pressed="true"], #listen[aria-pressed="true"] {
  color: var(--sel-text);
  background: linear-gradient(#5b95ea, var(--sel));
  border-color: var(--accent);
}

#air-state { font-size: 10px; color: var(--text-3); letter-spacing: .03em; }
#air-state.on { color: var(--on-air); font-weight: 700; }

/* Two decks, as on a DJ mixer: what only the DJ hears on the left, what
   the station plays on the right. */
#decks {
  flex: 1 1 auto; min-width: 0; margin: 0 auto;
  display: flex; align-items: center; justify-content: center; gap: 12px;
}
.deck { flex: 0 1 400px; min-width: 0; display: flex; align-items: center; }
.deck-art {
  flex: 0 0 auto; width: 46px; height: 46px; margin-right: 8px;
  border-radius: 4px; object-fit: cover;
  border: 1px solid rgba(0, 0, 0, .25);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
  background: var(--s-slot);
}
.deck-art.empty { visibility: hidden; }
.lcd {
  position: relative; flex: 1 1 auto; min-width: 0;
  height: 56px; padding: 5px 10px;
  border: 1px solid var(--line-strong); border-radius: 5px;
  background: linear-gradient(var(--s-lcd-hi), var(--s-lcd-lo));
  box-shadow: inset 0 1px 2px rgba(0,0,0,.22);
  display: flex; flex-direction: column; justify-content: center;
  text-align: center; overflow: hidden;
}
.deck-label {
  position: absolute; top: 3px; left: 6px;
  font-size: 8px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-4);
}
#deck-live.on-air .deck-label { color: var(--on-air); }
#deck-live.on-air .lcd { border-color: var(--on-air); }
.lcd-empty { color: var(--text-4); font-weight: 600; }
.lcd-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lcd-sub { color: var(--text-3); font-size: 11px; white-space: nowrap;
           overflow: hidden; text-overflow: ellipsis; }
.lcd-scrub { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--text-3); }
/* The station keeps the clock, so the bars show where things are and take
   no clicks. */
.progress {
  flex: 1; height: 6px; border-radius: 3px; overflow: hidden;
  background: var(--s-slot); box-shadow: inset 0 1px 1px rgba(0,0,0,.25);
}
.progress-fill { display: block; height: 100%; width: 0; background: var(--text-3); }

.deck-caption { font-size: 10px; color: var(--text-3); letter-spacing: .03em; }

.live-controls { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.controls.small { gap: 4px; }
.controls.small button { width: 24px; height: 24px; font-size: 10px; }
#air {
  min-width: 98px; padding: 2px 10px; border-radius: 11px; font-weight: 700;
  border: 1px solid var(--line-strong); cursor: pointer;
  background: linear-gradient(var(--s-white), var(--s-raised-lo));
}
#air:disabled { opacity: .45; cursor: default; }
/* Off the air is the call to action; once live, the button says how to stop
   and stays red so nobody wonders whether the station is broadcasting. */
#air.live { color: #fff; border-color: var(--on-air);
            background: linear-gradient(#e0574a, var(--on-air)); }

.search { display: flex; align-items: center; gap: 6px; }
.search button, .pill {
  padding: 3px 10px; border: 1px solid var(--line-strong); border-radius: 11px;
  background: linear-gradient(var(--s-white), var(--s-raised-lo)); cursor: pointer;
}
.search button:active, .pill:active { background: linear-gradient(var(--s-pressed-hi), var(--s-pressed-lo)); }
.search input {
  width: 210px; padding: 3px 9px;
  border: 1px solid var(--line-strong); border-radius: 11px;
  background: var(--s-white); font: inherit; color: var(--text);
}

/* Etched into the chrome: the line is the groove's shadow and the white
   shadow below it the lit lower lip. */
.mark {
  width: 34px; height: 32px; flex: 0 0 auto;
  color: rgba(90, 100, 112, .42);
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .95));
}
.mark-dark { display: none; }
@media (prefers-color-scheme: dark) {
  .mark-light { display: none; }
  .mark-dark {
    display: block;
    color: rgba(200, 206, 214, .38);
    filter: drop-shadow(0 -1px 0 rgba(0, 0, 0, .55));
  }
}

/* ---------- frame ---------- */

main { flex: 1 1 auto; display: flex; min-height: 0; }

#sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--s-sidebar);
  overflow: auto; padding: 8px 0;
  border-right: 1px solid var(--line-strong);
}
.sec {
  padding: 8px 12px 3px;
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-3);
  display: flex; align-items: center; gap: 4px;
}
.sec button {
  width: 18px; height: 15px; line-height: 1; padding: 0;
  border: 1px solid var(--line-strong); border-radius: 3px;
  background: linear-gradient(var(--s-raised-hi), var(--s-raised-lo));
  cursor: pointer; font-size: 10px; color: var(--text-2);
}
.sec button:first-of-type { margin-left: auto; }
#sidebar ul { list-style: none; margin: 0; padding: 0; }
#sidebar li > .item {
  padding: 3px 12px; cursor: default;
  display: flex; align-items: center; gap: 5px;
  white-space: nowrap; overflow: hidden;
}
#sidebar li > .item.selected { background: var(--sel); color: var(--sel-text); }
#sidebar .ico { opacity: .75; width: 12px; text-align: center; flex: 0 0 12px; }
#sidebar .lbl { overflow: hidden; text-overflow: ellipsis; }
#sidebar .n { margin-left: auto; opacity: .55; font-size: 10px; padding-left: 6px; }
#sidebar .dot { color: var(--on-air); font-size: 9px; }
#sidebar .item input {
  font: inherit; width: 100%; padding: 0 3px; margin: -1px 0;
  border: 1px solid var(--sel); border-radius: 2px;
  background: var(--s-white); color: var(--text);
}
#playlist-tree ul { padding-left: 14px; }
#playlist-tree .disc { width: 10px; flex: 0 0 10px; text-align: center; font-size: 9px;
                       opacity: .65; cursor: pointer; }
#playlist-tree li.collapsed > ul { display: none; }
/* Where a dragged song or playlist lands. Not the selection color: it is a
   target, not what the list shows. */
#sidebar .item.drop-into { background: var(--good); color: var(--s-white); border-radius: 3px; }
#sidebar .item.took-drop { animation: took-drop .6s ease-out; }
@keyframes took-drop { from { background: var(--good); } to { background: transparent; } }
#sidebar .hint { padding: 2px 12px 6px 29px; color: var(--text-4); font-size: 11px; }

#content { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }

#view-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; flex: 0 0 auto;
  background: linear-gradient(var(--s-head-hi), var(--s-head-lo));
  border-bottom: 1px solid var(--line);
}
#view-title { font-weight: 700; font-size: 13px; white-space: nowrap;
              overflow: hidden; text-overflow: ellipsis; }
#view-actions { margin-left: auto; display: flex; gap: 6px; }

/* ---------- column browser ---------- */

#browser {
  display: flex; height: var(--browser-h); flex: 0 0 var(--browser-h);
  background: var(--s-white);
  border-bottom: 1px solid var(--line-strong);
}
#browser .col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column;
                border-right: 1px solid var(--line); }
#browser .hdr { padding: 3px 8px; font-weight: 600;
                background: var(--chrome); border-bottom: 1px solid var(--line); }
#browser ul { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 1 auto; }
#browser li { padding: 1px 8px; cursor: default; white-space: nowrap;
              overflow: hidden; text-overflow: ellipsis; }
#browser li:nth-child(even) { background: var(--stripe); }
#browser li.selected { background: var(--sel); color: var(--sel-text); }
#browser li .detail { opacity: .6; }

/* ---------- track table ---------- */

#table { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; overflow: auto;
         position: relative; }
#thead { display: flex; background: var(--chrome); position: sticky; top: 0; z-index: 2;
         border-bottom: 1px solid var(--line-strong); min-width: max-content; }
.th { padding: 3px 6px; font-weight: 600; border-right: 1px solid var(--line);
      white-space: nowrap; overflow: hidden; }
#rows { min-width: max-content; outline: none; }
.row { display: flex; height: var(--row-h); line-height: var(--row-h); cursor: default; }
.row:nth-child(even) { background: var(--stripe); }
.row.selected { background: var(--sel); color: var(--sel-text); }
.row.playing .c-name::before { content: "\25B6  "; font-size: 8px; }
/* The song on the preview deck, marked like headphones on a cue. */
.row.previewing .c-name::before { content: "\266B  "; font-size: 9px; color: var(--accent); }
.row.previewing.selected .c-name::before { color: inherit; }
.row.dead { color: var(--line-strong); font-style: italic; }
.row.drop-above { box-shadow: inset 0 2px 0 var(--sel); }
.row.drop-below { box-shadow: inset 0 -2px 0 var(--sel); }
.cell { padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-num    { flex: 0 0 var(--w-num); text-align: right; opacity: .55; }
.c-name   { flex: 0 0 var(--w-name); }
.c-time   { flex: 0 0 var(--w-time); text-align: right; font-variant-numeric: tabular-nums; }
.c-artist { flex: 0 0 var(--w-artist); }
.c-album  { flex: 0 0 var(--w-album); }

#empty {
  position: absolute; inset: 40px 0 auto; text-align: center;
  color: var(--text-4); font-size: 13px; padding: 30px; line-height: 1.6;
}

/* ---------- stats ---------- */

#stats { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 14px 18px 24px; }
#stats h3 { margin: 18px 0 6px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.stats-audience { display: flex; gap: 10px; }
.figure {
  flex: 0 0 auto; min-width: 120px; padding: 8px 14px;
  background: var(--s-panel); border: 1px solid var(--line-soft); border-radius: 6px;
}
.figure-n { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.figure-l { color: var(--text-3); font-size: 11px; }
.stats-table { border-collapse: collapse; min-width: 640px; }
.stats-table th {
  text-align: left; padding: 3px 8px; font-weight: 600; white-space: nowrap;
  background: var(--chrome); border-bottom: 1px solid var(--line-strong);
}
.stats-table td {
  padding: 0 8px; height: var(--row-h); white-space: nowrap;
  max-width: 300px; overflow: hidden; text-overflow: ellipsis;
}
.stats-table tbody tr:nth-child(even) { background: var(--stripe); }
.stats-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.stats-empty { color: var(--text-4); padding: 8px 0; }

/* ---------- status ---------- */

#status {
  flex: 0 0 auto; padding: 4px 12px; text-align: center;
  background: var(--chrome); border-top: 1px solid var(--line-strong); font-size: 11px;
}
#status.bad { color: var(--bad); font-weight: 600; }

/* ---------- menus and dialogs ---------- */

#ctx {
  position: fixed; z-index: 50; min-width: 190px; padding: 3px;
  background: var(--s-panel); color: var(--text-panel);
  border: 1px solid var(--line-strong); border-radius: 5px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
  max-height: 70vh; overflow: auto;
}
#ctx button {
  display: block; width: 100%; text-align: left;
  padding: 4px 10px; border: 0; border-radius: 3px;
  background: none; cursor: pointer;
}
#ctx button:hover { background: var(--sel); color: var(--sel-text); }
#ctx button:disabled { opacity: .4; cursor: default; background: none; color: inherit; }
#ctx hr { border: 0; border-top: 1px solid var(--line-faint); margin: 3px 0; }
#ctx .ctx-head { padding: 4px 10px 2px; font-size: 10px; letter-spacing: .04em;
                 text-transform: uppercase; color: var(--text-3); }

dialog.panel {
  width: 340px; padding: 0 16px 16px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--s-panel); color: var(--text-panel);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .34);
}
dialog.panel::backdrop { background: rgba(0, 0, 0, .28); }
.dlg-head {
  margin: 0 -16px 12px; padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(var(--s-head-hi), var(--s-head-lo));
  border-radius: 7px 7px 0 0;
}
.dlg-head h2 { margin: 0; font-size: 12px; font-weight: 600; }
dialog.panel p { line-height: 1.5; margin: 0 0 12px; }
dialog.panel .pill.primary { background: linear-gradient(#5b95ea, var(--sel)); color: var(--sel-text);
                             border-color: var(--accent); font-weight: 600; }
.dlg-error { color: var(--bad); }
