/*
 * Every colour the dashboard uses is named here and nowhere else, so the whole
 * palette can be retuned, or a second theme added, without hunting through the
 * rules below for stray hex values.
 */

:root {
  /* Surfaces, from the page backdrop up to a hovered control. */
  --bg: #000;
  --surface: #000;
  --surface-2: #161616;
  --surface-3: #242424;
  --header-top: #000;
  --well: rgba(255, 255, 255, 0.08);

  /* Borders. The strong tone is for a hovered or armed edge. */
  --line: #2c2c2c;
  --line-strong: #414141;

  /* Text. */
  --text: #ececec;
  --muted: #a3a3a3;

  /* The accent, and the near-black that stays legible on top of it. */
  --accent: #c97b3c;
  --accent-hover: #d98a48;
  --accent-soft: #33240f;
  --accent-line: #5c4225;
  --accent-line-strong: #6b4a29;
  --on-accent: #1a1209;

  /* Status, as text, and as the border of an Artists status pill. */
  --good: #7fa96b;
  --good-line: #3d4d36;
  --warn: #d4a23c;
  --warn-line: #52432a;
  --bad: #c4685e;
  --bad-line: #53322e;

  /* The two banner tones across the top of the page. */
  --banner-ok-bg: #166534;
  --banner-ok-text: #ecfdf3;
  --banner-bad-bg: #991b1b;
  --banner-bad-text: #fef2f2;

  /*
   * A badge takes a background, a border and a text tone together, so they are
   * grouped per badge rather than per role. A premiere borrows the held green,
   * which is also the In Plex tick; a finale has its own.
   */
  --chip-held-bg: #2a4231;
  --chip-held-line: #3c6b4b;
  --chip-held-text: #7fd39b;
  --chip-part-bg: #363b28;
  --chip-part-line: #4d5630;
  --chip-part-text: #bfcc7a;
  --chip-digital-bg: #2c4133;
  --chip-digital-line: #34543f;
  --chip-digital-text: #8fd0a4;
  --chip-cinema-bg: #413426;
  --chip-cinema-line: #5a452a;
  --chip-cinema-text: #d0aa6a;
  --chip-event-bg: #2d3f47;
  --chip-event-line: #33505c;
  --chip-event-text: #8fc7dc;
  --chip-finale-bg: #46342d;
  --chip-finale-line: #6a463a;
  --chip-finale-text: #e0a68f;

  --radius: 14px;
  --content: 1080px;
  --gutter: max(24px, calc((100% - var(--content)) / 2 + 24px));
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 10px 28px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    15px/1.58 'Segoe UI',
    system-ui,
    -apple-system,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}

/* ------------------------------------------------------------- top bar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px var(--gutter);
  background: linear-gradient(180deg, var(--header-top), var(--surface));
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.disc {
  width: 44px;
  height: 44px;
  flex: none;
}

.topbar h1 {
  font-size: 21px;
}

.tagline {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

/* -------------------------------------------------------------- buttons */

.btn {
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition:
    background 0.12s,
    border-color 0.12s;
}
.btn:hover {
  background: var(--surface-3);
  border-color: var(--line-strong);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-quiet {
  background: transparent;
}
.btn-tiny {
  font-size: 12px;
  padding: 4px 9px;
}
/* On a touchscreen a small button is easy to miss, so every small button and
   chip is at least a fingertip (44 px) square there. The rows they sit in are
   allowed to wrap, so the bigger buttons still fit a phone-width card. */
@media (pointer: coarse) {
  .btn-tiny {
    min-height: 44px;
    min-width: 44px;
    padding: 6px 12px;
  }
  .chip {
    min-height: 44px;
  }
  .card-actions,
  .filter-summary {
    flex-wrap: wrap;
  }
}

/* ------------------------------------------------------------- progress */

.progress {
  padding: 12px var(--gutter) 14px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line);
}
.progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 7px;
}
.bar {
  height: 5px;
  background: var(--well);
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.4s ease;
}
#progress-eta {
  margin-top: 6px;
  color: var(--text);
}
#progress-current {
  margin-top: 6px;
  min-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.banner {
  margin: 0;
  padding: 12px var(--gutter);
  font-size: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--banner-bad-bg);
  color: var(--banner-bad-text);
}
.banner.ok {
  background: var(--banner-ok-bg);
  color: var(--banner-ok-text);
}
.banner.info {
  background: var(--surface-2);
  color: var(--text);
}

