:root {
  /* Catppuccin Mocha, named as the palette names them so a colour can be
     checked against the published spec rather than against memory. */
  --crust: #11111b;
  --mantle: #181825;
  --base: #1e1e2e;
  --surface0: #313244;
  --surface1: #45475a;
  --surface2: #585b70;
  --overlay0: #6c7086;
  --overlay1: #7f849c;
  --overlay2: #9399b2;
  --subtext0: #a6adc8;
  --subtext1: #bac2de;
  --text: #cdd6f4;
  --lavender: #b4befe;
  --blue: #89b4fa;
  --sapphire: #74c7ec;
  --sky: #89dceb;
  --teal: #94e2d5;
  --green: #a6e3a1;
  --yellow: #f9e2af;
  --peach: #fab387;
  --maroon: #eba0ac;
  --red: #f38ba8;
  --mauve: #cba6f7;
  --pink: #f5c2e7;

  /* Roles. Mocha's accents are light on a dark ground, so anything filled with
     an accent takes dark text — --on-accent, never --fg. */
  --bg: var(--crust);
  --card: var(--base);
  --raised: var(--surface0);
  --sunken: var(--mantle);
  --line: var(--surface0);
  --fg: var(--text);
  --muted: var(--overlay2);
  --accent: var(--lavender);
  --on-accent: var(--crust);
  --ok: var(--green);
  --warn: var(--yellow);
  --danger: var(--red);
}

* { box-sizing: border-box; }
/* `hidden` means hidden. Any class rule setting `display` outranks the UA's
   `[hidden]` rule, which is how both transport glyphs ended up drawn at once
   and how the idle view ended up underneath a progress bar. */
[hidden] { display: none !important; }
html, body { margin: 0; }
html { height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  /* Fixed-height app shell. dvh tracks Chrome Android's retractable toolbar,
     so the shell matches the *visible* viewport; only the tab panels scroll. */
  height: 100dvh;
  overflow: hidden;
  display: flex;
  justify-content: center;
}
main {
  width: 100%; max-width: 440px;
  height: 100dvh;
  display: flex; flex-direction: column;
}
:focus-visible { outline: 2px solid var(--lavender); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- shell ----------------------------------------------------------- */
/* One 44px line instead of a title row, a connection line, a full-width
   primary button and a tab strip. The chip is the connect control: connecting
   is something you do twice a session and it had a permanent full-width slot. */
.topbar {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--bg);
}
h1 { font-size: 17px; margin: 0; letter-spacing: .2px; font-weight: 600; }
.connchip {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 12px;
  color: var(--muted); background: var(--sunken);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px 6px 10px; cursor: pointer;
}
.connchip:hover { background: var(--raised); }
.connchip.on { color: var(--green); border-color: color-mix(in oklab, var(--green) 40%, transparent); }
.batt {
  font-size: 11.5px; color: var(--overlay1);
  font-variant-numeric: tabular-nums; white-space: nowrap;
  margin-left: auto;
}
.batt.low { color: var(--peach); }
.batt + .connchip { margin-left: 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--overlay0); flex: none; }
.connchip.on .dot { background: var(--green); box-shadow: 0 0 7px var(--green); }

/* First run. Sized and placed to be the obvious thing to press, which the
   status chip in the top corner cannot be. */
.cta {
  flex: none; display: grid; gap: 11px; justify-items: center;
  margin: 0 16px 12px; padding: 18px 16px;
  border-radius: 14px; text-align: center;
  background: var(--card); border: 1px solid var(--line);
}
.cta p { margin: 0; color: var(--subtext0); font-size: 14px; max-width: 30ch; }
.cta button { width: 100%; max-width: 260px; padding: 14px; font-size: 15px; }

/* The link went away without being asked to. In the thumb zone, because the
   only useful response is a tap. */
.lostbar {
  flex: none; display: flex; align-items: center; gap: 10px;
  margin: 0 16px 10px; padding: 10px 11px 10px 13px;
  border-radius: 11px; font-size: 13px;
  background: color-mix(in oklab, var(--peach) 13%, var(--base));
  border: 1px solid color-mix(in oklab, var(--peach) 45%, transparent);
  color: var(--peach);
}
.lostbar span { flex: 1 1 auto; min-width: 0; }

