:root {
  --bg: #101114;
  --panel: #181a1f;
  --line: #2a2d35;
  --text: #ece9e2;
  --muted: #9a978f;
  --accent: #d8ff5a;
  --accent-ink: #14160c;
  --warn: #ffb454;
  --danger: #ff7a6b;
  --spotify: #1ed760;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --dock-height: 0px;
  color-scheme: dark;
}

/* W84: a light theme, used when the device is set to light or when chosen in the footer. */
:root[data-theme="light"] {
  --bg: #f5f3ee;
  --panel: #ffffff;
  --line: #d9d5cb;
  --text: #1b1c20;
  --muted: #625f58;
  --accent: #4a6400;
  --accent-ink: #f5f3ee;
  --warn: #9a5700;
  --danger: #b8321f;
  --spotify: #138a43;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f3ee;
    --panel: #ffffff;
    --line: #d9d5cb;
    --text: #1b1c20;
    --muted: #625f58;
    --accent: #4a6400;
    --accent-ink: #f5f3ee;
    --warn: #9a5700;
    --danger: #b8321f;
    --spotify: #138a43;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
body.docked { --dock-height: 232px; padding-bottom: calc(var(--dock-height) + 16px); }

a { color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

.top, main, footer {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
}

.top {
  display: flex;
  align-items: center;
  gap: 8px 18px;
  flex-wrap: wrap;
  padding-top: 18px;
  padding-bottom: 16px;
}

.wordmark {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.wordmark span { color: var(--accent); }

.nav { display: flex; gap: 4px 14px; flex-wrap: wrap; font-size: 0.9rem; }
.nav a { color: var(--muted); text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); border-bottom-color: var(--accent); }

.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.pill {
  font: 0.75rem/1 var(--mono);
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
}
.pill.live { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.pill.offline { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.pill-action { color: var(--text); border-color: var(--text); }
.pill-action:hover { background: var(--text); color: var(--bg); }

.search { display: flex; gap: 8px; }
.search input {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  font-size: 1rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.search.small input { padding: 9px 12px; font-size: 0.95rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.quiet { background: transparent; color: var(--text); border-color: var(--line); font-weight: 500; }
button.quiet:hover { border-color: var(--muted); }
button.small { padding: 5px 10px; font-size: 0.8rem; }
button.danger, .linkish.danger { color: var(--danger); }
button.icon {
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 4px 6px;
  font-weight: 400;
  line-height: 1;
  min-width: 28px;
  min-height: 28px;
}
button.icon:hover { color: var(--accent); }
.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.linkish:hover { color: var(--accent); filter: none; }
.fav.on, .icon.fav.on { color: var(--accent); }
button.radio.on { border-color: var(--accent); color: var(--accent); }

.notice {
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.9rem;
}
.notice.good { border-left-color: var(--accent); }

.empty { color: var(--muted); margin: 40px 0; text-align: center; }
.empty.short { margin: 24px 0 8px; }
.recent-searches { justify-content: center; margin-bottom: 8px; }
.recent-searches .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clear-recent { font-size: 0.8rem; font-weight: 400; letter-spacing: 0; }
.loading::after { content: " …"; }
.still-working { font-size: 0.85rem; margin-top: -6px; }

h1, h2 { letter-spacing: -0.02em; margin: 0; }
h1 { font-size: clamp(1.4rem, 4vw, 2rem); line-height: 1.2; }
h2 {
  margin-top: 28px;
  font-size: 0.8rem;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

section { margin-top: 20px; }
#view > :first-child { margin-top: 24px; }
.source { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 4px; font: 0.75rem var(--mono); color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; }
.links { margin: 10px 0 0; display: flex; gap: 8px 16px; flex-wrap: wrap; align-items: center; font-size: 0.85rem; color: var(--muted); }
.links a:hover { color: var(--accent); }

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--muted);
}
.actions button { padding: 8px 12px; font-size: 0.85rem; }
.select-all { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.filters { margin-top: 16px; font-size: 0.85rem; color: var(--muted); }
.filters summary { cursor: pointer; color: var(--text); }
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px 14px;
  margin-top: 12px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.filters-grid label { display: grid; gap: 4px; }
.filters-grid label.check { display: flex; align-items: center; gap: 8px; grid-column: span 2; }
.filters-grid .filter-buttons { display: flex; gap: 8px; grid-column: 1 / -1; }
.filters-grid button { padding: 7px 12px; }
input[type="number"], input[type="text"], input[type="search"], input[type="password"], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  min-width: 0;
}
textarea { width: 100%; font-family: var(--mono); font-size: 0.85rem; line-height: 1.5; background: var(--panel); }

.rows { list-style: none; margin: 10px 0 0; padding: 0; }
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
}
.row:hover { background: var(--panel); }
.row.played .title { color: var(--muted); }
.row .play { flex: none; }
.row .play.none { color: var(--line); display: inline-block; text-align: center; min-width: 28px; }
.grip {
  flex: none; background: none; border: 0; padding: 8px 7px; color: var(--muted);
  cursor: grab; touch-action: none; font-size: 1rem; line-height: 1;
}
.grip:hover { color: var(--accent); }
.row.dragging { background: var(--panel); box-shadow: 0 0 0 1px var(--accent) inset; }
.row.dragging .grip { cursor: grabbing; color: var(--accent); }
.actions .sorter button { padding: 0; font-size: inherit; }
.row.dragging, .row.dragging * { user-select: none; }
.sorter { display: flex; align-items: center; gap: 4px 10px; font-size: 0.8rem; flex-wrap: wrap; }
.num { font: 0.8rem var(--mono); color: var(--muted); min-width: 1.6rem; text-align: right; }
.score { font: 0.8rem var(--mono); color: var(--accent); min-width: 2.6rem; text-align: right; }
.what { flex: 1; min-width: 0; }
.what .title, .what .artist { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.what .title:hover, .what .artist:hover { text-decoration: underline; }
.what .artist { font-size: 0.85rem; color: var(--muted); }
.what .meta { display: block; font: 0.72rem var(--mono); color: var(--muted); }
.what a.sound-tag { width: fit-content; text-decoration: none; color: var(--muted); }
.what a.sound-tag:hover { text-decoration: underline; }
.row-links { display: flex; align-items: center; gap: 4px 12px; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.row-links a:hover { color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; font-size: 0.85rem; }
.chips .note { flex-basis: 100%; font-size: 0.78rem; }
.chip { padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
button.chip { background: none; color: inherit; font: inherit; cursor: pointer; }
.chip.active { border-color: var(--accent); color: var(--accent); }
.chip.still:hover { border-color: var(--line); color: inherit; }
.style-group h2 { margin: 22px 0 0; font-size: 1rem; }
.style-group .chips { margin-top: 8px; }
.styles-filter { width: 100%; max-width: 360px; }
.chip-pair { display: inline-flex; gap: 2px; }
.chip-pair .chip-mix { padding-left: 7px; padding-right: 7px; }
.mix-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.mix-form .styles-filter { flex: 1 1 200px; }
.tempo-form .bpm { width: 5.5em; }
.tempo-form select { max-width: 100%; }

.cards { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.card { display: grid; gap: 4px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; background: var(--panel); }
.card:hover { border-color: var(--accent); }

.import-box { margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line); }
.import-box > .muted { font-size: 0.85rem; margin: 8px 0 0; }
.import-box .choice-list { max-width: 520px; }
.import-box > button { margin-top: 12px; }
.import-bar { display: block; width: 100%; max-width: 520px; height: 6px; margin-top: 10px; border: 0; border-radius: 3px; background: var(--line); accent-color: var(--accent); overflow: hidden; }
.import-bar[hidden] { display: none; }
.import-bar::-webkit-progress-bar { background: var(--line); }
.import-bar::-webkit-progress-value { background: var(--accent); transition: width 0.4s; }
.import-bar::-moz-progress-bar { background: var(--accent); }

.pickers { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
.picker { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); min-width: 0; }
.picked { margin: 0; }
.choice-list { display: grid; gap: 6px; margin-top: 10px; }
.choice {
  text-align: left;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 500;
  padding: 8px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.choice:hover { border-color: var(--accent); filter: none; }

.tracklist { margin-top: 16px; }
.plain { padding-left: 18px; font-size: 0.85rem; }

footer { margin-top: 56px; padding-bottom: 32px; font: 0.75rem var(--mono); color: var(--muted); }

/* player dock */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--panel) 96%, black);
  border-top: 1px solid var(--line);
}
.dock-video { flex: none; width: 356px; height: 200px; background: black; border-radius: 6px; overflow: hidden; }
.dock-video iframe { width: 100%; height: 100%; display: block; }
.dock-body { flex: 1; min-width: 0; display: grid; gap: 8px; }
.dock-now { display: grid; min-width: 0; }
.dock-title, .dock-artist { text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock-title { font-weight: 600; }
.dock-artist { color: var(--muted); font-size: 0.9rem; }
.dock-pos { font: 0.75rem var(--mono); color: var(--muted); background: none; border: 0; padding: 0; text-align: left; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.dock-pos:hover { color: var(--text); }
/* W91: Up next */
.queue-tools { margin: 6px 0 0; }
.queue-list { list-style: none; margin: 10px 0 0; padding: 0; max-height: 60vh; overflow: auto; }
.queue-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.queue-list .q-num { font: 0.75rem var(--mono); color: var(--muted); min-width: 2.2em; text-align: right; }
.queue-list .q-pick { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 4px 0; color: var(--text); cursor: pointer; font: inherit; }
.queue-list .q-pick span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-list .q-artist { color: var(--muted); font-size: 0.85rem; }
.queue-list li.now .q-pick, .queue-list li.now .q-num { color: var(--accent); }
.queue-list li.gone { opacity: 0.5; }
.queue-list .q-move { min-width: 32px; padding-left: 4px; padding-right: 4px; }
.queue-list .q-move:disabled { opacity: 0.25; cursor: default; }
.dock-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* Phones only: there "Copy link" and "Copy queue" don't fit (W76). */
#dock-share { display: none; }
.dock-controls .big { font-size: 1.4rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-height) + 20px);
  transform: translateX(-50%);
  z-index: 30;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  max-width: calc(100vw - 32px);
}

dialog {
  width: min(680px, calc(100vw - 24px));
  max-height: calc(100vh - 48px);
  padding: 20px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
}
dialog::backdrop { background: rgb(0 0 0 / 0.65); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.matches { max-height: 46vh; overflow: auto; }
.tag { font: 0.7rem var(--mono); padding: 3px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.tag.match { color: var(--accent); }
.tag.maybe { color: var(--warn); }
.tag.saved { color: var(--spotify); border-color: color-mix(in srgb, var(--spotify) 40%, var(--line)); flex: none; white-space: nowrap; }
.skip-saved { display: flex; align-items: center; gap: 8px; margin: 10px 0 4px; font-size: 0.85rem; color: var(--muted); }
.playlist-form { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; margin-top: 16px; font-size: 0.85rem; color: var(--muted); }
.playlist-form label { flex: 1; display: grid; gap: 4px; min-width: 200px; }
.playlist-form.inline { margin-top: 12px; }

.login {
  display: grid;
  gap: 10px;
  max-width: 360px;
  margin: 48px auto 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.login input { font-size: 1rem; padding: 12px 14px; }

@media (max-width: 700px) {
  /* Phone: a square video (YouTube's 200px minimum) beside compact controls. */
  body.docked { --dock-height: 224px; }
  .dock { gap: 10px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); align-items: stretch; }
  .dock-video { width: 200px; height: 200px; }
  .dock-body { align-content: space-between; }
  .dock-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .dock-controls { gap: 2px; }
  .dock-controls button.icon { min-width: 36px; min-height: 36px; }
  #dock-copy, #dock-copy-queue { display: none; }
  #dock-share { display: inline-block; }
  .pickers { grid-template-columns: 1fr; }
  .pills { margin-left: 0; }
}

@media (max-width: 560px) {
  .row { flex-wrap: wrap; }
  .row .row-links { flex-basis: 100%; padding-left: 38px; flex-wrap: wrap; }
  .select-all { margin-left: 0; }
  .filters-grid label.check { grid-column: 1 / -1; }
}

/* Keyboard use: a visible ring on whatever has focus, a skip link, the shortcut sheet. */
a:focus-visible, button:focus-visible, summary:focus-visible, input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
#view:focus { outline: none; }
.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}
.skip:focus { top: 12px; }
footer #keys-open, footer #theme-toggle { margin-top: 12px; font: inherit; }
footer #theme-toggle { margin-left: 8px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 16px 0; align-items: baseline; }
.keys dt, .keys dd { margin: 0; }
kbd {
  font: 0.8rem var(--mono);
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--panel);
}
@media (hover: none) and (pointer: coarse) { footer #keys-open { display: none; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }

/* Guests: what a guest doesn't get, and the owner's guest list. */
body.guest .nav a[href="#tracklist"] { display: none; }
.guest-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.08)); }
.guest-row.gone { opacity: 0.55; }
.guest-who { display: grid; gap: 2px; min-width: 0; }
.guest-who .muted { font-size: 0.85rem; }
.invite-box { margin-top: 16px; }
.invite-link { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; overflow-wrap: anywhere; user-select: all; margin: 8px 0; }

/* First-visit guide and About page (W18). */
.guide { margin: 20px 0 8px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.guide h2 { margin: 0 0 8px; font-size: 1rem; }
.guide ol { margin: 0; padding-left: 20px; line-height: 1.55; }
.guide li + li { margin-top: 4px; }
.guide .actions { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.about { max-width: 680px; line-height: 1.6; }
.about h2 { margin-top: 28px; font-size: 1.05rem; }
.about-terms { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.about-terms dt { font-weight: 600; }
.about-terms dd { margin: 0; color: var(--muted); }
.whats-new { padding-left: 1.1rem; margin: 0; }
.whats-new li { margin: 4px 0; color: var(--muted); }
.whats-new strong { color: var(--text); }
@media (max-width: 560px) {
  .about-terms { grid-template-columns: 1fr; gap: 2px; }
  .about-terms dd { margin-bottom: 10px; }
}

/* Analysing a link's audio (roadmap 1.8) */
.button-link { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--accent); color: var(--bg); text-decoration: none; font-weight: 600; }
.button-link:hover { filter: brightness(1.1); }
.steps { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 6px; }
.steps li { padding-left: 1.6em; position: relative; }
.steps li::before { position: absolute; left: 0; }
.steps li.done { color: var(--muted); }
.steps li.done::before { content: "✓"; color: var(--accent); }
.steps li.now { font-weight: 600; }
.steps li.now::before { content: "●"; color: var(--accent); }
.steps li.todo { color: var(--muted); }
.steps li.todo::before { content: "○"; }
.home-new { margin: -28px 0 28px; font-size: 0.85rem; text-align: center; }
/* The short intro (shown once there are recents) keeps only 8px below it, so
   the pull-up above would put this line on top of it. */
.empty.short + .home-new { margin-top: 0; }

/* Notes (W56) */
.note-form { max-width: 640px; margin-top: 12px; }
.note-form .note-text { font-family: inherit; font-size: 0.95rem; }
.note-form .actions { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.note-row { padding: 10px 0; border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.08)); }
.note-row .note-body { margin: 0 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-row .muted { margin: 0; font-size: 0.85rem; }
.note-row.unread .note-body { font-weight: 600; }
#footer a.notes-new { color: var(--accent); }
.note-about { margin-top: 18px; font-size: 0.85rem; }
.notes-done { margin-top: 18px; } .notes-done summary { cursor: pointer; color: var(--muted, #999); }
.note-reply { margin: 6px 0 0; padding-left: 10px; border-left: 2px solid var(--accent); white-space: pre-wrap; overflow-wrap: anywhere; } .note-reply-form { margin-top: 6px; }
#search-misses { margin-top: 32px; } .miss-row { padding: 6px 0; border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.08)); overflow-wrap: anywhere; }
.home-quiet code { overflow-wrap: anywhere; }
/* W93: the short address line on About and the guests page. */
.share-site { margin: 12px 0; }
.share-site a { font-weight: 600; overflow-wrap: anywhere; }

/* Privacy page (1 Dec): Google asks for one to publish the YouTube sign-in. */
.privacy { max-width: 680px; margin: 24px auto; line-height: 1.6; }
.privacy h1 { font-size: 1.4rem; }
.privacy h2 { font-size: 1rem; margin-top: 24px; }
