:root {
  --bg: #0d1014;
  --panel: #161b22;
  --panel-2: #1d232c;
  --line: #2a323d;
  --text: #e7edf3;
  --dim: #8b98a8;
  --accent: #4da3ff;
  --accent-dim: #2b5f96;
  --good: #3fca7d;
  --warn: #f0b429;
  --bad: #f0625d;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  padding: 24px 20px 48px;
  display: flex;
  justify-content: center;
}

.wrap {
  width: 100%;
  max-width: 560px;
}

h1 {
  font-size: 20px;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.sub {
  color: var(--dim);
  font-size: 13px;
  margin: 0 0 20px;
}

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

.card h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
  margin: 0 0 12px;
  font-weight: 600;
}

label { display: block; font-size: 13px; color: var(--dim); margin-bottom: 6px; }

input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

input[type="text"]:focus { outline: 2px solid var(--accent-dim); border-color: var(--accent); }

button {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 18px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
  -webkit-tap-highlight-color: transparent;
}

button:hover:not(:disabled) { background: #263041; border-color: #3a4757; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

button.primary { background: var(--accent); border-color: var(--accent); color: #06121f; }
button.primary:hover:not(:disabled) { background: #6ab3ff; border-color: #6ab3ff; }

button.big { width: 100%; padding: 18px; font-size: 17px; }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap-row { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

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

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--dim);
  margin-bottom: 14px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dim);
  flex: none;
  transition: background 0.2s;
}

.dot.connecting { background: var(--warn); animation: pulse 1.1s ease-in-out infinite; }
.dot.live { background: var(--good); }
.dot.failed { background: var(--bad); }

@keyframes pulse { 50% { opacity: 0.35; } }

.via {
  margin-left: auto;
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--dim);
}

/* Room code / pairing ---------------------------------------------------- */

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 34px;
  letter-spacing: 0.22em;
  text-align: center;
  padding: 14px 0 10px;
  color: var(--accent);
}

.qr {
  display: flex;
  justify-content: center;
  padding: 8px 0 12px;
}

.qr img, .qr canvas { border-radius: 8px; background: #fff; padding: 8px; }

.link {
  font-size: 12px;
  color: var(--dim);
  word-break: break-all;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Drop zone -------------------------------------------------------------- */

.drop {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  color: var(--dim);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.drop:hover, .drop.over { border-color: var(--accent); background: rgba(77, 163, 255, 0.06); }
.drop strong { color: var(--text); display: block; margin-bottom: 4px; font-size: 15px; }

/* Progress --------------------------------------------------------------- */

.bar {
  height: 6px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0 6px;
}

.bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.15s linear;
}

.meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); }

/* Transport -------------------------------------------------------------- */

.track-name {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-sub { font-size: 12px; color: var(--dim); margin-bottom: 16px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--pct, 0%), var(--panel-2) var(--pct, 0%));
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--pct, 0%), var(--panel-2) var(--pct, 0%));
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  margin-top: -5px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
}

input[type="range"]:disabled { opacity: 0.4; cursor: not-allowed; }

.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); margin-top: 2px; }

.transport { display: flex; gap: 10px; align-items: center; margin: 16px 0 6px; }
.transport button { flex: 1; padding: 16px; font-size: 16px; }