/* A card has just been put on the reader. Above the tab bar so it is under a
   thumb, and the whole strip is the control. */
.scanned-strip {
  flex: none; display: flex; align-items: center; gap: 9px;
  margin: 0 16px 10px; padding: 11px 13px;
  border-radius: 11px; font-size: 13px; text-align: left;
  background: color-mix(in oklab, var(--green) 13%, var(--base));
  border: 1px solid color-mix(in oklab, var(--green) 45%, transparent);
  color: var(--text);
}
.scanned-strip .pip {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--green); box-shadow: 0 0 7px var(--green);
}
.scanned-strip span:nth-child(2) { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.scanned-strip .go {
  flex: none; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--green);
}

/* The "use" shortcut on a folder row in the picker. */
.picklist .rowuse {
  flex: none; font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent); padding: 5px 8px; border-radius: 7px;
  border: 1px solid color-mix(in oklab, var(--lavender) 45%, transparent);
}
.picklist .rowuse:hover { background: color-mix(in oklab, var(--lavender) 18%, transparent); }

/* Tabs at the bottom: five destinations, and a thumb reaches them there. */
.tabs {
  flex: none;
  display: grid; grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--line); background: var(--sunken);
  padding: 7px 4px calc(env(safe-area-inset-bottom) + 9px);
}
.tab {
  display: grid; gap: 4px; justify-items: center;
  background: transparent; border: 0; padding: 4px 0;
  color: var(--overlay0); cursor: pointer;
  font: inherit; font-size: 9.5px; letter-spacing: .05em; text-transform: uppercase;
}
.tab svg { width: 20px; height: 20px; display: block; }
.tab.active { color: var(--accent); }

#controls {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  padding: 0 16px;
}
.tabpanel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.tabpanel[hidden] { display: none; }
.tabpanel[data-panel="player"], .tabpanel[data-panel="settings"] { overflow-y: auto; }
.tabpanel[data-panel="cards"], .tabpanel[data-panel="library"],
.tabpanel[data-panel="playlists"] { overflow: hidden; }
.tabpanel[data-panel="library"] > .card,
.tabpanel[data-panel="playlists"] > .card.grow {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
}
#controls[disabled] { opacity: .5; pointer-events: none; }
fieldset { border: 0; margin: 0; padding: 0; }

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

/* ---- controls -------------------------------------------------------- */
button {
  font: inherit; color: var(--fg); background: var(--raised);
  border: 1px solid var(--surface1); border-radius: 10px;
  padding: 11px 14px; cursor: pointer; transition: background .12s, transform .05s;
}
button:hover { background: var(--surface1); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.primary:hover { background: var(--blue); border-color: var(--blue); }
.full { width: 100%; }
.tiny { padding: 5px 11px; font-size: 13px; white-space: nowrap; }

input[type=text], select, #plName, #setSleep {
  font: inherit; color: var(--fg); background: var(--sunken);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; width: 100%;
}
input[type=range] { width: 100%; accent-color: var(--accent); height: 28px; }

/* ---- player ---------------------------------------------------------- */
/* One surface, not three cards. Status, transport and position are one thing
   you look at; volume is a separate control, so it is a separate block rather
   than a third box with the same border and radius. */
.np {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 22px 20px 18px;
  display: grid; gap: 14px;
  margin-top: 4px;
}
.np-card {
  display: flex; align-items: center; gap: 8px;
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--subtext0);
}
.np-card .swatch { width: 9px; height: 9px; border-radius: 3px; background: var(--c); flex: none; }
/* The name is the thing being read at a glance; the rest of the eyebrow is
   context for it. */