/* ----------------------------------------------------------------- tabs */

.tabs {
  display: flex;
  gap: 2px;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  overflow-x: auto;
}
.tab {
  font: inherit;
  font-size: 14px;
  padding: 12px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover {
  color: var(--text);
}
.tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.pill {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 11.5px;
  color: var(--muted);
}
.tab.is-active .pill {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

/* A row of views inside one tab, drawn as a segmented switch so it reads as a
   choice within the page rather than a second tab bar. */
.subtabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  max-width: 100%;
  overflow-x: auto;
}
.subtab {
  font: inherit;
  font-size: 13.5px;
  padding: 7px 14px;
  border: none;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.12s,
    color 0.12s;
}
.subtab:hover {
  color: var(--text);
}
.subtab.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.subtab.is-active .pill {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

main {
  padding: 22px var(--gutter) 60px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.panel-head p {
  margin: 0;
}
.panel-tools {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------- filters */

.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.filters .search {
  flex: 1 1 240px;
  min-width: 170px;
}
.filters select.input {
  width: auto;
  min-width: 150px;
}

.chips {
  display: flex;
  gap: 4px;
}
.chip {
  font: inherit;
  font-size: 13px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s,
    border-color 0.12s;
}
.chip:hover {
  color: var(--text);
  border-color: var(--line-strong);
}
.chip.is-on {
  background: var(--accent-soft);
  border-color: var(--accent-line-strong);
  color: var(--accent);
  font-weight: 600;
}

.filter-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 24px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------------------------------------------------------- release cards */

.cards {
  display: grid;
  gap: 12px;
}

.card {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 15px 17px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.is-dismissed {
  opacity: 0.5;
}

.art {
  width: 76px;
  height: 76px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-2);
  flex: none;
}
.art-fallback {
  display: grid;
  place-items: center;
  font-size: 26px;
  color: var(--muted);
}


.card-title {
  font-weight: 600;
  margin: 0 0 2px;
}
.card-artist {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0;
}
/*
 * Two lines, so every suggestion card is the same height and the list still
 * scans at a glance. The full text is on the element's tooltip.
 */
.card-blurb {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 4px 0 0;
}

.card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--muted);
}

/* A tag is a label, not a control: no border, a faint fill and small type, so
   it never reads as one of the buttons beside it. */
.tag {
  display: inline-block;
  padding: 0 6px;
  border: 0;
  border-radius: 3px;
  background: var(--well);
  color: var(--muted);
  font-size: 11px;
  line-height: 18px;
  text-transform: lowercase;
  white-space: nowrap;
}
.tag.new {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
  text-transform: none;
  font-weight: 600;
}

.card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* A link that sits among buttons is drawn as one, quieter than Trailer, with
   an arrow to say it opens somewhere else. */
a.btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  white-space: nowrap;
}
.btn-ghost {
  background: transparent;
}
.btn-out::after {
  content: '↗' / '';
  margin-left: 4px;
  font-size: 0.9em;
  opacity: 0.7;
}

a.link {
  color: var(--accent);
  text-decoration: none;
  font-size: 12.5px;
}
a.link:hover {
  text-decoration: underline;
}

/* ---------------------------------------------------------- episode list */

.episode-list {
  grid-column: 1 / -1;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 4px;
}
.episode-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 6px 9px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 13px;
}

/* ------------------------------------------------------- youtube player */

/* A lyric opened in its card, the way the trailer player opens. */
.lyric-text {
  margin: 0;
  max-height: 60vh;
  overflow: auto;
  white-space: pre-wrap;
  font: inherit;
  line-height: 1.5;
}
.lyric-input {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  font: inherit;
}

