:root {
  --bg: #f4f1ea;
  --paper: #fffdf8;
  --ink: #1b1a17;
  --muted: #6f6a60;
  --line: #e2dccf;
  --accent: #e4572e;
  --accent-ink: #fff;
  --yt: #d93025;
  --sp: #1db954;
  --ok: #2f7d4f;
  --err: #b3261e;
  --warn: #9a6a00;
  --radius: 10px;
  color-scheme: light;
}
/* Theme: Auto follows the device; the switch sets data-theme="light"/"dark" on <html>. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141311;
    --paper: #1d1c19;
    --ink: #ece7dc;
    --muted: #9c968a;
    --line: #34312b;
    --accent: #ff6b3d;
    --ok: #6cc28f;
    --err: #ff8a80;
    --warn: #e6b450;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141311;
  --paper: #1d1c19;
  --ink: #ece7dc;
  --muted: #9c968a;
  --line: #34312b;
  --accent: #ff6b3d;
  --ok: #6cc28f;
  --err: #ff8a80;
  --warn: #e6b450;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.01em; }
h1 { font-size: 30px; margin: 8px 0 16px; }
h2 { font-size: 19px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.topbar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--ink); color: var(--bg);
}
.brand { font-weight: 800; font-size: 18px; text-decoration: none; display: flex; align-items: center; gap: 10px; letter-spacing: -0.02em; }
.disc { width: 20px; height: 20px; border-radius: 50%; background:
  radial-gradient(circle, var(--accent) 0 3px, var(--ink) 3px 4px, #444 4px 5px, #222 5px 7px, #3a3a3a 7px 8px, #222 8px); display: inline-block; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.topbar nav a { text-decoration: none; padding: 6px 10px; border-radius: 6px; opacity: .8; }
.topbar nav a:hover { opacity: 1; background: rgba(255,255,255,.08); }
.topbar nav a.on { opacity: 1; background: rgba(255,255,255,.14); }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.role { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 2px 6px; border-radius: 4px; background: rgba(255,255,255,.15); }
.role-admin { background: var(--accent); color: var(--accent-ink); }
button.link { background: none; border: 0; color: inherit; cursor: pointer; text-decoration: underline; font: inherit; padding: 0; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 24px 16px 64px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card.narrow { max-width: 420px; margin: 40px auto; }
.card.empty { text-align: center; padding: 40px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.flash-ok { border-color: var(--ok); color: var(--ok); }
.flash-error { border-color: var(--err); color: var(--err); }

.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }

input, select, button { font: inherit; }
input:not([type=checkbox]), select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--ink); min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer;
  text-decoration: none; font-weight: 600; font-size: 14px; white-space: nowrap;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--err); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.yt { border-color: var(--yt); color: var(--yt); }
.btn.sp { border-color: var(--sp); color: var(--sp); }
.btn.yt:not(.ghost) { background: var(--yt); color: #fff; }
.btn.sp:not(.ghost) { background: var(--sp); color: #fff; }
.btn.ghost { border-style: dashed; font-weight: 500; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label, .grid-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.stack input, .grid-form input, .grid-form select { color: var(--ink); font-size: 15px; }
label.check { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--ink) !important; font-size: 15px !important; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.grid-form .wide { grid-column: 1 / -1; }
form.inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* releases */
.day { margin: 28px 0; }
.day h2 { display: flex; align-items: baseline; gap: 10px; border-bottom: 2px solid var(--ink); padding-bottom: 6px; }
.day .dow { font-size: 22px; font-weight: 800; }
.day .date { color: var(--muted); font-weight: 500; }
.day.is-past h2 { border-bottom-color: var(--line); }
.pill { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 99px; background: var(--line); color: var(--ink); font-weight: 700; }
.today-pill { background: var(--accent); color: var(--accent-ink); }
.albums { list-style: none; margin: 0; padding: 0; }
.album { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.album .title { font-size: 16px; }
.album .artist { font-weight: 700; }
.album .sep { color: var(--muted); }
.album .sub { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); margin-top: 3px; }
.album.not-new .title { opacity: .65; }
.links { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag { text-decoration: none; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--ink); }
.tag:hover { border-color: var(--accent); }
.badge { padding: 1px 8px; border-radius: 4px; background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); font-size: 12px; font-weight: 600; }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 8px; }
.table td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: middle; }
.table tr.dim td { opacity: .55; }
.table { display: block; overflow-x: auto; }
.kind { font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 4px; color: #fff; }
.kind-slack { background: #4a154b; }
.kind-discord { background: #5865f2; }
.status { font-weight: 700; font-size: 12px; text-transform: uppercase; }
.status-ok { color: var(--ok); } .status-error { color: var(--err); } .status-running { color: var(--warn); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stats div { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; }
.stats b { font-size: 26px; }
.stats span { color: var(--muted); font-size: 13px; }
.jobbuttons { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

.albumlist .arow { border-bottom: 1px solid var(--line); }
.arow summary { display: grid; grid-template-columns: 100px 1fr 180px 70px 40px; gap: 10px; padding: 9px 4px; cursor: pointer; align-items: center; font-size: 14px; }
.arow[open] { background: color-mix(in srgb, var(--accent) 5%, transparent); padding-bottom: 12px; }
.arow .grid-form, .arow > .actions { padding: 6px 8px; }
.arow .g { color: var(--muted); font-size: 13px; }

@media (max-width: 680px) {
  .topbar { padding: 12px 16px; }
  .album { flex-direction: column; align-items: flex-start; }
  .links { justify-content: flex-start; }
  .arow summary { grid-template-columns: 1fr; gap: 2px; }
  h1 { font-size: 24px; }
}

/* multi-select genre picker */
.multi { position: relative; }
.multi > summary {
  list-style: none; cursor: pointer; padding: 7px 30px 7px 10px; border: 1px solid var(--line);
  border-radius: 7px; background: var(--paper); min-width: 150px; max-width: 260px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative;
}
.multi > summary::-webkit-details-marker { display: none; }
.multi > summary::after { content: "▾"; position: absolute; right: 10px; top: 7px; color: var(--muted); }
.multi[open] > summary { outline: 2px solid var(--accent); outline-offset: -1px; }
.multi .menu {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; width: 280px; max-width: calc(100vw - 32px);
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15); padding: 8px;
}
.multi .menu-search { width: 100%; margin-bottom: 6px; }
.multi .options { max-height: 300px; overflow-y: auto; }
.multi .opt { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.multi .opt:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.multi .opt .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.multi .menu-actions { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 10px; }
.chip { display: inline-flex; gap: 6px; align-items: center; text-decoration: none; padding: 2px 10px; border-radius: 99px;
  background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 600; }
.chip:hover { filter: brightness(1.08); }
.tag.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.albumlink { text-decoration: none; }
.albumlink:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.rtype { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--muted); color: var(--muted); }

.day { scroll-margin-top: calc(var(--topbar-h, 0px) + var(--stickyhead-h, 0px) + 12px); }
.jump { margin: 0 0 8px; }
.multi .menu-left { display: flex; gap: 6px; }
.multi .menu .btn:disabled { opacity: .5; cursor: default; }

/* feeds */
.subbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.subbar .jump { margin: 0; }
.feedmaker > summary.btn { padding: 4px 10px; min-width: 0; max-width: none; }
.feedmaker > summary.btn::after { content: none; }
.feedmaker .menu { left: auto; right: 0; width: 320px; gap: 8px; }
.feedmaker .menu p { margin: 0; }
.feedlist { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.feedrow { border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.feedhead { display: flex; flex-direction: column; gap: 4px; }
.feedname { font-weight: 700; min-width: 0; flex: 1; max-width: 360px; }
.feedurl { display: flex; gap: 6px; }
.feedurl input { flex: 1; min-width: 0; }

/* favorites */
.multi .opt label { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; cursor: pointer; }
.multi .opt label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi .opt .count { margin-left: 4px; }
.star { background: none; border: 0; cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; color: var(--muted); border-radius: 4px; }
.star:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.star.on { color: #e0a100; }
.favrow { display: flex; align-items: center; gap: 8px; padding: 6px; margin-bottom: 4px; border-radius: 6px; font-weight: 700; cursor: pointer;
  background: color-mix(in srgb, #e0a100 10%, transparent); }
.favrow .count { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 400; }
.favrow:has(input:disabled) { opacity: .6; cursor: default; }
.fav-hint { margin: 0 6px 6px; }
.fav-chip { background: #e0a100; color: #1b1a17; }
.favlist { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.favlist .chip { cursor: pointer; border: 0; font: inherit; font-size: 13px; }

/* album covers */
.album { justify-content: flex-start; }
.album .meta { flex: 1; min-width: 0; }
.cover { width: 64px; height: 64px; border-radius: 6px; object-fit: cover; flex: 0 0 64px; background: var(--line); }
.nocover { background:
  radial-gradient(circle, var(--paper) 0 4px, transparent 4px),
  radial-gradient(circle, color-mix(in srgb, var(--muted) 35%, var(--line)) 0 60%, var(--line) 60%); }
.cover.nocover { border-radius: 6px; }
.arow summary { grid-template-columns: 36px 100px 1fr 180px 70px 40px; }
.thumb { width: 36px; height: 36px; border-radius: 4px; object-fit: cover; display: inline-block; }
.coveredit { display: flex; gap: 14px; align-items: flex-start; }
.coveredit img, .nocover.big { width: 96px; height: 96px; border-radius: 8px; object-fit: cover; flex: 0 0 96px; }
@media (max-width: 680px) {
  .album { flex-direction: row; flex-wrap: wrap; align-items: flex-start; }
  .album .links { width: 100%; padding-left: 80px; }
  .cover { width: 56px; height: 56px; flex-basis: 56px; }
  .arow summary { grid-template-columns: 36px 1fr; }
}

.sitefoot { max-width: 1040px; margin: 0 auto; padding: 0 16px 28px; text-align: right; font-size: 12px; }
.sitefoot a { color: var(--muted); text-decoration: none; }
.sitefoot a:hover { text-decoration: underline; }

/* Job progress (admin Jobs page) */
.jobprog { padding: 12px 0; border-top: 1px solid var(--line); }
.jobprog:first-child { border-top: 0; padding-top: 0; }
.jobprog-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.jobprog-stage { margin: 6px 0; }
.jobprog-detail { margin-top: 6px; overflow-wrap: anywhere; }
.bar { position: relative; height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .4s ease; }
.bar-busy > span { width: 30%; position: absolute; animation: bar-busy 1.4s ease-in-out infinite; }
@keyframes bar-busy { from { left: -30%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .bar-busy > span { animation: none; width: 100%; opacity: .5; } }
button[data-job]:disabled { opacity: .6; cursor: progress; }

/* Releases page: header (title, filters, notes) stays visible while scrolling */
.stickyhead {
  position: sticky; top: var(--topbar-h, 0px); z-index: 30; background: var(--bg);
  margin: -24px -16px 0; padding: 16px 16px 4px;
  border-bottom: 1px solid transparent; transition: border-color .15s, box-shadow .15s;
}
.stickyhead.stuck { border-bottom-color: var(--line); box-shadow: 0 6px 16px -10px rgba(0,0,0,.25); }
.stickyhead h1 { margin-top: 0; }
.stickyhead > p:last-child { margin-bottom: 8px; }
.stickyhead-sentinel { height: 1px; margin-bottom: -1px; }
/* On short screens (landscape phones) a pinned header would cover most of the page. */
@media (max-height: 560px) {
  .stickyhead { position: static; }
  .day { scroll-margin-top: 12px; }
}
@media (max-width: 680px) {
  .stickyhead h1 { margin-bottom: 8px; }
}

/* Admins: the top navigation bar stays visible while scrolling */
.topbar-sticky { position: sticky; top: 0; z-index: 40; }
@media (max-height: 560px) {
  .topbar-sticky { position: static; }
}
/* Phones: compact nav bar (logo + account on one line, page links on one sideways-scrolling line),
   so it stays short enough to keep pinned. */
@media (max-width: 680px) {
  .topbar { gap: 6px 12px; padding: 10px 16px 6px; }
  .topbar .who { margin-left: auto; }
  .topbar nav {
    order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; margin: 0 -10px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a { white-space: nowrap; flex: none; }
}

/* Genre picker: "Add selected to favorites" row */
.multi .fav-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 6px; }
.multi .fav-actions .btn { width: 100%; }
.multi .fav-actions .btn:disabled { opacity: .5; cursor: default; }
.multi .fav-actions + .menu-actions { border-top: 0; margin-top: 4px; }

/* "How AudioList works" welcome dialog (Releases page) */
body.intro-open { overflow: hidden; }
.intro-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(15, 14, 12, .55);
}
.intro-backdrop[hidden] { display: none; }
.intro {
  position: relative; width: min(600px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35); padding: 20px 22px 16px;
}
.intro-close {
  position: absolute; top: 8px; right: 10px; width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer;
}
.intro-close:hover { background: var(--line); color: var(--ink); }
.intro [hidden] { display: none !important; }  /* .btn's display would otherwise win */
.intro-img { display: block; margin: 28px 0 14px; }
.intro-img img {
  display: block; width: 100%; height: auto; aspect-ratio: 2 / 1; object-fit: cover; object-position: top left;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.intro-count { margin: 0 0 4px; }
.intro h2 { font-size: 21px; margin: 0 0 8px; }
.intro-step p:last-child { margin: 0 0 4px; line-height: 1.5; }
.intro-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.intro-dots { display: flex; gap: 8px; }
.intro-dot { width: 9px; height: 9px; padding: 0; border-radius: 50%; border: 0; background: var(--line); cursor: pointer; }
.intro-dot.on { background: var(--accent); }
.intro-buttons { display: flex; gap: 8px; }
.intro .link { color: var(--muted); }
@media (max-width: 480px) {
  .intro { padding: 16px 16px 12px; }
  .intro h2 { font-size: 19px; }
}

/* theme switch (top right) */
.theme-switch { display: inline-flex; gap: 2px; padding: 2px; border-radius: 8px; background: color-mix(in srgb, currentColor 10%, transparent);
  margin-left: auto; flex: 0 0 auto; }
.theme-switch button { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 26px;
  border: 0; border-radius: 6px; background: none; color: inherit; opacity: .65; cursor: pointer; padding: 0; }
.theme-switch button:hover { opacity: 1; background: color-mix(in srgb, currentColor 12%, transparent); }
.theme-switch button[aria-pressed="true"] { opacity: 1; background: color-mix(in srgb, currentColor 24%, transparent); }
.theme-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.theme-switch svg { width: 16px; height: 16px; }
.vh { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