#npCardName { font-weight: 600; }
.np-card-where { color: var(--overlay1); }
.np-card-where::before { content: "\00B7"; margin-right: 8px; }
.np-track {
  font-size: 12px; color: var(--overlay1);
  font-variant-numeric: tabular-nums; margin-top: -8px;
}
.np-state {
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--overlay1);
}
.np-state.playing { color: var(--green); }
.np-title {
  font-size: 24px; font-weight: 600; line-height: 1.15;
  letter-spacing: -.015em; word-break: break-word; text-wrap: balance;
  margin-top: -6px;
}
.np-title.idle { color: var(--overlay1); font-weight: 400; font-size: 18px; }

.progress { display: grid; gap: 4px; }
.seekbar { width: 100%; height: 22px; accent-color: var(--accent); margin: 0; }
.bar { height: 6px; border-radius: 3px; margin: 8px 0; }
/* An unknown duration is a different object from a zero-length one. Both used
   to draw an empty bar, so a track whose length the decoder has not worked
   out was pixel-identical to one that had just started. */
.bar.unknown {
  background: repeating-linear-gradient(115deg, var(--surface0) 0 5px, var(--mantle) 5px 10px);
}
.times {
  display: flex; justify-content: space-between; color: var(--overlay1);
  font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.times .unknown { color: var(--warn); font-variant-numeric: normal; }

/* Centred on play, with stop pinned to the edge: the row is sized by how
   often each button is pressed, and stop was the widest target on the page. */
.transport { position: relative; display: flex; align-items: center; justify-content: center; gap: 16px; }
.tbtn {
  width: 48px; height: 48px; border-radius: 50%; padding: 0;
  display: grid; place-items: center;
  background: var(--raised); border: 1px solid var(--surface1); color: var(--subtext1);
}
.tbtn svg { width: 19px; height: 19px; display: block; }
/* `.tbtn svg` outranks the UA's [hidden] rule, so the hidden glyph needs
   saying again here — without it both play and pause draw at once. */
.tbtn svg[hidden] { display: none; }
.tbtn.play {
  width: 66px; height: 66px;
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
}
.tbtn.play:hover { background: var(--blue); border-color: var(--blue); }
.tbtn.play svg { width: 26px; height: 26px; }
.tbtn.sm {
  position: absolute; right: 0;
  width: 34px; height: 34px; background: transparent; border-color: transparent; color: var(--overlay0);
}
.tbtn.sm:hover { background: var(--raised); color: var(--fg); }
.tbtn.sm svg { width: 14px; height: 14px; }

.volblock { padding: 18px 20px 4px; display: grid; gap: 6px; }
.vlabel {
  display: flex; align-items: baseline; gap: 9px;
  color: var(--muted); font-size: 13px;
}
.vlabel b { color: var(--fg); font-variant-numeric: tabular-nums; }
/* The answer to "where is this going?" is also the way to change it, so it is
   shaped like something you press rather than like a caption. */
.vlabel .vdest {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 12px; font-weight: 500;
  color: var(--sapphire);
  background: var(--sunken); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px 5px 9px; cursor: pointer;
  max-width: 62%;
}
.vlabel .vdest span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.vlabel .vdest svg { width: 14px; height: 14px; flex: none; display: block; }
.vlabel .vdest:hover { background: var(--raised); color: var(--sky); border-color: var(--surface1); }

/* ---- idle ------------------------------------------------------------- */
/* Shown in place of the transport when there is nothing to transport. Every
   figure on it is one the box has actually sent. */
.idle { display: grid; justify-items: center; gap: 14px; padding: 6px 0 2px; }
.idle-card { width: 60px; height: 40px; color: var(--surface2); }
.idle-say { margin: 0; color: var(--subtext0); font-size: 14px; text-align: center; max-width: 26ch; }
.recent { width: 100%; display: grid; gap: 8px; }
.recent h2 {
  margin: 0; font-size: 9.5px; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase; color: var(--overlay0);
}
.recent-list { display: grid; gap: 7px; }
/* The same shape as a card tile, with the play control on the end, so the
   thing you tap to start a card looks like the card it starts. */
.rcard {
  display: grid; grid-template-columns: 5px minmax(0, 1fr) auto;
  align-items: stretch; gap: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; text-align: left;
}
.rcard .swatch { background: var(--c); }
.rcard .main { display: grid; gap: 2px; min-width: 0; padding: 10px 12px; }
.rcard .nm { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.rcard .tgt { font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.rcard .go {
  width: 52px; align-self: stretch; padding: 0;
  display: grid; place-items: center;
  background: transparent; border: 0; border-left: 1px solid var(--line);
  border-radius: 0; color: var(--accent);
}
.rcard .go svg { width: 18px; height: 18px; display: block; }
.rcard .go:hover { background: color-mix(in oklab, var(--lavender) 16%, transparent); }

/* The play control on a card tile, same shape as the one on a recent card. */
.tileplay {
  width: 52px; align-self: stretch; padding: 0;
  display: grid; place-items: center;
  background: transparent; border: 0; border-left: 1px solid var(--line);
  border-radius: 0; color: var(--accent);
}
.tileplay svg { width: 18px; height: 18px; display: block; }
.tileplay:hover { background: color-mix(in oklab, var(--lavender) 16%, transparent); }

.idle-facts {
  margin: 0; width: 100%;
  display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--line); border: 1px solid var(--line);
  border-radius: 11px; overflow: hidden;
}
.idle-facts > div { background: var(--sunken); padding: 11px 13px; display: grid; gap: 3px; }
.idle-facts dt {
  font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--overlay0);
}
.idle-facts dd {
  margin: 0; font-size: 13px; color: var(--subtext1);
  word-break: break-word;
}

/* ---- settings -------------------------------------------------------- */
.grouphead {
  display: flex; align-items: baseline; gap: 10px;
  margin: 18px 2px 8px;
}
.grouphead:first-child { margin-top: 4px; }
.grouphead h2 {
  margin: 0; font-size: 11px; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase; color: var(--overlay1);
}
.grouphead span {
  margin-left: auto; font-size: 11px; color: var(--overlay0);
  font-variant-numeric: tabular-nums;
}

/* One destination list, not a segmented control plus two lists that could
   show the same speaker twice. Where audio goes is one choice. */
.dests { display: grid; gap: 7px; }
.dest {
  display: grid; grid-template-columns: 17px minmax(0, 1fr) auto;
  align-items: center; gap: 11px;
  width: 100%; text-align: left;
  padding: 12px 13px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--line); color: var(--fg);
}
.dest.sel { border-color: var(--accent); background: color-mix(in oklab, var(--lavender) 8%, var(--base)); }
.dest .radio {
  width: 15px; height: 15px; border-radius: 50%;
  border: 1.5px solid var(--surface2); box-sizing: border-box;
}
.dest.sel .radio { border-color: var(--accent); border-width: 5px; }
.dest .nm { font-size: 14px; font-weight: 500; word-break: break-word; }
.dest .meta { display: block; font-size: 11.5px; color: var(--overlay1); margin-top: 2px; word-break: break-word; }
.dest .meta.warn { color: var(--warn); }
.dest .meta.bad { color: var(--maroon); }
.dest .meta.good { color: var(--green); }
.dest .rssi { font-size: 11px; color: var(--overlay1); font-variant-numeric: tabular-nums; }
.dest .act {
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); background: transparent;
  border: 1px solid var(--surface1); border-radius: 7px; padding: 6px 9px;
}
.dest .act:hover { background: var(--raised); color: var(--fg); }
.ghost {
  width: 100%; text-align: center;
  border: 1px dashed var(--surface1); background: transparent;
  color: var(--muted); border-radius: 12px; padding: 12px;
  font-size: 13px;
}
.ghost:hover { background: var(--card); color: var(--fg); }
.spin {
  width: 13px; height: 13px; border-radius: 50%; display: inline-block;
  border: 2px solid var(--surface1); border-top-color: var(--accent);
  animation: spin 900ms linear infinite; vertical-align: -2px;
}
@keyframes spin { to { rotate: 360deg; } }