.player {
  grid-column: 1 / -1;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.player-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.chev {
  margin-right: 5px;
  display: inline-block;
}

/* Folding by height keeps the frame mounted, so audio carries on. */
.player-frame {
  max-height: 60vh;
  overflow: hidden;
  transition: max-height 0.18s ease;
}
.player.is-collapsed .player-frame {
  max-height: 0;
}

.player iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-width: 720px;
  border: 0;
  border-radius: 8px;
  /* Black, not a surface tone: it is the letterboxing around the video. */
  background: #000;
  display: block;
}

.tag.held {
  background: var(--chip-held-bg);
  border-color: var(--chip-held-line);
  color: var(--chip-held-text);
  text-transform: none;
  font-weight: 600;
}
/* Plain tag colours, but keeps "Plex" capitalised to match the held tag. */
.tag.not-held {
  color: var(--muted);
  text-transform: none;
}
.tag.part-held {
  background: var(--chip-part-bg);
  border-color: var(--chip-part-line);
  color: var(--chip-part-text);
  text-transform: none;
}
.tick {
  color: var(--chip-held-text);
  font-weight: 700;
}

.tag.date-digital {
  background: var(--chip-digital-bg);
  border-color: var(--chip-digital-line);
  color: var(--chip-digital-text);
  text-transform: none;
}
.tag.date-cinema {
  background: var(--chip-cinema-bg);
  border-color: var(--chip-cinema-line);
  color: var(--chip-cinema-text);
  text-transform: none;
}

.tag.event {
  background: var(--chip-event-bg);
  border-color: var(--chip-event-line);
  color: var(--chip-event-text);
  text-transform: none;
}

/* A premiere reads as a start, a finale as an end, so they take their own
   colours rather than sharing the plain event badge. */
.tag.event.premiere {
  background: var(--chip-held-bg);
  border-color: var(--chip-held-line);
  color: var(--chip-held-text);
}
.tag.event.finale {
  background: var(--chip-finale-bg);
  border-color: var(--chip-finale-line);
  color: var(--chip-finale-text);
}

/* ------------------------------------------------------------- artists */

.artists {
  display: grid;
  gap: 6px;
}

.artist-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.artist-row.is-muted {
  opacity: 0.45;
}
.artist-row .art {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}
.artist-name {
  font-weight: 500;
}
.artist-sub {
  font-size: 12.5px;
  color: var(--muted);
}

.status {
  font-size: 11.5px;
  padding: 1px 7px;
  border-radius: 4px;
  border: 1px solid var(--line);
}
.status-resolved,
.status-manual {
  color: var(--good);
  border-color: var(--good-line);
}
.status-ambiguous,
.status-pending {
  color: var(--warn);
  border-color: var(--warn-line);
}
.status-not_found,
.status-error {
  color: var(--bad);
  border-color: var(--bad-line);
}

.fix {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
}
.candidate {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  padding: 6px 8px;
  background: var(--surface-2);
  border-radius: 6px;
}

/* -------------------------------------------------------------- forms */

.form {
  max-width: 620px;
  display: grid;
  gap: 22px;
}
/* On a wide screen the sections sit in two columns rather than one narrow
   strip with half the page empty. Columns, not a grid, so a tall section does
   not leave a gap beside the short ones. */
