/*
 * MyMediaServer — shared design system.
 *
 * One source of truth for fonts, colours, buttons, tables (zebra striping),
 * badges and forms, so every htmx tab looks the same. Everything is driven by
 * CSS custom properties, so a user's settings (theme + accent) can restyle the
 * whole surface by overriding a couple of variables on <html>.
 */

:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  /* dark is the default theme */
  --bg: #0f1216;
  --surface: #161b22;
  --surface-2: #1d2530;
  --border: #262d38;
  --border-strong: #38414f;
  --text: #f0f2f6;
  --muted: #c4ccd8;
  --zebra: #12171d;          /* even-row tint */

  --accent: #2d7cf6;         /* user-overridable */
  --accent-text: #ffffff;
  --ok: #6ee7a0;
  --ok-bg: #14351f;
  --warn: #ffcf4d;
  --warn-bg: #3a2f10;
  --danger: #ff9f9f;

  --radius: 8px;
  --radius-lg: 12px;
  color-scheme: dark;

  /* categorical chart palette (dataviz-validated order, dark-surface steps) */
  --series-1: #3987e5; --series-2: #008300; --series-3: #d55181; --series-4: #c98500;
  --series-5: #199e70; --series-6: #d95926; --series-7: #9085e9; --series-8: #e66767;
}

:root[data-theme="light"] {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: #dde1e7;
  --border-strong: #c3cad3;
  --text: #1a1f26;
  --muted: #5b6472;
  --zebra: #f0f2f5;
  --accent-text: #ffffff;
  --ok: #1f8a4c;
  --ok-bg: #e3f5ea;
  --warn: #9a6a00;
  --warn-bg: #fbf0d6;
  --danger: #b3261e;
  color-scheme: light;
  /* light-surface steps of the same validated palette */
  --series-1: #2a78d6; --series-2: #008300; --series-3: #e87ba4; --series-4: #eda100;
  --series-5: #1baf7a; --series-6: #eb6834; --series-7: #4a3aa7; --series-8: #e34948;
}

/* honour reduce-motion, either the OS or the user setting */
:root[data-motion="reduce"] * { transition: none !important; animation: none !important; }

* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 var(--font); background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* header */
.hdr { padding: 16px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
       display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 5; }
.hdr h1 { margin: 0; font-size: 17px; font-weight: 600; }
.hdr .spacer { flex: 1; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 20px 24px 60px; }