.setrow {
  display: flex; justify-content: space-between; align-items: baseline;
  color: var(--muted); font-size: 13px; margin: 14px 0 6px;
}
.setrow:first-child { margin-top: 0; }
.setrow label { color: var(--fg); }
.setrow span { font-variant-numeric: tabular-nums; }
.btrow { display: flex; gap: 8px; margin: 8px 0; }
.btrow button { flex: 1; }
.seg.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.sinklist { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.sinklist button { text-align: left; }
.sinklist .sub { color: var(--muted); font-size: 12px; }
.sinklist .rssi { color: var(--muted); font-variant-numeric: tabular-nums; float: right; }
/* One block per physical button, its three gestures stacked inside. Stacked
   rather than a column each: three selects across a phone is 90px of width
   apiece, and the gesture names are what need reading. */
.btngrp + .btngrp { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.btnname { font-weight: 600; font-size: 14px; margin-bottom: 8px; border-radius: 6px; }
.btnmap { display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: center; }
.btnmap label { color: var(--muted); font-size: 13px; }
/* Echoes a press, so it fades. A highlight left standing would be claiming
   "this is the button you are holding" long after the thumb moved. */
.btnname.pressed { animation: btnflash 1.4s ease-out; }
@keyframes btnflash {
  from { background: color-mix(in oklab, var(--accent) 35%, transparent); color: var(--text); }
  to { background: transparent; }
}
.btnmap select { padding: 9px 10px; }
#setSleep { margin-top: 6px; }

dialog#btDialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 0; max-width: 92vw; width: 420px;
  background: var(--card); color: var(--fg);
}
dialog#btDialog::backdrop { background: rgba(17, 17, 27, .66); }
#btDialog .dlg { padding: 16px; }

/* ---- lists (library, playlists, cards) -------------------------------- */
.lib-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 10px; }
.crumb { color: var(--muted); font-size: 13px; word-break: break-all; }