@media (min-width: 1000px) {
  .form {
    display: block;
    max-width: none;
    columns: 2;
    column-gap: 22px;
  }
  .form fieldset {
    break-inside: avoid;
    margin-bottom: 22px;
  }
}
.form fieldset .row {
  margin-bottom: 16px;
}
.form fieldset .row.save-row {
  margin: 4px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 20px;
  margin: 0;
  background: var(--surface);
}
legend {
  padding: 0 8px;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.field {
  display: grid;
  gap: 5px;
  margin-bottom: 16px;
}
.field > span:first-child {
  font-size: 13.5px;
  font-weight: 500;
}
.field.narrow {
  grid-template-columns: 1fr auto;
  align-items: center;
}
.suffix {
  display: flex;
  align-items: center;
  gap: 8px;
}
.suffix .input {
  width: 80px;
}
.suffix em {
  min-width: 2.2em;
  font-style: normal;
  color: var(--muted);
  font-size: 13px;
}

.input {
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
.input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.check input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.row.wrap {
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 8px;
}

.history {
  margin-top: 34px;
  max-width: 620px;
}
.history h2 {
  font-size: 15px;
  margin-bottom: 10px;
}
.scan-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty strong {
  display: block;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 5px;
}

@media (max-width: 720px) {
  .filters .search {
    flex-basis: 100%;
  }
}

@media (max-width: 560px) {
  :root {
    --gutter: 14px;
  }
  .card {
    grid-template-columns: 60px 1fr;
  }
  .card-actions {
    grid-column: 2;
  }
  .art {
    width: 60px;
    height: 60px;
  }
  .field.narrow {
    grid-template-columns: 1fr;
  }
}

/* ================================================== stat tiles and cards */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.tile {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.tile-label {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 6px;
}
.tile-value {
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.tile-note {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 6px;
}

.chart-card {
  padding: 16px 18px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.chart-head h2 {
  font-size: 15px;
  margin-bottom: 3px;
}
.chart-head p {
  margin: 0;
}


/* ------------------------------------------------------------ accordion */

/* A collapsed section that sits above a list without crowding it. Native
   details/summary, so keyboard and screen readers get the behaviour free. */
.accordion {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.accordion-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.accordion-head::-webkit-details-marker {
  display: none;
}
.accordion-head:hover .accordion-title,
.accordion-head:focus-visible .accordion-title {
  color: var(--text);
}
.accordion-head::before {
  content: '';
  flex: none;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}
.accordion[open] > .accordion-head::before {
  transform: rotate(45deg);
}
.accordion-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.accordion-body {
  padding: 0 18px 18px;
}
.accordion-body .chart-head {
  margin-bottom: 10px;
}


/* A per-tab refresh sits quietly beside the filters, not competing with the
   primary action in the header. */
.btn-refresh {
  font-size: 13px;
  white-space: nowrap;
}

/* ------------------------------------------ search result detail panel */

.details {
  grid-column: 1 / -1;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
}
.detail-tagline {
  font-style: italic;
  color: var(--muted);
}
.detail-summary {
  max-width: 68ch;
  line-height: 1.5;
}
.detail-cast {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 13px;
}
.detail-actor {
  white-space: nowrap;
}

/* ------------------------------------------------- day headings in a feed */

.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.day-head:first-child {
  margin-top: 0;
}
.day-name {
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* An armed two-step button, waiting for its second press. */

.btn.is-armed {
  border-color: var(--bad);
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, transparent);
}

/* ------------------------------------------------------------ dashboard */

.dash-heading {
  font-size: 15px;
  margin: 22px 0 10px;
}
.dash-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.dash-heading-row .dash-heading {
  margin-bottom: 10px;
}
.dash-heading-row select {
  width: auto;
  margin-top: 12px;
}

.stream-row {
  align-items: start;
}
/* Posters, not artist portraits, so they keep their shape. */
.stream-row .art,
.poster-row .art {
  width: 48px;
  height: 72px;
  border-radius: 6px;
}
.stream-main {
  min-width: 0;
}
.stream-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.stream-progress .bar {
  flex: 1;
}

.added-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 14px;
  margin-top: 10px;
}
.added-item {
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.added-item .art {
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
}
.added-title {
  font-size: 13px;
  font-weight: 500;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.added-item .artist-sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0 14px;
}

.rank-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(60px, 1fr) auto;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.rank-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rank-bar {
  height: 8px;
  background: var(--well);
  border-radius: 4px;
  overflow: hidden;
}
.rank-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}
.rank-value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 3ch;
  text-align: right;
}

@media (max-width: 560px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
  .stream-row {
    grid-template-columns: 48px 1fr;
  }
  .stream-row .card-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}


/* ------------------------------------------------------------- utilities */

/* Read out by screen readers, not shown. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
}

.btn-scan {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* A line that needs reading before the list: an old chart, unsaved settings. */
.notice {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin: 0 0 14px;
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 13.5px;
}

.empty-actions {
  margin-top: 14px;
}

/* ------------------------------------------------ compact feed rows */

/* Out now and Coming soon are lists to scan, so each release is one short row:
   a small poster, the title with its artist or episode beside it, and the tags
   and date underneath. Roughly three times as many fit on a screen as the old
   cards did. */
#out-list,
#upcoming-list {
  gap: 4px;
}
#out-list .day-head,
#upcoming-list .day-head {
  margin-top: 14px;
}
#out-list .day-head:first-child,
#upcoming-list .day-head:first-child {
  margin-top: 0;
}
.card.feed-row {
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  box-shadow: none;
}
.feed-row .art {
  width: 40px;
  height: 40px;
  border-radius: 4px;
}
.feed-row .art-poster {
  height: 60px;
}
.feed-row .art-fallback {
  font-size: 16px;
}
.feed-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  margin: 0;
}
.feed-line .card-title {
  margin: 0;
  min-width: 0;
  flex: 0 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* The subtitle gives way first when the line is tight. */
.feed-line .card-artist {
  min-width: 0;
  flex: 0 1000 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-row .card-meta {
  gap: 6px;
  margin-top: 3px;
}
.feed-row .card-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}
.feed-row .episode-list {
  margin-top: 4px;
  padding-top: 6px;
}

/* --------------------------------------------------------- poster grid */

/* Trending and Suggestions: posters in a grid, the way Recently added shows
   them, with the actions as small buttons under each one. */
.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 22px 14px;
  align-items: start;
}
.poster-grid > .day-head,
.poster-grid > .empty,
.poster-grid > .grid-slot {
  grid-column: 1 / -1;
}
.poster-grid > .day-head {
  margin-top: 8px;
}
.poster-grid > .day-head:first-child {
  margin-top: 0;
}
.grid-slot:empty {
  display: none;
}
.grid-slot .player {
  margin-top: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.poster-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.poster-art {
  position: relative;
}
.poster-art .art {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
}
.poster-art.is-square .art {
  aspect-ratio: 1;
}
.poster-art .art-fallback {
  font-size: 40px;
}
.rank {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 26px;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.78);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.poster-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}
.poster-meta {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.poster-why {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.poster-body .card-blurb {
  -webkit-line-clamp: 3;
  line-clamp: 3;
  font-size: 12.5px;
}
.poster-body .card-meta:empty {
  display: none;
}
.poster-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

/* ------------------------------------------------------- A to Z jump bar */

/* Only the letters the list holds. It sticks to the top while the list scrolls
   on a wide screen; on a phone it is one row that scrolls sideways. */
.jumpbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 0;
  margin-bottom: 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.chart-card .jumpbar {
  background: var(--surface);
}
.jump {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.jump:hover,
.jump:focus-visible {
  background: var(--surface-2);
  color: var(--accent);
}
[data-letter] {
  scroll-margin-top: 56px;
}
.show-more {
  margin: 10px 0 0;
}

/* A poster in a row of names keeps its shape rather than being cut to a circle. */
.artist-row .art-poster {
  width: 40px;
  height: 60px;
  border-radius: 4px;
  justify-self: center;
}

/* ---------------------------------------------------------- recent plays */

.play-list {
  display: grid;
  margin-top: 6px;
}
.play-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}
.play-row:last-child {
  border-bottom: 0;
}
.play-row .art {
  width: 28px;
  height: 42px;
  border-radius: 4px;
}
.play-row .art-fallback {
  font-size: 13px;
}
.play-main {
  min-width: 0;
}
.play-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.play-row .artist-sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.play-when {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- lyrics */

.ly-overview {
  margin: 0 0 12px;
  font-size: 13.5px;
}

/* -------------------------------------------- bottom navigation, phones */

.bottomnav {
  display: none;
}
.bnav-tab {
  font: inherit;
  font-size: 11px;
  line-height: 1.2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 52px;
  padding: 6px 2px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.bnav-tab.is-active {
  color: var(--accent);
}
.bnav-label {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bnav-icon {
  position: relative;
  display: inline-flex;
}
.bnav-icon .icon {
  width: 24px;
  height: 24px;
}
.bnav-icon .pill {
  position: absolute;
  top: -6px;
  left: 15px;
  min-width: 18px;
  margin: 0;
  padding: 0 5px;
  font-size: 10.5px;
  line-height: 16px;
  text-align: center;
  background: var(--surface-3);
  color: var(--text);
}
.bnav-tab.is-active .pill {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.more-list {
  display: grid;
  gap: 8px;
}
.more-item {
  font: inherit;
  display: grid;
  gap: 2px;
  min-height: 56px;
  padding: 14px 16px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
}
.more-item:hover {
  border-color: var(--line-strong);
}
.more-title {
  font-weight: 600;
}

@media (max-width: 700px) {
  /* The seven tabs do not fit across a phone, so the bottom bar takes over. */
  .tabs {
    display: none;
  }
  .bottomnav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    padding: 4px calc(4px + env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom))
      calc(4px + env(safe-area-inset-left));
    background: var(--surface);
    border-top: 1px solid var(--line);
  }
  main {
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }

  /* One line of header: the mark, the name, and the check button as an icon. */
  .topbar {
    flex-wrap: nowrap;
    gap: 10px;
    padding-top: calc(10px + env(safe-area-inset-top));
    padding-bottom: 10px;
  }
  .brand {
    gap: 10px;
    min-width: 0;
  }
  .disc {
    width: 32px;
    height: 32px;
  }
  .topbar h1 {
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tagline {
    display: none;
  }
  .topbar-actions {
    flex: none;
  }
  .btn-scan {
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
  }
  .btn-scan .icon {
    width: 20px;
    height: 20px;
  }
  .btn-scan .btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  #stop-btn {
    min-height: 44px;
  }

  /* Recently added is one row that scrolls sideways, not a wall of posters. */
  .added-strip {
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-auto-columns: 108px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    padding-bottom: 6px;
  }
  .added-item {
    scroll-snap-align: start;
  }

  .jumpbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .jump {
    flex: none;
    min-width: 36px;
    height: 36px;
  }

  .poster-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 20px 12px;
  }
}

@media (max-width: 560px) {
  .card.feed-row {
    grid-template-columns: 40px minmax(0, 1fr);
  }
  .feed-row .card-actions {
    justify-content: flex-start;
  }
  .feed-line {
    flex-wrap: wrap;
    row-gap: 0;
  }
}

@media (pointer: coarse) {
  .jump {
    min-width: 44px;
    min-height: 44px;
  }
}

/* The hidden attribute always wins, even over a class that sets display. */
[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------- sign-in */

/* While signing in, nothing behind the card can be reached. */
body.signing-in > :not(#signin) {
  visibility: hidden;
}
.signin {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--bg);
}
.signin-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow);
}
.signin-card .disc {
  width: 44px;
  height: 44px;
}
.signin-card h2 {
  margin: 0;
  font-size: 20px;
}
.signin-card p {
  margin: 0;
}
.signin-card .field {
  margin: 0;
}
.signin-card .btn {
  justify-self: start;
  padding: 10px 16px;
}
.signin-status {
  min-height: 1.4em;
  color: var(--muted);
}
.signin-status.bad {
  color: var(--bad);
}
#phone-server-field .row .input {
  flex: 1;
  min-width: 0;
}
.session-list {
  list-style: none;
  margin: 8px 0 14px;
  padding: 0;
  display: grid;
  gap: 6px;
}
.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}