.vol { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.vol span { font-size: 12px; color: var(--dim); width: 34px; flex: none; }

/* Player-specific -------------------------------------------------------- */

.gate {
  text-align: center;
  padding: 26px 18px;
}

.gate p { color: var(--dim); font-size: 14px; margin: 0 0 18px; }

.now {
  font-size: 15px;
  text-align: center;
  padding: 10px 0;
}

.now .state { color: var(--dim); font-size: 13px; margin-top: 4px; }

.hint {
  font-size: 12px;
  color: var(--dim);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.hint code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }

.err {
  background: rgba(240, 98, 93, 0.12);
  border: 1px solid rgba(240, 98, 93, 0.35);
  color: #ffb0ad;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 14px;
  white-space: pre-wrap;
}

[hidden] { display: none !important; }

.choose { display: grid; gap: 12px; margin-top: 20px; }

.choose a {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.15s, background 0.15s;
}

.choose a:hover { border-color: var(--accent); background: var(--panel-2); }
.choose strong { display: block; font-size: 16px; margin-bottom: 4px; }
.choose span { color: var(--dim); font-size: 13px; }

/* A play button that needs a tap to clear Chrome's autoplay block. */
button.attention {
  background: var(--warn);
  border-color: var(--warn);
  color: #2a1d00;
  animation: nudge 1.4s ease-in-out infinite;
}

button.attention:hover:not(:disabled) { background: #ffc74a; border-color: #ffc74a; }

@keyframes nudge {
  50% { box-shadow: 0 0 0 6px rgba(240, 180, 41, 0.16); }
}

/* Collapsible capability report, shown on both ends. */
.diag-wrap {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.diag-wrap summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--dim);
  user-select: none;
}

.diag-wrap pre {
  margin: 10px 0 0;
  padding: 10px;
  background: var(--panel-2);
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--dim);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow: auto;
}

/* Library and queue lists ------------------------------------------------- */

.list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}

.list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 6px;
}

.list li.current {
  border-color: var(--accent);
  background: rgba(77, 163, 255, 0.09);
}

.list li.dragging { opacity: 0.4; }
.list li.drop-target { border-color: var(--accent); }

.list .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.list .size {
  font-size: 11px;
  color: var(--dim);
  flex: none;
}

.list button {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  flex: none;
}

.list .handle {
  cursor: grab;
  color: var(--dim);
  flex: none;
  user-select: none;
}

.empty {
  color: var(--dim);
  font-size: 13px;
  margin: 0 0 10px;
}

button.subtle {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
}

.via.online {
  color: var(--good);
  border-color: rgba(63, 202, 125, 0.4);
}

/* A transient status line, distinct from a failure. */
.err.notice {
  background: rgba(240, 180, 41, 0.12);
  border-color: rgba(240, 180, 41, 0.35);
  color: #f2cd7a;
}

/* Audio-session keepalive toggle. */
.toggle {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 16px 0 4px;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
}

.toggle input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  flex: none;
  accent-color: var(--accent);
}

.toggle strong { display: block; font-size: 13px; font-weight: 600; }
.toggle small { display: block; margin-top: 3px; font-size: 11px; color: var(--dim); line-height: 1.45; }

/* Playlists ---------------------------------------------------------------- */

.sub-head {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
  margin: 20px 0 10px;
  font-weight: 600;
}

.list.tabs li { cursor: pointer; }

.list.tabs li.active {
  border-color: var(--accent);
  background: rgba(77, 163, 255, 0.12);
}

.list .count {
  font-size: 11px;
  color: var(--dim);
  flex: none;
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.new-playlist { margin-bottom: 4px; }

input.plain {
  text-transform: none;
  letter-spacing: normal;
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
}

.modes {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.modes button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121f;
}

.playing-from {
  margin-left: auto;
  font-size: 11px;
  color: var(--dim);
}

.now .context {
  font-size: 11px;
  color: var(--dim);
  margin-top: 2px;
}

/* Schedules ---------------------------------------------------------------- */

.days {
  display: flex;
  gap: 6px;
  margin: 14px 0 10px;
  flex-wrap: wrap;
}

.days button {
  flex: 1;
  min-width: 44px;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 500;
}

.days button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121f;
}

.tz-note {
  font-size: 11px;
  color: var(--dim);
  margin: 10px 0 0;
}

.list .when {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  flex: none;
  color: var(--text);
}

.list li.off .name,
.list li.off .when { opacity: 0.45; }

/* ==========================================================================
   Desktop remote layout: rail + main + a player bar that never scrolls away.
   The phone page keeps the centred single column above.
   ========================================================================== */

body.app {
  display: block;
  padding: 0 0 96px;   /* clearance for the fixed player */
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 11px 18px;
  background: rgba(13, 16, 20, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 700; letter-spacing: -0.01em; }
.topbar-status { font-size: 13px; color: var(--dim); }
.spacer { flex: 1; }

.room-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0.14em;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent);
}