/* A tappable path, so getting back up three folders is three taps on the thing
   you are going to rather than three on "up". */
.trail {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
  min-width: 0; font-size: 12px;
}
.trail .crumb-seg {
  background: transparent; border: 0; padding: 3px 5px; border-radius: 6px;
  color: var(--overlay1); font: inherit; max-width: 13ch;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.trail .crumb-seg:hover { background: var(--raised); color: var(--fg); }
.trail .crumb-seg.here { color: var(--fg); font-weight: 500; }
.trail .sep { color: var(--surface2); }

/* A statement of fact about why the list is not moving. */
.strip {
  display: flex; gap: 9px; align-items: flex-start;
  margin-bottom: 10px; padding: 10px 12px; border-radius: 10px;
  background: color-mix(in oklab, var(--warn) 9%, var(--base));
  border: 1px solid color-mix(in oklab, var(--warn) 40%, transparent);
  color: var(--warn); font-size: 12px; line-height: 1.4;
}
.strip .ic { flex: none; }
.strip.bad {
  background: color-mix(in oklab, var(--maroon) 10%, var(--base));
  border-color: color-mix(in oklab, var(--maroon) 45%, transparent);
  color: var(--maroon);
  margin: 0 0 10px;
}
.lib-actions { display: flex; gap: 6px; }

.pl, .lib, .cards { list-style: none; margin: 0; padding: 0; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.lib li { display: flex; align-items: center; gap: 9px; padding: 10px 6px; border-top: 1px solid var(--line); }
.lib li:first-child { border-top: 0; }
.pl { display: grid; gap: 8px; align-content: start; }
.pl .empty { color: var(--muted); font-size: 13px; padding: 24px 4px; text-align: center; }
.lib li.dir { cursor: pointer; }
.lib li.dir:hover { background: var(--raised); }
.lib .ic { width: 16px; text-align: center; opacity: .8; }
.lib .empty, .pl .empty, .cards .empty { color: var(--muted); }
.lib .assign { padding: 4px 9px; font-size: 12px; }
.libact { margin-left: auto; display: flex; gap: 6px; flex: none; }
.libact button {
  width: 32px; height: 32px; padding: 0;
  display: grid; place-items: center; font-size: 12px;
  background: transparent; border-color: transparent; color: var(--muted);
}
.libact button:hover { background: var(--raised); color: var(--fg); }
.libact button { font-size: 14px; line-height: 1; }
.pl .danger {
  color: var(--danger); border-color: color-mix(in oklab, var(--danger) 45%, transparent);
  background: color-mix(in oklab, var(--danger) 10%, transparent);
}
.pl .danger:hover { background: color-mix(in oklab, var(--danger) 18%, transparent); }
/* Quiet until pointed at. A row action that advertises itself in red is one
   more thing competing with the file name for a thumb. */
.libact .del { color: color-mix(in oklab, var(--danger) 72%, var(--overlay0)); }
.libact .del:hover { background: color-mix(in oklab, var(--danger) 18%, transparent); color: var(--danger); }
.hint { color: var(--muted); font-size: 12px; margin-top: 8px; }
/* Standing guidance at the foot of a panel. The rule is what makes its
   position read as deliberate rather than as text that drifted down. */
.footnote {
  flex: none; margin: 0; padding: 10px 2px 12px;
  border-top: 1px solid var(--line);
  color: var(--overlay1); font-size: 11.5px; line-height: 1.45;
}
.footnote b { color: var(--subtext0); font-weight: 600; }

.pltracks {
  list-style: none; margin: 0; padding: 0;
  max-height: 42dvh; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 11px;
}
.pltracks li {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 8px; border-top: 1px solid var(--line); font-size: 13px;
}
.pltracks li:first-child { border-top: 0; }
.pltracks .empty { color: var(--overlay1); padding: 16px 10px; justify-content: center; }
.pltracks .ix {
  flex: none; width: 18px; text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; color: var(--overlay0); font-variant-numeric: tabular-nums;
}
.pltracks .tnm { flex: 1 1 auto; min-width: 0; word-break: break-word; }
/* 32px targets: at 12px the two arrows were a pair that was hard to hit and
   easy to confuse with each other. */
.pltracks .mv {
  flex: none; width: 34px; height: 34px; padding: 0;
  display: grid; place-items: center;
  background: var(--raised); border-color: var(--surface1); color: var(--subtext1);
}
.pltracks .mv svg { width: 15px; height: 15px; display: block; }
.pltracks .mv:hover { background: var(--surface1); color: var(--fg); }
.pltracks .mv:disabled { opacity: .3; }
.pltracks .mv.rm { background: transparent; border-color: transparent; color: var(--overlay1); }
.pltracks .mv.rm:hover {
  background: color-mix(in oklab, var(--danger) 16%, transparent); color: var(--danger);
}

/* What the box answered, not what the writes returned. */
.savemsg {
  margin: 0; padding: 10px 12px; border-radius: 10px;
  font-size: 12.5px; line-height: 1.45;
  background: var(--sunken); border: 1px solid var(--line); color: var(--subtext0);
}
.savemsg.good { color: var(--green); border-color: color-mix(in oklab, var(--green) 45%, transparent); }
.savemsg.warn { color: var(--warn); border-color: color-mix(in oklab, var(--warn) 45%, transparent); }
.savemsg.bad { color: var(--maroon); border-color: color-mix(in oklab, var(--maroon) 45%, transparent); }

.pickbar {
  display: none; margin-bottom: 10px; padding: 10px 12px; border-radius: 9px;
  background: color-mix(in oklab, var(--lavender) 12%, var(--base));
  border: 1px solid color-mix(in oklab, var(--lavender) 45%, transparent);
  color: var(--subtext1); font-size: 13px;
  align-items: center; justify-content: space-between; gap: 10px;
}
.pickbar.show { display: flex; }
.pickbtns { display: flex; gap: 7px; flex: none; }

/* ---- cards ----------------------------------------------------------- */
/* A card is a physical thing a child picks up: a colour, a sticker, a number
   printed on it. Rows of identical text made matching the thing in your hand
   to the thing on screen a reading task. */
.cardlist {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: grid; gap: 8px; align-content: start;
  padding-bottom: 4px;
}
.cardlist .empty {
  color: var(--muted); font-size: 13px;
  padding: 24px 4px; text-align: center;
}
/* A colour stripe down the leading edge rather than a bar on top: in one
   column the eye runs down the left, and that is where the card's colour
   should be waiting.
   Three stacked lines rather than a right-hand column, so a long track name
   gets the full width instead of sharing it with an id that never wraps. */
.tile {
  display: grid; grid-template-columns: 5px minmax(0, 1fr) auto;
  align-items: stretch;
  text-align: left; padding: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 13px;
  color: var(--fg); overflow: hidden;
}
.tile .swatch { background: var(--c); }
.tile .main { display: grid; gap: 4px; min-width: 0; padding: 14px 15px; }
.tile .nm {
  font-size: 15px; font-weight: 600; line-height: 1.3;
  overflow-wrap: anywhere;
}
.tile .nm.noname { color: var(--overlay1); font-weight: 500; font-style: italic; }
.tile .tgt {
  font-size: 12.5px; color: var(--muted); line-height: 1.35;
  overflow-wrap: anywhere;
}
.tile .where {
  font-size: 11px; color: var(--overlay1); overflow-wrap: anywhere;
}
.tile .num {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px; color: var(--overlay0); font-variant-numeric: tabular-nums;
  letter-spacing: .02em; margin-top: 1px;
}

/* A playlist tile is a card tile with its actions alongside, so the two
   lists read as the same kind of object. */
.pltile { grid-template-columns: 1fr auto; padding: 0; }
/* The outer grid holds the body and the play control; the 5px stripe column
   belongs to the body's own grid, not to this one. */
.cardtile { grid-template-columns: minmax(0, 1fr) auto; padding: 0; }
.cardtile .tilebody {
  display: grid; grid-template-columns: 5px minmax(0, 1fr);
  align-items: stretch; text-align: left;
  background: transparent; border: 0; border-radius: 0; padding: 0;
  color: var(--fg); min-width: 0;
}
.cardtile .tilebody:hover { background: var(--raised); }
.pltile .tilebody {
  display: grid; grid-template-columns: 5px minmax(0, 1fr);
  align-items: stretch; text-align: left;
  background: transparent; border: 0; border-radius: 0; padding: 0;
  color: var(--fg); min-width: 0;
}
.pltile .tilebody:hover { background: var(--raised); }
.pltile .tileact {
  flex: none; width: 44px; align-self: stretch; padding: 0;
  display: grid; place-items: center;
  background: transparent; border: 0; border-left: 1px solid var(--line);
  border-radius: 0; color: var(--overlay1);
}
.pltile .tileact svg { width: 15px; height: 15px; display: block; }
.pltile .tileact:hover {
  background: color-mix(in oklab, var(--danger) 16%, transparent); color: var(--danger);
}
.tile.unassigned { border-style: dashed; border-color: var(--surface1); background: transparent; }
.tile.unassigned { border-style: dashed; }
.tile.unassigned .swatch { background: var(--surface1); }
.tile.scanned { animation: flash 1.8s ease-out; }
@keyframes flash {
  from { border-color: var(--green); background: color-mix(in oklab, var(--green) 20%, var(--base)); }
  to { border-color: var(--line); background: var(--card); }
}

/* ---- bottom sheet ----------------------------------------------------- */
/* The dialog covers the viewport rather than sitting at the bottom of it, so
   everything outside the panel is a click target that closes. ::backdrop does
   not bubble, so a bottom-anchored dialog has no way to be tapped past. */
dialog.sheet {
  border: 0; padding: 0; margin: 0; max-width: none; max-height: none;
  position: fixed; inset: 0; width: 100%; height: 100%;
  background: transparent; color: var(--fg);
  display: none;
}
dialog.sheet[open] { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
dialog.sheet::backdrop { background: rgba(17, 17, 27, .66); }
.sheetbody {
  width: 100%; max-width: 440px;
  /* Set by the drag handler while a sheet is being pulled down. */
  transform: translateY(var(--drag, 0px));
  background: var(--base);
  border: 1px solid var(--surface1); border-bottom: 0;
  border-radius: 18px 18px 0 0;
  padding: 12px 18px calc(env(safe-area-inset-bottom) + 20px);
  display: grid; gap: 12px;
  max-height: 88dvh; overflow-y: auto;
}
/* The handle and the title row are the drag surface: dragging the scrollable
   body instead would fight the list under it. */
.sheetgrip { touch-action: none; cursor: grab; display: grid; gap: 12px; }
.sheetgrip:active { cursor: grabbing; }
.sheetbody .grab {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--surface2); justify-self: center;
  margin: 2px 0 2px;
}
.sheethead { display: flex; align-items: center; gap: 9px; }
.sheethead .swatch { width: 11px; height: 11px; border-radius: 4px; background: var(--c); flex: none; }
.sheethead .t { font-size: 17px; font-weight: 600; word-break: break-word; }
.sheethead .t.noname { color: var(--overlay1); font-weight: 500; font-style: italic; }
.sheethead .n {
  margin-left: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; color: var(--overlay1); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px;
  background: var(--sunken); border: 1px solid var(--line);
  border-radius: 10px; padding: 3px;
}
.seg button {
  background: transparent; border: 0; border-radius: 7px;
  padding: 7px 0; font-size: 12.5px; color: var(--muted);
}
.seg button.on { background: var(--raised); color: var(--fg); font-weight: 600; }

/* The picker's own list: fixed height so the sheet does not jump as you
   browse into folders of different sizes. */
.picklist {
  list-style: none; margin: 0;
  max-height: 46dvh; min-height: 46dvh; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 11px; padding: 0 2px;
}
.picklist li {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 9px; border-top: 1px solid var(--line); cursor: pointer;
}
.picklist li:first-child { border-top: 0; }
.picklist li:hover { background: var(--raised); }
.picklist .ic { width: 18px; text-align: center; flex: none; opacity: .85; }
.picklist .nm { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.picklist .chev { color: var(--overlay0); font-size: 12px; flex: none; }
.picklist .empty { justify-content: center; color: var(--muted); padding: 22px 10px; cursor: default; }
.picklist li.picked { background: color-mix(in oklab, var(--lavender) 13%, transparent); }
.picklist li.picked .chev { color: var(--accent); }
#pickTrail { padding: 0 2px; }

.sheetrow { display: flex; gap: 8px; }
.sheetrow input[type=text] { flex: 1 1 auto; min-width: 0; }
.target {
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  width: 100%; text-align: left;
  background: var(--sunken); border: 1px solid var(--line); border-radius: 11px;
  padding: 12px 13px; color: var(--fg); font-size: 13px;
}
.target .ic { text-align: center; }
.target .go { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.target.none { border-style: dashed; color: var(--overlay1); }
.cmodes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cmode {
  display: flex; align-items: center; gap: 8px;
  background: var(--sunken); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
.cmode label { color: var(--muted); font-size: 12px; flex: none; }
.cmode select {
  border: 0; background: transparent; padding: 0; width: auto;
  margin-left: auto; text-align: right; font-size: 12.5px;
}
.grouphead-sm {
  font-size: 10.5px; font-weight: 600; letter-spacing: .13em;
  text-transform: uppercase; color: var(--overlay1); margin-top: 2px;
}
.swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.swatches .sw {
  width: 26px; height: 26px; border-radius: 8px; padding: 0;
  border: 1px solid transparent; background: var(--c);
}
.swatches .sw.on { outline: 2px solid var(--fg); outline-offset: 2px; }
.playnow {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; padding: 12px;
}
.playnow svg { width: 16px; height: 16px; display: block; }
.sheetbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheetbtns .danger {
  color: var(--danger); background: transparent;
  border-color: color-mix(in oklab, var(--danger) 45%, transparent);
}
.sheetbtns .danger:hover { background: color-mix(in oklab, var(--danger) 15%, transparent); }

/* ---- notices --------------------------------------------------------- */
.note { flex: none; color: var(--overlay1); font-size: 12px; text-align: center; margin: 4px 0 14px; }
.banner {
  flex: none; margin: 0 16px 12px;
  background: color-mix(in oklab, var(--warn) 12%, var(--base));
  border: 1px solid color-mix(in oklab, var(--warn) 45%, transparent);
  color: var(--warn);
  border-radius: 10px; padding: 12px 14px; font-size: 13px;
  display: none;
}
.banner.show { display: block; }