/* buttons — the one button system */
.btn { font: inherit; border: 1px solid transparent; border-radius: var(--radius);
       padding: 9px 16px; cursor: pointer; background: var(--accent); color: var(--accent-text);
       display: inline-flex; align-items: center; gap: 7px; line-height: 1.2;
       transition: filter .12s, background .12s, border-color .12s; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn.ghost:hover { border-color: var(--accent); filter: none; }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.btn.sm { padding: 5px 10px; font-size: 13px; }

/* forms */
input[type=text], input[type=search], input[type=password], input[type=number], input[type=email], input:not([type]), select {
  font: inherit; background: var(--bg); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 10px 12px; width: 100%; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
label.chk { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
        padding: 16px; }
.muted { color: var(--muted); }

/* list + zebra striping (shared by every tab) */
.list .row { display: flex; align-items: center; gap: 14px; padding: 10px 12px;
             border-bottom: 1px solid var(--border); transition: background .12s; }
.list .row:nth-child(even) { background: var(--zebra); }
.list .row:hover { background: var(--surface-2); }
.list .row img { width: 40px; height: 60px; object-fit: cover; border-radius: 4px;
                 background: var(--surface-2); flex: 0 0 auto; }
.list .row .meta { flex: 1; min-width: 0; }
.list .row .ti { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .row .sub { color: var(--muted); font-size: 13px; }

/* badges */
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--surface-2);
         color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }

/* quality grade badge (A best → D worst) */
.grade { font-weight: 700; font-size: 13px; width: 24px; height: 24px; border-radius: 6px;
         display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.grade.tg { font-size: 12px; width: 22px; height: 22px; border-radius: 5px; }
.grade-A { background: #14351f; color: #6ee7a0; }
.grade-B { background: #163049; color: #7fb2ff; }
.grade-C { background: #3a2f10; color: #ffcf4d; }
.grade-D { background: #3a1414; color: #ff9f9f; }

/* distribution bar (quality dashboard) */
.distrow { margin-bottom: 12px; }
.distrow .lab { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.distrow .lab .k { color: var(--text); text-transform: capitalize; }
.distrow .lab .v { color: var(--muted); }
.distbar { height: 8px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.distbar > i { display: block; height: 100%; border-radius: 6px; background: var(--accent); }
.statrow { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
        padding: 12px 16px; min-width: 120px; }
.stat .n { font-size: 22px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; }

/* donut (pie) chart — CSS conic-gradient, no library */
.piewrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { position: relative; width: 150px; height: 150px; border-radius: 50%; flex: 0 0 auto; }
.donut::after { content: ""; position: absolute; inset: 30%; border-radius: 50%;
                background: var(--surface); }
.pielegend { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.pielegend li { display: flex; align-items: center; gap: 8px; margin: 5px 0; }
.pielegend .sw { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.pielegend .k { text-transform: capitalize; }
.pielegend .v { color: var(--muted); margin-left: auto; padding-left: 16px; }
.chartgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }

/* sortable data table */
/* border-collapse:separate (not collapse) so sticky <th> renders correctly in
   Chrome — with collapse the header detaches and floats over rows. */
.ltable { width: 100%; border-collapse: separate; border-spacing: 0; }
/* Column headers read in their authored case (e.g. "Show", "Seasons"), not
   ALL CAPS — first letter upper, the rest as written. Applies to every table. */
.ltable th { text-align: left; padding: 10px 10px; font-size: 14px; text-transform: none;
             letter-spacing: .03em; color: var(--muted);
             box-shadow: inset 0 -1px 0 var(--border);
             position: sticky; top: 54px; background: var(--bg); z-index: 6; }
.ltable th.sortable a { color: var(--muted); text-decoration: none; white-space: nowrap; }
.ltable th.sortable a:hover { color: var(--text); }
/* Home-page media-drive bar — prominent so the eject button is unmissable. */
.drivebar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
      margin: 0 0 20px; padding: 12px 16px; border-radius: 12px;
      background: var(--surface); border: 1px solid var(--border-strong); }
.drivebar .drivestat { font-size: 14px; }
.drivebar .drivestat .on { color: #4ccf7f; }
.drivebar .drivestat .off { color: var(--muted); }
.btn.eject { background: #d0861f; color: #fff; border: 1px solid #d0861f;
      font-weight: 600; font-size: 14px; padding: 9px 18px; border-radius: 8px; }
.btn.eject:hover:not(:disabled) { background: #e8992a; border-color: #e8992a; }
.btn.eject:disabled { opacity: .45; cursor: default; }

.ltable th.num, .ltable td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ltable th.center, .ltable td.center { text-align: center; font-variant-numeric: tabular-nums; }
/* back-to-top button that lives in the sticky header's action column */
.homebtn { background: none; border: none; cursor: pointer; font-size: 15px;
           line-height: 1; padding: 2px 4px; opacity: .7; color: var(--text); }
.homebtn svg { width: 28px; height: 28px; display: block; }
.homebtn:hover { opacity: 1; transform: translateY(-1px); }
.ltable td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ltable tbody tr:nth-child(even) { background: var(--zebra); }
.ltable tbody tr:hover { background: var(--surface-2); }
.ltable td.ti { font-weight: 500; }
.ltable td.ti .sub, .ltable td.sub { color: var(--muted); font-size: 13px; }
.ltable td.pcell, .ltable td.acell { width: 1px; white-space: nowrap; }

/* Clickable artist — redraws the table filtered to that artist. Reads as text
   until hovered so the row still scans cleanly. */
.ltable td.artcell .artlink { color: inherit; text-decoration: none;
      border-bottom: 1px dotted var(--border-strong); cursor: pointer; }
.ltable td.artcell .artlink:hover { color: var(--accent); border-bottom-color: var(--accent); }
.ltable td.genrecell { color: var(--muted); font-size: 13px; max-width: 260px;
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* "Albums by X" banner shown while the table is filtered to one artist. */
.artistfilter { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px;
      font-size: 15px; }

/* poster thumbnail + hover-out card (extensible: add buttons/links inside) */
.tn { width: 36px; height: 54px; object-fit: cover; border-radius: 4px;
      background: var(--surface-2); display: block; }
.tn-empty { display: inline-block; }
.thumb { position: relative; display: inline-block; }
.hovercard { position: absolute; left: 44px; top: -28px; z-index: 90; display: none;
             padding: 6px; background: var(--surface); border: 1px solid var(--border-strong);
             border-radius: 10px; box-shadow: 0 14px 34px rgba(0,0,0,.55); }
.hovercard img { width: 180px; height: 270px; object-fit: cover; border-radius: 6px; display: block; }
.hovercard.sq img { width: 220px; height: 220px; }   /* album covers are square */
.thumb:hover .hovercard { display: block; }

/* custom tooltip — a black box with white text + drop shadow, in place of the
   OS's title bubble (which can't be styled). Opt in with data-tip="…". */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); z-index: 100; pointer-events: none; white-space: nowrap;
  background: #000; color: #fff; font-size: 14px; font-weight: 500; line-height: 1.4;
  padding: 7px 11px; border-radius: 7px; border: 1px solid rgba(255,255,255,.10);
  box-shadow: 0 6px 18px rgba(0,0,0,.6); }

/* 3D status dot */
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%;
       box-shadow: inset 0 -1px 2px rgba(0,0,0,.45), 0 1px 2px rgba(0,0,0,.35); }
.dot-ok      { background: radial-gradient(circle at 35% 30%, #b7f7cd, #2ec16b 55%, #17864a); }
.dot-pending { background: radial-gradient(circle at 35% 30%, #ffe4a3, #f5a623 55%, #b9781a); }
.dot-bad     { background: radial-gradient(circle at 35% 30%, #ffc2c2, #ef4444 55%, #991b1b); }
.dot-skip    { background: radial-gradient(circle at 35% 30%, #d9dee6, #9aa4b2 55%, #5b6472); }
/* ══════════════════════════════════════════════════════════════════════
   SITE-WIDE QUALITY-GRADE PALETTE  (A → D, best → worst)
       A = green      B = blue      C = amber      D = red
   Single source of truth for grade colour anywhere quality is shown. The
   .grade-A…D letter badges (above) and these .dot-A…D quality dots share the
   SAME hues, so a colour always means the same grade across the site. Any new
   quality UI — dots, letter chips, charts, legends, filters — MUST reuse this
   scale. The dots are the 3D radial-gradient form of the badge colours.
   ══════════════════════════════════════════════════════════════════════ */
.dot-A { background: radial-gradient(circle at 35% 30%, #b7f7cd, #2ec16b 55%, #17864a); }
.dot-B { background: radial-gradient(circle at 35% 30%, #bcdcff, #3b82f6 55%, #1d4ed8); }
.dot-C { background: radial-gradient(circle at 35% 30%, #ffe9b0, #f5b823 55%, #b9781a); }
.dot-D { background: radial-gradient(circle at 35% 30%, #ffc2c2, #ef4444 55%, #991b1b); }

/* Status-header rollover: colour tally for the whole library */
.statushdr { position: relative; }
.statustip {
  display: none; position: absolute; top: 100%; right: 0;
  z-index: 40; margin-top: 6px; padding: 8px 12px; white-space: nowrap;
  background: var(--panel, #1b1f24); border: 1px solid var(--line, #2a2f36);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.45);
  font-weight: 400; text-align: left; text-transform: none; letter-spacing: 0;
}
.statushdr:hover .statustip { display: block; }
.statustip b { display: block; margin-bottom: 5px; font-size: .82rem; }
.statustip .stline { display: flex; align-items: center; gap: 7px; padding: 2px 0; font-size: .8rem; }
.statustip .dot { width: 11px; height: 11px; }

/* Match-now inline feedback (success closes the modal; miss/error stays open) */
.matchmsg:empty { display: none; }
.matchmsg {
  margin: 8px 0 2px; padding: 8px 11px; border-radius: 7px;
  font-size: .85rem; line-height: 1.35; border: 1px solid transparent;
}
.matchmsg.ok   { background: rgba(46,193,107,.14); border-color: rgba(46,193,107,.35); color: #8ee9b2; }
.matchmsg.warn { background: rgba(245,166,35,.14); border-color: rgba(245,166,35,.35); color: #f5cd86; }
.matchmsg.err  { background: rgba(239,68,68,.14);  border-color: rgba(239,68,68,.38);  color: #f4a6a6; }

.pill-foreign { background: rgba(90,176,255,.16); border-color: rgba(90,176,255,.4); color: #9ccaf5; }

/* Subtitles panel (Edit modal) */
.subspanel { margin: 8px 0 2px; padding: 10px 12px; border: 1px solid var(--line,#2a2f36);
  border-radius: 8px; background: rgba(255,255,255,.02); }
.subshead { font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.sublist { list-style: none; margin: 0 0 8px; padding: 0; }
.sublist li { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: .84rem; }
.sublist .sublang { font-weight: 600; }
.sublist .subsrc { color: var(--muted,#8a94a0); font-size: .78rem; }
.sublist li .btn { margin-left: auto; }
.subupload { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.subupload input[type=file] { font-size: .8rem; max-width: 230px; }
.subupload select { font-size: .82rem; }

/* modal (edit record) */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none;
           align-items: center; justify-content: center; z-index: 100; }
.overlay.open { display: flex; }
.dialog { width: min(600px, 95vw); max-height: 92vh; background: var(--surface);
          border: 1px solid var(--border-strong); border-radius: 12px; overflow: hidden;
          display: flex; flex-direction: column; font-size: 15px; }
/* Roomier variant for editors that carry a lot (e.g. the album editor). */
.dialog.dialog-lg { width: min(780px, 96vw); }
.dialog .dscroll { overflow-y: auto; padding: 18px; }
/* Album editor: label + field on one line, and Artist/Year sharing a row so the
   wide modal stops wasting horizontal space. */
.dialog .field-inline { display: flex; align-items: center; gap: 12px; }
.dialog .field-inline > label { flex: 0 0 84px; margin-bottom: 0; text-align: right;
                                white-space: nowrap; }
.dialog .field-inline > input { flex: 1; min-width: 0; }
.dialog .field-row { display: flex; gap: 18px; align-items: flex-start;
                     margin-bottom: 16px; }
.dialog .field-row .field-inline { margin-bottom: 0; }
/* Tighter labels + smaller gap when three fields share the row (Album/Artist/Year),
   so the inputs keep usable width. */
.dialog .field-row { gap: 12px; }
.dialog .field-row .field-inline > label { flex-basis: 46px; }
.dialog .field-row .field-inline { gap: 8px; }
.dialog .field-row .grow { flex: 1; min-width: 0; }
.dialog .field-row .yr { flex: 0 0 auto; }
.dialog .field-row .yr > label { flex-basis: auto; }
.dialog .field-row .yr > input { flex: 0 0 96px; width: 96px; }
@media (max-width: 560px) {          /* stack again on a narrow screen */
  .dialog .field-row { flex-direction: column; gap: 16px; }
  .dialog .field-inline { flex-wrap: wrap; }
  .dialog .field-inline > label { flex-basis: auto; text-align: left; }
}
/* "Not identified" flag on album rows — a provider never matched it, so it
   needs a title/date cleanup + re-fetch. Amber to draw the eye without alarm. */
.unmatched { margin-left: 7px; color: #e0a53a; font-size: 12px; cursor: help;
             vertical-align: 1px; }
/* Filter toggles (Show duplicates / Unidentified) read clearly ON in green. */
.libcontrols .btn.on { color: #4ccf7f; border-color: #4ccf7f; font-weight: 600;
                       background: color-mix(in srgb, #4ccf7f 15%, transparent); }
/* Album editor: file list (reveal/delete junk), and the MusicBrainz match card. */
.btn.xs { font-size: 12px; padding: 3px 8px; }
.filelist { list-style: none; margin: 0; padding: 0; max-height: 220px;
            overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.filelist .frow { display: flex; align-items: center; gap: 10px; padding: 6px 10px;
                  border-bottom: 1px solid var(--border); font-size: 13px; }
.filelist .frow:last-child { border-bottom: none; }
.filelist .fn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
                white-space: nowrap; }
.filelist .fsz { flex: 0 0 auto; font-size: 12px; }
.filelist .fdel { flex: 0 0 auto; display: flex; align-items: center; }
.metamatch { margin-top: 8px; padding: 12px 14px; border: 1px solid var(--border);
             border-radius: 9px; display: flex; align-items: center; gap: 12px;
             flex-wrap: wrap; font-size: 13.5px; }
.metamatch .mm-line { flex: 1; min-width: 200px; }
/* Browse-artist release list */
.rgbox { margin-top: 10px; border: 1px solid var(--border); border-radius: 9px;
         padding: 10px 12px; }
.rghead { display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
          flex-wrap: wrap; }
.rghead .muted { flex: 1; min-width: 120px; font-size: 12.5px; }
.rgsearch { flex: 0 0 auto; width: 190px; font-size: 13px; padding: 6px 11px;
            border-radius: 999px; background: var(--surface-2, #23262e);
            color: inherit; border: 1px solid var(--border); }
.rglist { list-style: none; margin: 0; padding: 0; max-height: 300px;
          overflow-y: auto; }
.rglist li { display: flex; align-items: center; gap: 10px; padding: 6px 4px;
             border-bottom: 1px solid var(--border); font-size: 13.5px; }
.rglist li:last-child { border-bottom: none; }
.rgtitle { flex: 1; min-width: 0; }
.rgtype { flex: 0 0 auto; font-size: 12px; }
/* The album name is the click target now (no separate "Use" button). */
.rgtitle.rghot { cursor: pointer; border-radius: 5px; padding: 3px 6px; margin: -3px -6px;
                 transition: background .1s, color .1s; }
.rgtitle.rghot:hover, .rgtitle.rghot:focus-visible {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent); outline: none; }
.rgtitle.rghot:hover b, .rgtitle.rghot:focus-visible b { text-decoration: underline; }
.metamatch.found { border: 1px solid #2f9e5c;
                   background: color-mix(in srgb, #4ccf7f 12%, transparent); }
.metamatch.found .mm-tick { color: #4ccf7f; font-weight: 700; }
.metamatch.nomatch { border: 1px solid #7a5b1f;
                     background: color-mix(in srgb, #e0a53a 10%, transparent); }
/* Fetch-from-MusicBrainz — a prominent green call to action. */
.btn.fetchbtn { background: #2f9e5c; border-color: #2f9e5c; color: #fff;
                font-weight: 600; }
.btn.fetchbtn:hover { filter: brightness(1.08); }
.btn.ok { background: #2f9e5c; border-color: #2f9e5c; color: #fff; font-weight: 600; }
.btn.ok:hover { filter: brightness(1.08); }
.descbox { width: 100%; font-size: 14px; line-height: 1.5; padding: 10px 12px;
           border-radius: 8px; background: var(--surface-2, #23262e);
           border: 1px solid var(--border); color: inherit; resize: vertical;
           font-family: inherit; }
/* "Look up metadata" heading: an ⓘ whose hover tooltip carries the file-tag
   reference + match status (saves the space the old always-on lines took). */
.hint-i { display: inline-flex; align-items: center; justify-content: center;
          width: 17px; height: 17px; border-radius: 50%; font-size: 11px;
          margin-left: 6px; color: var(--muted); border: 1px solid var(--border);
          cursor: help; vertical-align: 1px; }
.hint-i:hover, .hint-i:focus { color: var(--text); border-color: var(--border-strong); }
.mbmini { font-size: 12px; font-weight: 400; margin-left: 8px; }
/* "Select from Albums" — the primary identify action (normal size, accent). */
.btn.go { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.go:hover { filter: brightness(1.08); }
/* Applied-from-match feedback: the button confirms, the changed fields flash. */
.btn.applied { background: #2f9e5c; border-color: #2f9e5c; color: #fff; opacity: 1; }
.dialog input.flash { animation: fieldflash 1.4s ease-out; }
@keyframes fieldflash {
  0%, 25% { box-shadow: 0 0 0 2px #4ccf7f;
            background: color-mix(in srgb, #4ccf7f 20%, var(--surface-2, #23262e)); }
  100% { box-shadow: none; }
}
/* Identification status badge in the album-editor header. */
.idstatus { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
            margin-left: 10px; vertical-align: 2px; border: 1px solid transparent; }
.idstatus.ok { color: #4ccf7f; border-color: #2f9e5c;
               background: color-mix(in srgb, #4ccf7f 14%, transparent); }
.idstatus.edited { color: #8ab4f8; border-color: #3b5b90;
                   background: color-mix(in srgb, #8ab4f8 14%, transparent); }
.idstatus.no { color: #e0a53a; border-color: #7a5b1f;
               background: color-mix(in srgb, #e0a53a 12%, transparent); }
.idstatus.manual { color: #c9a2f0; border-color: #6b4b9a;
                   background: color-mix(in srgb, #c9a2f0 14%, transparent); }
/* "Add New" first row of the album list stands apart from the matches. */
.rglist li.rgnew { background: color-mix(in srgb, var(--accent) 10%, transparent);
                   border-radius: 7px; border-bottom: none; margin-bottom: 4px; }
/* Files accordion in the album editor — collapsed by default, caret in the head. */
.filesacc > summary { cursor: pointer; list-style: none; font-weight: 600;
                      user-select: none; display: flex; align-items: center; gap: 6px; }
.filesacc > summary::-webkit-details-marker { display: none; }
.filesacc .acc-caret { display: inline-block; transition: transform .12s;
                       color: var(--muted); font-size: 12px; }
.filesacc[open] .acc-caret { transform: rotate(90deg); }
/* Banner shown in place of the album list after "Add New" is chosen. */
.rgconfirm { padding: 9px 11px; border-radius: 7px; font-size: 13px; line-height: 1.4;
             color: #c9a2f0; border: 1px solid #6b4b9a;
             background: color-mix(in srgb, #c9a2f0 12%, transparent); }
.regenlink { font-size: 12px; font-weight: 400; color: var(--accent);
             margin-left: 8px; text-decoration: none; cursor: pointer; }
.regenlink:hover { text-decoration: underline; }
/* Artwork compare/choose — its own roomy overlay stacked over the edit modal. */
.overlay.overlay-top { z-index: 200; }
.dialog.dialog-xl { width: min(1000px, 96vw); }
.artadd { display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
          margin-bottom: 16px; }
.artgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
           gap: 16px; }
.artcard { border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
           background: var(--surface-2, #23262e); display: flex; flex-direction: column; }
.artcard.primary { border: 2px solid #4ccf7f; }
.artimg { aspect-ratio: 1; background: #111; display: flex; align-items: center;
          justify-content: center; }
.artimg img { width: 100%; height: 100%; object-fit: contain; }
.artmeta { display: flex; align-items: center; justify-content: space-between;
           gap: 8px; padding: 8px 10px 4px; font-size: 12px; }
.srcbadge { background: var(--surface); border: 1px solid var(--border);
            border-radius: 999px; padding: 2px 9px; font-weight: 600; }
.artres { color: var(--muted); white-space: nowrap; }
.artcard .artuse { margin: 6px 10px 10px; }
.artcard .artis { margin: 6px 10px 10px; color: #4ccf7f; font-weight: 600;
                  font-size: 13px; text-align: center; }
/* Genre editor: the artist's curated genres as removable chips + an ADD dropdown
   limited to the closed MusicGenre vocabulary (no free text — anti-bloat). */
.genrebox { display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
            margin-bottom: 10px; min-height: 4px; }
.genrechip { display: inline-flex; align-items: center; gap: 4px;
             padding: 5px 5px 5px 12px; background: var(--surface-2, #23262e);
             border: 1px solid var(--border); border-radius: 999px; font-size: 13.5px; }
.genrechip button { border: none; background: none; color: var(--muted);
             cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px;
             border-radius: 50%; }
.genrechip button:hover { color: #ff6b6b; }
.genreadd { display: flex; gap: 8px; align-items: center; }
.genrepick { font-size: 13.5px; padding: 6px 10px; border-radius: 999px;
             background: var(--surface-2, #23262e); color: inherit;
             border: 1px solid var(--border); width: auto; cursor: pointer; }
.genre-empty { color: var(--muted); font-size: 13px; padding: 2px 0; }
.editbtns { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center;
            margin: 18px 0 6px; }
/* Lookup actions kept on a single left-aligned row (shortened labels fit). */
.editbtns.editbtns-1line { flex-wrap: nowrap; justify-content: flex-start;
                           gap: 8px; align-items: center; }
.editbtns.editbtns-1line .btn { white-space: nowrap; }
.filerow { font-size: 13.5px; margin: 12px 0 4px; word-break: break-all; }
.dialog input[type=text], .dialog input[type=number], .dialog input[type=search] {
          font-size: 15.5px; padding: 11px 13px; }
.dialog .dhead { padding: 15px 18px; border-bottom: 1px solid var(--border);
                 display: flex; align-items: center; justify-content: space-between; }
.dialog .dhead h3 { margin: 0; font-size: 17px; }
.dialog .field > label { font-size: 15px; }
.dialog .btn { font-size: 14.5px; }
.dialog .btn.sm { font-size: 14px; padding: 7px 13px; }
.dialog .muted { font-size: 13px; }
/* artist type-ahead dropdown */
.suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 30;
           margin-top: 4px; background: var(--surface); border: 1px solid var(--border-strong);
           border-radius: 8px; overflow: hidden auto; max-height: 260px;
           box-shadow: 0 10px 26px rgba(0,0,0,.45); }
.suggest:empty { display: none; }
.sugitem { display: block; width: 100%; text-align: left; background: none; border: none;
           color: var(--text); padding: 9px 12px; font-size: 14px; cursor: pointer; }
.sugitem:hover { background: var(--surface-2); color: var(--accent); }
/* modals are draggable by their title bar */
.dhead, .sleeve-head { cursor: move; user-select: none; }
.dhead button, .sleeve-head button { cursor: pointer; }
/* delete-confirm + generic destructive styling */
/* Delete buttons use a vivid, unmistakable red (matches the callout red) — not
   the muted --danger token, which is a light text-pink on the dark theme. */
.btn.danger { background: #e5342b; color: #fff; border-color: #e5342b; }
.btn.danger:hover { background: #c62a22; border-color: #c62a22; }
.danger-text { color: var(--danger, #c0392b); }
.dangerbox { border: 1px solid var(--danger, #c0392b); background: rgba(192,57,43,.08);
             border-radius: 8px; padding: 12px; margin-top: 10px; }
.confirmin { margin-top: 4px; padding: 7px 10px; border-radius: 6px; width: 120px;
             border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); }
.err { color: var(--danger, #c0392b); font-size: 12px; margin-top: 6px; }
/* artwork uploader / cropper */
.artbox { border: 1px solid var(--border); background: var(--surface-2);
          border-radius: 8px; padding: 12px; margin-top: 10px; }
.filebtn { font-size: 15px; padding: 10px 18px; display: inline-block; cursor: pointer; }
.cropwrap { border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden;
            background: repeating-conic-gradient(#8883 0% 25%, #0000 0% 50%) 50% / 16px 16px; }
.cropcanvas { display: block; cursor: grab; touch-action: none; }
.cropcanvas:active { cursor: grabbing; }
/* ── Albums view ──────────────────────────────────────────────────────── */
.viewtoggle { display: inline-flex; border: 1px solid var(--border-strong);
              border-radius: 999px; overflow: hidden; margin: 4px 0 2px; }
.viewtoggle .seg { padding: 6px 18px; font-size: 13px; color: var(--text);
                   text-decoration: none; background: var(--surface-2); }
.viewtoggle .seg.on { background: var(--accent); color: #fff; }
.viewtoggle .seg:not(.on):hover { filter: brightness(1.1); }

.albumgrid { display: grid; gap: 18px 16px;
             grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.albumcard { display: flex; flex-direction: column; gap: 2px; text-align: left;
             background: none; border: none; color: var(--text); padding: 0; }
/* The jacket and the text block are separate buttons now (cover pop-out vs play). */
.albumcard .jacketbtn, .albumcard .cardtext {
  background: none; border: none; color: inherit; padding: 0; cursor: pointer;
  text-align: left; font: inherit; width: 100%; }
.albumcard .cardtext { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.albumcard .cardtext:hover .atitle { color: var(--accent); }
/* Specs overlay the bottom of the cover on hover (no row-drop). pointer-events:
   none lets a click fall through to the jacket button → cover pop-out. */
.cardspecs { position: absolute; left: 0; right: 0; bottom: 0; padding: 11px 8px 4px;
             display: flex; flex-wrap: wrap; gap: 0 9px; align-items: center;
             font-size: 11px; line-height: 1.1; color: #fff; opacity: 0; transition: opacity .12s;
             pointer-events: none; border-radius: 0 0 8px 8px;
             background: linear-gradient(transparent, rgba(0,0,0,.55) 45%, rgba(0,0,0,.9)); }
.albumcard:hover .cardspecs { opacity: 1; }
.cardspecs .cs-q { display: inline-flex; align-items: center; gap: 4px; }
.cardspecs .dot { width: 9px; height: 9px; }
/* Full-width zero-height spacer forces mix + year onto a second line. */
.cardspecs .cs-br { flex: 0 0 100%; height: 0; margin: 0; }
.albumcard .jacket { position: relative; aspect-ratio: 1; width: 100%;
             border-radius: 8px; overflow: hidden; background: var(--surface-2);
             box-shadow: 0 4px 14px rgba(0,0,0,.28); display: grid; place-items: center; }
.albumcard .jacket img { width: 100%; height: 100%; object-fit: cover; }
/* TV posters are 2:3 portrait — square tiles crop them, so shows go oblong */
.showcard .jacket { aspect-ratio: 2 / 3; }
/* genre filter chips */
.genrebar { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 16px; }
.genrechip { font-size: 12.5px; padding: 5px 12px; border-radius: 999px; text-decoration: none;
             border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); }
.genrechip:hover { border-color: var(--accent); }
.genrechip.on { border-color: var(--accent); font-weight: 600; color: var(--accent);
                background: color-mix(in srgb, var(--accent) 18%, transparent); }
.genrechip.clear { color: var(--danger, #c0392b); border-color: var(--danger, #c0392b); }
.genrechip .gcount { color: var(--muted); font-size: 11px; margin-left: 6px; }
.genrechip.on .gcount { color: var(--accent); }
.genrebar .gcap { align-self: center; font-size: 11.5px; margin-left: 4px; }
.albumcard:hover .jacket { box-shadow: 0 8px 22px rgba(0,0,0,.42); transform: translateY(-2px); }
.albumcard .jacket, .albumcard:hover .jacket { transition: transform .12s, box-shadow .12s; }
.nocover { font-size: 34px; color: var(--muted); }
/* Cover-grid corner controls: 🗑 delete (top-left) and ✎ edit (top-right), both
   admin-only and revealed on hover. The wrapper is the grid item, so the card
   must fill it (min-width:0 lets a long title wrap, not stretch the card). */
.albumcard-wrap { position: relative; }
.albumcard-wrap > .albumcard { width: 100%; min-width: 0; }
/* The "not identified" flag moves to the BOTTOM-left so it never collides with
   the trash can that now lives top-left. */
.cardflag { position: absolute; bottom: 6px; left: 6px; color: #e0a53a; font-size: 13px;
            text-shadow: 0 1px 3px rgba(0,0,0,.8); pointer-events: none; }
.cardedit, .cardtrash { position: absolute; top: 7px; z-index: 3; opacity: 0;
            width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
            background: rgba(0,0,0,.72); border: 1px solid var(--border-strong);
            color: #fff; font-size: 14px; transition: opacity .12s, background .12s; }
.cardedit { right: 7px; }
.cardtrash { left: 7px; }
.albumcard-wrap:hover .cardedit, .albumcard-wrap:hover .cardtrash { opacity: 1; }
.cardedit:hover { background: rgba(0,0,0,.9); }
.cardtrash:hover { background: #e5342b; border-color: #e5342b; }
.albumcard .atitle { font-size: 13px; font-weight: 600; margin-top: 8px;
             white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.albumcard .aartist, .albumcard .acount { font-size: 12px;
             white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loadmore { grid-column: 1 / -1; height: 1px; }
/* album table (List layout) */
.albumrow { cursor: pointer; }
.albumrow:hover { background: var(--surface-2); }
.albumrow .thumbcell { width: 44px; padding: 4px 6px; }
.minicover { width: 34px; height: 34px; object-fit: cover; border-radius: 4px;
             background: var(--surface-2); display: grid; place-items: center; }
.minicover.nocov { color: var(--muted); font-size: 16px; }
/* TV show list rows carry portrait posters, so their mini is 2:3, not square */
.showrow .thumbcell { width: 42px; }
.minicover.showmini { width: 30px; height: 45px; }

/* record-sleeve modal */
.sleeve { width: min(680px, 95vw); max-height: 92vh; background: var(--surface);
          border: 1px solid var(--border-strong); border-radius: 12px;
          display: flex; flex-direction: column; overflow: hidden; }
.sleeve-head { padding: 14px 18px; border-bottom: 1px solid var(--border);
               display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sleeve-head h3 { margin: 0; font-size: 16px; }
.sleeve-body { display: flex; gap: 18px; padding: 18px; overflow-y: auto;
               flex: 1; min-height: 0; }
/* Keep the sleeve's player controls (play/pause + ♫ lyrics + ✕) always
   reachable. The track list scrolls inside the modal while the mini-player stays
   pinned at the bottom; without this, opening the lyrics/stats panel pushed the
   controls past the modal's 92vh cap and they became unclickable. Scoped to
   .sleeve so the full-page album view is unaffected. */
.sleeve .albumbox { min-height: 0; }
.sleeve .albumbox .tracklist { overflow-y: auto; min-height: 0; }
.sleeve .miniplayer { flex: none; }
.jacketbig { position: relative; flex: 0 0 200px; width: 200px; height: 200px;
             margin-right: 60px;  /* reserve space so the vinyl peek never covers tracks */
             border-radius: 4px; background: var(--surface-2); display: grid;
             place-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.jacketbig img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px;
             position: relative; z-index: 2; }
.jacketbig .vinyl { position: absolute; top: 9%; right: -20%; width: 82%; height: 82%;
             border-radius: 50%; z-index: 1; transition: right .35s ease;
             background: radial-gradient(circle at center,
               #2a2a2a 0 18%, #111 18% 20%, #2a2a2a 20% 34%, #111 34% 36%,
               #2a2a2a 36% 50%, #0a0a0a 50% 100%);
             box-shadow: 0 4px 14px rgba(0,0,0,.5); }
.jacketbig .vinyl::after { content: ""; position: absolute; inset: 42%;
             border-radius: 50%; background: var(--accent); }
.sleeve:hover .jacketbig .vinyl { right: -27%; }
@media (max-width: 560px) {
  .sleeve-body { flex-direction: column; align-items: center; }
  .jacketbig { margin-right: 0; }
}

.tracklist { flex: 1; min-width: 0; }
.tracklist .disctracks { list-style: none; margin: 0; padding: 0; }
.dischdr { display: flex; align-items: center; gap: 6px;
           font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
           color: var(--muted); margin: 10px 0 3px; padding: 0 8px; }
.dischdr:first-child { margin-top: 0; }
.dischdr .vinyl-ic { width: 16px; height: 16px; flex: 0 0 auto; }
/* Tighter track rows — leading halved (6px→3px) for a denser list. */
.trk { display: flex; align-items: center; gap: 10px; padding: 3px 8px;
       border-radius: 6px; font-size: 13px; }
/* Per-track quality dot (replaces the old A/B/C/D letter badge). Fixed box so
   the durations stay in a clean column. Colours = site-wide .dot-A…D. */
.trk .trkdot { flex: 0 0 auto; width: 13px; height: 13px; cursor: help; }
/* Track-dropdown header: quality colour-key on the left (hover for the grade
   legend), Edit-album button on the right. padding-right clears the ✕ close. */
.albumbox-hd { display: flex; align-items: center; justify-content: space-between;
               gap: 10px; padding: 0 30px 5px 8px; }
.albumbox-actions { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.albumeditbtn { display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.albumeditbtn .edit-ic { width: 15px; height: 15px; }
.tracklegend { display: inline-flex; align-items: center; gap: 4px;
               padding: 2px 6px; border-radius: 6px; cursor: help; }
.tracklegend:hover { background: var(--surface-2); }
.tracklegend .qkeylbl { font-size: 10.5px; text-transform: uppercase;
               letter-spacing: .05em; color: var(--muted); }
.tracklegend .dot { width: 9px; height: 9px; }
.trk:hover { background: var(--surface-2); }
.trk.playing { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.trk .tno { width: 22px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.trk .ttitle { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* fixed-width so the grade badges and durations line up in a clean column */
.trk .tdur { font-variant-numeric: tabular-nums; min-width: 46px; text-align: right; }
.trk .tplay, .trk .tpop { background: none; border: none; color: var(--muted);
       cursor: pointer; font-size: 17px; padding: 2px 4px; }
.trk .tpop { min-width: 26px; text-align: center; }
.trk .tplay:hover, .trk .tpop:hover, .trk.playing .tplay { color: var(--accent); }
.albumbox { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
/* Song title is the play target now (the leading ▶ was removed), so make it read
   as clickable. Scoped away from TV episode rows, which have their own styling. */
.trk:not(.ep) .ttitle { cursor: pointer; }
.trk:not(.ep) .ttitle:hover { color: var(--accent); }
/* Explicit close for the table accordion — clearer than clicking the row again.
   The track list reserves a right gutter so the ✕ never overlaps a track's
   ⧉ pop-out button on the first row. */
.albumbox .tracklist { padding-right: 24px; }
.albumclose { position: absolute; top: 0; right: 0; z-index: 3; background: none;
      border: none; color: var(--muted); font-size: 15px; line-height: 1;
      cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.albumclose:hover { color: var(--text); background: var(--surface-2); }
.albumbox .tracklist { flex: 1; }
/* Player now sits at the TOP of the dropdown — divider BELOW it, separating it
   from the track fields. */
.miniplayer { margin: 2px 0 8px; border-bottom: 1px solid var(--border);
              padding-bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.miniplayer .mpbar { display: flex; align-items: center; gap: 6px; }
/* Now-playing heading: prominent (bigger than the 12px it was, bold), coloured
   by the track's quality grade; the .nptext child keeps the ellipsis so the
   tooltip (::after on .np) isn't clipped by overflow. */
.miniplayer .np { display: inline-flex; min-width: 0; font-size: 15px;
              font-weight: 700; color: var(--muted); cursor: help; }
.miniplayer .nptext { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.miniplayer .np.np-A { color: #6ee7a0; }
.miniplayer .np.np-B { color: #7fb2ff; }
.miniplayer .np.np-C { color: #ffcf4d; }
.miniplayer .np.np-D { color: #ff9f9f; }
/* Breathing room after the last track (~5 blank lines). */
.albumbox .tracklist { padding-bottom: 96px; }
.miniplayer .mpspacer { flex: 1; }
.mpbtn { background: none; border: 1px solid var(--border); border-radius: 6px;
         color: var(--muted); cursor: pointer; padding: 2px 8px; font-size: 13px; }
.mpbtn:hover, .mpbtn.on { border-color: var(--accent); color: var(--accent); }
.miniplayer audio { width: 100%; height: 34px; }
.mppanel { margin-top: 2px; border-top: 1px dashed var(--border); padding-top: 8px;
           max-height: 220px; overflow: auto; }
.statspanel div { display: flex; justify-content: space-between; gap: 12px;
           font-size: 12px; padding: 2px 0; }
.statspanel span { color: var(--muted); }
.lyrics { white-space: pre-wrap; font: inherit; font-size: 13px; line-height: 1.5; margin: 0; }
/* Synced (time-highlighted) lyrics. The panel is positioned so a line's
   offsetTop is panel-relative for auto-scroll. */
.lyricspanel { position: relative; }
.lyrics.synced { white-space: normal; }
.lyrics.synced .lyricln { margin: 0; padding: 3px 0; font-size: 13px; line-height: 1.5;
                          color: var(--muted); opacity: .7; transition: color .15s, opacity .15s; }
.lyrics.synced .lyricln.on { color: var(--accent); font-weight: 600; opacity: 1; }

/* album table: expandable rows + quality dot + actions */
.chev { display: inline-block; color: var(--muted); font-size: 11px; margin-right: 4px;
        transition: transform .12s; }
.albumrow.expanded .chev { transform: rotate(90deg); }
.qcell { text-align: center; width: 78px; white-space: nowrap; }
/* Quality badge: colored dot + short format label (FLAC/MP3); the full spec
   summary is the hover tooltip. The dot here is a touch smaller than the
   status dots so it sits neatly beside the label text. */
.qbadge { display: inline-flex; align-items: center; gap: 6px; cursor: help; }
.qbadge .dot { width: 11px; height: 11px; }
.qfmt { font-size: 11px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
/* Mix column: channel layout (Stereo / 5.1 / Dolby…); same label size as the
   Quality format label, with a data-tip spelling out surround + Dolby/DTS. */
.mixcell { text-align: center; width: 62px; white-space: nowrap; }
.mixcell .qfmt { cursor: help; }
/* Non-sortable header label (e.g. Mix) — matches the sortable-link colour but
   isn't a link. */
.ltable th .colhdr { color: var(--muted); }

/* Reusable quality-grade legend popover — hover the Quality header (or any
   .haslegend element) to see the colour scheme. Table styled after Image #11:
   Grade / Colour / Meaning with the real .dot-A…D swatches. */
/* Anchor the popover to an inline-block span, NOT the <th> — position:relative
   on a table-cell shifts it vertically in some engines. */
.ltable th.haslegend { overflow: visible; }
.qlegend-anchor { position: relative; display: inline-block; cursor: help; }
.qlegend {
  display: none; position: absolute; top: 100%; left: 0; z-index: 60;
  margin-top: 6px; padding: 6px; white-space: nowrap; text-align: left;
  text-transform: none; letter-spacing: 0; font-weight: 400;
  background: var(--panel, #1b1f24); border: 1px solid var(--line, #2a2f36);
  border-radius: 9px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.qlegend-anchor:hover .qlegend { display: block; }
.qlegend-tbl { border-collapse: collapse; font-size: 12.5px; color: var(--text); }
.qlegend-tbl th, .qlegend-tbl td {
  border: 1px solid var(--line, #2a2f36); padding: 5px 11px; text-align: left; }
.qlegend-tbl thead th { color: var(--muted); font-weight: 600; }
.qlegend-tbl td:first-child { font-weight: 700; text-align: center; }
.qlegend-tbl td .dot { width: 13px; height: 13px; vertical-align: -2px; margin-right: 4px; }
/* "Found N albums · N tracks" line under the search box. */
.foundline { font-size: 12.5px; margin: 2px 2px 8px; }
.foundline b { color: var(--text); font-weight: 700; }
.sicon { display: inline-flex; align-items: center; }
.sicon svg { width: 15px; height: 15px; display: block; }
.acell { white-space: nowrap; text-align: right; }
.detailrow { display: none; }
.detailrow.open { display: table-row; }
.detailrow .detcell { padding: 4px 14px 14px; background: var(--surface-2); }

/* clickable table cell (artist / album -> page) */
.celllink { color: var(--text); text-decoration: none;
            border-bottom: 1px dotted var(--border-strong); }
.celllink:hover { color: var(--accent); border-color: var(--accent); }

/* dedicated album page */
/* audiobook page: full-width inline player above the chapter list */
.bookaudio { width: 100%; margin: 12px 0 14px; }
.bookchapters .chap { cursor: pointer; }
.albumpage { display: flex; gap: 24px; align-items: flex-start; }
.ap-art { flex: 0 0 300px; display: flex; flex-direction: column; gap: 12px; }
.ap-art .jacketbig { width: 240px; height: 240px; flex: none; margin-right: 60px; }
.ap-actions { display: flex; gap: 8px; }
.ap-main { flex: 1; min-width: 0; }
.ap-title { margin: 0 0 2px; font-size: 22px; }
.ap-sub { color: var(--muted); margin-bottom: 14px; }
.ap-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
           gap: 8px 18px; margin-bottom: 18px; }
.ap-meta > div { display: flex; flex-direction: column; font-size: 13px; }
.ap-meta span { color: var(--muted); font-size: 11px; text-transform: uppercase;
                letter-spacing: .04em; margin-bottom: 1px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
@media (max-width: 640px) { .albumpage { flex-direction: column; } }

/* film detail page */
.film-backdrop { position: absolute; top: 0; left: 0; right: 0; height: 360px; z-index: 0;
                 background-size: cover; background-position: center 20%; pointer-events: none; }
.filmpage { position: relative; z-index: 1; }
.filmpage .ap-title { font-size: 26px; }
.pill { display: inline-block; border: 1px solid var(--border-strong); border-radius: 4px;
        padding: 0 6px; font-size: 12px; color: var(--muted); }
.ratingrow { display: flex; flex-wrap: wrap; gap: 18px; margin: 12px 0 4px; align-items: center; }
.ratingrow .prov { font-size: 14px; }
.ratingrow .prov b { color: var(--muted); margin-right: 5px; }
.starline .star { font-size: 15px; color: var(--border-strong); }
.starline .star.on { color: #f5b400; }
.film-overview { font-size: 14.5px; line-height: 1.6; max-width: 72ch; margin: 10px 0 4px; }
.film-section { margin-top: 18px; }
.film-section h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase;
                   letter-spacing: .05em; color: var(--muted); }
.awchips, .moodchips { display: flex; flex-wrap: wrap; gap: 6px; }
.awchip { font-size: 12.5px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--accent);
          background: color-mix(in srgb, var(--accent) 12%, transparent); }
.film-credits > div { font-size: 14px; margin-bottom: 6px; }
.film-credits .clab { display: inline-block; width: 84px; color: var(--muted);
          font-size: 12px; text-transform: uppercase; letter-spacing: .04em; vertical-align: top; }
.film-tech { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 12px; }
.film-tech > summary { cursor: pointer; font-size: 13px; color: var(--muted);
          list-style: none; user-select: none; }
.film-tech > summary::-webkit-details-marker { display: none; }
.film-tech > summary::before { content: "▸ "; }
.film-tech[open] > summary::before { content: "▾ "; }

/* artist page header */
.artisthead { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; }
.artistpic { width: 120px; height: 120px; border-radius: 50%; overflow: hidden; flex: none;
             background: var(--surface-2); display: grid; place-items: center; }
.artistpic img { width: 100%; height: 100%; object-fit: cover; }

.trophy { font-size: 12px; cursor: help; white-space: nowrap; }
.mystars { font-size: 12px; color: #f5b400; white-space: nowrap; }
/* rating dialog */
.ratedim { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.ratedim > label { width: 74px; flex: 0 0 auto; font-size: 13px; color: var(--muted); }
.stars { display: inline-flex; gap: 2px; }
.star { background: none; border: none; cursor: pointer; font-size: 22px; line-height: 1;
        color: var(--border-strong); padding: 0 1px; transition: color .08s; }
.star.on { color: #f5b400; }
.stars:hover .star { color: var(--border-strong); }
.stars:hover .star.on { color: #f5b400; }
.moodchips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; cursor: pointer;
        border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); }
.chip.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.chip input { display: none; }
.provratings { display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
        margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.provratings .prov { font-size: 13px; }
.provratings .prov b { color: var(--muted); font-weight: 600; margin-right: 4px; }
/* TV show page: poster is portrait, no vinyl reserve */
.jacketbig.showjacket { margin-right: 0; width: 200px; height: 300px; }
.jacketbig.showjacket img { border-radius: 4px; }
/* season accordion + clickable episodes */
.season { border-bottom: 1px solid var(--border); }
.season > summary { cursor: pointer; list-style: none; padding: 9px 8px;
      font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.season > summary::-webkit-details-marker { display: none; }
.season > summary:hover { color: var(--text); }
.seasonposter { width: 30px; height: 45px; object-fit: cover; border-radius: 3px;
                vertical-align: middle; margin-right: 10px; }
.season .disctracks { padding-bottom: 6px; }
.trk.ep { cursor: pointer; }
.trk.ep:hover { background: var(--surface-2); }
.trk.ep:hover .ttitle { color: var(--accent); }
.trk.ep { align-items: flex-start; }
.trk.ep .tno { min-width: 22px; padding-top: 1px; }
.trk.ep .tdur { padding-top: 1px; }
.trk.ep .epmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.trk.ep .epmain .ttitle { flex: none; }
.epdesc { position: relative; font-size: 12px; color: var(--muted); line-height: 1.45;
          white-space: normal; display: -webkit-box; -webkit-line-clamp: 2;
          -webkit-box-orient: vertical; overflow: hidden; }
/* hover to reveal the full description (no layout shift) */
.trk.ep:hover .epdesc::after {
  content: attr(data-full); position: absolute; left: 0; top: 100%; margin-top: 4px;
  z-index: 80; width: max-content; max-width: 520px; white-space: normal;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 10px 13px; font-size: 13px; line-height: 1.5;
  box-shadow: 0 14px 34px rgba(0,0,0,.55); pointer-events: none; }
.editmode { display: inline-flex; align-items: center; gap: 8px; font-size: 13px;
      margin-bottom: 10px; cursor: pointer; user-select: none; }
.editmode input { cursor: pointer; }
.seasons.editing .trk.ep { cursor: text; }
.seasons.editing .trk.ep:hover { background: color-mix(in srgb, var(--danger, #c0392b) 14%, transparent); }
.seasons.editing .trk.ep:hover .ttitle { color: var(--danger, #c0392b); }
/* awards browser */
.awards td { font-size: 13px; vertical-align: top; }
.awards .yr { font-weight: 600; color: var(--muted); }
.awcell a { color: inherit; text-decoration: none; }
.awcell.owned { color: var(--accent); font-weight: 600; }
.awcell.owned::before { content: "● "; font-size: 9px; vertical-align: middle; }
.owned-eg { color: var(--accent); font-weight: 600; }
.grandslam { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.gs { font-size: 13px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border);
      background: var(--surface-2); }
.gs a { color: inherit; text-decoration: none; }
.gs.owned { border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* toasts — front and centre (top) so confirmations are unmissable */
.toasts { position: fixed; top: 22px; left: 50%; transform: translateX(-50%);
          z-index: 500; display: flex; flex-direction: column; gap: 8px;
          align-items: center; pointer-events: none; }
.toast { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
         border-left: 4px solid var(--accent); border-radius: 10px; padding: 13px 22px;
         font-size: 15px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.45);
         animation: toastlife 4.5s forwards; }
.toast.toast-ok { border-color: #2f9e5c; border-left-color: #4ccf7f;
                  background: color-mix(in srgb, #4ccf7f 16%, var(--surface));
                  color: #b9f2cf; }
.toast.toast-err { border-color: #b5453a; border-left-color: #ff6b6b;
                   background: color-mix(in srgb, #ff6b6b 14%, var(--surface));
                   color: #ffc9c4; }
@keyframes toastlife { 0%,7% { opacity: 0; transform: translateY(-10px); }
                       11%,84% { opacity: 1; transform: none; }
                       100% { opacity: 0; transform: translateY(-8px); } }
[data-motion="reduce"] .toast { animation-duration: 3s; }
.lookup-link { color: var(--accent); text-decoration: underline; cursor: pointer; word-break: break-all; }
.lookup-link:hover { filter: brightness(1.15); }
/* identify candidate cards */
.idcard { display: flex; gap: 10px; text-align: left; align-items: flex-start;
          background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
          border-radius: 8px; padding: 8px; cursor: pointer; width: 100%; }
.idcard:hover { border-color: var(--accent); }
.idcard img, .idcard .idposter { width: 40px; height: 60px; object-fit: cover; border-radius: 4px;
          background: var(--bg); flex: 0 0 auto; }
.idcard .idmeta { font-size: 13px; overflow: hidden; }
.idcard .idmeta .muted { font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2;
          -webkit-box-orient: vertical; overflow: hidden; }

/* progress bar (SSE scan showcase) */
.bar { height: 10px; background: var(--surface-2); border-radius: 20px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 20px;
           transition: width .4s ease; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* misc */
.sentinel { padding: 18px; text-align: center; color: var(--muted); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border-strong);
        border-top-color: var(--accent); border-radius: 50%; animation: sp .7s linear infinite;
        vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 14px; }
/* Add-a-library form (home page). Summary acts as a button; form is a plain card. */
.addlib { margin-top: 22px; }
.addlib > summary { list-style: none; width: max-content; cursor: pointer;
                    display: inline-flex; align-items: center; }
.addlib > summary::-webkit-details-marker { display: none; }
.addlib[open] > summary { margin-bottom: 12px; }
.addlibform { max-width: 660px; }
.addlibform .field-row { display: flex; gap: 14px; align-items: flex-start; }
.addlibform .field-row .grow { flex: 1; min-width: 0; }
.addlibform input, .addlibform select { width: 100%; }
.folder { display: block; background: var(--surface); border: 1px solid var(--border);
          border-radius: var(--radius-lg); padding: 16px; transition: border-color .12s, transform .12s; }
.folder:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; }
.folder .k { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.folder .t { font-size: 16px; font-weight: 600; margin: 4px 0; color: var(--text); }
/* Library tile with admin ✎/🗑 corner actions (revealed on hover). */
.folder-wrap { position: relative; }
.folder-wrap > .folder { height: 100%; }
.folder-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px;
                  opacity: 0; transition: opacity .12s; }
.folder-wrap:hover .folder-actions { opacity: 1; }
.libbtn { width: 27px; height: 27px; border-radius: 7px; cursor: pointer; font-size: 12px;
          background: rgba(0,0,0,.62); border: 1px solid var(--border-strong); color: #fff;
          transition: background .12s, border-color .12s; }
.libbtn.libedit:hover { background: rgba(0,0,0,.9); border-color: var(--accent); }
.libbtn.librm:hover { background: #e5342b; border-color: #e5342b; }
/* Server folder picker (Add-library form). */
.fbrowse { border: 1px solid var(--border); border-radius: 9px; margin-top: 10px;
           background: var(--surface-2); overflow: hidden; }
.fbhead { display: flex; align-items: center; gap: 8px; padding: 8px 10px;
          border-bottom: 1px solid var(--border); }
.fbpath { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
          max-width: 300px; color: var(--text); }
.fblist { list-style: none; margin: 0; padding: 5px; max-height: 240px; overflow-y: auto; }
.fbrow { display: block; width: 100%; text-align: left; background: none; border: none;
         color: var(--text); padding: 6px 9px; border-radius: 6px; cursor: pointer;
         font-size: 13px; }
.fbrow:hover { background: var(--surface); }
.searchbar { background: var(--bg); padding: 12px 0;
             display: flex; align-items: center; gap: 12px; }

/* Compact, sticky toolbar: the Lists/Covers tabs + all controls on ONE line that
   stays pinned just below the page header while the grid scrolls under it. */
.libtoolbar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 14px;
              position: sticky; top: 54px; z-index: 6; background: var(--bg);
              padding: 6px 0 8px; margin: -12px 0 6px;   /* pull up: kill head space */
              border-bottom: 1px solid var(--border); }
.libtoolbar .viewtoggle { margin: 0; }
.libtoolbar .libcontrols { margin: 0; flex: 1 1 auto; align-items: center; }
/* Open Filter: its chips take a FULL-WIDTH line of their own below the compact
   button row (order:last), instead of squeezing Artist First / Search sideways
   and floating them at the chip block's vertical centre. */
.libtoolbar .filteracc[open] { flex: 1 1 100%; order: 20; align-items: flex-start; }
.libtoolbar .filteracc[open] .genrebar { flex: 1 1 100%; margin-top: 2px; }
/* Slimmer buttons (less vertical bulk) while pinned. */
.libtoolbar .viewtoggle .seg { padding: 4px 15px; }
.libtoolbar .libcontrols .btn.sm,
.libtoolbar .searchacc > summary.searchtoggle { padding: 4px 12px; }
/* The search input was default-tall (10px pad); trim it to match the chips. */
.libtoolbar .searchbar input[type=search] { padding: 5px 11px; }
/* Lists page: the toolbar pins like Covers, and the table's own sticky column
   headers stack just BELOW it (pushed from top:54px down to clear the toolbar). */
#albumtablewrap .ltable th { top: 95px; }

/* Filter + Search toggles share one row; when collapsed they sit side by side.
   Opening one expands its content INLINE to the right of its chip. */
.libcontrols { display: flex; flex-wrap: wrap; align-items: flex-start;
               gap: 8px 14px; margin: 6px 0 10px; }
.searchacc { display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
             flex: 0 0 auto; }                 /* collapsed = just the chip */
.searchacc[open] { flex: 1 1 320px; }          /* opened = grow to fill the line */
.searchacc > summary.searchtoggle {
  list-style: none; cursor: pointer; user-select: none; width: max-content;
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; font-size: 13px;
  padding: 6px 13px; border-radius: 999px; color: var(--text);
  border: 1px solid var(--border-strong); background: var(--surface-2); }
.searchacc > summary.searchtoggle::-webkit-details-marker { display: none; }
.searchacc > summary.searchtoggle::marker { content: ""; }
.searchacc > summary.searchtoggle:hover { border-color: var(--accent); }
/* Open state stays neutral/white (like the Filter chip) — no blue icon/border,
   and keep the "Search" label visible so it reads the same as Filter. */
.searchacc[open] > summary.searchtoggle { border-color: var(--border-strong); color: var(--text); }
.searchacc .searchbar { flex: 1 1 260px; padding: 0; }
.searchacc .searchbar input { flex: 1 1 auto; width: auto; }
/* filter chips form a block to the right of the toggle; top-align the chip so
   it lines up with the first chip row when they wrap over several lines. */
.filteracc { align-items: flex-start; }
.filteracc[open] > summary.searchtoggle { margin-top: 3px; }
.filteracc .genrebar { flex: 1 1 300px; margin: 0; }

/* htmx request indicators (shown only while a request is in flight) */
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* chat (RAG) */
.chat-turn { margin-bottom: 20px; }
.bubble { max-width: 80%; padding: 11px 15px; border-radius: 14px; margin: 6px 0;
          line-height: 1.5; white-space: pre-wrap; }
.bubble.user { background: var(--accent); color: var(--accent-text); margin-left: auto;
               border-bottom-right-radius: 4px; }
.bubble.ai { background: var(--surface); border: 1px solid var(--border);
             border-bottom-left-radius: 4px; }
.bubble.err { color: var(--warn); }
.chat-items { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.chatcard { width: 96px; font-size: 12px; color: var(--text); }
.chatcard img { width: 96px; aspect-ratio: 2/3; object-fit: cover; border-radius: 6px;
                background: var(--surface-2); display: block; margin-bottom: 4px; }
.chatchip { font-size: 12px; padding: 4px 10px; border-radius: 16px;
            background: var(--surface-2); color: var(--muted); }
.chatbar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0;
           display: flex; gap: 10px; }
.chatbar input { flex: 1; }

/* Favourites shelf (/htmx/favorites/). The star itself reuses .star above. */
.star:hover { color: #f5b400; }
.favgrid { display: grid; gap: 16px;
           grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.favcard { position: relative; display: flex; flex-direction: column; }
.favlink { display: flex; flex-direction: column; gap: 6px; text-decoration: none;
           color: inherit; }
.favposter { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 8px;
             background: var(--panel); }
.favposter.nocov { display: flex; align-items: center; justify-content: center;
                   font-size: 34px; color: var(--border-strong); }
.favtitle { font-size: 13px; line-height: 1.3; }
.favstar { position: absolute; top: 6px; right: 6px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.favkind { font-size: 11px; text-transform: capitalize; }

/* YouTube page (/htmx/youtube/). */
.ytadd { display: flex; gap: 10px; flex-wrap: wrap; }
.ytadd input[name="url"] { flex: 1 1 340px; }
.ytadd input[name="labels"] { flex: 0 1 220px; }
.ytfilters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip.sm { font-size: 11px; padding: 1px 8px; }
.ytgrid { display: grid; gap: 18px;
          grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.ytcard { display: flex; flex-direction: column; }
.ytmedia { position: relative; aspect-ratio: 16/9; border-radius: 8px;
           overflow: hidden; background: #000; }
.ytthumb { width: 100%; height: 100%; padding: 0; border: 0; cursor: pointer;
           position: relative; background: #000; }
.ytthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ytplaybtn { position: absolute; inset: 0; margin: auto; width: 54px; height: 54px;
             display: flex; align-items: center; justify-content: center;
             font-size: 22px; color: #fff; background: rgba(0,0,0,.55);
             border-radius: 50%; transition: background .1s; }
.ytthumb:hover .ytplaybtn { background: #cc0000; }
.ytdur { position: absolute; right: 6px; bottom: 6px; font-size: 11px; color: #fff;
         background: rgba(0,0,0,.8); padding: 1px 5px; border-radius: 3px; }
.ytframe { width: 100%; height: 100%; border: 0; }
.ytmeta { padding: 8px 2px 4px; flex: 1; }
.yttitle { font-size: 13px; line-height: 1.35; font-weight: 500;
           display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
           overflow: hidden; }
.ytsub { font-size: 12px; margin-top: 3px; }
.ytlabels { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.ytactions { display: flex; gap: 6px; padding: 4px 2px; }

/* Audible library page (/htmx/audible/). */
.abstatus { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.abstatus .on { color: #4ccf7a; }
.abstatus .off { color: #c2cbd6; }
.absearch { margin-bottom: 14px; }
.absearch input { width: 100%; }
.abfilters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.abgrid { display: grid; gap: 18px;
          grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.abcard { display: flex; flex-direction: column; }
.abcover { position: relative; display: block; aspect-ratio: 1/1; border-radius: 8px;
           overflow: hidden; background: var(--panel); }
.abcover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.abcover .nocover { display: flex; align-items: center; justify-content: center;
                    height: 100%; font-size: 34px; }
.abbadge { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px;
           display: flex; align-items: center; justify-content: center;
           border-radius: 50%; font-size: 12px; font-weight: 700; color: #06210f;
           background: #4ccf7a; box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.abmeta { padding: 8px 2px 4px; }
.abtitle { font-size: 13px; font-weight: 500; line-height: 1.3;
           display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
           overflow: hidden; }
.absub { font-size: 11.5px; margin-top: 2px; }

/* Album-table artwork toggle (the 👁 in the cover-column header). Three states
   cycled on click: 0 covers shown → 1 covers hidden, rows a little tighter →
   2 covers hidden, rows as dense as possible → back to 0. The eye stays visible
   in every state (its column keeps a little width). */
.eyebtn { background: none; border: 0; cursor: pointer; padding: 0;
          line-height: 0; color: var(--muted); opacity: .9; display: inline-flex; }
.eyebtn:hover { color: var(--text); opacity: 1; }
.eyebtn svg { width: 32px; height: 32px; display: block; }
/* Hide the covers, but keep the column ~28px so the eye stays clickable. */
.ltable.noart .minicover,
.ltable.noart .thumb { display: none; }
.ltable.noart .thumbcell,
.ltable.noart .thumbhdr { width: 28px; }
/* Artwork off → tight rows (half the padding + tighter leading). */
.ltable.noart td { padding-top: 2px; padding-bottom: 2px; line-height: 1.25; }

/* Utilities page — DVD → MP4 converter. */
.legalnote { border-color: #7a5a1a; }
.dvdjob { padding: 10px 0; border-bottom: 1px solid var(--border); }
.dvdjob:last-child { border-bottom: 0; }
.dvdjob-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.pbar { height: 8px; border-radius: 4px; background: var(--panel); overflow: hidden; margin-top: 6px; }
.pbar > span { display: block; height: 100%; background: var(--accent); transition: width .4s; }

/* Covers "Reverse" toggle — show the artist first, album second (order + swap
   the emphasis). Default (no class) shows album first as authored. */
.albumgrid.byartist .aartist { order: 2; margin-top: 8px;
                               color: var(--text); font-weight: 600; font-size: 13px; }
.albumgrid.byartist .atitle { order: 3; margin-top: 0;
                              color: var(--muted); font-weight: 400; font-size: 12px; }

/* Chat result cards are now links to the record. */
a.chatcard { text-decoration: none; color: inherit; }
a.chatcard:hover { text-decoration: none; }

/* Bulk-delete confirm list (duplicates view). */
.dupdel-list { list-style: none; margin: 10px 0; padding: 0; max-height: 280px;
               overflow-y: auto; font-size: 13px; }
.dupdel-list li { display: flex; justify-content: space-between; gap: 12px;
                  padding: 4px 0; border-bottom: 1px solid var(--border); }
.acell .dupsel { width: 16px; height: 16px; cursor: pointer; vertical-align: middle; }

/* Selected duplicate rows — pale yellow highlight so the picks stand out. */
.ltable tr.albumrow.rowsel,
.ltable tr.albumrow.rowsel > td { background: rgba(240, 214, 105, .16); }
.ltable tr.albumrow.rowsel:hover > td { background: rgba(240, 214, 105, .22); }

/* Search-scope selector in front of the album search box. */
.searchscope { width: auto; flex: 0 0 auto; padding: 8px 8px; border-radius: 8px 0 0 8px;
               border-right: 0; }
.searchbar input[name="q"] { border-radius: 0 8px 8px 0; }

/* ── Managed household profiles ─────────────────────────────────────────── */
/* "Who's watching?" picker */
.wsw { display: flex; flex-direction: column; align-items: center; padding-top: 6vh; }
.wsw-title { font-size: 26px; font-weight: 700; margin: 0 0 28px; }
.profilegrid { display: flex; flex-wrap: wrap; gap: 22px; justify-content: center; }
.profilecard { display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: 128px; padding: 14px 10px; background: none; border: none; cursor: pointer;
  color: var(--text); text-decoration: none; border-radius: 12px; transition: transform .12s; }
.profilecard:hover { transform: translateY(-3px); text-decoration: none; }
.pfavatar { display: flex; align-items: center; justify-content: center;
  width: 96px; height: 96px; border-radius: 14px; font-size: 46px; line-height: 1;
  background: var(--surface-2); border: 2px solid transparent; }
.profilecard:hover .pfavatar { border-color: var(--accent); }
.pfavatar.big { width: 72px; height: 72px; font-size: 36px; margin: 0 auto; }
.pfname { font-size: 15px; font-weight: 600; }
.pfkind { font-size: 12px; color: var(--muted); }
.addcard .pfavatar { font-size: 40px; color: var(--muted);
  border: 2px dashed var(--border-strong); background: none; }

/* PIN gate overlay */
.pinmodal { position: fixed; inset: 0; z-index: 200; display: flex;
  align-items: center; justify-content: center; background: rgba(0,0,0,.6); }
.pincard { background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 14px; padding: 26px 30px; text-align: center; min-width: 260px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.pincard h3 { margin: 10px 0 0; }
.pininput { text-align: center; letter-spacing: .5em; font-size: 20px; width: 180px; }

/* Manage-profiles list */
.profilerows { display: flex; flex-direction: column; gap: 8px; }
.profilerow { display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.profilerow .pfavatar { width: 40px; height: 40px; font-size: 22px; border-radius: 9px; }
.profilerow .pfname { flex: 0 0 auto; }
.profileform { max-width: 460px; margin-top: 14px; }
.prow { display: flex; gap: 12px; }
.prow .field { flex: 1; }
.btn.ghost.sm.danger:hover { border-color: var(--danger, #e5534b); color: var(--danger, #e5534b); }

/* Persistent "watching as …" switcher chip (bottom-right) */
.profilechip { position: fixed; right: 14px; bottom: 14px; z-index: 120;
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,.35);
  color: var(--text); text-decoration: none; font-size: 13px; }
.profilechip:hover { border-color: var(--accent); text-decoration: none; }
.profilechip .pfavatar { width: 26px; height: 26px; font-size: 16px; border-radius: 8px; }
.profilechip .pfchipname { font-weight: 600; }

/* ── Friend sharing ─────────────────────────────────────────────────────── */
.checkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 6px 14px; }
.sharerows { display: flex; flex-direction: column; gap: 10px; }
.sharerow { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.sharerow.inactive { opacity: .55; }
.sharemain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.sharehead { display: flex; align-items: center; gap: 8px; }
.sharelink { display: flex; gap: 6px; margin-top: 4px; }
.sharelink .linkin { flex: 1; font-size: 12px; padding: 6px 8px; color: var(--muted);
  font-family: var(--font-mono); }
.sharelibs { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }

/* ── Household activity dashboard ───────────────────────────────────────── */
.actgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px,1fr)); gap: 12px; }
.actcard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.acthead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.acthead .pfavatar { width: 44px; height: 44px; font-size: 24px; border-radius: 10px; }
.actstats { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.actstats b { color: var(--text); }
.actlast { font-size: 12px; margin-top: 8px; }
.actfeed { display: flex; flex-direction: column; }
.feedrow { display: flex; align-items: center; gap: 12px; padding: 9px 4px;
  border-bottom: 1px solid var(--border); font-size: 14px; }
.feedav { font-size: 20px; width: 26px; text-align: center; flex: 0 0 auto; }
.feedicon { flex: 0 0 auto; }
.feedtitle { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feedstate { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.feedwhen { flex: 0 0 auto; font-size: 12px; min-width: 92px; text-align: right; }
/* Most-watched ranked list (activity dashboard) */
.mwlist { display: flex; flex-direction: column; }
.mwrow { display: flex; align-items: center; gap: 12px; padding: 9px 4px;
  border-bottom: 1px solid var(--border); font-size: 14px; }
.mwrank { flex: 0 0 auto; width: 22px; text-align: right; font-weight: 700;
  color: var(--muted); font-variant-numeric: tabular-nums; }
.mwmeta { flex: 0 0 auto; font-size: 12.5px; }
.mwmeta b { color: var(--text); }
/* Quality page — storage/re-encode panels */
.qhd { margin: 0 0 12px; font-size: 13px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); }
.reencode { display: flex; align-items: center; gap: 16px; margin-bottom: 14px;
  border-left: 3px solid #ffcf4d; }
.reencode .reencode-main { flex: 1; min-width: 0; font-size: 14px; }
.reencode .btn { flex: 0 0 auto; }

/* Audible: collapsible genre filter + imported-badge toggle */
.abfilteracc { margin-bottom: 12px; }
.abfilteracc > summary.abfiltertoggle {
  list-style: none; cursor: pointer; user-select: none; display: inline-flex;
  align-items: center; gap: 6px; font-size: 13px; padding: 6px 13px;
  border-radius: 999px; color: var(--text); width: max-content;
  border: 1px solid var(--border-strong); background: var(--surface-2); }
.abfilteracc > summary.abfiltertoggle::-webkit-details-marker { display: none; }
.abfilteracc > summary.abfiltertoggle:hover { border-color: var(--accent); }
.abfilteracc[open] > summary.abfiltertoggle { border-color: var(--accent); }
.abfilteracc .abfilters { margin-top: 10px; }
.abshowbar { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 0 0 12px; }
.abbadge-toggle { background: none; border: 1px solid var(--border); cursor: pointer;
  color: var(--muted); font-size: 12px; padding: 3px 9px; border-radius: 999px; }
.abbadge-toggle:hover { border-color: var(--accent); color: var(--text); }
#ablist.nobadges .abbadge { display: none; }

/* Re-encode page */
.rcbar { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin-bottom: 4px; }
.rcbar .spacer { flex: 1; }
.rclist { display: flex; flex-direction: column; max-height: 460px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px; }
.rcrow { display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.rcrow:last-child { border-bottom: none; }
.rcrow:hover { background: var(--surface-2); }
.rcname { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rcmeta { flex: 0 0 auto; font-size: 12px; font-variant-numeric: tabular-nums; }
.rcjobs { display: flex; flex-direction: column; gap: 8px; }
.rcjob { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; }
.rcjob-error { border-color: color-mix(in srgb, var(--danger,#e5534b) 45%, var(--border)); }
.rcjobhead { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.rcjobname { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }

/* ── Grouped video view (Documentaries etc.) ─────────────────────────────
   A multi-video sub-folder folds into one expandable <details> card; a
   standalone film is a single row. Presentation-only grouping by folder. */
.vglist { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.vgtotal { font-size: 12px; margin: 0 4px; }
.vgroup { border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
          background: var(--surface); }
.vgroup > summary { list-style: none; cursor: pointer; }
.vgroup > summary::-webkit-details-marker { display: none; }
/* Positioning context for the group's ✎, which sits OUTSIDE <details> so a
   click on it can't also toggle the card open. */
.vgroupwrap { position: relative; }
/* Right padding reserves the ✎'s lane, so it never lands on the year. */
.vgsum { display: flex; align-items: center; gap: 12px; padding: 8px 34px 8px 12px; }
.vgsum:hover { background: var(--surface-2); }
/* top is half the HEADER's height (8px pad + 60px thumb + 8px pad), not 50% —
   50% would centre it on the whole card, which grows when the group expands. */
.vgtedit { position: absolute; right: 8px; top: 38px; transform: translateY(-50%);
           opacity: 0; transition: opacity .12s; background: none; border: 0;
           cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1;
           padding: 4px 6px; border-radius: 6px; z-index: 1; }
/* Keyboard users get it on focus; pointer users on hover of the header. */
.vgroupwrap:hover .vgtedit, .vgtedit:focus-visible { opacity: 1; }
.vgtedit:hover { color: var(--accent); background: var(--surface-2); }
/* Quiet marker that this heading is a display override, not the folder name. */
.vgren { flex: 0 0 auto; font-size: 11px; opacity: .55; cursor: help; }
.vgcaret { transition: transform .15s; color: var(--muted); font-size: 12px;
           flex: 0 0 auto; }
.vgroup[open] > summary .vgcaret { transform: rotate(90deg); }
.vgthumb { flex: 0 0 auto; width: 42px; height: 60px; border-radius: 5px;
           overflow: hidden; background: var(--surface-2); display: grid;
           place-items: center; }
.vgthumb img { width: 100%; height: 100%; object-fit: cover; }
.vgthumb .vgph { font-size: 20px; opacity: .5; }
.vsingle .vgthumb { width: 36px; height: 52px; }
.vgtitle { flex: 1 1 auto; min-width: 0; font-weight: 600; white-space: nowrap;
           overflow: hidden; text-overflow: ellipsis; }
.vgcount { flex: 0 0 auto; font-size: 12px; color: #fff; background: var(--accent);
           border-radius: 999px; padding: 2px 9px; font-weight: 600; }
.vgyear { flex: 0 0 auto; font-size: 12.5px; }
.vgmembers { border-top: 1px solid var(--border); padding: 4px 0; }
/* The ✎ overlays the row's right edge, so the row reserves space for it and the
   wrapper (not the link) is the positioning context — a button inside the <a>
   would be invalid HTML and would navigate on click. */
.vgrowwrap { position: relative; }
.vgrow { display: flex; align-items: center; gap: 10px; padding: 6px 38px 6px 40px;
         text-decoration: none; color: var(--text); }
.vgrow:hover { background: var(--surface-2); }
.vgedit { position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
          opacity: 0; transition: opacity .12s; background: none; border: 0;
          cursor: pointer; color: var(--muted); font-size: 14px; line-height: 1;
          padding: 4px 6px; border-radius: 6px; }
/* Keyboard users get it on focus; pointer users on row hover. */
.vgrowwrap:hover .vgedit, .vgedit:focus-visible { opacity: 1; }
.vgedit:hover { color: var(--accent); background: var(--surface); }
.vgn { flex: 0 0 auto; width: 22px; text-align: right; color: var(--muted);
       font-size: 12px; font-variant-numeric: tabular-nums; }
.vgmt { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden;
        text-overflow: ellipsis; }
.vgrow:hover .vgmt { color: var(--accent); }
.vgres, .vgy { flex: 0 0 auto; font-size: 11.5px; }
/* Standalone film row — same rhythm as a group header, no caret/expand. */
.vsingle { display: flex; align-items: center; gap: 12px; padding: 7px 12px;
           border: 1px solid var(--border); border-radius: 10px;
           background: var(--surface); text-decoration: none; color: var(--text); }
.vsingle:hover { background: var(--surface-2); }
.vsingle:hover .vgtitle { color: var(--accent); }

/* ── Per-video location block (film page) ────────────────────────────────
   Owner sees coordinates + two privacy toggles; guests see it only when both
   are on. Both default off, so a geotagged clip stays private until opted in. */
.filmloc-coords { display: flex; align-items: center; gap: 12px; margin: 2px 0 8px; }
.filmloc-coords .mono { font-family: ui-monospace, monospace; font-size: 13px; }
.filmloc-toggles { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.loctoggle { font-size: 12.5px; padding: 5px 12px; border-radius: 999px;
             border: 1px solid var(--border-strong); background: var(--surface-2);
             color: var(--muted); cursor: pointer; white-space: nowrap; }
.loctoggle:hover { filter: brightness(1.1); }
.loctoggle.on { background: #2f9e5c; border-color: #2f9e5c; color: #fff; font-weight: 600; }
.filmloc-note { font-size: 12px; margin-left: 2px; }
.filmloc-place { font-size: 14px; font-weight: 600; margin: 2px 0 2px; }
.filmmap { height: 220px; border-radius: 10px; overflow: hidden; margin: 8px 0;
           border: 1px solid var(--border); background: var(--surface-2); }
.filmmap .leaflet-control-attribution { font-size: 10px; }

/* ── Rumble wrapper + description (film page) ────────────────────────────── */
.rumble-badge { display: inline-flex; align-items: center; gap: 5px; font-weight: 700;
                color: #85c742; }   /* placeholder — swap in the official logo */
.rumble-embed { position: relative; width: 100%; aspect-ratio: 16/9; border-radius: 10px;
                overflow: hidden; background: #000; margin: 4px 0 8px; }
.rumble-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.rumble-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rumble-publish p { margin: 0 0 8px; }
.rumble-linkform { display: flex; gap: 8px; margin-top: 8px; }
.rumble-linkform input { flex: 1; min-width: 0; }
.descbox { width: 100%; resize: vertical; background: var(--surface-2);
           color: var(--text); border: 1px solid var(--border-strong);
           border-radius: 8px; padding: 12px 14px; font: inherit; line-height: 1.55;
           min-height: 200px; margin-bottom: 6px; }
/* Give the description room to breathe on wide screens (a 400-word summary). */
.filmdesc { max-width: 820px; }
.filmdesc .film-overview { max-width: 820px; }

/* ── Per-clip chat (film page) ───────────────────────────────────────────── */
.chatlist { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 10px; }
.chatmsg { background: var(--surface-2); border-radius: 8px; padding: 7px 10px; }
.chatmeta { font-size: 12px; display: flex; align-items: center; gap: 6px; }
.chatmeta .muted { font-weight: 400; }
.chatdel { margin-left: auto; background: none; border: none; color: var(--muted);
           cursor: pointer; font-size: 12px; line-height: 1; padding: 2px 4px; }
.chatdel:hover { color: #e5342b; }
.chatbody { font-size: 13.5px; margin-top: 2px; white-space: pre-wrap; }
.chatform { display: flex; gap: 8px; align-items: flex-end; }
.chatbox { flex: 1; resize: vertical; background: var(--surface-2); color: var(--text);
           border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px;
           font: inherit; }
/* Rumble published-status cell in the grouped video list. */
.rumble-cell { flex: 0 0 auto; font-size: 12px; color: var(--border-strong);
               width: 16px; text-align: center; }
.rumble-cell.on { color: #85c742; }   /* green = live on Rumble */

/* ── Rumble integration page ─────────────────────────────────────────────── */
.rumblecfg .card { margin-bottom: 14px; }
.rb-h2 { font-size: 15px; margin: 0 0 12px; }
.rb-statusrow { display: flex; align-items: center; gap: 8px; }
.rb-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.rb-dot.on { background: #2f9e5c; box-shadow: 0 0 0 3px rgba(47,158,92,.2); }
.rb-how { font-size: 13px; margin: 10px 0 0; line-height: 1.5; }
.okcard { border-color: #2f9e5c; color: #7fe0a5; margin-bottom: 14px; }
/* Song-search results: the matched track name(s) in place of album specs. */
.songcell { color: var(--text); font-size: 13.5px; }
.songcell .songlink { color: var(--accent); cursor: pointer; text-decoration: none;
                      white-space: nowrap; margin-right: 4px; }
.songcell .songlink:hover { text-decoration: underline; }

/* AI-summary button row + working state */
.descbtns { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.summarizing { display: flex; align-items: center; gap: 10px; color: var(--muted);
               font-size: 13.5px; padding: 8px 0; }
.summarizing .spin { width: 16px; height: 16px; border: 2px solid var(--border-strong);
                     border-top-color: var(--accent); border-radius: 50%;
                     animation: mmsspin .8s linear infinite; display: inline-block; }
@keyframes mmsspin { to { transform: rotate(360deg); } }

/* Touch screens: no hover. Hover pop-ups would swallow the first tap, and the
   card edit/delete buttons (shown on hover with a mouse) must be visible to be
   used safely. */
@media (hover: none) {
  .hovercard { display: none !important; }
  .cardedit, .cardtrash { opacity: 1; }
}
/* On-page cover view (coverLightbox), used where pop-up windows don't work. */
.coverbox { z-index: 300; cursor: zoom-out; padding: 12px; }
.coverbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }

/* ---- Phones (narrow screens) -------------------------------------------- */
@media (max-width: 640px) {
  /* The header holds up to 15 links: let them wrap instead of forcing the page
     sideways, and don't pin a now-tall header over the content. */
  .hdr { flex-wrap: wrap; padding: 10px 12px; gap: 6px 14px; position: static; }
  .hdr h1 { flex-basis: 100%; }
  .hdr .spacer { display: none; }
  .wrap { padding: 12px 12px 48px; }
  /* Wide tables scroll inside themselves rather than widening the page; their
     sticky headers assumed a fixed 54px page header, so they scroll normally. */
  .ltable { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .ltable th { position: static; }
  /* Music / audiobook table: album and artist only (the rest is in the track list). */
  .col-tracks, .col-size, .col-quality, .col-mix, .col-year, .col-format,
  .col-qgrade, .col-genre { display: none; }
}
/* ---- Touch screens: finger-sized targets --------------------------------- */
@media (pointer: coarse) {
  .trk { padding: 10px 8px; }
  .trk .tplay, .trk .tpop { min-width: 40px; min-height: 40px; }
  .btn.xs { padding: 8px 12px; font-size: 13px; }
  .btn.sm { padding: 9px 14px; }
  .mpbtn, .albumclose { min-width: 44px; min-height: 44px; }
  input[type=range] { min-height: 32px; }
}
