:root {
    --bg: #0c0d0f; --panel: #161819; --fg: #ececec; --muted: #8b9096;
    --accent: #4fd1c5; --line: #26292c;
   }
   * { box-sizing: border-box; }
   html, body { margin: 0; height: 100%; }
   body {
    background: radial-gradient(1200px 600px at 50% -10%, #1a1d20, var(--bg));
    color: var(--fg); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    height: 100vh;
   }
   /* ---------- listener page layout: player left, chat right ---------- */
   body.listen, body.listen #app { height: auto; min-height: 100vh; }
   body.listen #app { max-width: 1860px; }
   /* The chat and the phantom column opposite it always share one width, so the
     player stays centred whatever that width works out to. 600px where there is
     room; narrower rather than squeezing the player on smaller screens. */
   body.listen { --chatw: clamp(320px, 30vw, 600px); }
   body.listen main { justify-content: flex-start; padding-top: 8px; }
   
   .stage { display: flex; gap: 20px; align-items: stretch; flex: 1; min-height: 0; }
   /* An empty column mirroring the chat's width, so the player sits centred on the
     page instead of centred in whatever space the chat leaves over. */
   .stage::before { content: ""; flex: none; width: var(--chatw); }
   .stage main { flex: 1; min-width: 0; }
   
   /* The pane needs a *definite* height: #app is min-height:100vh with height:auto,
     so without this the log's flex:1 has nothing to resolve against and the log
     grows with every message instead of scrolling. */
   .chatpane {
    width: var(--chatw); flex: none;
    display: flex; flex-direction: column;
    padding-top: 8px;
    position: sticky; top: 18px;
    height: calc(100vh - 96px);
   }
   /* min-height:0 the whole way down, or a flex child refuses to shrink below its
     content and the overflow never kicks in. */
   .chatpane #chat { flex: 1; min-height: 0; display: flex; }
   .chatpane .chat { flex: 1; min-height: 0; }
   .chatpane .chat-log { flex: 1; height: auto; min-height: 0; }
   
   /* Both controls belong to the mobile drawer only. */
   .chattoggle, .chatclose { display: none; }
   
   /* Below this there isn't room for player + chat side by side without squeezing
     the player, so the chat becomes a drawer instead. */
   @media (max-width: 1249px) {
    .stage { display: block; }
    .stage::before { display: none; }
   
    .chatpane {
      position: fixed; top: 0; right: 0; bottom: 0;
      height: auto; /* top+bottom define it here, not the desktop calc() */
      width: min(92vw, 520px);
      background: var(--bg);
      border-left: 1px solid var(--line);
      box-shadow: -16px 0 44px rgba(0, 0, 0, .55);
      padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
      transform: translateX(100%);
      transition: transform .22s ease;
      /* Below .overlay (z-index 10) so the join screen still covers everything. */
      z-index: 9;
    }
    .chatpane.open { transform: translateX(0); }
   
    .chatclose {
      display: block; align-self: flex-end;
      background: transparent; color: var(--muted);
      border: 1px solid var(--line); border-radius: 8px;
      padding: 4px 10px; cursor: pointer; margin-bottom: 8px;
    }
    .chatclose:hover { color: var(--accent); border-color: var(--accent); }
   
    .chattoggle {
      display: block; position: fixed;
      right: 14px; bottom: calc(14px + env(safe-area-inset-bottom));
      width: 48px; height: 48px; border-radius: 50%;
      background: var(--accent); color: #04201d;
      border: 0; font-size: 20px; line-height: 1; cursor: pointer;
      box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
      z-index: 8;
    }
   }
   
   #app { max-width: 720px; margin: 0 auto; padding: 18px 18px 28px; height: 100vh; display: flex; flex-direction: column; }
   header { display: flex; align-items: center; justify-content: space-between; }
   /* Listener page: station name above the live counter, stacked and centred. */
   .brandhead { flex-direction: column; justify-content: center; gap: 3px; }
   .stationname { font-size: 21px; font-weight: 800; letter-spacing: 1.5px; color: var(--fg); }
   .brand { font-weight: 800; letter-spacing: .5px; color: var(--accent); font-size: 18px; }
   .live { color: var(--muted); font-size: 12px; letter-spacing: .5px; }
   .live .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ff4d4d; margin-right: 6px; animation: pulse 1.6s infinite; }
   @keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }
   
   main { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
   #art {
    width: min(60vh, 420px); aspect-ratio: 1; border-radius: 14px; background: var(--panel) center/cover no-repeat;
    box-shadow: 0 16px 50px rgba(0,0,0,.55); flex: none;
   }
   #meta { text-align: center; }
   #meta .t { font-size: 22px; font-weight: 700; }
   #meta .by { color: var(--muted); margin-top: 2px; }
   #player { width: 100%; max-width: 560px; }
   #player iframe, #player audio { width: 100%; border: 0; border-radius: 10px; }
   #player audio { margin-top: 6px; }
   /* keep the actual media element present but visually minimal (sync, not control) */
   #player.hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
   .status { color: var(--muted); font-size: 12px; min-height: 16px; }
   .sharebtn {
    background: var(--panel); color: var(--fg); border: 1px solid var(--line);
    border-radius: 99px; padding: 10px 20px; font-size: 14px; cursor: pointer;
   }
   a.sharebtn { text-decoration: none; display: inline-block; }
   .sharebtn:hover { border-color: var(--accent); color: var(--accent); }
   
   /* Request QR on the listener page — scan it from another device, or click it
     to open the request page in a new tab. */
   .reqqr {
    display: flex; flex-direction: column; align-items: center; gap: 7px;
    color: var(--muted); font-size: 12px; text-decoration: none;
   }
   .reqqr img {
    background: #fff; border-radius: 8px; padding: 7px; display: block;
    border: 1px solid transparent;
   }
   .reqqr:hover { color: var(--accent); }
   .reqqr:hover img { border-color: var(--accent); }
   
   .aboutlink {
    color: var(--muted); font-size: 12px; text-decoration: none;
    border-bottom: 1px dotted var(--line); padding-bottom: 1px;
   }
   .aboutlink:hover { color: var(--accent); border-bottom-color: var(--accent); }
   
   /* ---------- about page ---------- */
   body.aboutpage, body.aboutpage #app { height: auto; min-height: 100vh; }
   body.aboutpage #app { max-width: 640px; }
   .aboutmain { display: block; padding: 26px 0 40px; }
   .aboutmain p { color: #c9cdd1; line-height: 1.7; margin: 0; font-style: italic; }
   
   .overlay {
    position: fixed; inset: 0; background: rgba(8,9,11,.92);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 10;
   }
   .overlay.gone { display: none; }
   #joinBtn {
    background: var(--accent); color: #04201d; border: 0; font-weight: 800; font-size: 18px;
    padding: 16px 28px; border-radius: 12px; cursor: pointer;
   }
   #joinBtn:hover { filter: brightness(1.08); }
   .joinhint { color: var(--muted); font-size: 13px; }
   
   /* ---------- admin dashboard ---------- */
   body.admin { height: auto; min-height: 100vh; }
   .loginbox { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 26px; display: flex; flex-direction: column; gap: 10px; width: 280px; }
   .loginbox input { background: #0a0c0d; color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 15px; }
   .loginbox button, .admin button.primary, #loginBtn { background: var(--accent); color: #04201d; border: 0; font-weight: 700; padding: 10px 14px; border-radius: 8px; cursor: pointer; }
   .formmsg { color: var(--muted); font-size: 13px; min-height: 16px; }
   
   body.admin #dash { max-width: 1200px; margin: 0 auto; padding: 14px 18px 40px; }
   body.admin header { position: sticky; top: 0; background: var(--bg); padding: 8px 0; z-index: 5; border-bottom: 1px solid var(--line); }
   .hd-right { display: flex; align-items: center; gap: 10px; }
   .clock { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
   .activepill { background: #232c2b; color: var(--accent); border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; font-size: 12px; }
   .admin header button { background: var(--panel2, #1f2224); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; }
   .admin header button.primary { background: var(--accent); color: #04201d; border: 0; font-weight: 700; }
   .savemsg { color: var(--accent); font-size: 13px; min-height: 18px; padding-top: 6px; }
   
   .adminmain { display: grid; grid-template-columns: 360px 1fr; gap: 18px; margin-top: 8px; }
   .panel h2 { font-size: 14px; display: flex; align-items: center; gap: 10px; justify-content: space-between; }
   .panel .search { background: var(--panel2,#1f2224); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 12px; }
   .liblist { max-height: 70vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
   .libitem { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--line); cursor: grab; font-size: 13px; }
   .libitem:hover { background: var(--panel2,#1f2224); }
   .li-l { color: var(--muted); font-size: 11px; white-space: nowrap; }
   
   .showcard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
   .showcard.onair { box-shadow: inset 3px 0 0 var(--accent); border-color: #2c3a38; }
   .showhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
   .showname { font-weight: 700; text-transform: capitalize; min-width: 70px; }
   .showcard.onair .showname::after { content: " • on air"; color: var(--accent); font-weight: 500; font-size: 11px; }
   .showhead .t { background: #0a0c0d; color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; }
   .showhead .dash { color: var(--muted); }
   .shuf { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 4px; }
   .cnt { color: var(--muted); font-size: 12px; margin-left: auto; }
   .droplist { list-style: decimal; margin: 8px 0 0; padding: 6px 6px 6px 26px; min-height: 30px; border: 1px dashed var(--line); border-radius: 8px; }
   .droplist.over { border-color: var(--accent); background: #12201e; }
   .droplist.collapsed { list-style: none; min-height: 0; padding: 4px 10px; margin-top: 6px; opacity: .75; }
   .showcard.collapsed { padding-bottom: 8px; }
   .fold { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 12px; padding: 0 4px 0 0; line-height: 1; }
   .fold:hover { color: var(--accent); }
   .foldctl { display: flex; gap: 6px; font-weight: 400; }
   .foldctl button { background: var(--panel2,#1f2224); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font-size: 12px; cursor: pointer; }
   .foldctl button:hover { border-color: var(--accent); color: var(--accent); }
   .srow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 4px; cursor: grab; font-size: 13px; }
   .srow:hover { background: var(--panel2,#1f2224); }
   .hintrow { color: var(--muted); list-style: none; font-size: 12px; }
   .rm { background: transparent; border: 0; color: var(--muted); cursor: pointer; }
   .rm:hover { color: #ff6b6b; }
   
   /* admin preview */
   .preview { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 8px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); min-height: 44px; }
   .prevlabel { color: var(--muted); font-size: 12px; min-width: 90px; }
   #previewMedia audio { height: 32px; vertical-align: middle; }
   .prevstop { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; cursor: pointer; padding: 2px 8px; margin-left: auto; }
   .prevstop:hover { color: #ff6b6b; border-color: #ff6b6b; }
   .libitem .prev { background: transparent; border: 1px solid var(--line); color: var(--accent); border-radius: 50%; width: 22px; height: 22px; cursor: pointer; font-size: 10px; line-height: 1; flex: none; }
   .libitem .prev:hover { background: var(--accent); color: #04201d; }
   .libitem { align-items: center; }
   .li-t { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
   
   /* show-membership chips in the admin song list */
   .li-chips { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 55%; }
   .li-chips .chip {
    font-size: 9px; letter-spacing: .3px; text-transform: capitalize;
    background: #232c2b; color: var(--accent); border: 1px solid #2c3a38;
    border-radius: 99px; padding: 1px 7px; white-space: nowrap;
   }
   .libitem.inshow { background: rgba(79,209,197,.05); }
   
   /* admin now-playing pill */
   .nowpill { color: var(--accent); font-size: 12px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
   
   /* one-shot request queue */
   .queuebar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 0 2px; }
   .queuebar input {
    background: #0a0c0d; color: var(--fg); border: 1px solid var(--line);
    border-radius: 8px; padding: 8px 10px; font-size: 13px; flex: 1 1 340px; min-width: 220px;
   }
   .queuebar input:focus { outline: none; border-color: var(--accent); }
   .qhint { color: var(--muted); font-size: 12px; flex: 1 1 100%; }
   .queuelist { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
   .qrow {
    display: flex; align-items: center; gap: 8px; font-size: 13px;
    background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
    border-radius: 8px; padding: 6px 10px;
   }
   .qrow.onair { background: #12201e; }
   .qpos { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; min-width: 54px; }
   .qrow .qt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
   .qkind { color: var(--muted); font-size: 11px; }
   .qrow .rm:hover { color: #ff6b6b; }
   
   /* requests awaiting the DJ's approval */
   .pendingbox { border: 1px solid #4a4033; background: #1c1813; border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
   .pendhead { font-size: 13px; font-weight: 700; color: #e5b567; margin-bottom: 6px; }
   .pendcount { color: var(--muted); font-weight: 400; }
   .prow { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 5px 0; border-top: 1px solid #302a22; }
   .prow:first-child { border-top: 0; }
   .prow .pn { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
   .prow .pby { color: var(--muted); font-size: 11px; }
   .prow .pk { color: var(--muted); font-size: 11px; }
   .prow button { border-radius: 6px; padding: 3px 10px; font-size: 12px; cursor: pointer; border: 1px solid var(--line); }
   .prow .ok { background: var(--accent); color: #04201d; border: 0; font-weight: 700; }
   .prow .no { background: transparent; color: var(--muted); }
   .prow .no:hover { color: #ff6b6b; border-color: #ff6b6b; }
   
   /* QR overlay on the admin dashboard */
   .qrcard { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
   .qrtitle { font-weight: 700; }
   .qrcard img { background: #fff; border-radius: 8px; padding: 8px; }
   .qrurl { color: var(--muted); font-size: 12px; word-break: break-all; max-width: 280px; text-align: center; }
   .qrcard button { background: var(--panel2,#1f2224); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 16px; cursor: pointer; }
   
   /* ---------- public request page ---------- */
   body.reqpage { height: auto; min-height: 100vh; }
   body.reqpage #app { max-width: 520px; height: auto; }
   .backlink { color: var(--muted); text-decoration: none; font-size: 13px; }
   .backlink:hover { color: var(--accent); }
   .reqmain { display: block; }
   .nowcard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 14px 0; }
   .nowlabel { color: var(--accent); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; margin-right: 8px; }
   .reqform { display: flex; flex-direction: column; gap: 10px; }
   .reqform label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
   .reqform .opt { color: #6b7076; font-size: 11px; }
   .reqform input {
    background: #0a0c0d; color: var(--fg); border: 1px solid var(--line);
    border-radius: 8px; padding: 11px; font-size: 16px; /* 16px keeps iOS from zooming */
   }
   .reqform input:focus { outline: none; border-color: var(--accent); }
   .reqform button { background: var(--accent); color: #04201d; border: 0; font-weight: 800; padding: 13px; border-radius: 10px; font-size: 15px; cursor: pointer; }
   .reqform button:disabled { opacity: .6; }
   .reqlists h2 { font-size: 13px; color: var(--muted); margin: 22px 0 6px; font-weight: 600; }
   .qlist { display: flex; flex-direction: column; gap: 4px; }
   .qitem { display: flex; align-items: center; gap: 8px; font-size: 13px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
   .qitem.ok { border-left: 3px solid var(--accent); }
   .qitem.wait { border-left: 3px solid #e5b567; opacity: .85; }
   .qitem .qn { color: var(--muted); font-size: 11px; min-width: 12px; }
   .qitem .qname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
   .qitem .qkind { color: var(--muted); font-size: 11px; }
   .qitem.mine { border-left-width: 3px; }
   .qitem.hidden { opacity: .5; }
   .qitem.hidden .qname { color: var(--muted); font-style: italic; }
   .qyours { background: var(--accent); color: #04201d; font-size: 10px; font-weight: 700;
    border-radius: 99px; padding: 1px 7px; letter-spacing: .3px; }
   .h2note { color: #6b7076; font-size: 11px; font-weight: 400; }
   .qempty { color: var(--muted); font-size: 12px; padding: 6px 2px; }
   .qrbox { margin: 26px 0 10px; text-align: center; }
   .qrcap { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
   .qrbox img { background: #fff; border-radius: 8px; padding: 8px; }
      