.pair-panel {
  max-width: 420px;
  margin: 16px auto 0;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.split {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 18px;
}

.rail,
.main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.rail > section,
.main > section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-head h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
  margin: 0;
  font-weight: 600;
}

.panel-head .count {
  font-size: 11px;
  color: var(--dim);
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
}

input.filter {
  width: 160px;
  flex: none;
  padding: 6px 10px;
  font-size: 12px;
}

/* Player bar --------------------------------------------------------------- */

.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 10px 18px;
  background: rgba(22, 27, 34, 0.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.pl-transport { display: flex; gap: 6px; flex: none; }
.pl-transport button { padding: 9px 14px; font-size: 15px; }

.pl-now { flex: 1 1 150px; min-width: 0; }
.pl-now .track-name { font-size: 14px; margin-bottom: 0; }
.pl-now .track-sub { font-size: 11px; margin-bottom: 0; }

.pl-seek {
  flex: 2 1 280px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pl-seek input[type="range"] { flex: 1; min-width: 0; }

.pl-modes { display: flex; gap: 6px; flex: none; }
.pl-modes button { padding: 7px 10px; font-size: 12px; }

.pl-vol {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 160px;
  min-width: 120px;
}

.pl-vol input[type="range"] { flex: 1; min-width: 0; }

.player .time {
  font-size: 11px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  flex: none;
}

.player .playing-from { margin-left: 0; }

/* One column once the rail stops earning its width. */
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; padding: 14px; }
  .pl-modes,
  .pl-vol { display: none; }   /* the phone has its own volume anyway */
  body.app { padding-bottom: 132px; }
}

/* The error/notice line sits outside the centred column on the remote. */
.app > .err { margin: 12px 18px 0; }

/* ==========================================================================
   Schedule view: a week grid, so overlapping playlists are visible at a glance
   ========================================================================== */

.views { display: flex; gap: 4px; }
.views button { padding: 6px 12px; font-size: 12px; }
.views button.on { background: var(--accent); border-color: var(--accent); color: #06121f; }

.sched-view {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 18px;
}

.sched-view > .panel-head { margin-bottom: 12px; }

.sched-selected {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--panel-2);
  border: 1px solid var(--accent);
  border-radius: 10px;
}

.cal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.cal-head,
.cal-grid {
  display: grid;
  grid-template-columns: 54px repeat(7, minmax(0, 1fr));
}

.cal-head {
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.cal-head div {
  padding: 9px 6px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
}

.cal-head div.today { color: var(--accent); }

.cal-scroll {
  max-height: 62vh;
  overflow-y: auto;
}

.cal-gutter {
  position: relative;
  border-right: 1px solid var(--line);
}

.cal-gutter span {
  position: absolute;
  right: 6px;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.cal-col {
  position: relative;
  border-right: 1px solid var(--line);
  cursor: crosshair;
  /* One faint line per hour, a brighter one every six. */
  background-image:
    repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour, 44px));
}

.cal-col:last-child { border-right: 0; }
.cal-col.today { background-color: rgba(77, 163, 255, 0.04); }

.chip {
  position: absolute;
  left: 3px;
  right: 3px;
  min-height: 20px;
  padding: 2px 6px;
  border-radius: 6px;
  border-left: 3px solid var(--chip, var(--accent));
  background: color-mix(in srgb, var(--chip, var(--accent)) 26%, var(--panel-2));
  color: var(--text);
  font-size: 11px;
  line-height: 1.35;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.1s, filter 0.1s;
}

.chip:hover { filter: brightness(1.25); }
.chip.selected { outline: 2px solid var(--text); outline-offset: -2px; }
.chip.off { background: transparent; border: 1px dashed var(--line); border-left: 3px solid var(--line); opacity: 0.65; }
.chip b { font-weight: 600; font-variant-numeric: tabular-nums; }
.chip i { font-style: normal; opacity: 0.8; }

.now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--bad);
  z-index: 3;
  pointer-events: none;
}

.now-line::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bad);
}

.sched-form {
  margin-top: 16px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

select.plain {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
}

@media (max-width: 700px) {
  .cal-head, .cal-grid { grid-template-columns: 40px repeat(7, minmax(0, 1fr)); }
  .chip i { display: none; }
}
