/* ==========================================================================================
   Media Search App - design system
   1 tokens · 2 base · 3 layout · 4 primitives · 5 overlays · 6 media · 7 pages · 8 admin
   Colours, fonts, radius, density come from the theme engine (js/boot.js + js/core/theme.js). Hit targets >= 40 px.
   ========================================================================================== */

/* ------------------------------------------------------------------------------ 1 tokens */
/* The theme engine (js/boot.js) writes the BASE tokens as inline custom properties on <html> before first paint:
   --accent --accent-2 --accent-text --accent-contrast --bg --surface --surface-2 --text --text-muted --border
   --font --font-heading --heading-weight --font-scale --radius --density --thumb-ratio --card-min.
   The values below are only the fallback (template "aurora", dark); everything else is DERIVED from them. */
:root {
  --accent: #6d8dff;
  --accent-2: #59b8f0;
  --accent-text: #8aa4ff;
  --accent-contrast: #0b0d12;
  --bg: #0e1116;
  --surface: #181e27;
  --surface-2: #1f2631;
  --text: #e8ecf3;
  --text-muted: #9aa5b8;
  --border: #283041;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-heading: var(--font);
  --heading-weight: 700;
  --font-scale: 1;
  --radius: 10px;
  --density: 1;
  --thumb-ratio: 16 / 9;
  --card-min: 232px;

  /* derived */
  --sunken-mix: 78%;
  --accent-strong: var(--accent-text);
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --accent-gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
  --bg-raised: color-mix(in srgb, var(--surface) 55%, var(--bg));
  --bg-sunken: color-mix(in srgb, var(--bg) var(--sunken-mix), #000);
  --surface-3: color-mix(in srgb, var(--surface-2) 86%, var(--text));
  --border-strong: color-mix(in srgb, var(--border) 70%, var(--text));
  --text-faint: color-mix(in srgb, var(--text-muted) 78%, var(--bg));
  --ok: #3fcf8e;
  --warn: #f2b84b;
  --err: #f47272;
  --info: #59b8f0;
  --adult: #ff6fa5;
  --ok-soft: color-mix(in srgb, var(--ok) 16%, transparent);
  --warn-soft: color-mix(in srgb, var(--warn) 16%, transparent);
  --err-soft: color-mix(in srgb, var(--err) 16%, transparent);
  --info-soft: color-mix(in srgb, var(--info) 16%, transparent);
  --adult-soft: color-mix(in srgb, var(--adult) 16%, transparent);
  --tag-s: 55%;
  --tag-l: 70%;
  --tag-bg-l: 22%;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, 0.45);
  --shadow-3: 0 24px 64px rgba(0, 0, 0, 0.6);
  --scrim: rgba(4, 6, 10, 0.68);

  --s1: calc(4px * var(--density));
  --s2: calc(8px * var(--density));
  --s3: calc(12px * var(--density));
  --s4: calc(16px * var(--density));
  --s5: calc(24px * var(--density));
  --s6: calc(32px * var(--density));
  --s7: calc(48px * var(--density));
  --radius-sm: calc(var(--radius) * 0.6);
  --radius-lg: calc(var(--radius) * 1.4);
  --radius-pill: 999px;
  --btn-radius: var(--radius);
  --hit: 40px;
  --topbar-h: 60px;
  --sidebar-w: 264px;
  --rail-w: 88px;
  --mini-h: 72px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

:root[data-mode="light"] {
  --sunken-mix: 95%;
  --ok: #157a4e;
  --warn: #8f5a00;
  --err: #c93434;
  --info: #136ea8;
  --adult: #c02a6b;
  --tag-s: 62%;
  --tag-l: 30%;
  --tag-bg-l: 92%;
  --shadow-1: 0 1px 2px rgba(20, 30, 50, 0.08);
  --shadow-2: 0 8px 28px rgba(20, 30, 50, 0.14);
  --shadow-3: 0 24px 64px rgba(20, 30, 50, 0.24);
  --scrim: rgba(20, 26, 38, 0.46);
}

/* ------------------------------------------------------------------------------ 2 base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--border-strong) transparent;
}

html.no-scroll,
html.no-scroll body {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: calc(15px * var(--font-scale))/var(--line-height, 1.5) var(--font);
  letter-spacing: var(--letter-spacing, 0em);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* text display (Administration -> Appearance -> Typography) */
:root[data-text-rendering="crisp"] body {
  -webkit-font-smoothing: auto;
  -moz-osx-font-smoothing: auto;
  text-rendering: optimizeLegibility;
}

:root[data-numbers="tabular"] body {
  font-variant-numeric: tabular-nums;
}

h1, h2, h3, p, ul, ol, dl, dd, figure, pre {
  margin: 0;
}

h1, h2, h3, .brand-name {
  font-family: var(--font-heading);
  font-weight: var(--heading-weight);
}

h1, h2, h3 {
  text-transform: var(--heading-transform, none);
  font-variant-caps: var(--heading-caps, normal);
}

:root[data-heading-case="upper"] :is(h1, h2, h3) {
  letter-spacing: 0.04em;
}

/* programmatic focus after navigation lands on the page heading: no ring for that */
h1[tabindex="-1"]:focus {
  outline: none;
}

ul, ol {
  padding: 0;
  list-style: none;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img, video, svg {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
}

[hidden] {
  display: none !important;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--accent-soft);
}

code, kbd, .mono {
  font-family: var(--mono);
  font-size: 0.92em;
}

.icon {
  flex: none;
  display: inline-block;
  vertical-align: middle;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.muted { color: var(--text-muted); }
.small { font-size: calc(13px * var(--font-scale)); }
.nowrap { white-space: nowrap; }
.truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.break { overflow-wrap: anywhere; word-break: break-word; }
.grow { flex: 1 1 auto; min-width: 0; }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-err { color: var(--err); }
.row { display: flex; align-items: center; gap: var(--s2); }
.row.wrap, .wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.plain-list { display: flex; flex-direction: column; gap: var(--s1); }

.linklike {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-strong);
  text-align: inherit;
}

.linklike:hover {
  text-decoration: underline;
}

.prerender {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--s5);
  color: var(--text-muted);
}

.prerender h1 {
  margin-bottom: var(--s3);
  color: var(--text);
  font-size: calc(24px * var(--font-scale));
}

.prerender a {
  display: inline-block;
  margin: 0 var(--s3) var(--s2) 0;
}

.prerender img {
  max-width: 320px;
  height: auto;
  border-radius: var(--radius);
}

.noscript {
  padding: var(--s4);
  text-align: center;
  color: var(--text-muted);
}

.boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--s5);
  text-align: center;
  color: var(--text-muted);
}

/* ------------------------------------------------------------------------------ 3 layout */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: var(--topbar-h);
}

.app.has-mini {
  padding-bottom: calc(var(--mini-h) + env(safe-area-inset-bottom, 0px));
}

.skip-link {
  position: fixed;
  top: -100px;
  left: var(--s3);
  z-index: 300;
  padding: var(--s2) var(--s4);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.skip-link:focus {
  top: var(--s3);
}

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: var(--s3);
  height: var(--topbar-h);
  padding: 0 var(--s4);
  padding-left: max(var(--s4), env(safe-area-inset-left, 0px));
  padding-right: max(var(--s4), env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--bg-raised) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar .topbar-menu {
  display: inline-flex;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
  color: var(--text);
  font-weight: 700;
  font-size: calc(16px * var(--font-scale));
  letter-spacing: 0.01em;
}

.brand:hover {
  text-decoration: none;
}

.brand-name {
  max-width: 200px;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #7aa2ff, #4f6fe0);
  color: #fff;
}

.brand-mark-lg {
  width: 52px;
  height: 52px;
  border-radius: 14px;
}

.topsearch {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  max-width: 620px;
  margin: 0 auto;
  color: var(--text-muted);
}

.topsearch > .icon {
  position: absolute;
  left: 14px;
  pointer-events: none;
}

.topsearch-input {
  width: 100%;
  height: var(--hit);
  padding: 0 44px 0 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-sunken);
  color: var(--text);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.topsearch-input::placeholder {
  color: var(--text-faint);
}

.topsearch-input:hover {
  border-color: var(--border-strong);
}

.topsearch-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.topsearch-kbd {
  position: absolute;
  right: 12px;
  padding: 1px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  color: var(--text-faint);
  font-size: calc(12px * var(--font-scale));
  pointer-events: none;
}

/* the search page has its own, larger box */
.app.on-search .topsearch {
  visibility: hidden;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-left: auto;
}

.conn-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: calc(13px * var(--font-scale));
  animation: pulse 1.6s ease-in-out infinite;
}

.usermenu-btn {
  padding-left: 4px;
  max-width: 220px;
}

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: calc(14px * var(--font-scale));
}

.avatar-sm {
  display: inline-grid;
  width: 26px;
  height: 26px;
  font-size: calc(12px * var(--font-scale));
  vertical-align: middle;
}

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 110;
  width: min(320px, 86vw);
  padding: var(--s4) var(--s2) var(--s6);
  padding-left: max(var(--s2), env(safe-area-inset-left, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-3);
  transform: translateX(-105%);
  transition: transform 0.22s var(--ease);
  visibility: hidden;
}

.sidebar.is-open {
  transform: none;
  visibility: visible;
}

.sidebar-title {
  margin: var(--s4) var(--s3) var(--s1);
  color: var(--text-faint);
  font-size: calc(11.5px * var(--font-scale));
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-empty {
  padding: var(--s2) var(--s3);
}

.sidebar .skeleton-block {
  padding: var(--s2) var(--s3);
}

.side-link {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: var(--hit);
  padding: 0 var(--s3);
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--text-muted);
  font-weight: 500;
  text-align: left;
}

.side-link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.side-link.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tree-row {
  display: flex;
  align-items: center;
  min-height: var(--hit);
  padding-right: var(--s1);
  border-radius: var(--radius);
  color: var(--text-muted);
}

.tree-row:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tree-row.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tree-toggle {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: var(--hit);
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: inherit;
}

.tree-toggle-empty {
  visibility: hidden;
}

.tree-link {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  gap: var(--s2);
  min-width: 0;
  min-height: var(--hit);
  color: inherit;
  font-weight: 500;
}

.tree-link:hover {
  text-decoration: none;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 105;
  background: var(--scrim);
}

.main {
  min-width: 0;
}

.main:focus {
  outline: none;
}

.page {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  max-width: 1720px;
  margin: 0 auto;
  padding: var(--s5);
  padding-left: max(var(--s5), env(safe-area-inset-left, 0px));
  padding-right: max(var(--s5), env(safe-area-inset-right, 0px));
}

.page-loading {
  align-items: center;
  padding-top: 20vh;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s3) var(--s4);
}

.page-title {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: calc(24px * var(--font-scale));
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.page-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  color: var(--text-muted);
}

.section-title {
  margin-bottom: var(--s2);
  font-size: calc(15px * var(--font-scale));
  font-weight: 700;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: var(--s4);
  align-items: start;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--s4);
}

/* ------------------------------------------------------------------------------ 4 primitives */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--hit);
  padding: 0 var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--btn-radius);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: calc(14px * var(--font-scale));
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.05s;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  transform: none;
}

.btn.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.btn-primary {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover {
  border-color: transparent;
  background: var(--accent-strong);
}

/* button style of the theme (Administration -> Appearance) */
:root[data-buttons="soft"] .btn-primary {
  background: var(--accent-soft);
  color: var(--accent-text);
}

:root[data-buttons="soft"] .btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
}

:root[data-buttons="outline"] .btn-primary {
  border-color: var(--accent);
  background: transparent;
  color: var(--accent-text);
}

:root[data-buttons="outline"] .btn-primary:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

:root[data-buttons="gradient"] .btn-primary {
  background: var(--accent-gradient);
  color: var(--accent-contrast);
}

:root[data-buttons="gradient"] .btn-primary:hover {
  filter: brightness(1.08);
}

:root[data-buttons="ghost"] .btn-primary {
  background: transparent;
  color: var(--accent-text);
}

:root[data-buttons="ghost"] .btn-primary:hover {
  background: var(--accent-soft);
}

:root[data-button-shape="pill"] {
  --btn-radius: 999px;
}

:root[data-button-shape="square"] {
  --btn-radius: 2px;
}

/* "notch": bevelled top-left / bottom-right corners (the Nexus signature). corner-shape keeps borders, shadows and the
   focus ring on the bevel; older engines clip instead and show a plain rounded focus ring. */
:root[data-button-shape="notch"] {
  --btn-radius: 10px;
  --notch: 10px;
}

@supports (corner-shape: bevel) {
  :root[data-button-shape="notch"] :is(.btn-primary, .btn-danger, .btn-lg) {
    border-radius: var(--notch) 3px var(--notch) 3px;
    corner-shape: bevel round bevel round;
  }
}

@supports not (corner-shape: bevel) {
  :root[data-button-shape="notch"] :is(.btn-primary, .btn-danger, .btn-lg):not(:focus-visible) {
    border-radius: 0;
    clip-path: polygon(var(--notch) 0, 100% 0, 100% calc(100% - var(--notch)), calc(100% - var(--notch)) 100%, 0 100%, 0 var(--notch));
  }
}

/* input field style of the theme (Administration -> Appearance): outline is the base look above */
:root[data-fields="filled"] :is(.input, .select, .textarea, .taginput, .tokeninput) {
  border-color: transparent;
  background: var(--surface-2);
}

:root[data-fields="filled"] :is(.input, .select, .textarea):hover {
  border-color: transparent;
  background: color-mix(in srgb, var(--surface-2) 88%, var(--text));
}

:root[data-fields] :is(.input, .select, .textarea):focus-visible,
:root[data-fields] :is(.taginput, .tokeninput):focus-within {
  border-color: var(--accent);
}

:root[data-fields] :is(.input, .select, .textarea)[aria-invalid="true"] {
  border-color: var(--err);
}

:root[data-fields="underline"] :is(.input, .select, .textarea, .taginput, .tokeninput) {
  border-width: 0 0 2px;
  border-radius: 0;
  background: transparent;
  padding-left: 2px;
}

:root[data-fields="underline"] :is(.input, .select, .textarea, .taginput):focus-visible,
:root[data-fields="underline"] .taginput:focus-within {
  box-shadow: 0 2px 0 0 var(--accent);
}

.btn-danger {
  border-color: transparent;
  background: var(--err-soft);
  color: var(--err);
}

.btn-danger:hover {
  border-color: transparent;
  background: var(--err);
  color: #fff;
}

.btn-danger-ghost:hover {
  border-color: transparent;
  background: var(--err-soft);
  color: var(--err);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  border-color: transparent;
  background: var(--surface-2);
  color: var(--text);
}

.btn-sm {
  min-height: 34px;
  padding: 0 var(--s3);
  font-size: calc(13px * var(--font-scale));
}

.btn-lg {
  min-height: 48px;
  padding: 0 var(--s5);
  font-size: calc(15px * var(--font-scale));
}

.btn-icon {
  width: var(--hit);
  padding: 0;
}

.btn-icon.btn-sm {
  width: 34px;
}

.btn-block {
  width: 100%;
}

/* Touch devices (phones, Quest): small buttons grow to a comfortable target. */
@media (pointer: coarse) {
  .btn-sm {
    min-height: var(--hit);
  }

  .btn-icon.btn-sm {
    width: var(--hit);
  }
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
}

.segmented-btn {
  display: grid;
  place-items: center;
  min-width: 38px;
  min-height: 32px;
  padding: 0 var(--s2);
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: calc(13px * var(--font-scale));
}

.segmented-btn:hover {
  color: var(--text);
}

.segmented-btn.is-active {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

@media (pointer: coarse) {
  .segmented-btn {
    min-width: 42px;
    min-height: 38px;
  }
}

.input,
.select,
.textarea,
.taginput {
  width: 100%;
  min-height: var(--hit);
  padding: 0 var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--text);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.toolbar .input,
.toolbar .select,
.filters .select {
  width: auto;
}

.toolbar .input {
  min-width: 200px;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-faint);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--border-strong);
}

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible,
.taginput:focus-within {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input:disabled,
.select:disabled {
  opacity: 0.6;
}

.textarea {
  padding: var(--s2) var(--s3);
  line-height: 1.5;
  resize: vertical;
}

.textarea[aria-invalid="true"] {
  border-color: var(--err);
}

.select {
  padding-right: 34px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238894a8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  text-overflow: ellipsis;
}

.select option {
  background: var(--surface);
  color: var(--text);
}

.select-sm {
  min-height: 36px;
  font-size: calc(13px * var(--font-scale));
}

.select-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding-right: var(--s3);
  background-image: none;
  text-align: left;
}

.input-num {
  width: 110px;
  font-variant-numeric: tabular-nums;
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group > .input,
.input-group > .select {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group > .input-unit,
.input-group > .btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: 0;
}

.input-unit {
  display: flex;
  align-items: center;
  padding: 0 var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: calc(13px * var(--font-scale));
  white-space: nowrap;
}

.input-icon {
  position: relative;
  display: flex;
  align-items: center;
  color: var(--text-muted);
}

.input-icon > .icon {
  position: absolute;
  left: 12px;
  pointer-events: none;
}

.input-icon > .input {
  padding-left: 36px;
  min-width: 240px;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  color: var(--text-muted);
  font-size: calc(13px * var(--font-scale));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  color: var(--text);
  font-weight: 600;
  font-size: calc(13.5px * var(--font-scale));
}

.field-help {
  display: block;
  color: var(--text-muted);
  font-size: calc(13px * var(--font-scale));
  font-weight: 400;
}

.field-error {
  color: var(--err);
  font-size: calc(13px * var(--font-scale));
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s4);
}

.form-row > .field {
  flex: 1 1 180px;
}

.form-grid {             /* fields side by side, as many as fit (used by the provider detail) */
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--s3) var(--s4);
  align-items: end;
}

.form-row-end {           /* a row of fields with its button at the bottom line (inline "add" forms) */
  align-items: flex-end;
}

.form-row > .field-action {
  flex: 0 0 auto;
}

.form-row > .form-row-full {
  flex-basis: 100%;
  margin: 0;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: var(--hit);
  cursor: pointer;
}

.toggle {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease);
}

/* 28 px tall control, 40 px tall hit area */
.toggle::before {
  content: "";
  position: absolute;
  inset: -7px -4px;
}

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.18s var(--ease), background 0.18s var(--ease);
}

.toggle.is-on {
  border-color: var(--accent);
  background: var(--accent);
}

.toggle.is-on .toggle-knob {
  transform: translateX(18px);
  background: #fff;
}

.toggle:disabled {
  opacity: 0.5;
}

.taginput {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 5px var(--s2);
  cursor: text;
}

.taginput-field {
  flex: 1 1 120px;
  min-width: 80px;
  min-height: 28px;
  padding: 0 var(--s1);
  border: 0;
  background: none;
}

.taginput-field:focus-visible {
  outline: none;
}

/* multi-value combobox (persons, categories, delegates): chips + input; the list is a floating layer (5 overlays) */
.tokeninput {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: var(--hit);
  padding: 5px var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--text);
  cursor: text;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.tokeninput:hover {
  border-color: var(--border-strong);
}

.tokeninput:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tokeninput.is-disabled {
  opacity: 0.6;
  cursor: default;
}

.tokeninput-list {
  display: contents;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tokeninput-field {
  flex: 1 1 96px;
  min-width: 72px;
  min-height: 28px;
  padding: 0 var(--s1);
  border: 0;
  background: none;
  color: inherit;
}

.tokeninput-field:focus-visible {
  outline: none;
}

.tokeninput-field::placeholder {
  color: var(--text-faint);
}

.tokeninput.is-full .tokeninput-field {
  flex-basis: 40px;
  cursor: default;
}

.tokeninput-busy {
  flex: none;
  margin-right: var(--s1);
  color: var(--text-muted);
}

.token {
  max-width: 100%;
  min-width: 0;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--accent-soft);
}

.token > a {
  color: inherit;
}

/* free text (not a directory value): dashed outline */
.token.is-free {
  border-style: dashed;
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.token.is-flash {
  animation: token-flash 0.9s var(--ease);
}

.token .chip-x {
  flex: none;
}

/* 28 px control, 40 px hit area */
@media (pointer: coarse) {
  .chip-x,
  .token .chip-x {
    position: relative;
    width: 28px;
    height: 28px;
  }

  .chip-x::before,
  .token .chip-x::before {
    content: "";
    position: absolute;
    inset: -6px;
  }
}

.segmented-xs {
  padding: 2px;
  border-radius: var(--radius-sm);
}

.segmented-xs .segmented-btn {
  min-width: 0;
  min-height: 22px;
  padding: 0 7px;
  border-radius: calc(var(--radius-sm) - 1px);
  font-size: calc(11.5px * var(--font-scale));
}

@media (pointer: coarse) {
  .segmented-xs .segmented-btn {
    min-height: 32px;
    padding: 0 10px;
  }
}

.avatar-img {
  display: inline-grid;
  place-items: center;
  flex: none;
  overflow: hidden;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-faint);
}

.avatar-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pdot {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: hsl(var(--tag-hue, 220) 60% 60%);
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  min-width: 0;
}

:root[data-cards="elevated"] .card,
:root[data-cards="elevated"] .stat {
  border-color: transparent;
  box-shadow: var(--shadow-2);
}

:root[data-cards="bordered"] .card,
:root[data-cards="bordered"] .stat {
  border-color: var(--border-strong);
  box-shadow: none;
}

:root[data-cards="glass"] .card,
:root[data-cards="glass"] .stat,
:root[data-cards="glass"] .menu,
:root[data-cards="glass"] .modal {
  border-color: color-mix(in srgb, var(--text) 14%, transparent);
  background: color-mix(in srgb, var(--surface) 62%, transparent);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
}

.card-link {
  color: inherit;
  transition: border-color 0.15s var(--ease), transform 0.15s var(--ease);
}

.card-link:hover {
  border-color: var(--border-strong);
  text-decoration: none;
  transform: translateY(-1px);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2) var(--s4);
  padding: var(--s4);
  border-bottom: 1px solid var(--border);
}

.card-head:last-child {
  border-bottom: 0;
}

.card-title {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: calc(16px * var(--font-scale));
  font-weight: 700;
}

.card-subtitle {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: calc(13px * var(--font-scale));
  font-weight: 400;
}

.card-body {
  padding: var(--s4);
}

.card-body + .card-body {
  border-top: 1px solid var(--border);
}

.card-empty {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s5) var(--s4);
}

.card > .alert,
.card > .skeleton-block,
.card > .pager {
  margin: var(--s4);
}

.card > .empty {
  padding: var(--s6) var(--s4);
}

.filters {
  justify-content: flex-start;
}

.filters .input {
  width: auto;
  flex: 1 1 200px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: calc(12px * var(--font-scale));
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: middle;
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.badge-count {
  margin-left: 2px;
  color: var(--text);
}

.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-err { background: var(--err-soft); color: var(--err); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent-strong); }
.badge-muted { background: var(--surface-3); color: var(--text-muted); }
.badge-adult { background: var(--adult-soft); color: var(--adult); letter-spacing: 0.02em; }
.badge-dark { background: rgba(8, 10, 14, 0.78); color: #fff; }

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}

.chips-tight {
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: calc(13.5px * var(--font-scale));
  font-weight: 500;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  text-decoration: none;
}

.chip.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.chip-soft {
  border-color: transparent;
  background: var(--surface-2);
  color: var(--text-muted);
}

.chip-static {
  min-height: 28px;
  padding-right: 4px;
  background: var(--surface-3);
  cursor: default;
}

.chip-x {
  display: grid;
  place-items: center;
  width: 24px;   /* WCAG 2.2 target size minimum */
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
}

.chip-x:hover {
  background: var(--err-soft);
  color: var(--err);
}

.chip-person {
  padding-left: 6px;
}

.chip-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
}

@media (pointer: coarse) {
  .chip {
    min-height: var(--hit);
  }
}

.cap {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: calc(12px * var(--font-scale));
}

.ptag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 1px 8px;
  border-radius: var(--radius-sm);
  background: hsl(var(--tag-hue, 220) 40% var(--tag-bg-l));
  color: hsl(var(--tag-hue, 220) var(--tag-s) var(--tag-l));
  font-size: calc(12px * var(--font-scale));
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ptag-lg {
  padding: 3px 10px;
  font-size: calc(13px * var(--font-scale));
}

a.ptag:hover {
  text-decoration: none;
  filter: brightness(1.12);
}

.tabs {
  display: flex;
  gap: var(--s1);
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: 44px;
  margin-bottom: -1px;
  padding: 0 var(--s4);
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
}

.tab.is-active {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.tab-count {
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  font-size: calc(12px * var(--font-scale));
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  container-type: inline-size;  /* the columns below react to the table's own width, not the window */
  container-name: table;
}

/* secondary columns: hidden when the table's box is narrow (sidebar open, laptop window), so the row stays on one
   screen with its actions instead of scrolling sideways */
@container table (max-width: 1200px) {
  .table .hide-lg { display: none; }
}

@container table (max-width: 820px) {
  .table .hide-md { display: none; }
  .table-wrap .table th, .table-wrap .table td { padding-left: var(--s2); padding-right: var(--s2); }
  .table-wrap .table th:first-child, .table-wrap .table td:first-child { padding-left: var(--s3); }
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: calc(14px * var(--font-scale));
}

.table th,
.table td {
  padding: 10px var(--s4);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.table th {
  color: var(--text-muted);
  font-size: calc(12px * var(--font-scale));
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--surface);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table-hover tbody tr:hover,
.table tr.is-clickable:hover {
  background: var(--surface-2);
}

.table tr.is-clickable {
  cursor: pointer;
}

.table tr.is-off {
  opacity: 0.6;
}

.table tr.is-current {
  background: var(--accent-soft);
}

.table tr.is-err td:first-child {
  box-shadow: inset 3px 0 0 var(--err);
}

.table tr.is-live {
  animation: flash 1.6s var(--ease);
}

.table .row-actions {   /* beats `.table td { text-align: left }` */
  text-align: right;
  white-space: nowrap;
  width: 1%;
}

.table .nowrap {
  white-space: nowrap;
}

.table .nowrap .chips {
  flex-wrap: nowrap;
}

/* a person in a table row: avatar, name and badges on one line */
.user-cell {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  white-space: nowrap;
}

.user-cell > strong {
  overflow: hidden;
  max-width: 22ch;
  text-overflow: ellipsis;
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table-dense th,
.table-dense td {
  padding: 7px var(--s3);
}

.row-group th {
  padding-top: var(--s4);
  background: var(--surface-2);
  color: var(--text);
}

.row-detail td {
  background: var(--bg-sunken);
}

.row-actions {
  text-align: right;
  white-space: nowrap;
}

.row-actions > * + * {
  margin-left: 6px;
}

.cell-sub {
  display: block;
  max-width: 420px;
  color: var(--text-muted);
  font-size: calc(12.5px * var(--font-scale));
  font-weight: 400;
}

.cell-err {
  color: var(--err);
}

.cell-wrap {
  min-width: 220px;
}

.cell-title {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: var(--hit);
  color: var(--text);
  text-align: left;
}

.cell-title:hover {
  text-decoration: none;
}

.cell-title:hover strong {
  color: var(--accent-strong);
}

.cell-media {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 280px;
}

.cell-thumb {
  display: grid;
  place-items: center;
  flex: none;
  width: 72px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--text-faint);
}

.cell-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cell-media-text {
  min-width: 0;
}

.col-progress {
  min-width: 120px;
  width: 16%;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
}

.pager-info {
  color: var(--text-muted);
  font-size: calc(13px * var(--font-scale));
}

.progress {
  position: relative;
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.3s var(--ease);
}

.progress-ok .progress-bar { background: var(--ok); }
.progress-warn .progress-bar { background: var(--warn); }
.progress-err .progress-bar { background: var(--err); }

.progress.is-indeterminate .progress-bar {
  position: absolute;
  width: 38%;
  animation: indeterminate 1.2s ease-in-out infinite;
}

.spinner {
  display: inline-block;
  flex: none;
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

.spinner-lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
  color: var(--accent);
}

.skeleton {
  position: relative;
  overflow: hidden;
  border-color: transparent;
  background: var(--surface-2);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 7%, transparent), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-block {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.skeleton-line {
  height: 14px;
  border-radius: var(--radius-sm);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  padding: var(--s7) var(--s4);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: var(--s2);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
}

.empty-err .empty-icon {
  background: var(--err-soft);
  color: var(--err);
}

.empty-title {
  font-size: calc(18px * var(--font-scale));
  font-weight: 700;
}

.empty-text {
  max-width: 520px;
  color: var(--text-muted);
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s2);
  margin-top: var(--s3);
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--info-soft);
  color: var(--text);
}

.alert > .icon {
  margin-top: 2px;
  color: var(--info);
}

.alert-body {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.alert-title {
  display: block;
}

.alert-actions {
  display: flex;
  flex: none;
  gap: var(--s2);
}

.alert-ok { background: var(--ok-soft); }
.alert-ok > .icon { color: var(--ok); }
.alert-warn { background: var(--warn-soft); }
.alert-warn > .icon { color: var(--warn); }
.alert-err { background: var(--err-soft); }
.alert-err > .icon { color: var(--err); }

.kv {
  display: grid;
  grid-template-columns: minmax(120px, max-content) minmax(0, 1fr);
  gap: 6px var(--s4);
  font-size: calc(14px * var(--font-scale));
}

.kv dt {
  color: var(--text-muted);
}

.kv-wide {
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
}

.kv-tight {
  gap: 3px var(--s3);
  font-size: calc(13px * var(--font-scale));
}

.kv-inline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s5);
}

.kv-inline dt {
  display: inline;
}

.kv-inline dt::after {
  content: ":";
}

.kv-inline dd {
  display: inline;
  margin-left: 6px;
  font-weight: 600;
}

.kv-inline > * {
  white-space: nowrap;
}

.code {
  overflow: auto;
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--text);
  font: calc(12.5px * var(--font-scale))/1.55 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

.code-err {
  max-height: 260px;
  border-color: color-mix(in srgb, var(--err) 40%, var(--border));
  color: var(--err);
}

.console {
  background: #05070a;
  color: #cfe3d4;
  white-space: pre;
  overflow-wrap: normal;
}

.codebox {
  position: relative;
}

.codebox-copy {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  opacity: 0.85;
}

.result-box {
  margin-top: var(--s3);
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
}

.hint-box {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-top: 4px;
  padding: 4px 4px 4px var(--s2);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
}

.hint-box code {
  flex: 1 1 auto;
}

/* Settings > Designer / pipelines > System test (web/js/admin/systest.js) */
.systest-job {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  margin-bottom: var(--s3);
}

.systest-rec {
  margin: var(--s3) 0;
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.systest-rec .check {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}

.jobprogress {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.jobprogress-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
}

.jobprogress.is-compact {
  font-size: calc(13px * var(--font-scale));
}

.jobprogress-msg {
  flex: 1 1 auto;
  color: var(--text-muted);
  font-size: calc(13px * var(--font-scale));
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--s3);
}

.stat-grid-sm {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow-1);
}

a.stat:hover,
button.stat:hover {
  border-color: var(--border-strong);
  text-decoration: none;
}

.stat.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.stat.is-err .stat-value {
  color: var(--err);
}

.stat-wide {
  grid-column: span 2;
}

.stat-sm {
  padding: var(--s3);
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
}

.stat-value {
  font-size: calc(26px * var(--font-scale));
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.stat-sm .stat-value {
  font-size: calc(20px * var(--font-scale));
}

.stat-of {
  color: var(--text-muted);
  font-size: calc(15px * var(--font-scale));
  font-weight: 500;
}

.stat-sub {
  color: var(--text-muted);
  font-size: calc(12.5px * var(--font-scale));
}

.timeline {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s5);
  padding: var(--s3);
  border-radius: var(--radius);
  background: var(--bg-sunken);
}

.timeline li {
  display: flex;
  flex-direction: column;
}

.timeline-label {
  color: var(--text-muted);
  font-size: calc(12px * var(--font-scale));
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-faint);
}

.live-dot.is-on {
  background: #ff5468;
  animation: pulse 1.2s ease-in-out infinite;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
}

.stepper-value {
  min-width: 44px;
  font-size: calc(22px * var(--font-scale));
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------------------ 5 overlays */
/* command palette (Ctrl/Cmd+K) */
.palette-backdrop {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: min(14vh, 140px) var(--s4) var(--s4);
  background: var(--scrim);
  animation: fade 0.16s var(--ease);
}

.palette {
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: min(72vh, 620px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  animation: palette-in 0.2s var(--ease);
}

.palette-backdrop.is-closing {
  opacity: 0;
  transition: opacity 0.16s var(--ease);
}

.palette-backdrop.is-closing .palette {
  transform: scale(0.97);
  transition: transform 0.16s var(--ease);
}

@keyframes palette-in {
  from { opacity: 0; transform: scale(0.97) translateY(-6px); }
}

.palette-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0 var(--s4);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.palette-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 58px;
  border: 0;
  background: none;
  color: var(--text);
  font-size: calc(17px * var(--font-scale));
}

.palette-input:focus-visible {
  outline: none;
}

.palette-kbd,
.palette-foot kbd,
.palette-enter {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-muted);
  font: 500 calc(11px * var(--font-scale)) / 1.6 var(--mono);
}

.palette-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s2);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.palette-group {
  padding: var(--s3) var(--s3) var(--s1);
  color: var(--text-faint);
  font-size: calc(11px * var(--font-scale));
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: 44px;
  padding: 0 var(--s3);
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--text);
  text-align: left;
  font-size: calc(14px * var(--font-scale));
  cursor: pointer;
}

.palette-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.palette-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: calc(var(--radius) * 0.7);
  background: var(--surface-2);
}

.palette-item.is-active .palette-icon {
  background: var(--surface);
}

.palette-label {
  min-width: 0;
  font-weight: 600;
}

.palette-hint {
  min-width: 0;
  color: var(--text-muted);
  font-size: calc(13px * var(--font-scale));
}

.palette-enter {
  margin-left: auto;
}

.palette-empty {
  padding: var(--s5) var(--s4);
  text-align: center;
}

.palette-foot {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: var(--s2) var(--s4);
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
}

.palette-foot kbd + kbd {
  margin-left: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .palette-backdrop, .palette { animation: none; }
}

.dropdown {
  position: relative;
  display: inline-block;
  min-width: 0;
}

.filter .dropdown,
.field .dropdown {
  display: block;
}

.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 120;
  min-width: 240px;
  max-width: min(360px, calc(100vw - 24px));
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  animation: pop 0.14s var(--ease);
}

.menu-left {
  right: auto;
  left: 0;
}

.menu-scroll {
  max-height: min(340px, 50vh);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.menu-head {
  display: flex;
  flex-direction: column;
  padding: var(--s2) var(--s3) var(--s3);
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.menu-item,
.menu-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: var(--hit);
  padding: 0 var(--s3);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font-weight: 500;
  font-size: calc(14px * var(--font-scale));
  text-align: left;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--surface-2);
  text-decoration: none;
}

.menu-item-danger {
  color: var(--err);
}

.menu-check {
  cursor: pointer;
}

.menu-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.menu-empty {
  padding: var(--s3);
}

.menu-sep {
  height: 1px;
  margin: 6px 0;
  background: var(--border);
}

.menu-item-static {
  margin: 0;
}

/* floating layers: teleported to <body>, positioned by core/floating.js - above dialogs, below toasts */
.floating {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 320;
  max-width: calc(100vw - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.menu-floating {
  right: auto;
  min-width: 0;
}

.typeahead {
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  animation: pop 0.14s var(--ease);
}

:root[data-cards="glass"] .typeahead {
  border-color: color-mix(in srgb, var(--text) 14%, transparent);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
}

.typeahead-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.typeahead-option {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 44px;
  padding: 5px var(--s3);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: calc(14px * var(--font-scale));
  cursor: pointer;
}

.typeahead-option > .icon {
  flex: none;
  color: var(--text-faint);
}

.typeahead-option.is-active {
  background: var(--accent-soft);
}

.typeahead-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.typeahead-name {
  font-weight: 600;
}

.typeahead-name mark {
  border-radius: 3px;
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  color: inherit;
}

.typeahead-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  color: var(--text-muted);
  font-size: calc(12px * var(--font-scale));
}

.typeahead-sub .badge {
  padding: 0 6px;
  font-size: calc(11px * var(--font-scale));
}

.typeahead-providers {
  display: flex;
  flex: none;
  align-items: center;
  gap: 3px;
  max-width: 40%;
}

.typeahead-provider {
  margin-left: 3px;
  color: var(--text-muted);
  font-size: calc(12px * var(--font-scale));
}

.typeahead-note {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin: 0;
  padding: var(--s2) var(--s3);
  color: var(--text-muted);
  font-size: calc(13px * var(--font-scale));
}

.typeahead-note.is-error {
  color: var(--err);
}

.typeahead-foot {
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

.typeahead-note kbd {
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: calc(11.5px * var(--font-scale));
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s4);
  background: var(--scrim);
  animation: fade 0.16s var(--ease);
}

.modal-backdrop.is-drawer {
  justify-content: flex-end;
  padding: 0;
}

.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  animation: pop 0.18s var(--ease);
}

.modal:focus-visible {
  outline: none;
}

.modal-sm { max-width: 440px; }
.modal-lg { max-width: 820px; }
.modal-xl { max-width: 1100px; }

.modal.drawer {
  height: 100%;
  max-height: none;
  border-width: 0 0 0 1px;
  border-radius: 0;
  animation: slide-in 0.2s var(--ease);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) var(--s3) var(--s3) var(--s5);
  border-bottom: 1px solid var(--border);
}

.modal-title {
  min-width: 0;
  font-size: calc(17px * var(--font-scale));
  font-weight: 700;
  overflow-wrap: anywhere;
}

.modal-body {
  flex: 1 1 auto;
  padding: var(--s5);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s2);
  padding: var(--s3) var(--s5);
  padding-bottom: max(var(--s3), env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
}

.modal-body section {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.modal-body section > .section-title {
  margin-bottom: 0;
}

.confirm-text {
  color: var(--text-muted);
}

.toasts {
  position: fixed;
  right: var(--s4);
  bottom: var(--s4);
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.app.has-mini ~ .toasts {
  bottom: calc(var(--mini-h) + var(--s4));
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s2) var(--s2) var(--s4);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--info);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  pointer-events: auto;
}

.toast > .icon { color: var(--info); }
.toast-ok { border-left-color: var(--ok); }
.toast-ok > .icon { color: var(--ok); }
.toast-warn { border-left-color: var(--warn); }
.toast-warn > .icon { color: var(--warn); }
.toast-error { border-left-color: var(--err); }
.toast-error > .icon { color: var(--err); }

.toast-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: calc(14px * var(--font-scale));
}

.toast-enter-active,
.toast-leave-active {
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.toast-enter-from,
.toast-leave-to {
  opacity: 0;
  transform: translateY(8px);
}

/* ------------------------------------------------------------------------------ 6 media */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: var(--s5) var(--s4);
}

.media-grid.is-dense {
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
}

.media-grid.is-list {
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s3);
}

.mcard {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  min-width: 0;
}

.mcard-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg-sunken);
  color: var(--text-faint);
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  transition: box-shadow 0.15s var(--ease);
}

.mcard-thumb:hover {
  box-shadow: 0 0 0 2px var(--accent);
}

.mcard-img,
.mcard-clip {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mcard-clip {
  background: #000;
}

.mcard-frame {
  animation: fade 0.25s var(--ease);
}

.mcard-noimg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.mcard-badges {
  position: absolute;
  top: 6px;
  left: 6px;
  display: flex;
  gap: 4px;
}

.mcard-badges .badge {
  padding: 1px 6px;
  font-size: calc(11px * var(--font-scale));
  backdrop-filter: blur(4px);
}

.mcard-badges .badge-accent {
  background: var(--accent);
  color: var(--accent-contrast);
}

.mcard-badges .badge-adult {
  background: rgba(8, 10, 14, 0.78);
}

.mcard-duration,
.mcard-state {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(8, 10, 14, 0.82);
  color: #fff;
  font-size: calc(12px * var(--font-scale));
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.mcard-state {
  right: auto;
  left: 6px;
  background: var(--err);
}

.mcard-watched {
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
}

.mcard-watched span {
  display: block;
  height: 100%;
  background: var(--accent);
}

/* already played items (appearance.played_marker: off | badge | dim) */
.mcard-played {
  position: absolute;
  left: 6px;
  bottom: 9px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px 2px 5px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.5;
  color: #fff;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.mcard.is-completed .mcard-played {
  background: color-mix(in srgb, var(--accent) 82%, #000);
}

html[data-played="off"] .mcard-played {
  display: none;
}

html[data-played="dim"] .mcard.is-played .mcard-img {
  opacity: 0.55;
  filter: saturate(0.55);
  transition: opacity 0.15s ease, filter 0.15s ease;
}

html[data-played="dim"] .mcard.is-played:hover .mcard-img,
html[data-played="dim"] .mcard.is-played:focus-within .mcard-img {
  opacity: 1;
  filter: none;
}

html[data-played="dim"] .mcard.is-played .mcard-title {
  color: var(--text-muted);
}

.mcard.is-list .mcard-played span {
  display: none; /* list rows are small: the check mark alone */
}

.mcard.is-gone .mcard-img {
  filter: grayscale(1) brightness(0.6);
}

.mcard-fav,
.mcard-add {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: var(--hit);
  height: var(--hit);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(8, 10, 14, 0.55);
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s var(--ease), background 0.15s var(--ease);
}

/* "add to playlist" sits left of the favorite button (guests have no favorite button: it takes the corner) */
.mcard-fav ~ .mcard-add {
  right: calc(var(--hit) + 8px);
}

.mcard:hover .mcard-fav,
.mcard:hover .mcard-add,
.mcard-fav:focus-visible,
.mcard-add:focus-visible,
.mcard-fav.is-on {
  opacity: 1;
}

.mcard-fav.is-on {
  color: #ff5d7a;
}

.mcard-fav:hover,
.mcard-add:hover {
  background: rgba(8, 10, 14, 0.85);
}

/* no hover on touch screens / in the headset: the controls are always there */
@media (hover: none), (pointer: coarse) {
  .mcard-fav,
  .mcard-add {
    opacity: 1;
  }
}

.mcard-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.mcard-title {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-weight: 600;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.mcard-title:hover {
  color: var(--accent-strong);
  text-decoration: none;
}

.mcard-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  color: var(--text-muted);
  font-size: calc(12.5px * var(--font-scale));
}

.mcard-bit + .mcard-bit::before {
  content: "·";
  margin-right: 8px;
}

/* the persons / uploader are the last bit of the meta row: they shrink (ellipsis) before anything wraps */
.mcard-persons {
  flex: 0 1 auto;
  max-width: 100%;
  color: var(--text-muted);
  font-size: inherit;
}

.mcard-meta > :is(.ptag, .mcard-bit) + .mcard-persons::before {
  content: "·";
  margin-right: 8px;
}

.mcard-persons a {
  color: var(--text-muted);
}

.mcard-persons a:hover {
  color: var(--accent-strong);
}

/* audio: square cover */
.mcard.is-audio .mcard-thumb {
  aspect-ratio: 1 / 1;
}

/* list layout */
.mcard.is-list {
  flex-direction: row;
  gap: var(--s4);
  padding: var(--s2);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
}

.mcard.is-list:hover {
  border-color: var(--border);
  background: var(--surface);
}

.mcard.is-list .mcard-thumb {
  flex: none;
  align-self: flex-start; /* keep the 16:9 box when the text column is taller */
  width: clamp(132px, 24vw, 260px);
}

.mcard.is-list.is-audio .mcard-thumb {
  width: clamp(72px, 12vw, 112px);
}

.mcard.is-list .mcard-body {
  flex: 1 1 auto;
  justify-content: center;
  padding-right: calc(var(--hit) * 2 + var(--s2));
}

.mcard.is-list .mcard-title {
  font-size: calc(16px * var(--font-scale));
}

.mcard.is-list .mcard-fav,
.mcard.is-list .mcard-add {
  top: 50%;
  right: var(--s2);
  transform: translateY(-50%);
  background: transparent;
  color: var(--text-muted);
  opacity: 1;
}

.mcard.is-list .mcard-fav ~ .mcard-add {
  right: calc(var(--s2) + var(--hit));
}

.mcard.is-list .mcard-add:hover {
  color: var(--text);
}

.mcard.is-list .mcard-fav.is-on {
  color: #ff5d7a;
}

.mcard-skeleton .mcard-thumb {
  border-radius: var(--radius);
}

.more {
  display: flex;
  justify-content: center;
  padding: var(--s4) 0;
}

.sentinel {
  height: 1px;
}

.searchbox {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 6px 6px 6px var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: var(--shadow-1);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.searchbox:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.searchbox-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  border: 0;
  background: none;
  color: var(--text);
  font-size: calc(17px * var(--font-scale));
}

.searchbox-input:focus-visible {
  outline: none;
}

.searchbox-input::-webkit-search-cancel-button,
.topsearch-input::-webkit-search-cancel-button {
  filter: grayscale(1);
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--text-faint);
}

.crumbs-sep {
  width: 1px;
  height: 22px;
  margin: 0 var(--s2);
  background: var(--border-strong);
}

.filterbar-toggle {
  display: none;
}

.filterbar-body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s3);
}

.filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 0 1 170px;
  min-width: 140px;
}

.filter-wide {
  flex-basis: 230px;
}

.filter-range {
  flex-basis: auto;
}

.filter-range .input-num {
  width: 84px;
}

.filter-label {
  color: var(--text-muted);
  font-size: calc(12px * var(--font-scale));
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-reset {
  align-self: flex-end;
}

/* multi-value person / category fields: wider, the all / any switch shares the label row */
.filter-tokens {
  flex: 1 1 300px;
  min-width: min(100%, 240px);
  max-width: 560px;
  align-self: flex-start;
}

.filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  min-height: 18px;
}

.filter-hint {
  color: var(--text-muted);
  font-size: calc(12px * var(--font-scale));
}

.active-tokens {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.active-tokens-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
}

.active-tokens-label:not(:first-child) {
  margin-left: var(--s3);
}

.active-tokens .token {
  min-height: 32px;
}

.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s3);
}

.results-head .section-title {
  margin: 0;
}

.results-title {
  min-width: 0;
  flex: 1 1 300px;
}

.provider-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pchip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: calc(13px * var(--font-scale));
}

@media (pointer: coarse) {
  .pchip {
    min-height: var(--hit);
  }
}

.pchip:hover {
  border-color: var(--border-strong);
}

.pchip.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.pchip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: hsl(var(--tag-hue, 220) 60% 60%);
}

.pchip-name {
  font-weight: 600;
}

.pchip-count {
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pchip-ms {
  color: var(--text-faint);
  font-size: calc(12px * var(--font-scale));
}

/* the provider was asked several times (one query per person / category) */
.pchip-times {
  color: var(--accent-strong);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.provider-status {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  min-width: 0;
}

.provider-strip-detail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.variant-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px var(--s4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.variant {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
  max-width: 100%;
  font-size: calc(13px * var(--font-scale));
}

.variant-name {
  font-weight: 600;
}

.pchip.is-error {
  border-color: color-mix(in srgb, var(--err) 50%, var(--border));
  color: var(--err);
}

/* the site blocks automated access: left out for a while - a state, shown quietly */
.pchip.is-blocked {
  color: var(--text-muted);
  opacity: 0.7;
}

.pchip.is-pending,
.pchip.is-running {
  color: var(--text-muted);
}

/* ------------------------------------------------------------------------------ 7 pages */
.login {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--s5);
  background:
    radial-gradient(900px 480px at 15% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 420px at 100% 110%, var(--info-soft), transparent 60%),
    var(--bg);
}

.login-tools {
  position: absolute;
  top: var(--s4);
  right: var(--s4);
  display: flex;
  align-items: center;
  gap: var(--s2);
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  width: 100%;
  max-width: 400px;
  padding: var(--s6);
  box-shadow: var(--shadow-2);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s2);
  text-align: center;
}

.login-title {
  font-size: calc(22px * var(--font-scale));
  font-weight: 700;
}

.media-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
  gap: var(--s5);
  align-items: start;
}

.media-layout > .media-main:only-child {
  grid-column: 1 / -1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.media-main {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  min-width: 0;
}

.media-side {
  min-width: 0;
}

.media-side .mcard.is-list {
  gap: var(--s3);
  padding: 4px;
}

.media-side .mcard.is-list .mcard-thumb {
  width: 148px;
}

.media-side .mcard.is-list .mcard-title {
  font-size: calc(14px * var(--font-scale));
}

.media-side .mcard.is-list .mcard-body {
  padding-right: 0;
}

.media-side .mcard.is-list .mcard-fav,
.media-side .mcard.is-list .mcard-add,
.media-side .mcard-persons {
  display: none;
}

.player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - var(--topbar-h) - 96px);
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: #000;
  box-shadow: var(--shadow-2);
}

.player-stage {
  position: absolute;
  inset: 0;
}

.stage-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background-color: #05070a;
  background-position: center;
  background-size: cover;
}

.stage-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 10, 0.72);
  backdrop-filter: blur(6px);
}

.stage-note {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
  width: min(420px, 86%);
  color: #e8ecf3;
  text-align: center;
}

.stage-note .jobprogress {
  width: 100%;
}

.stage-note .jobprogress.is-compact {
  font-size: calc(13px * var(--font-scale));
}

.jobprogress-msg {
  color: rgba(232, 236, 243, 0.72);
}

.stage-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s4);
  padding: var(--s4);
  border-color: color-mix(in srgb, var(--err) 45%, var(--border));
}

.stage-error > .icon {
  color: var(--err);
}

.stage-error-title {
  font-size: calc(17px * var(--font-scale));
  font-weight: 700;
}

/* the same video at other providers, offered when nothing here plays */
.stage-alternatives {
  display: grid;
  gap: var(--s1);
  flex-basis: 100%;
  min-width: 0;
}

.stage-alt {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: background-color var(--dur-fast, 0.15s) ease, border-color var(--dur-fast, 0.15s) ease;
}

.stage-alt:hover,
.stage-alt:focus-visible {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.audio-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: clamp(220px, 34vh, 340px);
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: #05070a;
  box-shadow: var(--shadow-2);
}

.audio-slot {
  position: absolute;
  inset: 0;
}

.audio-host {
  width: 100%;
  height: 100%;
}

/* the parked audio player: in the document (keeps playing) but not visible / focusable */
.audio-holder {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 320px;
  height: 180px;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
}

.media-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3);
}

.media-title {
  flex: 1 1 320px;
  min-width: 0;
  font-size: calc(22px * var(--font-scale));
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.media-head {
  container-type: inline-size;
}

.media-actions {
  display: flex;
  flex-wrap: wrap;   /* favourite, playlist, cast, download, share ... wrap on phones instead of widening the page */
  gap: var(--s2);
  min-width: 0;
}

/* too narrow for every label (split / side columns, tablets): the secondary actions become icons - one tidy row instead of
   a lone button on a line of its own; the name stays as tooltip and for screen readers */
@container (max-width: 1240px) {  /* every label needs ~1150 px (Czech) */
  .media-actions .btn-label:not(.btn-label-keep) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .media-actions .btn:has(> .btn-label:not(.btn-label-keep)):not(:has(> .btn-label-keep)) {
    min-width: var(--hit);
    justify-content: center;
    padding-inline: 0;
  }
}

.menu-item.narrow-only {
  display: none;
}

@media (max-width: 480px) {  /* phones: cast / background go to the "more" menu, the wide player means nothing here */
  .media-actions .narrow-hide {
    display: none;
  }

  .menu-item.narrow-only {
    display: flex;
  }
}

@container (max-width: 540px) {
  .media-actions .btn-label-keep {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

.media-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s4);
  color: var(--text-muted);
}

/* the same video at other providers (merged duplicates of the result list) */
.media-alternatives {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  margin-top: var(--s2);
}

.stat-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: calc(14px * var(--font-scale));
}

.media-desc {
  padding: var(--s4);
}

.media-desc-text {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.media-desc-text.is-clamped {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  -webkit-box-orient: vertical;
}

/* ---- detail: the channel / uploader beside the provider, like a byline */
.media-byline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: min(100%, 24rem);
  min-height: 28px;
  padding: 2px 11px 2px 4px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text);
  font-size: calc(14px * var(--font-scale));
  font-weight: 600;
}

.media-byline > .icon {
  flex: none;
  margin-left: 5px;
  color: var(--text-muted);
}

.media-byline .chip-avatar {
  flex: none;
  width: 22px;
  height: 22px;
}

.media-byline:hover {
  background: var(--surface-3);
  text-decoration: none;
}

/* ---- detail: information card - description, people, tags, technical data as tabs */
.info-card {
  container-type: inline-size;
}

.info-tabs {
  padding: 0 var(--s2);
}

/* a narrow card (phones, the side column): the other tabs shrink to icon + count - one row, nothing out of sight */
@container (max-width: 560px) {
  .info-tabs .tab {
    padding: 0 var(--s3);
  }

  .info-tabs .tab:not(.is-active) .tab-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

.info-panel {
  min-width: 0;
  padding: var(--s4);
}

.info-panel:not(.is-active) {
  display: none;
}

.info-panel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* long lists scroll inside the card instead of pushing the streams far down */
.info-panel.info-people,
.info-panel.info-tags,
.info-panel.info-technical {
  max-height: 20rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.info-panel .media-desc-text.is-clamped {
  -webkit-line-clamp: 6;
  line-clamp: 6;
}

.info-more {
  margin-top: var(--s2);
  margin-left: calc(-1 * var(--s2));
}

.info-panel .chip {
  max-width: 100%;   /* a very long name or tag is cut with an ellipsis, it never widens the page */
}

.chip-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.info-groups {
  display: grid;
  gap: var(--s3);
}

.info-row {
  display: grid;
  grid-template-columns: minmax(6.5rem, max-content) minmax(0, 1fr);
  align-items: start;
  gap: var(--s2) var(--s4);
}

.info-label {
  padding-top: 9px;
  color: var(--text-muted);
  font-size: calc(13px * var(--font-scale));
  font-weight: 600;
}

@media (min-width: 900px) {
  .info-technical .kv-wide {  /* two pairs per row: half the height */
    grid-template-columns: minmax(130px, max-content) minmax(0, 1fr) minmax(130px, max-content) minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .info-row { grid-template-columns: minmax(0, 1fr); }
  .info-label { padding-top: 0; }
}

/* ---- detail: streams / downloads - folded to a quick choice in the header (components/quick-panel.js) */
.qpanel-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s2) var(--s4);
  min-height: 58px;
  padding: var(--s2) var(--s3) var(--s2) var(--s4);
  border-bottom: 1px solid transparent;  /* coloured when open - the header keeps its height */
}

.qpanel.is-open .qpanel-head {
  border-bottom-color: var(--border);
}

.qpanel-title {
  white-space: nowrap;
}

.qpanel-title > .icon {
  color: var(--text-muted);
}

.qpanel-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px var(--s5);
  min-width: 0;
  padding: 4px 0 4px var(--s4);
  border-left: 1px solid var(--border);
  transition: opacity 0.16s ease, visibility 0.16s;
}

/* unfolded: the quick choice gives way to the list, its space stays (nothing jumps) */
.qpanel.is-open .qpanel-nav {
  visibility: hidden;
  opacity: 0;
}

/* a group: its name on the left, its choices wrap beside it */
.qn-group {
  display: grid;
  grid-template-columns: max-content minmax(0, auto);
  align-items: start;
  column-gap: var(--s3);
  min-width: 0;
  max-width: 100%;
}

.qn-proto {
  position: relative;
  min-width: 5.2em;  /* the same for every group: stacked groups start their choices in one column */
  padding: 5px 14px 0 0;
  color: hsl(var(--qn-hue, 220) var(--tag-s) var(--tag-l));
  font-size: calc(12px * var(--font-scale));
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.qn-count {
  position: absolute;
  top: -0.7em;
  right: -7px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: hsl(var(--qn-hue, 220) 72% 36%);
  box-shadow: 0 0 0 2px var(--surface);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 18px;
  letter-spacing: 0;
  text-align: center;
  vertical-align: baseline;
}

.qn-items {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.qn-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: calc(12.5px * var(--font-scale));
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.qn-item:hover,
.qn-item:focus-visible {
  border-color: hsl(var(--qn-hue, 220) 70% 50%);
  color: hsl(var(--qn-hue, 220) var(--tag-s) var(--tag-l));
  text-decoration: none;
}

.qn-item:focus-visible {
  outline: 2px solid hsl(var(--qn-hue, 220) 70% 50%);
  outline-offset: 1px;
}

.qn-item.is-current {
  border-color: hsl(var(--qn-hue, 220) 70% 50%);
  background: hsl(var(--qn-hue, 220) 40% var(--tag-bg-l));
  color: hsl(var(--qn-hue, 220) var(--tag-s) var(--tag-l));
}

.qn-item.is-expired {
  border-style: dashed;
  color: var(--text-muted);
}

.qn-item .tone-warn {
  color: var(--warn);
}

.qn-more {
  background: transparent;
  color: var(--text-muted);
}

.qn-empty {
  padding: 4px 0;
}

.qpanel-toggle {
  gap: 2px;
  width: auto;
  min-width: var(--hit);
  padding: 0 8px;
}

.qpanel-total {
  min-width: 2ch;
  color: var(--text-muted);
  font-size: calc(12px * var(--font-scale));
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.qpanel-hint {
  padding: var(--s3) var(--s4) 0;
}

/* phones: a row of the full list is a small block - name on top, values and actions below; no column out of sight */
@media (max-width: 640px) {
  .qpanel-body .table thead {
    display: none;
  }

  .qpanel-body .table,
  .qpanel-body .table tbody {
    display: block;
  }

  .qpanel-body .table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px var(--s3);
    padding: var(--s3) var(--s4);
    border-bottom: 1px solid var(--border);
  }

  .qpanel-body .table td {
    display: block;
    padding: 0;
    border: 0;
    color: var(--text-muted);
    font-size: calc(13px * var(--font-scale));
  }

  .qpanel-body .table td:first-child {
    flex: 1 1 100%;
    min-width: 0;
    color: var(--text);
    font-size: calc(14px * var(--font-scale));
  }

  .qpanel-body .table td.num {
    text-align: left;
  }

  .qpanel-body .table td.row-actions {
    margin-left: auto;
  }

  .qpanel-body .row-actions .btn > span:not(.badge) {  /* icon buttons here; the label stays for screen readers */
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .qpanel-body .row-actions .btn {
    min-width: var(--hit);
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .qpanel-head {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "title toggle" "nav nav";
    row-gap: var(--s1);
  }

  .qpanel-title { grid-area: title; }
  .qpanel-toggle { grid-area: toggle; }

  .qpanel-nav {
    grid-area: nav;
    padding: 2px 0 var(--s2);
    border-left: 0;
  }

  .qpanel.is-open .qpanel-nav {
    display: none;   /* a row of its own on phones: nothing to keep */
  }
}

@media (pointer: coarse) {
  .qn-item {
    min-height: 32px;
    padding: 0 11px;
  }

  .qn-proto {
    padding-top: 8px;
  }
}

.thumbstrip {
  display: flex;
  gap: var(--s2);
  padding-bottom: var(--s2);
  overflow-x: auto;
  scroll-snap-type: x proximity;
}

.thumbstrip img {
  flex: none;
  width: 176px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  object-fit: cover;
  scroll-snap-align: start;
}

.media-foot {
  padding-bottom: var(--s4);
}

.miniplayer {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 95;
  display: flex;
  align-items: center;
  gap: var(--s3);
  height: calc(var(--mini-h) + env(safe-area-inset-bottom, 0px));
  padding: 0 var(--s4) env(safe-area-inset-bottom, 0px);
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-raised) 96%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.miniplayer-seek {
  position: absolute;
  inset: -8px 0 auto 0;
  height: 18px;
  cursor: pointer;
}

.miniplayer-seek::before,
.miniplayer-seek-fill {
  content: "";
  position: absolute;
  top: 8px;
  left: 0;
  height: 3px;
}

.miniplayer-seek::before {
  right: 0;
  background: var(--surface-3);
}

.miniplayer-seek-fill {
  background: var(--accent);
}

.miniplayer-seek:hover::before,
.miniplayer-seek:hover .miniplayer-seek-fill {
  top: 7px;
  height: 5px;
}

.miniplayer-info {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  gap: var(--s3);
  min-width: 0;
  color: var(--text);
}

.miniplayer-info:hover {
  text-decoration: none;
}

.miniplayer-cover {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--text-faint);
}

.miniplayer-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.miniplayer-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.miniplayer-title {
  font-weight: 600;
}

.miniplayer-sub {
  color: var(--text-muted);
  font-size: calc(13px * var(--font-scale));
}

.miniplayer-sub.is-error {
  color: var(--err);
}

.miniplayer-controls {
  display: flex;
  align-items: center;
  gap: var(--s1);
}

.miniplayer-play {
  width: 44px;
  min-height: 44px;
  border-radius: 50%;
}

.miniplayer-time {
  color: var(--text-muted);
  font-size: calc(13px * var(--font-scale));
  white-space: nowrap;
}

.person-head {
  display: flex;
  gap: var(--s5);
  padding: var(--s5);
}

.person-photo {
  display: grid;
  place-items: center;
  flex: none;
  width: 148px;
  height: 148px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--bg-sunken);
  color: var(--text-faint);
}

.person-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.person-info {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  min-width: 0;
}

.provider-tile {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: var(--s4);
}

.provider-tile-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
}

.provider-logo {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: hsl(var(--tag-hue, 220) 40% var(--tag-bg-l));
  color: hsl(var(--tag-hue, 220) var(--tag-s) var(--tag-l));
  font-size: calc(19px * var(--font-scale));
  font-weight: 800;
}

.provider-logo-lg {
  width: 56px;
  height: 56px;
  font-size: calc(24px * var(--font-scale));
}

.provider-logo-sm {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-size: calc(15px * var(--font-scale));
}

.provider-desc {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: var(--s3);
}

.cat-tile {
  position: relative;
  display: flex;
  align-items: flex-end;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  color: #fff;
}

.cat-tile:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.cat-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cat-tile-label {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2);
  width: 100%;
  padding: var(--s5) var(--s3) var(--s2);
  background: linear-gradient(transparent, rgba(5, 7, 10, 0.88));
  font-weight: 600;
  font-size: calc(14px * var(--font-scale));
}

.cat-tile-label .muted {
  color: rgba(255, 255, 255, 0.7);
}

/* ------------------------------------------------------------------------------ 8 admin */
.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--s2);
}

.actions-grid .btn {
  justify-content: flex-start;
  padding-top: var(--s2);
  padding-bottom: var(--s2);
  white-space: normal;
  text-align: left;
}

.loglist-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
}

.loglist-row:last-child {
  border-bottom: 0;
}

.loglist-msg {
  color: var(--err);
  font: calc(13px * var(--font-scale))/1.45 var(--mono);
  overflow-wrap: anywhere;
}

.settings {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: var(--s5);
  align-items: start;
  padding-bottom: 80px;
}

.settings-nav {
  position: sticky;
  top: calc(var(--topbar-h) + var(--s4));
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  min-width: 0;
}

.setting {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 380px);
  gap: var(--s3) var(--s5);
  align-items: start;
  padding: var(--s4);
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
}

.setting:last-child {
  border-bottom: 0;
}

.setting.is-dirty {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.setting-label {
  font-weight: 600;
}

.setting-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  margin-top: 4px;
  color: var(--text-faint);
  font-size: calc(12px * var(--font-scale));
  overflow-wrap: anywhere;
}

.setting-control {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.setting-control .fieldinput {
  width: 100%;
}

.setting.is-bool .setting-control {
  align-items: flex-end;
}

.setting.is-bool .fieldinput {
  width: auto;
}

.savebar {
  position: fixed;
  right: var(--s4);
  bottom: var(--s4);
  left: var(--s4);
  z-index: 96;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  animation: pop 0.18s var(--ease);
}

.app.has-mini .savebar {
  bottom: calc(var(--mini-h) + var(--s4));
}

.cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: 6px var(--s3) 6px 0;
  border-bottom: 1px solid var(--border);
}

.cat-row:last-child {
  border-bottom: 0;
}

.cat-row:hover {
  background: var(--surface-2);
}

.cat-row.is-off .cat-row-main {
  opacity: 0.5;
}

.cat-row-main {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  gap: var(--s3);
  min-width: 0;
  min-height: var(--hit);
}

.cat-row-text {
  display: flex;
  flex-direction: column;
}

.cat-row-name {
  font-weight: 600;
}

.cat-row-actions {
  display: flex;
  align-items: center;
  flex: none;
  gap: 2px;
}

.cat-row-actions .toggle {
  margin-right: var(--s2);
}

.worker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: var(--s3);
  padding: var(--s4);
}

.worker {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: var(--s4);
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-faint);
  border-radius: var(--radius);
  background: var(--bg-sunken);
}

.worker.is-idle { border-left-color: var(--ok); }
.worker.is-busy, .worker.is-starting { border-left-color: var(--info); }
.worker.is-stopping { border-left-color: var(--warn); }
.worker.is-crashed { border-left-color: var(--err); }

.worker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
}

.worker-actions {
  display: flex;
  flex-wrap: wrap;   /* stop / restart / detail on narrow cards */
  gap: var(--s2);
  margin-top: auto;
}

.queue-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2) var(--s4);
}

.queue-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 4px var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
}

.logview {
  font: calc(12.5px * var(--font-scale))/1.5 var(--mono);
}

.logrow {
  padding: 5px var(--s4);
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
}

.logrow:last-child {
  border-bottom: 0;
}

.logrow.is-live {
  animation: flash 1.6s var(--ease);
}

.logrow-main {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  min-width: 0;
}

.logrow-ts {
  flex: none;
  color: var(--text-faint);
}

.logrow-level {
  flex: none;
  width: 58px;
  font-weight: 700;
}

.logrow-module {
  flex: none;
  max-width: 130px;
  overflow: hidden;
  color: hsl(var(--tag-hue, 220) var(--tag-s) var(--tag-l));
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logrow-msg {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logrow-msg.is-open {
  overflow: visible;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.logrow-more {
  flex: none;
  align-self: center;
  min-height: 26px;
  padding: 0 6px;
}

.logrow-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 2px 0 2px calc(58px + var(--s3));
}

td .logrow-tags {
  margin: 0;
}

.logtag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-muted);
  font: calc(11.5px * var(--font-scale))/1.7 var(--mono);
}

button.logtag:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.logtag.is-static {
  border-style: dashed;
}

.lvl-debug .logrow-level { color: var(--text-faint); }
.lvl-info .logrow-level { color: var(--info); }
.lvl-warning { border-left-color: var(--warn); }
.lvl-warning .logrow-level { color: var(--warn); }
.lvl-error, .lvl-critical { border-left-color: var(--err); background: color-mix(in srgb, var(--err) 6%, transparent); }
.lvl-error .logrow-level, .lvl-critical .logrow-level { color: var(--err); }

.check-state {
  width: 44px;
}

.check-title {
  min-width: 250px;
}

.check-state.is-ok { color: var(--ok); }
.check-state.is-warn { color: var(--warn); }
.check-state.is-fail { color: var(--err); }

.sample-list {
  margin-top: var(--s2);
  font-size: calc(13.5px * var(--font-scale));
}

/* ------------------------------------------------------------------------------ responsive */
@media (max-width: 1440px) {
  .media-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .media-layout > .media-main {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
  }

  .media-side {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
  }

  .media-side .media-grid.is-list {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  }
}

@media (max-width: 1180px) {
  .split {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 960px) {
  .settings {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-nav {
    position: static;
    flex-direction: row;
    gap: var(--s1);
    overflow-x: auto;
    padding-bottom: var(--s1);
  }

  .settings-nav .side-link {
    width: auto;
    flex: none;
    border: 1px solid var(--border);
    white-space: nowrap;
  }
}

@media (max-width: 720px) {
  :root {
    --topbar-h: 56px;
  }

  body {
    font-size: calc(15px * var(--font-scale));
  }

  .hide-sm {
    display: none !important;
  }

  .page {
    gap: var(--s3);
    padding: var(--s4) var(--s3);
  }

  .page-title {
    font-size: calc(20px * var(--font-scale));
  }

  .topbar {
    gap: var(--s2);
    padding: 0 var(--s2);
  }

  .brand-name,
  .topsearch-kbd {
    display: none;
  }

  .media-grid,
  .media-grid.is-dense {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s4) var(--s3);
  }

  .media-grid.is-list {
    grid-template-columns: minmax(0, 1fr);
  }

  /* one swipeable row instead of a tall stack of chips */
  .provider-strip {
    flex-wrap: nowrap;
    margin: 0 calc(-1 * var(--s3));
    padding: 2px var(--s3);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .provider-strip::-webkit-scrollbar {
    display: none;
  }

  .pchip {
    flex: none;
  }

  .mcard-title {
    font-size: calc(14px * var(--font-scale));
  }

  .filterbar-toggle {
    display: inline-flex;
    width: 100%;
    justify-content: flex-start;
  }

  .filterbar-toggle .icon:last-child {
    margin-left: auto;
  }

  .filterbar-body {
    display: none;
    margin-top: var(--s3);
    padding: var(--s3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
  }

  .filterbar.is-open .filterbar-body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter,
  .filter-wide {
    min-width: 0;
  }

  .filter-wide,
  .filter-range,
  .filter-tokens,
  .filter-reset {
    grid-column: 1 / -1;
  }

  .filter-tokens {
    max-width: none;
  }

  .searchbox {
    padding-left: var(--s3);
  }

  .searchbox .btn {
    padding: 0 var(--s3);
  }

  .stat-wide {
    grid-column: auto;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .setting {
    grid-template-columns: minmax(0, 1fr);
  }

  .setting.is-bool {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .audio-stage {
    width: calc(100% + 2 * var(--s3));
    margin: calc(-1 * var(--s4)) calc(-1 * var(--s3)) 0;
    border-radius: 0;
  }

  .person-head {
    flex-direction: column;
    align-items: center;
    padding: var(--s4);
    text-align: center;
  }

  .person-info {
    align-items: center;
  }

  .media-title {
    font-size: calc(19px * var(--font-scale));
  }

  .player-wrap {  /* edge to edge (layouts.css keeps that for .detail players too) */
    width: calc(100% + 2 * var(--s3));
    margin: calc(-1 * var(--s4)) calc(-1 * var(--s3)) 0;
    border-radius: 0;
  }

  .table th,
  .table td {
    padding: 9px var(--s3);
  }

  .cat-row {
    flex-wrap: wrap;
  }

  .cat-row-actions {
    margin-left: auto;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    max-width: none;
    max-height: 92vh;
    max-height: 92dvh;
    border-width: 1px 0 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    animation-name: slide-up;
  }

  .modal.drawer {
    max-height: none;
    border-radius: 0;
  }

  .modal-body {
    padding: var(--s4);
  }

  .modal-head {
    padding-left: var(--s4);
  }

  .modal-foot {
    padding-left: var(--s4);
    padding-right: var(--s4);
  }

  .toasts {
    right: var(--s3);
    left: var(--s3);
    width: auto;
  }

  .logrow-main {
    flex-wrap: wrap;
    gap: 2px var(--s2);
  }

  .logrow-msg {
    flex-basis: 100%;
  }

  .logrow-tags {
    margin-left: 0;
  }

  .miniplayer {
    gap: var(--s2);
    padding-left: var(--s3);
    padding-right: var(--s2);
  }
}

@media (max-width: 330px) {
  .media-grid,
  .media-grid.is-dense {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ------------------------------------------------------------------------------ motion */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  to { transform: translateX(100%); }
}

@keyframes indeterminate {
  0% { left: -40%; }
  100% { left: 100%; }
}

@keyframes pulse {
  50% { opacity: 0.45; }
}

@keyframes fade {
  from { opacity: 0; }
}

@keyframes pop {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
}

@keyframes slide-in {
  from { transform: translateX(40px); opacity: 0; }
}

@keyframes slide-up {
  from { transform: translateY(40px); opacity: 0; }
}

@keyframes flash {
  from { background: var(--accent-soft); }
}

@keyframes token-flash {
  0%, 60% { border-color: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Administration -> Appearance -> animations off */
:root[data-motion="off"] *,
:root[data-motion="off"] *::before,
:root[data-motion="off"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

:root[data-badges="off"] .mcard .ptag {
  display: none;
}

/* ------------------------------------------------------------------ thumbnail strip: frames are seek targets */
.thumbstrip-item {
  position: relative;
  flex: 0 0 auto;
  padding: 0;
  border: 2px solid transparent;
  border-radius: calc(var(--radius) * 0.6);
  background: none;
  overflow: hidden;
  cursor: pointer;
  line-height: 0;
  scroll-snap-align: start;
}

.thumbstrip-item:disabled { cursor: default; }
.thumbstrip-item img { display: block; border-radius: 0; }
.thumbstrip-item:not(:disabled):hover,
.thumbstrip-item:focus-visible { border-color: var(--accent); outline: none; }
.thumbstrip-item.is-current { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }

.thumbstrip-time {
  position: absolute;
  right: 4px;
  bottom: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.7rem;
  line-height: 1.5;
  color: #fff;
  background: rgba(0, 0, 0, 0.72);
}

/* ------------------------------------------------------------------ loop tool */
.looptool-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.looptool-head .card-title { display: inline-flex; align-items: center; gap: 8px; margin-right: auto; }
.looptool-saved { font-size: 0.8rem; color: var(--text-muted); }
.looptool-hint { margin: 0; font-size: 0.85rem; }

.looptool-bar {
  position: relative;
  height: 28px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  overflow: hidden;
}

.looptool-range,
.looptool-draft {
  position: absolute;
  top: 3px;
  bottom: 3px;
  min-width: 3px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 55%, transparent);
}

.looptool-range.is-off { background: color-mix(in srgb, var(--text-muted) 35%, transparent); }
.looptool-range.is-current { background: var(--accent); }
.looptool-draft { background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--accent) 45%, transparent) 0 6px, transparent 6px 12px); border: 1px dashed var(--accent); }
.looptool-head-pos { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--text); pointer-events: none; }

.looptool-mark { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.looptool-mark kbd, .looptool-at { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8em; opacity: 0.8; }
.looptool-mark kbd { padding: 0 5px; border: 1px solid currentColor; border-radius: 4px; }
.looptool-now { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-muted); }

.looptool-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.looptool-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.7);
}

.looptool-item.is-current { border-color: var(--accent); }
.looptool-item.is-off { opacity: 0.6; }
.looptool-check input { width: 18px; height: 18px; }
.looptool-label { flex: 1 1 140px; min-width: 110px; }
.looptool-time { display: inline-flex; align-items: center; gap: 2px; }
.looptool-time .input { width: 7.2ch; min-width: 78px; text-align: center; font-variant-numeric: tabular-nums; padding-inline: 4px; }
.looptool-len { min-width: 6ch; text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.looptool-order { display: inline-flex; gap: 2px; margin-left: auto; }
.looptool-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.looptool-foot .btn-ghost { margin-left: auto; }

/* ------------------------------------------------------------------ playlists */
.picker-item { margin: 0 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-list { list-style: none; margin: 8px 0; padding: 0; max-height: 46vh; overflow: auto; display: grid; gap: 2px; }
.picker-row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 8px; border-radius: calc(var(--radius) * 0.6); cursor: pointer; }
.picker-row:hover { background: var(--surface-2); }
.picker-row.is-busy { opacity: 0.6; }
.picker-row input { width: 18px; height: 18px; flex: 0 0 auto; }
.picker-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-meta { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }
.picker-new { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.picker-help { margin: 0; font-size: 0.85rem; }
.picker-actions { display: flex; justify-content: flex-end; gap: 8px; }
.picker-create { width: 100%; justify-content: center; margin-top: 8px; }

.plgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 16px; margin-top: 16px; }
.plcard { display: flex; flex-direction: column; overflow: hidden; color: inherit; text-decoration: none; }
.plcard:hover .plcard-title { color: var(--accent-text, var(--accent)); }
.plcard-cover { display: grid; aspect-ratio: 16 / 9; background: var(--surface-2); place-items: center; color: var(--text-muted); overflow: hidden; }
.plcard-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.plcard-cover.n2, .plcard-cover.n3, .plcard-cover.n4 { grid-template-columns: 1fr 1fr; gap: 2px; place-items: stretch; }
.plcard-cover.n3 img:first-child { grid-row: span 2; }
.plcard-cover.n4 { grid-template-rows: 1fr 1fr; }
.plcard-body { display: grid; gap: 4px; padding: 10px 12px 12px; }
.plcard-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plcard-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.82rem; color: var(--text-muted); margin: 0; }
.plcard-meta .badge { display: inline-flex; align-items: center; gap: 4px; }
.plcard-owner { font-size: 0.8rem; }

.plhead { display: grid; grid-template-columns: minmax(180px, 300px) 1fr; gap: 20px; padding: 16px; margin-bottom: 16px; }
.plhead-cover { border-radius: calc(var(--radius) * 0.8); }
.plhead-body { display: grid; gap: 10px; align-content: start; min-width: 0; }
.plhead-desc { margin: 0; white-space: pre-line; }
.plhead-rating { display: flex; align-items: center; gap: 8px; }
.plhead-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stars { display: inline-flex; }
.star { min-width: 32px; min-height: 40px; padding: 0; border: 0; background: none; font-size: 1.5rem; line-height: 1; color: var(--border); cursor: pointer; }
.star:disabled { cursor: default; }
.star.is-on { color: #f5b942; }
.star.is-mine { color: var(--accent); }

.pllist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.plrow { display: grid; grid-template-columns: 2.2ch 160px 1fr auto; align-items: center; gap: 12px; padding: 8px 12px; }
.plrow-n { text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.plrow-thumb { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: calc(var(--radius) * 0.6); overflow: hidden; background: var(--surface-2); }
.plrow-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
html[data-played="dim"] .plrow.is-played .plrow-thumb img { opacity: 0.55; filter: saturate(0.55); }
.plrow-main { display: grid; gap: 4px; min-width: 0; }
.plrow-title { font-weight: 600; color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.plrow-title:hover { color: var(--accent-text, var(--accent)); }
.plrow-sub { font-size: 0.82rem; }
.plrow-note { max-width: 520px; font-size: 0.85rem; }
.plrow-noteview { font-size: 0.85rem; font-style: italic; color: var(--text-muted); }
.plrow-actions { display: inline-flex; gap: 2px; }

@media (max-width: 720px) {
  .plhead { grid-template-columns: 1fr; }
  .plrow { grid-template-columns: 2ch 104px 1fr; }
  .plrow-actions { grid-column: 2 / -1; justify-content: flex-end; }
  .looptool-order { margin-left: 0; }
}

/* ---------------------------------------------------------------- unified person page (/people/<id>/<slug>) */
.people-head {
  display: flex;
  align-items: center;
  gap: var(--s5);
  padding: var(--s5);
  margin-bottom: var(--s5);
}

.people-head > .avatar-img {
  flex: none;
  border-radius: 50%;
}

.people-head-body {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  min-width: 0;
}

.people-head-body .page-title {
  margin: 0;
  overflow-wrap: anywhere;
}

.people-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}

.people-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s4);
}

.people-toolbar .section-title {
  flex: 1;
  margin: 0;
}

.people-toolbar .select {
  width: auto;
  min-width: 170px;
}

@media (max-width: 640px) {
  .people-head {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s3);
    padding: var(--s4);
  }

  .people-toolbar {
    flex-wrap: wrap;
  }

  .people-toolbar .section-title {
    flex-basis: 100%;
  }
}

/* ---------------------------------------------------------------- playlists: public index, comments, statistics, delegates */
.plindex-tools { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.plindex-tools .input { flex: 1 1 260px; }
.plindex-tools .select { flex: 0 1 230px; width: auto; }

.plsection { margin-top: 16px; }
.plsection > .section-title { margin: 0 0 12px; }

.comment-form { display: grid; gap: 6px; margin-bottom: 16px; }
.comment-form.is-reply { margin: 4px 0 8px 48px; }
.comment-form textarea { resize: vertical; min-height: 64px; }
.comment-form-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.comment-form-foot > .muted { margin-right: auto; }
.comment-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; max-width: 860px; }
.comment-thread { display: grid; gap: 8px; }
.comment { display: grid; grid-template-columns: 36px 1fr; gap: 12px; }
.comment.is-reply { margin-left: 48px; }
.comment-avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); color: var(--text-muted); font-weight: 650; }
.comment.is-reply .comment-avatar { width: 28px; height: 28px; font-size: 0.8rem; }
.comment.is-reply { grid-template-columns: 28px 1fr; }
.comment-main { min-width: 0; }
.comment-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 0; font-size: 0.85rem; color: var(--text-muted); }
.comment-head strong { color: var(--text); font-size: 0.92rem; }
.comment-body { margin: 2px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.comment-actions { display: flex; gap: 14px; margin: 4px 0 0; }
.link-btn { padding: 4px 0; border: 0; background: none; color: var(--text-muted); font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; }
.link-btn:hover, .link-btn:focus-visible { color: var(--accent-text, var(--accent)); text-decoration: underline; }
.link-btn.is-danger:hover, .link-btn.is-danger:focus-visible { color: var(--err); }

.plstats-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.plstats-head .section-title { margin: 0; }
.stat-tiles { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; transition: opacity 0.15s; }
.stat-tiles.is-loading { opacity: 0.55; }
.stat-tile { display: grid; gap: 2px; padding: 12px 14px; }
.stat-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.stat-value { font-size: 1.6rem; line-height: 1.15; font-variant-numeric: tabular-nums; }

.plchart { position: relative; margin: 0 0 16px; padding: 12px 14px 8px; }
.plchart-plot { position: relative; min-width: 0; }
.plchart svg { display: block; max-width: 100%; overflow: visible; }
.plchart-legend { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; font-size: 0.85rem; }
.plchart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.swatch-views { background: var(--accent); }
.swatch-plays { background: var(--accent-2); }
.plchart-grid line { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.plchart-grid text { fill: var(--text-muted); font-size: 11px; }
.plchart-area { fill: color-mix(in srgb, var(--accent) 18%, transparent); stroke: none; }
.plchart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.plchart-line.is-views, .plchart-dot.is-views { stroke: var(--accent); }
.plchart-line.is-plays, .plchart-dot.is-plays { stroke: var(--accent-2); }
.plchart-dot { fill: var(--surface); stroke-width: 2; vector-effect: non-scaling-stroke; }
.plchart-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; pointer-events: none; }

.plstats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 12px; }
.plstats-box { padding: 14px; min-width: 0; }
.plstats-title { margin: 0 0 10px; font-size: 1rem; }
.plstats-top { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; counter-reset: top; }
.plstats-top li { display: grid; grid-template-columns: 1.6em minmax(0, 1fr) auto; align-items: baseline; gap: 8px; counter-increment: top; }
.plstats-top li::before { content: counter(top) "."; color: var(--text-muted); font-variant-numeric: tabular-nums; text-align: right; }
.plstats-top li > a { color: inherit; }
.plstats-top li > span { font-size: 0.85rem; }
.bar-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.bar-rows li { display: grid; grid-template-columns: minmax(3.2em, 9em) 1fr auto; align-items: center; gap: 10px; font-size: 0.88rem; }
.bar-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.bar-fill.is-rating { background: #f5b942; }
.bar-count { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.delegate-lookup { position: relative; display: grid; gap: 6px; }
.delegate-options { position: absolute; z-index: 5; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px; list-style: none; max-height: 240px; overflow-y: auto; }
.delegate-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.delegate-row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: calc(var(--radius) * 0.6); }
.delegate-row .select { width: auto; }
.delegate-roles { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0; }
.delegate-roles dt { font-weight: 650; }
.delegate-roles dd { margin: 0; }

@media (max-width: 640px) {
  .comment-form.is-reply, .comment.is-reply { margin-left: 24px; }
  .delegate-row { grid-template-columns: auto 1fr auto; }
  .delegate-row .select { grid-column: 2 / 3; grid-row: 2; }
}

.table td > .select { min-width: 11em; }

/* ---------------------------------------------------------------- administration: remote worker nodes */
.node { border-top: 1px solid var(--border); padding: 14px 16px 6px; }
.node.is-offline .node-title strong { color: var(--text-muted); }
.node-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.node-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.node-title strong { font-size: 1.05rem; }
.node-title .cell-sub { flex-basis: 100%; margin: 0; }
.node-scale { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 12px 0 4px; padding: 12px; border-radius: calc(var(--radius) * 0.7); background: var(--surface-2); }
.node-scale .field { margin: 0; }
.node-scale .input-num { width: 6.5em; }
.node-scale-end { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.node-note { display: flex; align-items: flex-start; gap: 6px; margin: 10px 0 6px; }
.node-note .icon { flex: none; margin-top: 2px; }
.node > .table-wrap { margin: 8px -16px 0; }

@media (max-width: 640px) {
  .node-scale-end { margin-left: 0; flex-basis: 100%; }
}
.stack-sm { display: grid; gap: 6px; }

/* ---------------------------------------------------------------- registration + legal documents */
.login.standalone { align-content: start; padding-top: calc(var(--s5) + 44px); }
.register-wrap { position: relative; width: 100%; display: grid; place-items: center; }
.login.standalone .register-wrap .login-tools { position: fixed; top: var(--s4); right: var(--s4); z-index: 5; }
.register-card { max-width: 720px; }
.register-section { display: grid; gap: var(--s3); margin: 0; padding: var(--s4) 0 0; border: 0; border-top: 1px solid var(--border); min-width: 0; }
.register-section > legend { padding: 0 var(--s2) 0 0; margin-bottom: var(--s2); font-weight: 650; font-size: 0.95rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.register-section .form-row { gap: var(--s3); }
.register-section .field { margin: 0; min-width: 0; }
.register-section .input-short { max-width: 9em; }
.country-pick { display: flex; align-items: center; gap: var(--s2); }
.country-pick .select { flex: 1; min-width: 0; }
.country-flag { font-size: 1.6rem; line-height: 1; width: 1.6em; text-align: center; }
.code-group { align-items: center; gap: var(--s3); }
.input-code { max-width: 9em; font-family: var(--font-mono, ui-monospace, monospace); font-size: 1.25rem; letter-spacing: 0.35em; text-align: center; }
.field-help.is-ok { display: inline-flex; align-items: center; gap: 4px; color: var(--ok); }
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 6px; }
.pw-meter span { height: 4px; border-radius: 2px; background: var(--border); }
.pw-meter[data-score="1"] span:nth-child(-n + 1) { background: var(--err); }
.pw-meter[data-score="2"] span:nth-child(-n + 2) { background: var(--warn); }
.pw-meter[data-score="3"] span:nth-child(-n + 3) { background: var(--ok); }
.pw-meter[data-score="4"] span { background: var(--ok); }
.check-row { display: flex; align-items: flex-start; gap: var(--s2); cursor: pointer; }
.check-row input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); }
.check-row.is-invalid span { color: var(--err); }
.check-row .linklike { padding: 0; font: inherit; }
.login-alt { margin: 0; text-align: center; }
.login-legal { margin: 0; text-align: center; }
.login-legal a { color: inherit; }
.page-legal { max-width: 860px; margin: 0 auto; }
.legal { padding: var(--s6); }
.legal-switch { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s4); }
.legal-switch .chip.is-active { background: var(--accent-soft); color: var(--accent-text, var(--accent)); }
.legal-switch .muted { margin-left: auto; }
.legal-body { line-height: 1.6; }
.legal-body h1 { font-size: 1.6rem; margin: 0 0 var(--s3); }
.legal-body h2 { font-size: 1.15rem; margin: var(--s5) 0 var(--s2); }
.legal-body h3 { font-size: 1rem; margin: var(--s4) 0 var(--s2); }
.legal-body p { margin: 0 0 var(--s3); }
.legal-body ul { margin: 0 0 var(--s3); padding-left: 1.4em; }
.legal-body li { margin-bottom: 4px; }
.legal-body-modal { max-height: 60vh; overflow: auto; padding-right: var(--s2); }
.login.standalone .page-legal { width: 100%; }
@media (max-width: 640px) {
  /* flex-wrap already puts the fields below each other; a column direction would turn the 180px basis into a height */
  .register-section .form-row > .field { flex-basis: 100%; }
  .register-section .input-short { max-width: none; }
}

/* settings rows: the label column must never collapse (a fixed 240-380px control column ate it on narrow screens) */
.setting { grid-template-columns: minmax(160px, 1fr) minmax(200px, 380px); }
.setting.is-bool { grid-template-columns: minmax(0, 1fr) auto; }
.setting-info { min-width: 0; }
@media (max-width: 720px) {
  .setting:not(.is-bool) { grid-template-columns: minmax(0, 1fr); }
  .setting:not(.is-bool) .setting-control { align-items: stretch; }
}

/* ---------------------------------------------------------------- administration: worker detail + debug console */
.worker-name { padding: 0; text-align: left; color: inherit; }
.worker-name:hover strong { color: var(--accent-text, var(--accent)); }
.wdetail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: var(--s3); }
.wdetail-box { padding: var(--s3) var(--s4); margin: 0; }
.kv-inline { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0; padding: 8px 12px; border-radius: calc(var(--radius) * 0.6); background: var(--surface-2); }
.kv-inline dt { color: var(--text-muted); font-size: 0.78rem; }
.kv-inline dd { margin: 0 0 0 4px; font-variant-numeric: tabular-nums; }
.kv-inline dt::after { content: ''; }
.badge.ml { margin-left: 6px; }
.logview-compact .logrow { padding: 4px 6px; font-size: 0.82rem; }
.logview-compact .logrow-msg { white-space: pre-wrap; overflow-wrap: anywhere; }
.table-compact td, .table-compact th { padding-top: 4px; padding-bottom: 4px; }
.console { display: grid; gap: var(--s3); }
.console-quick { align-items: center; }
.console-help summary { list-style: none; cursor: pointer; }
.console-help summary::-webkit-details-marker { display: none; }
.console-help[open] { flex-basis: 100%; }
.console-help dl { margin: 8px 0 0; }
.console-form { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.console-prompt { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; }
.console-form .input { flex: 1 1 260px; }
.console-out { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.console-entry { border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: calc(var(--radius) * 0.6); padding: 8px 10px; }
.console-entry.is-ok { border-left-color: var(--ok); }
.console-entry.is-err { border-left-color: var(--err); }
.console-entry.is-running { border-left-color: var(--accent); }
.console-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.console-cmd { font-weight: 650; }
.console-pre { margin: 8px 0 0; max-height: 360px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.8rem; }
.console-data { margin-top: 6px; }

/* ------------------------------------------------------------------------------ casting, queue, receiver */
.cast-picker { gap: var(--s4); }
.cast-group { display: grid; gap: var(--s2); }
.cast-group-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.cast-group-title { margin: 0; font-size: calc(13px * var(--font-scale)); font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.cast-device {
  display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 56px; padding: 8px var(--s3);
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); text-align: left; cursor: pointer;
}
.cast-device:hover:not(:disabled), .cast-device:focus-visible { border-color: var(--accent); background: var(--surface-2); }
.cast-device:disabled { opacity: 0.6; cursor: default; }
.cast-device.is-busy { border-style: dashed; }
.cast-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); color: var(--accent-text, var(--accent)); }
.cast-text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.cast-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; flex: none; }
.cast-outputs { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.cast-running { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); padding: 8px var(--s3); border-radius: var(--radius-sm); background: var(--accent-soft, var(--surface-2)); }
.cast-running .small { flex: 1 1 100%; }
.cast-pin { padding: 0 var(--s3) var(--s2) 64px; }
.cast-help summary { cursor: pointer; color: var(--text-muted); }
.cast-help ul { margin: var(--s2) 0 0; padding-left: 1.2em; display: grid; gap: 6px; }

.miniplayer-queue, .remotebar-queue {
  position: absolute; right: var(--s3); bottom: calc(100% + var(--s2)); z-index: 2;
  width: min(420px, calc(100vw - 2 * var(--s3))); max-height: min(70vh, 560px); display: flex; flex-direction: column; padding: 0; box-shadow: var(--shadow-2);
}
.queue-panel { overflow: hidden; }
.queue-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s2); padding: var(--s3) var(--s3) var(--s2); border-bottom: 1px solid var(--border); }
.queue-panel-head p { margin: 2px 0 0; }
.queue-panel-title { margin: 0; font-size: calc(16px * var(--font-scale)); }
.queue-tools { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); }
.queue-list { list-style: none; margin: 0; padding: 4px; overflow: auto; flex: 1 1 auto; }
.queue-row { display: flex; align-items: center; gap: 2px; border-radius: var(--radius-sm); }
.queue-row.is-current { background: var(--surface-2); }
.queue-row.is-past { opacity: 0.62; }
.queue-main { display: flex; align-items: center; gap: var(--s2); flex: 1 1 auto; min-width: 0; padding: 6px; border: 0; background: none; color: var(--text); text-align: left; cursor: pointer; border-radius: var(--radius-sm); }
.queue-main:hover:not(:disabled) { background: var(--surface-2); }
.queue-thumb { display: grid; place-items: center; flex: none; width: 64px; height: 36px; overflow: hidden; border-radius: 4px; background: var(--bg-sunken); color: var(--text-faint); }
.queue-thumb img { width: 100%; height: 100%; object-fit: cover; }
.queue-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.queue-name { font-weight: 550; font-size: calc(14px * var(--font-scale)); }
.queue-row.is-current .queue-name { color: var(--accent-text, var(--accent)); }
.queue-now { flex: none; color: var(--accent); }
.queue-actions { display: flex; flex: none; }
.queue-one { margin-left: -4px; font-size: 10px; font-weight: 700; }

.remotebar { border-top-color: var(--accent); }
.remotebar-volume { width: 96px; accent-color: var(--accent); }
.remotebar.is-error .miniplayer-sub, .remotebar.is-offline .miniplayer-sub { color: var(--err); }

.bare { min-height: 100vh; min-height: 100dvh; }
.receiver { position: fixed; inset: 0; display: grid; place-items: center; background: #05070a; color: #e8ecf3; }
.receiver-stage { position: absolute; inset: 0; }
.receiver-idle { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--s3); width: min(560px, calc(100% - 32px)); text-align: center; }
.receiver-idle .muted { color: #a5afc0; }
.receiver-idle .icon { color: var(--accent); }
.receiver-title { margin: 0; font-size: clamp(24px, 4vw, 40px); }
.receiver-name { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; justify-content: center; margin: 0; font-size: 1.2rem; }
.receiver-conn { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.receiver-conn .badge-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn, #e0a030); }
.receiver-conn.is-ok .badge-dot { background: var(--ok); }
.receiver-unlock {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: var(--s3);
  padding-bottom: 12vh; border: 0; background: linear-gradient(to top, rgba(5, 7, 10, 0.86), transparent 60%); color: #fff; font-size: 1.1rem; cursor: pointer;
}
/* the MSA Receiver app: a bare stage - no player chrome, no pointer, the cover of an audio track fills the window */
.receiver.is-app .msap-top, .receiver.is-app .msap-bottom, .receiver.is-app .msap-bar { display: none !important; }
.receiver.is-app .receiver-stage { cursor: none; }
.receiver-idle-app { gap: var(--s2); }
.receiver-error { position: absolute; left: 16px; right: 16px; bottom: 16px; z-index: 6; margin: 0; padding: 8px 12px; border-radius: var(--radius-sm); background: rgba(160, 30, 40, 0.85); color: #fff; }
.row.center { justify-content: center; }

@media (max-width: 480px) {
  .miniplayer-cast, .remotebar .miniplayer-time { display: none; }
  .cast-pin { padding-left: var(--s3); }
  .cast-badges { display: none; }
}

.site-version { margin: 0; color: var(--text-faint); letter-spacing: 0.02em; }

/* ------------------------------------------------------------------------------ refine: filter helper, refined results, result sets */
.btn-xs { min-height: 28px; min-width: 28px; padding: 0 6px; font-size: calc(12px * var(--font-scale)); }
.btn-icon.btn-xs { width: 28px; padding: 0; }
.input-sm { min-height: 34px; padding: 4px 10px; font-size: calc(13.5px * var(--font-scale)); }
.chip-sm { min-height: 28px; padding: 0 10px; font-size: calc(12.5px * var(--font-scale)); gap: 4px; }
.chip.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text, var(--accent)); }
.menu-item.is-danger { color: var(--err); }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-inset { display: grid; gap: var(--s2); padding: var(--s3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-sunken); }

.refine-toggle .badge { margin-left: 2px; }
.refine-toggle.is-active { border-color: var(--accent); color: var(--accent-text, var(--accent)); }

/* the panel: a column right of the results (wide screens), a drawer (tablets), a bottom sheet (phones) */
.refine-panel {
  --refine-w: min(460px, 38vw);
  position: fixed; top: calc(var(--topbar-h) + var(--s2)); right: var(--s2); bottom: var(--s2); z-index: 96;
  display: flex; flex-direction: column; width: var(--refine-w); min-width: 360px;
  border: 1px solid var(--border); border-radius: calc(var(--radius) * 1.4); background: color-mix(in srgb, var(--bg-raised) 97%, transparent);
  box-shadow: var(--shadow-3, var(--shadow-2)); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  transform: translateX(calc(100% + 24px)); opacity: 0; visibility: hidden;
  transition: transform 0.26s var(--ease, ease), opacity 0.2s ease, visibility 0s linear 0.26s;
}
.refine-panel.is-open { transform: none; opacity: 1; visibility: visible; transition: transform 0.26s var(--ease, ease), opacity 0.2s ease; }
.app.has-mini .refine-panel { bottom: calc(var(--mini-h) + var(--s2) + env(safe-area-inset-bottom, 0px)); }
.refine-backdrop { display: none; }
.refine-grip { display: none; }
@media (min-width: 980px) {
  .page-search.has-refine, .page-set.has-refine { padding-right: calc(min(460px, 38vw) + var(--s2) + var(--s5)); transition: padding 0.26s var(--ease, ease); }
}
@media (max-width: 759px) {
  .refine-panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; min-width: 0; max-height: 88dvh; height: 88dvh; z-index: 150;
    border-radius: 18px 18px 0 0; border-bottom: 0; transform: translateY(100%);
  }
  .app.has-mini .refine-panel { bottom: 0; }
  .refine-backdrop { display: block; position: fixed; inset: 0; z-index: 149; background: var(--scrim, rgba(0, 0, 0, 0.45)); animation: fade-in 0.2s ease; }
  .refine-grip { display: block; width: 44px; height: 5px; margin: 8px auto 0; border-radius: 3px; background: var(--border-strong); }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .refine-panel, .refine-panel.is-open { transition: none; } }

.refine-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s3) var(--s2) var(--s4); }
.refine-headline { flex: 1 1 auto; min-width: 0; }
.refine-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: calc(17px * var(--font-scale)); }
.refine-title .icon { color: var(--accent); }
.refine-count { margin: 2px 0 0; color: var(--text-muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.refine-count strong { color: var(--text); font-size: 1.05em; }

.refine-tabs { display: flex; gap: 4px; padding: 0 var(--s3) var(--s2); overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); }
.refine-tabs::-webkit-scrollbar { display: none; }
.refine-tab {
  display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 34px; padding: 0 12px; border: 1px solid transparent; border-radius: var(--radius-pill);
  background: none; color: var(--text-muted); font-weight: 600; font-size: calc(13px * var(--font-scale)); white-space: nowrap; cursor: pointer;
}
.refine-tab:hover { color: var(--text); background: var(--surface-2); }
.refine-tab.is-active { color: var(--accent-text, var(--accent)); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

.refine-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: var(--s3) var(--s3) var(--s5); }
.refine-section { display: grid; gap: var(--s3); align-content: start; }
.refine-section > p { margin: 0; }
.refine-subtitle { margin: 0; font-size: calc(13px * var(--font-scale)); font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.refine-subhead { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; justify-content: space-between; margin-top: var(--s2); }
.refine-summary { margin: 0; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg-sunken); display: flex; gap: 6px; align-items: flex-start; line-height: 1.45; }
.refine-summary .icon { flex: none; margin-top: 2px; }

.refine-quick {
  display: flex; align-items: center; gap: 8px; padding: 0 12px; min-height: 42px; border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--text-muted);
}
.refine-quick:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.refine-quick-input { flex: 1 1 auto; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); font: inherit; }
.refine-quickchips { display: flex; flex-wrap: wrap; gap: 6px; }

/* filter chain */
.rgroup { position: relative; display: grid; gap: var(--s2); padding: var(--s2) var(--s2) var(--s2) calc(var(--s2) + 4px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.rgroup::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--accent); opacity: 0.8; }
.rgroup.is-or::before { background: var(--warn); }
.rgroup.is-not { border-color: color-mix(in srgb, var(--err) 45%, var(--border)); }
.rgroup.is-not::before { background: var(--err); }
.rgroup.is-off { opacity: 0.55; }
.rgroup.is-root { padding: var(--s2) var(--s2) var(--s2) calc(var(--s2) + 4px); background: var(--bg-sunken); }
.rgroup.depth-1 { background: color-mix(in srgb, var(--surface) 85%, var(--accent-soft)); }
.rgroup.depth-2 { background: var(--surface-2); }
.rgroup-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.rgroup-title { font-weight: 650; font-size: calc(13px * var(--font-scale)); }
.rgroup-hint { flex: 1 1 auto; }
.rgroup-tools { display: flex; gap: 2px; margin-left: auto; }
.rgroup-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rgroup-empty { padding: 6px 4px; }
.rgroup-join { display: flex; align-items: center; gap: 6px; padding-left: 14px; }
.rgroup-join::before, .rgroup-join::after { content: ""; height: 1px; flex: 1 1 auto; background: var(--border); }
.rgroup-join::before { flex: 0 0 10px; }
.rgroup-join-pill {
  padding: 1px 10px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--bg-raised);
  color: var(--accent-text, var(--accent)); font-size: 11px; font-weight: 800; letter-spacing: 0.06em; cursor: pointer;
}
.rgroup.is-or > .rgroup-list > .rgroup-join .rgroup-join-pill { color: var(--warn); }
.rgroup-add { display: flex; gap: var(--s2); flex-wrap: wrap; }
.segmented-sm .segmented-btn { min-height: 26px; min-width: 0; padding: 0 10px; font-size: 11.5px; letter-spacing: 0.04em; }

.rrule { display: flex; align-items: flex-start; gap: 6px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-raised); }
.rrule.is-not { border-color: color-mix(in srgb, var(--err) 50%, var(--border)); background: color-mix(in srgb, var(--bg-raised) 92%, var(--err-soft)); }
.rrule.is-off { opacity: 0.5; }
.rrule.is-incomplete { border-style: dashed; }
.rrule-not {
  flex: none; width: 30px; height: 34px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text-faint); font-size: 17px; font-weight: 700; line-height: 1; cursor: pointer;
}
.rrule-not:hover { color: var(--text); }
.rrule-not.is-on { border-color: var(--err); background: var(--err-soft); color: var(--err); }
.rrule-main { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; min-width: 0; }
.rrule-field { flex: 1 1 150px; min-width: 0; }
.rrule-op { flex: 0 1 150px; min-width: 0; }
.rrule-value { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: 1 1 100%; }
.rrule-text { flex: 1 1 160px; min-width: 0; }
.rrule-num { width: 110px; }
.rrule-dash, .rrule-unit { color: var(--text-muted); font-size: calc(12.5px * var(--font-scale)); }
.rrule-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.rrule-threshold { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.rrule-threshold input { width: 110px; accent-color: var(--accent); }
.rrule-tools { display: flex; flex-direction: column; gap: 2px; flex: none; }

/* sort / group keys */
.refine-keys { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.refine-key { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.refine-key .select { flex: 1 1 130px; min-width: 0; }
.refine-key-n { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text, var(--accent)); font-size: 12px; font-weight: 700; }
.refine-key-tools { display: flex; gap: 2px; margin-left: auto; }
.refine-add { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.refine-add .select { flex: 1 1 auto; }
.refine-row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.refine-row input[type="range"] { flex: 1 1 140px; accent-color: var(--accent); }

.refine-modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.refine-mode {
  display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--text); text-align: left; cursor: pointer;
}
.refine-mode:hover { border-color: var(--border-strong); }
.refine-mode.is-active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.refine-stat { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--text); }

/* search page: Online / Offline (the Preloader's offline database) */
.search-mode { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; margin: 0 0 var(--s2); padding: 3px; border: 1px solid var(--border);
  border-radius: var(--radius-pill); background: var(--surface); }
.search-mode-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 12px; border: 0; border-radius: var(--radius-pill);
  background: none; color: var(--text-muted); font-weight: 600; font-size: calc(13px * var(--font-scale)); cursor: pointer; }
.search-mode-btn:hover { color: var(--text); background: var(--surface-2); }
.search-mode-btn.is-active { color: var(--accent-text, var(--accent)); background: var(--accent-soft); }
.search-mode .small { padding: 0 8px; }

/* saved filters, history, sets */
.refine-save { display: flex; gap: 6px; }
.refine-save .input { flex: 1 1 auto; min-width: 0; }
/* "Saved & history": a compact list below the panel's tab menu - smaller rows, an own top margin, nothing wider than the panel */
.refine-section.is-saved { gap: var(--s2); margin-top: var(--s1, 4px); font-size: calc(12.5px * var(--font-scale)); }
.refine-section.is-saved :is(.refine-save, .refine-entries, .refine-subhead, > .input) { max-width: 100%; min-width: 0; }
.refine-section.is-saved .refine-save :is(.input, .btn) { min-height: 30px; height: 30px; font-size: inherit; }
.refine-section.is-saved .refine-save .btn { padding: 0 10px; }
.refine-section.is-saved > .input { min-height: 30px; height: 30px; font-size: inherit; }
.refine-section.is-saved .refine-subtitle { font-size: calc(11.5px * var(--font-scale)); }
.refine-section.is-saved .refine-subhead { margin-top: var(--s1, 4px); gap: 6px; }
.refine-section.is-saved .refine-subhead .btn { min-height: 26px; padding: 0 8px; font-size: inherit; }
.refine-section.is-saved .refine-entries { gap: 3px; }
.refine-section.is-saved .refine-entry-main { padding: 5px 8px; gap: 1px; font-size: calc(12.5px * var(--font-scale)); }
.refine-section.is-saved .refine-entry-main .small { font-size: calc(11.5px * var(--font-scale)); }
.refine-section.is-saved .refine-entry-tools .btn { width: 24px; height: 24px; min-height: 24px; }
.refine-entries { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.refine-entry { display: flex; align-items: center; gap: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.refine-entry:hover { border-color: var(--border-strong); }
.refine-entry.is-preset { border-left: 3px solid var(--accent); }
.refine-entry.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.refine-entry-main { display: grid; gap: 2px; flex: 1 1 auto; min-width: 0; padding: 8px 10px; border: 0; background: none; color: var(--text); text-align: left; cursor: pointer; font-size: calc(13.5px * var(--font-scale)); }
a.refine-entry-main:hover { text-decoration: none; }
.refine-entry-tools { display: flex; gap: 2px; padding-right: 4px; flex: none; }
.refine-entry-tools .is-active { color: var(--accent); }
.rsets { display: grid; gap: var(--s3); }
.rsets:not(.is-compact) { max-width: 820px; }
.rset-check { display: grid; place-items: center; padding-left: 10px; }
.rset-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.rsets-save .segmented, .rsets-merge .segmented { justify-self: start; flex-wrap: wrap; }

/* summary bar above the results */
.refine-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 0 var(--s3); padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 90%, var(--accent-soft));
}
.refine-bar-count { display: inline-flex; align-items: center; gap: 6px; padding-right: 6px; color: var(--text-muted); }
.refine-bar-count strong { color: var(--text); }
.refine-bar-count .icon { color: var(--accent); }
.refine-chip { max-width: 100%; }
.refine-chip .truncate { max-width: 34ch; }
.refine-chip.is-negative { border-color: color-mix(in srgb, var(--err) 50%, var(--border)); color: var(--err); }
.refine-chip.is-sort { border-style: dashed; }
.refine-chip.is-group-by, .refine-chip.is-dedupe { background: var(--surface-2); }
.refine-bar-tools { display: flex; gap: 4px; margin-left: auto; }

/* grouped results */
.rgv-tools { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s2); }
.rgv-tools > span { margin-right: auto; }
.rgv { margin: 0 0 var(--s3); }
.rgv-head { position: sticky; top: calc(var(--topbar-h) + 4px); z-index: 4; margin: 0 0 var(--s2); }
.rgv-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-raised) 94%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--text); font-weight: 650; font-size: calc(15px * var(--font-scale)); text-align: left; cursor: pointer;
}
.rgv-toggle:hover { border-color: var(--border-strong); }
.rgv-label { flex: 1 1 auto; min-width: 0; }
.rgv.is-dup > .rgv-head .rgv-toggle { border-left: 3px solid var(--warn); }
.rgv-body { padding-left: 0; }
.rgv-depth-1 .rgv-body, .rgv-depth-2 .rgv-body { padding-left: var(--s3); }
.rgv-depth-1 > .rgv-head .rgv-toggle { min-height: 34px; font-size: calc(14px * var(--font-scale)); background: var(--surface); }
.rgv-depth-2 > .rgv-head .rgv-toggle, .rgv-depth-3 > .rgv-head .rgv-toggle { min-height: 30px; font-size: calc(13px * var(--font-scale)); background: var(--surface); }
.rgv-depth-1 > .rgv-head, .rgv-depth-2 > .rgv-head, .rgv-depth-3 > .rgv-head { position: static; }
.rgv-more { margin: var(--s2) auto 0; display: flex; }

.mcard-actions { margin-left: auto; }
.mcard-actions .btn { opacity: 0.55; }
.mcard:hover .mcard-actions .btn, .mcard-actions .btn[aria-expanded="true"] { opacity: 1; }
.page-kicker { margin: 0 0 2px; font-size: calc(13px * var(--font-scale)); }
.page-kicker a { display: inline-flex; align-items: center; gap: 4px; color: var(--text-muted); }

@media (max-width: 480px) {
  .refine-modes { grid-template-columns: minmax(0, 1fr); }
  .rrule-tools { flex-direction: row; }
  .rrule { flex-wrap: wrap; }
  .rrule-main { flex-basis: calc(100% - 40px); }
  .rrule-tools { margin-left: auto; }
  .refine-chip .truncate { max-width: 22ch; }
}

/* ------------------------------------------------------------------------------ loader (Administration → Loader) */
.ld {
  --ld-color: var(--accent); --ld-color2: var(--accent-2, var(--accent)); --ld-error: var(--err); --ld-overlay: #000;
  --ld-track: color-mix(in srgb, var(--ld-color) 18%, transparent);
  --ld-dur: calc(1s / var(--ld-speed, 1)); --ld-in: calc(0.26s / var(--ld-speed, 1)); --ld-top: var(--topbar-h, 0px);
  position: fixed; inset: 0; z-index: 380; pointer-events: none; contain: layout style;
}
.ld.is-contained { position: absolute; --ld-top: 0px; z-index: 5; overflow: hidden; border-radius: inherit; }
.ld.has-overlay, .ld-fullscreen, .ld-phase-error.ld-err-stay { pointer-events: auto; }
.ld-phase-error { --ld-color: var(--ld-error); --ld-color2: var(--ld-error); --ld-track: color-mix(in srgb, var(--ld-error) 20%, transparent); }
.ld-phase-error.ld-err-stay { cursor: pointer; }

/* overlay: whole window / page content / a box around the object */
.ld-overlay {
  position: absolute; inset: 0; background: color-mix(in srgb, var(--ld-overlay) calc(var(--ld-overlay-opacity, 0.35) * 100%), transparent);
  backdrop-filter: blur(var(--ld-overlay-blur, 0px)); -webkit-backdrop-filter: blur(var(--ld-overlay-blur, 0px));
}
.ld-overlay.ld-scope-content { top: var(--ld-top); }
.ld-overlay.ld-scope-box { display: none; }
.ld-fullscreen:not(.has-overlay) { background: var(--bg); }

/* ---- bars */
.ld-bar { position: absolute; left: 0; right: 0; top: 0; height: var(--ld-thick, 3px); background: var(--ld-track); transform-origin: top; }
.ld-bottombar .ld-bar { top: auto; bottom: 0; transform-origin: bottom; }
.ld-bar-fill {
  position: absolute; inset: 0; transform-origin: left; will-change: transform;
  background: linear-gradient(90deg, var(--ld-color), var(--ld-color2)); box-shadow: 0 0 10px color-mix(in srgb, var(--ld-color) 60%, transparent);
}
.ld-bar-peg { position: absolute; right: 0; top: 50%; width: 80px; height: calc(var(--ld-thick, 3px) * 3); transform: translateY(-50%); background: radial-gradient(closest-side, color-mix(in srgb, var(--ld-color2) 70%, transparent), transparent); }
.ld-bar-tag .ld-pct, .ld-halo-tag .ld-pct { margin-left: 6px; font-size: inherit; }
.ld-bar-tag, .ld-halo-tag {
  position: absolute; right: 12px; top: calc(var(--ld-thick, 3px) + 8px); max-width: min(60vw, 420px); padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--bg-raised) 92%, transparent); box-shadow: var(--shadow-1); color: var(--text); font-size: 12px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums;
}
.ld-bottombar .ld-bar-tag { top: auto; bottom: calc(var(--ld-thick, 3px) + 8px); }

/* ---- halo: a glowing frame around the page */
.ld-halo {
  position: absolute; inset: 0; padding: var(--ld-thick, 3px); border-radius: inherit;
  background: conic-gradient(from var(--ld-angle, 0deg), var(--ld-color), var(--ld-color2), transparent 40%, var(--ld-color) 60%, var(--ld-color2), var(--ld-color));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: ld-halo-spin calc(var(--ld-dur) * 2.4) linear infinite; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--ld-color) 70%, transparent));
}
.ld-halo-tag { top: auto; bottom: 16px; right: 50%; transform: translateX(50%); }
@property --ld-angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes ld-halo-spin { to { --ld-angle: 360deg; } }

/* ---- the close button: stops what is loading */
.ld-close {
  display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 999px; cursor: pointer;
  pointer-events: auto; color: var(--text); background: color-mix(in srgb, var(--bg-raised) 92%, transparent); box-shadow: var(--shadow-1);
}
.ld-close svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.ld-close:hover { color: var(--err); }
.ld-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ld-close-edge { position: absolute; right: 12px; top: calc(var(--ld-thick, 3px) + 6px); }
.ld-bottombar .ld-close-edge { top: auto; bottom: calc(var(--ld-thick, 3px) + 6px); }
.ld-halo .ld-close-edge, .ld-halo ~ .ld-close-edge { top: 12px; }
.ld-bar-tag.has-close { right: 46px; }
.ld-close-box { position: absolute; top: -10px; right: -10px; z-index: 1; }
.ld-fullscreen .ld-close-box { position: fixed; top: calc(var(--ld-top) + 14px); right: 14px; }
.ld-island .ld-close-box { position: static; flex: none; width: 24px; height: 24px; margin-left: 2px; order: 9; background: rgba(255, 255, 255, 0.12); color: inherit; box-shadow: none; }
.ld-corner .ld-close-box { top: -8px; right: -8px; width: 22px; height: 22px; }

/* ---- boxes: fullscreen, centre, corner, island */
.ld-box {
  position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--text); text-align: center;
}
.ld-fullscreen .ld-box { gap: 18px; min-width: min(360px, 80vw); }
.ld-center-large .ld-box {
  min-width: min(300px, 80vw); padding: 26px 30px; border: 1px solid var(--border); border-radius: calc(var(--radius, 10px) * 1.6);
  background: color-mix(in srgb, var(--bg-raised) 92%, transparent); box-shadow: var(--shadow-3, var(--shadow-2)); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.ld-center-small .ld-box { gap: 0; }
.ld-corner .ld-box, .ld-island .ld-box { left: auto; top: auto; transform: none; }
.ld-corner .ld-box { padding: 10px; border-radius: 999px; background: color-mix(in srgb, var(--bg-raised) 90%, transparent); box-shadow: var(--shadow-2); }
.ld-island .ld-box {
  flex-direction: row; gap: 10px; min-height: 44px; max-width: min(92vw, 460px); padding: 8px 16px 10px 10px; border-radius: 999px; overflow: hidden;
  background: color-mix(in srgb, #0b0d12 88%, var(--ld-color)); color: #f2f4f8; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 0 0 1px color-mix(in srgb, var(--ld-color) 30%, transparent);
  transition: max-width 0.35s var(--ease), background 0.3s;
}
.ld-island .ld-text { flex-direction: row; align-items: baseline; gap: 8px; text-align: left; }
.ld-island .ld-track { position: absolute; left: 14px; right: 14px; bottom: 5px; width: auto; height: 2px; }
:is(.ld-corner, .ld-island).ld-pos-top-right .ld-box { top: calc(var(--ld-top) + 14px); right: 14px; }
:is(.ld-corner, .ld-island).ld-pos-top-left .ld-box { top: calc(var(--ld-top) + 14px); left: 14px; }
:is(.ld-corner, .ld-island).ld-pos-bottom-right .ld-box { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); right: 14px; }
:is(.ld-corner, .ld-island).ld-pos-bottom-left .ld-box { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); left: 14px; }
:is(.ld-corner, .ld-island).ld-pos-top-center .ld-box { top: calc(var(--ld-top) + 14px); left: 50%; transform: translateX(-50%); }
:is(.ld-corner, .ld-island).ld-pos-bottom-center .ld-box { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); }
.app.has-mini ~ .ld:is(.ld-corner, .ld-island):is(.ld-pos-bottom-right, .ld-pos-bottom-left, .ld-pos-bottom-center) .ld-box { bottom: calc(var(--mini-h) + 14px); }
.ld-box.ld-scope-box {
  width: var(--ld-box); height: var(--ld-box); max-width: 90vw; max-height: 80vh; padding: 16px; border-radius: calc(var(--radius, 10px) * 1.8);
  background: color-mix(in srgb, var(--ld-overlay) calc(var(--ld-overlay-opacity, 0.35) * 100%), transparent);
  backdrop-filter: blur(var(--ld-overlay-blur, 0px)); -webkit-backdrop-filter: blur(var(--ld-overlay-blur, 0px));
}
.ld-obj { position: relative; display: grid; place-items: center; width: var(--ld-size); height: var(--ld-size); flex: none; }
.ld-text { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; max-width: 100%; }
.ld-label { font-weight: 650; font-size: calc(14px * var(--font-scale, 1)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: min(70vw, 420px); }
.ld-fullscreen .ld-label { font-size: calc(17px * var(--font-scale, 1)); }
.ld-pct { color: var(--text-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.ld-island .ld-pct { color: rgba(242, 244, 248, 0.7); }
.ld-track { width: min(260px, 70vw); height: 4px; border-radius: 4px; overflow: hidden; background: var(--ld-track); }
.ld-track-fill { height: 100%; transform-origin: left; background: linear-gradient(90deg, var(--ld-color), var(--ld-color2)); will-change: transform; }
.ld-hint { font-size: 12px; color: var(--text-muted); }
.ld-mark { position: absolute; inset: 12%; width: 76%; height: 76%; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.ld-mark-ok { stroke: var(--ld-color); stroke-dasharray: 30; stroke-dashoffset: 30; animation: ld-draw calc(var(--ld-dur) * 0.45) ease-out forwards; }
.ld-mark-err { stroke: var(--ld-error); }
.ld-phase-done .ldi, .ld-phase-error .ldi { opacity: 0.25; transition: opacity 0.2s; }
.ld-phase-done:not(.ld-out-check) .ld-mark-ok { display: none; }
@keyframes ld-draw { to { stroke-dashoffset: 0; } }

/* ---- animated objects */
.ldi { position: relative; display: block; width: 100%; height: 100%; }
.ldi-ring { overflow: visible; animation: ld-rotate calc(var(--ld-dur) * 1.4) linear infinite; }
.ldi-ring-track, .ldi-ring-arc { fill: none; stroke-width: max(3px, calc(var(--ld-thick, 3px) * 1.2)); }
.ldi-ring-track { stroke: var(--ld-track); }
.ldi-ring-arc { stroke: var(--ld-color); stroke-linecap: round; stroke-dasharray: 80 125.66; transform-origin: center; animation: ld-dash calc(var(--ld-dur) * 1.4) ease-in-out infinite; }
.ldi-ring.is-determinate { animation: none; transform: rotate(-90deg); }
.ldi-ring.is-determinate .ldi-ring-arc { animation: none; transition: stroke-dasharray 0.35s ease-out; }
@keyframes ld-rotate { to { transform: rotate(360deg); } }
@keyframes ld-dash { 0% { stroke-dasharray: 2 125.66; stroke-dashoffset: 0; } 50% { stroke-dasharray: 90 125.66; stroke-dashoffset: -20; } 100% { stroke-dasharray: 2 125.66; stroke-dashoffset: -124; } }
.ldi-arc {
  border-radius: 50%; background: conic-gradient(from 0deg, transparent 10%, var(--ld-color) 70%, var(--ld-color2));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - max(4px, var(--ld-thick, 3px) * 1.6)), #000 calc(100% - max(4px, var(--ld-thick, 3px) * 1.6) + 1px));
  mask: radial-gradient(farthest-side, transparent calc(100% - max(4px, var(--ld-thick, 3px) * 1.6)), #000 calc(100% - max(4px, var(--ld-thick, 3px) * 1.6) + 1px));
  animation: ld-rotate var(--ld-dur) linear infinite;
}
.ldi-dots { display: flex; align-items: center; justify-content: center; gap: 12%; }
.ldi-dots i { width: 22%; aspect-ratio: 1; border-radius: 50%; background: var(--ld-color); animation: ld-bounce calc(var(--ld-dur) * 0.9) ease-in-out infinite; }
.ldi-dots i:nth-child(2) { animation-delay: calc(var(--ld-dur) * 0.15); background: color-mix(in srgb, var(--ld-color) 50%, var(--ld-color2)); }
.ldi-dots i:nth-child(3) { animation-delay: calc(var(--ld-dur) * 0.3); background: var(--ld-color2); }
@keyframes ld-bounce { 0%, 80%, 100% { transform: translateY(0) scale(0.7); opacity: 0.55; } 40% { transform: translateY(-45%) scale(1); opacity: 1; } }
.ldi-eq { display: flex; align-items: flex-end; justify-content: center; gap: 9%; padding: 12% 8%; }
.ldi-eq i { flex: 1; height: 100%; border-radius: 3px; background: linear-gradient(to top, var(--ld-color), var(--ld-color2)); transform-origin: bottom; animation: ld-eq calc(var(--ld-dur) * 0.9) ease-in-out infinite; }
.ldi-eq i:nth-child(2) { animation-delay: calc(var(--ld-dur) * -0.35); }
.ldi-eq i:nth-child(3) { animation-delay: calc(var(--ld-dur) * -0.65); }
.ldi-eq i:nth-child(4) { animation-delay: calc(var(--ld-dur) * -0.2); }
.ldi-eq i:nth-child(5) { animation-delay: calc(var(--ld-dur) * -0.5); }
@keyframes ld-eq { 0%, 100% { transform: scaleY(0.25); } 50% { transform: scaleY(1); } }
.ldi-pulse b { position: absolute; inset: 32%; border-radius: 50%; background: var(--ld-color); box-shadow: 0 0 18px color-mix(in srgb, var(--ld-color) 70%, transparent); }
.ldi-pulse i { position: absolute; inset: 0; border-radius: 50%; border: max(2px, var(--ld-thick, 3px)) solid var(--ld-color2); opacity: 0; animation: ld-ripple calc(var(--ld-dur) * 1.6) cubic-bezier(0.2, 0.6, 0.3, 1) infinite; }
.ldi-pulse i:nth-child(2) { animation-delay: calc(var(--ld-dur) * 0.8); }
@keyframes ld-ripple { 0% { transform: scale(0.35); opacity: 0.9; } 100% { transform: scale(1); opacity: 0; } }
.ldi-orbit b { position: absolute; inset: 38%; border-radius: 50%; background: var(--ld-color); }
.ldi-orbit i { position: absolute; inset: 0; border-radius: 50%; border: 1px dashed var(--ld-track); animation: ld-rotate calc(var(--ld-dur) * 1.2) linear infinite; }
.ldi-orbit i::after { content: ""; position: absolute; top: -6%; left: 50%; width: 16%; aspect-ratio: 1; margin-left: -8%; border-radius: 50%; background: var(--ld-color2); box-shadow: 0 0 10px var(--ld-color2); }
.ldi-orbit i:nth-child(3) { inset: 18%; animation-duration: calc(var(--ld-dur) * 0.7); animation-direction: reverse; }
.ldi-orbit i:nth-child(3)::after { background: var(--ld-color); box-shadow: 0 0 10px var(--ld-color); }
.ldi-logo { display: grid; place-items: center; perspective: 400px; }
.ldi-logo img { width: 78%; height: 78%; object-fit: contain; animation: ld-flip calc(var(--ld-dur) * 1.8) ease-in-out infinite; filter: drop-shadow(0 0 12px color-mix(in srgb, var(--ld-color) 60%, transparent)); }
@keyframes ld-flip { 0%, 100% { transform: rotateY(0) scale(1); } 50% { transform: rotateY(180deg) scale(0.9); } }
/* prism: three arcs at three speeds around a pulsing centre (the Nexus design, available to every design) */
.ldi-prism i { position: absolute; inset: 0; border-radius: 50%; border: max(2px, var(--ld-thick, 3px)) solid transparent; border-top-color: var(--ld-color); animation: ld-rotate calc(var(--ld-dur) * 1.2) linear infinite; }
.ldi-prism i:nth-child(1) { border-color: var(--ld-track); border-top-color: var(--ld-color); border-right-color: var(--ld-color); }
.ldi-prism i:nth-child(2) { inset: 20%; border-top-color: var(--ld-color2); border-right-color: var(--ld-color2); animation-duration: calc(var(--ld-dur) * 1.8); animation-direction: reverse; }
.ldi-prism i:nth-child(3) { inset: 36%; border-top-color: var(--text, #fff); animation-duration: calc(var(--ld-dur) * 0.9); }
.ldi-prism b { position: absolute; inset: 45%; border-radius: 50%; background: var(--ld-color); animation: ld-core calc(var(--ld-dur) * 1.2) ease-in-out infinite; }
@keyframes ld-core { 0%, 100% { transform: scale(0.6); opacity: 0.55; } 50% { transform: scale(1.15); opacity: 1; } }
/* nexus: the brand mark draws its ring, the triangle breathes, the dot circles */
.ldi-nexus svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ldi-nexus-ring, .ldi-nexus-handle { fill: none; stroke: var(--ld-color); stroke-width: 3.5; stroke-linecap: round; }
.ldi-nexus-ring { stroke-dasharray: 67; animation: ld-draw calc(var(--ld-dur) * 2.4) cubic-bezier(0.2, 0, 0, 1) infinite; }
.ldi-nexus-play { fill: var(--ld-color); transform-origin: 22px 22px; animation: ld-core calc(var(--ld-dur) * 1.2) ease-in-out infinite; }
.ldi-nexus i { position: absolute; left: 12.5%; top: 12.5%; width: 58%; height: 58%; animation: ld-rotate calc(var(--ld-dur) * 2.4) cubic-bezier(0.6, 0, 0.4, 1) infinite; }
.ldi-nexus i::after { content: ""; position: absolute; right: 4%; top: 8%; width: 18%; aspect-ratio: 1; border-radius: 50%; background: var(--ld-color2); box-shadow: 0 0 10px var(--ld-color2); }
@keyframes ld-draw { 0% { stroke-dashoffset: 67; } 55%, 80% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -67; } }
/* window: a small window whose lines fill in turn (the Atelier design, available to every design) */
.ldi-window { display: flex; flex-direction: column; gap: 9%; padding: 30% 14% 0; border-radius: 16%; box-shadow: inset 0 0 0 max(2px, var(--ld-thick, 3px)) var(--ld-color); }
.ldi-window b { position: absolute; left: 0; right: 0; top: 20%; height: max(2px, var(--ld-thick, 3px)); background: var(--ld-color); }
.ldi-window i { display: block; height: 9%; border-radius: 99px; background: var(--ld-color2); transform-origin: left; animation: ld-line calc(var(--ld-dur) * 1.4) cubic-bezier(0.4, 0, 0.2, 1) infinite; }
.ldi-window i:nth-of-type(2) { width: 80%; background: var(--ld-color); animation-delay: calc(var(--ld-dur) * -0.25); }
.ldi-window i:nth-of-type(3) { width: 60%; background: var(--ld-color); animation-delay: calc(var(--ld-dur) * -0.5); }
@keyframes ld-line { 0%, 100% { transform: scaleX(0.15); opacity: 0.4; } 50% { transform: scaleX(1); opacity: 1; } }
/* stack: three windows take turns at the front */
.ldi-stack i { position: absolute; left: 6%; bottom: 8%; width: 70%; height: 52%; border-radius: 14%; animation: ld-stack calc(var(--ld-dur) * 2.7) cubic-bezier(0.2, 0, 0, 1) infinite; }
.ldi-stack i:nth-child(1) { background: var(--ld-color); }
.ldi-stack i:nth-child(2) { background: var(--surface, #fff); box-shadow: inset 0 0 0 max(2px, var(--ld-thick, 3px)) var(--ld-color); animation-delay: calc(var(--ld-dur) * -0.9); }
.ldi-stack i:nth-child(3) { background: var(--ld-track); animation-delay: calc(var(--ld-dur) * -1.8); }
@keyframes ld-stack {
  0%, 20% { transform: translate(0, 0); opacity: 1; z-index: 3; }
  33%, 53% { transform: translate(12%, -14%) scale(0.94); opacity: 0.7; z-index: 2; }
  66%, 86% { transform: translate(24%, -28%) scale(0.88); opacity: 0.45; z-index: 1; }
  100% { transform: translate(0, 0); opacity: 1; z-index: 3; }
}
/* mosaic (Tessera): four tiles light up one after another, the second colour marks the newest */
.ldi-mosaic { display: grid; grid-template-columns: 1fr 1fr; gap: 12%; padding: 6%; box-sizing: border-box; }
.ldi-mosaic i { border-radius: 22%; background: var(--ld-track); animation: ld-mosaic calc(var(--ld-dur) * 2.4) var(--ease, ease-in-out) infinite; }
.ldi-mosaic i:nth-child(2) { animation-delay: calc(var(--ld-dur) * 0.6); }
.ldi-mosaic i:nth-child(4) { animation-delay: calc(var(--ld-dur) * 1.2); }
.ldi-mosaic i:nth-child(3) { animation-delay: calc(var(--ld-dur) * 1.8); }
@keyframes ld-mosaic {
  0%, 100% { background: var(--ld-track); transform: scale(0.86); }
  12% { background: var(--ld-color2, var(--ld-color)); transform: scale(1); }
  40% { background: var(--ld-color); transform: scale(1); }
  70% { background: var(--ld-track); transform: scale(0.86); }
}

/* ---- event: start */
.ld :is(.ld-bar, .ld-box, .ld-halo, .ld-overlay) { animation-fill-mode: both; }
.ld-in-fade :is(.ld-bar, .ld-box, .ld-halo, .ld-overlay) { animation: ld-in-fade var(--ld-in) ease-out both; }
.ld-in-scale .ld-box, .ld-in-scale .ld-halo { animation: ld-in-scale var(--ld-in) var(--ease, ease-out) both; }
.ld-in-scale :is(.ld-bar, .ld-overlay) { animation: ld-in-fade var(--ld-in) ease-out both; }
.ld-in-slide :is(.ld-box, .ld-halo) { animation: ld-in-slide var(--ld-in) var(--ease, ease-out) both; }
.ld-in-slide .ld-bar { animation: ld-in-bar var(--ld-in) var(--ease, ease-out) both; }
.ld-in-slide .ld-overlay, .ld-in-blur .ld-overlay, .ld-in-grow .ld-overlay { animation: ld-in-fade var(--ld-in) ease-out both; }
.ld-in-blur :is(.ld-bar, .ld-box, .ld-halo) { animation: ld-in-blur calc(var(--ld-in) * 1.4) ease-out both; }
.ld-in-grow .ld-bar { animation: ld-in-bar var(--ld-in) cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.ld-in-grow :is(.ld-box, .ld-halo) { animation: ld-in-grow calc(var(--ld-in) * 1.5) cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.ld-in-none :is(.ld-bar, .ld-box, .ld-halo, .ld-overlay) { animation: none; }
@keyframes ld-in-fade { from { opacity: 0; } }
@keyframes ld-in-scale { from { opacity: 0; scale: 0.7; } }
@keyframes ld-in-slide { from { opacity: 0; translate: 0 16px; } }
@keyframes ld-in-bar { from { opacity: 0; scale: 1 0; } }
@keyframes ld-in-blur { from { opacity: 0; filter: blur(10px); } }
@keyframes ld-in-grow { from { opacity: 0; scale: 0.2; } }

/* ---- event: progress (running) */
.ld-run-smooth :is(.ld-bar-fill, .ld-track-fill) { transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.3, 1); }
.ld-run-steps :is(.ld-bar-fill, .ld-track-fill) { transition: transform 0.45s steps(4, end); }
.ld-run-pulse:is(.ld-phase-start, .ld-phase-progress) :is(.ld-obj, .ld-bar-fill, .ld-track-fill, .ld-halo) { animation: ld-breathe calc(var(--ld-dur) * 1.3) ease-in-out infinite; }
.ld-run-pulse :is(.ld-bar-fill, .ld-track-fill) { transition: transform 0.35s ease-out; }
.ld-run-shimmer :is(.ld-bar-fill, .ld-track-fill) { transition: transform 0.35s ease-out; overflow: hidden; }
.ld-run-shimmer:is(.ld-phase-start, .ld-phase-progress) :is(.ld-bar-fill, .ld-track-fill)::after,
.ld-run-shimmer:is(.ld-phase-start, .ld-phase-progress).ld-center-large .ld-box::after,
.ld-run-shimmer:is(.ld-phase-start, .ld-phase-progress).ld-island .ld-box::after {
  content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.35) 50%, transparent 80%);
  animation: ld-shimmer calc(var(--ld-dur) * 1.3) linear infinite; pointer-events: none; border-radius: inherit;
}
.ld-run-glow :is(.ld-bar-fill, .ld-track-fill) { transition: transform 0.35s ease-out; }
.ld-run-glow:is(.ld-phase-start, .ld-phase-progress) :is(.ld-bar-fill, .ld-obj, .ld-halo) { animation: ld-glow calc(var(--ld-dur) * 1.4) ease-in-out infinite; }
@keyframes ld-breathe { 0%, 100% { opacity: 1; scale: 1; } 50% { opacity: 0.7; scale: 0.94; } }
@keyframes ld-shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@keyframes ld-glow { 0%, 100% { filter: drop-shadow(0 0 2px color-mix(in srgb, var(--ld-color) 40%, transparent)); } 50% { filter: drop-shadow(0 0 14px var(--ld-color)); } }

/* ---- event: done */
.ld-phase-done.ld-out-fade :is(.ld-bar, .ld-box, .ld-halo, .ld-overlay) { animation: ld-out-fade calc(0.26s / var(--ld-speed, 1)) ease-in forwards; }
.ld-phase-done.ld-out-shrink :is(.ld-box, .ld-halo) { animation: ld-out-shrink calc(0.32s / var(--ld-speed, 1)) ease-in forwards; }
.ld-phase-done.ld-out-shrink :is(.ld-bar, .ld-overlay) { animation: ld-out-bar calc(0.32s / var(--ld-speed, 1)) ease-in forwards; }
.ld-phase-done.ld-out-slide :is(.ld-box, .ld-halo) { animation: ld-out-slide calc(0.3s / var(--ld-speed, 1)) ease-in forwards; }
.ld-phase-done.ld-out-slide .ld-bar { animation: ld-out-up calc(0.3s / var(--ld-speed, 1)) ease-in forwards; }
.ld-phase-done.ld-out-slide.ld-bottombar .ld-bar { animation-name: ld-out-down; }
.ld-phase-done.ld-out-slide .ld-overlay, .ld-phase-done.ld-out-flash .ld-overlay, .ld-phase-done.ld-out-check .ld-overlay { animation: ld-out-fade calc(0.3s / var(--ld-speed, 1)) ease-in forwards; }
.ld-phase-done.ld-out-check :is(.ld-box, .ld-bar, .ld-halo) { animation: ld-out-fade calc(0.25s / var(--ld-speed, 1)) ease-in calc(0.45s / var(--ld-speed, 1)) forwards; }
.ld-phase-done.ld-out-check .ld-mark-ok { animation: ld-draw calc(0.3s / var(--ld-speed, 1)) ease-out forwards, ld-pop calc(0.4s / var(--ld-speed, 1)) cubic-bezier(0.3, 1.6, 0.5, 1); }
.ld-phase-done.ld-out-flash :is(.ld-bar, .ld-box, .ld-halo) { animation: ld-out-flash calc(0.45s / var(--ld-speed, 1)) ease-out forwards; }
.ld-phase-done.ld-out-none :is(.ld-bar, .ld-box, .ld-halo, .ld-overlay) { visibility: hidden; }
@keyframes ld-out-fade { to { opacity: 0; } }
@keyframes ld-out-shrink { to { opacity: 0; scale: 0.3; } }
@keyframes ld-out-bar { to { opacity: 0; scale: 1 0; } }
@keyframes ld-out-slide { to { opacity: 0; translate: 0 18px; } }
@keyframes ld-out-up { to { translate: 0 -100%; opacity: 0; } }
@keyframes ld-out-down { to { translate: 0 100%; opacity: 0; } }
@keyframes ld-pop { from { scale: 0.4; } }
@keyframes ld-out-flash { 0% { filter: brightness(1); } 30% { filter: brightness(2.2) drop-shadow(0 0 16px var(--ld-color)); opacity: 1; } 100% { opacity: 0; filter: brightness(1); } }

/* ---- event: error */
.ld-phase-error.ld-err-shake :is(.ld-box, .ld-bar-tag, .ld-halo-tag, .ld-bar) { animation: ld-shake calc(0.5s / var(--ld-speed, 1)) cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
.ld-phase-error.ld-err-flash :is(.ld-box, .ld-bar, .ld-halo) { animation: ld-err-flash calc(0.5s / var(--ld-speed, 1)) ease-in-out 3 both; }
.ld-phase-error.ld-err-stay .ld-box, .ld-phase-error.ld-err-stay .ld-bar-tag { box-shadow: 0 0 0 2px var(--ld-error), var(--shadow-2); }
.ld-phase-error .ld-bar-fill { transform: scaleX(1) !important; }
.ld-phase-error .ld-label { color: var(--ld-error); white-space: normal; }
.ld-island.ld-phase-error .ld-box { background: color-mix(in srgb, #0b0d12 70%, var(--ld-error)); }
.ld-island.ld-phase-error .ld-label { color: #fff; }
@keyframes ld-shake { 10%, 90% { translate: -1px 0; } 20%, 80% { translate: 3px 0; } 30%, 50%, 70% { translate: -6px 0; } 40%, 60% { translate: 6px 0; } }
@keyframes ld-err-flash { 50% { filter: drop-shadow(0 0 16px var(--ld-error)) brightness(1.4); } }

@media (prefers-reduced-motion: reduce) {
  .ld *, .ld *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .ld:is(.ld-phase-start, .ld-phase-progress) .ldi { opacity: 0.8; }
}
@media (max-width: 520px) {
  .ld-bar-tag { max-width: 70vw; }
  .ld-island .ld-box { max-width: calc(100vw - 24px); }
}

/* ---- Administration → Loader */
.lda-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: var(--s4); align-items: start; }
.lda-main { display: grid; gap: var(--s4); min-width: 0; }
.lda-side { position: sticky; top: calc(var(--topbar-h) + var(--s3)); }
@media (max-width: 1100px) { .lda-layout { grid-template-columns: minmax(0, 1fr); } .lda-side { position: static; order: -1; } }
.lda-card .card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }
.lda-card > :not(.card-head) { margin: 0 var(--s4) var(--s4); }
.lda-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s2); }
.lda-tile {
  display: grid; gap: 4px; padding: 8px 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--text); text-align: left; cursor: pointer; transition: border-color 0.15s, transform 0.15s;
}
.lda-tile:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.lda-tile.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--surface) 85%, var(--accent-soft)); }
.lda-thumb { position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden; border-radius: calc(var(--radius) * 0.7); background: var(--bg); border: 1px solid var(--border); }
.lda-thumb .ld { --ld-top: 10px; }
.lda-thumb .ld-fullscreen .ld-box, .lda-thumb .ld-center-large .ld-box { transform: translate(-50%, -50%) scale(0.45); }
.lda-thumb .ld-island .ld-box, .lda-thumb .ld-corner .ld-box { scale: 0.6; transform-origin: bottom right; }
.lda-thumb .ld-bar-tag, .lda-thumb .ld-halo-tag, .lda-thumb .ld-text { display: none; }
.lda-mock { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(2, 1fr); grid-template-rows: 10px repeat(2, 1fr); gap: 5px; padding: 0 8px 8px; }
.lda-mock::before { content: ""; grid-column: 1 / -1; background: var(--surface-2); margin: 0 -8px; }
.lda-mock i { border-radius: 4px; background: var(--surface-2); }
.lda-positions { display: grid; grid-template-columns: repeat(3, 34px); grid-template-rows: repeat(2, 26px); gap: 4px; }
.lda-pos { position: relative; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; }
.lda-pos i { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.lda-pos.is-active { border-color: var(--accent); }
.lda-pos.is-active i { background: var(--accent); }
.lda-pos.is-top-left { grid-area: 1 / 1; } .lda-pos.is-top-left i { top: 4px; left: 4px; }
.lda-pos.is-top-center { grid-area: 1 / 2; } .lda-pos.is-top-center i { top: 4px; left: calc(50% - 4px); }
.lda-pos.is-top-right { grid-area: 1 / 3; } .lda-pos.is-top-right i { top: 4px; right: 4px; }
.lda-pos.is-bottom-left { grid-area: 2 / 1; } .lda-pos.is-bottom-left i { bottom: 4px; left: 4px; }
.lda-pos.is-bottom-center { grid-area: 2 / 2; } .lda-pos.is-bottom-center i { bottom: 4px; left: calc(50% - 4px); }
.lda-pos.is-bottom-right { grid-area: 2 / 3; } .lda-pos.is-bottom-right i { bottom: 4px; right: 4px; }
.lda-objects { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--s2); }
.lda-object.ld {
  position: relative; inset: auto; z-index: auto; pointer-events: auto; display: grid; justify-items: center; gap: 8px; padding: 14px 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); cursor: pointer;
}
.lda-object.ld.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.lda-row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.lda-row input[type="range"] { flex: 1 1 140px; accent-color: var(--accent); }
.lda-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s3); }
.lda-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.lda-swatch { min-height: 32px; padding: 0 14px; border: 1px solid var(--border); border-radius: 999px; background: linear-gradient(135deg, var(--accent), var(--accent-2, var(--accent))); color: #fff; font-weight: 650; font-size: 12.5px; cursor: pointer; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
.lda-swatch.is-active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.lda-colors { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s3); }
.lda-color { display: grid; gap: 4px; }
.lda-color-row { display: flex; align-items: center; gap: 6px; }
.lda-color-row input[type="color"] { width: 40px; height: 34px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.lda-color-row .input { flex: 1 1 auto; min-width: 0; }
.lda-event { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: var(--s2); align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.lda-event-name { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.lda-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.lda-dot.is-progress { background: var(--info); } .lda-dot.is-done { background: var(--ok); } .lda-dot.is-error { background: var(--err); }
.lda-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.lda-toggles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 4px var(--s3); }
.lda-preview-card > :not(.card-head) { margin: 0 var(--s4) var(--s3); }
.lda-preview-card .card-head { display: flex; align-items: center; justify-content: space-between; }
.lda-frame { position: relative; aspect-ratio: 16 / 11; overflow: hidden; border: 1px solid var(--border); border-radius: calc(var(--radius) * 1.2); background: var(--bg); }
.lda-frame .ld { --ld-top: 22px; }
.lda-frame-top { display: flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; background: var(--surface-2); }
.lda-frame-top i { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.lda-frame-top span { flex: 1; height: 8px; margin-left: 10px; border-radius: 4px; background: var(--surface); }
.lda-frame-page { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px; }
.lda-frame-page b { grid-column: 1 / -1; height: 18px; width: 45%; border-radius: 4px; background: var(--surface-2); }
.lda-frame-page i { aspect-ratio: 16 / 10; border-radius: 6px; background: var(--surface); }
.lda-demo .is-active { color: var(--accent); }
@media (max-width: 560px) { .lda-event { grid-template-columns: minmax(0, 1fr); } }

/* installation / update reports of a worker machine */
.winstall { display: block; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.winstall.is-failed { border-color: color-mix(in srgb, var(--err) 45%, var(--border)); }
.winstall-head { display: flex; align-items: center; gap: var(--s2); width: 100%; padding: 8px 10px; border: 0; background: none; color: var(--text); text-align: left; cursor: pointer; }
.winstall-head .mono { flex: 1 1 auto; min-width: 0; }
.winstall-head .muted { white-space: nowrap; }
.winstall-body { display: grid; gap: var(--s2); padding: 0 10px 10px; }
.winstall-error { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--err); }
.winstall-body .console-pre { max-height: 320px; overflow: auto; background: var(--bg-sunken); padding: 8px 10px; border-radius: var(--radius-sm); }

/* ---------------------------------------------------------------- media relays (Administration -> Workers) */
.relay.is-off .node-title strong { color: var(--text-muted); }
.relay-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px 16px; margin: 12px 0 0; }
.relay-stats > div { min-width: 0; }
.relay-stats dt { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.relay-stats dd { margin: 2px 0 0; font-variant-numeric: tabular-nums; }
.relay-failures { margin: 10px 0 4px; }
.relay-failure-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.relay-failure-list li { display: grid; grid-template-columns: minmax(80px, auto) minmax(0, 1fr) auto auto; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: calc(var(--radius) * 0.6); background: var(--surface-2); opacity: 0.7; }
.relay-failure-list li.is-active { opacity: 1; box-shadow: inset 3px 0 0 var(--err); }
.relay-transfers { margin: 8px 0 4px; }
.relay-transfers .table-wrap { margin-top: 6px; }
.relay-howto { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 16px 14px; margin: 0; border-top: 1px solid var(--border); }
.relay-howto code { overflow-wrap: anywhere; }
.switch-inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
@media (max-width: 640px) {
  .relay-failure-list li { grid-template-columns: minmax(0, 1fr) auto; }
  .relay-failure-list li > span { grid-column: 1 / -1; }
}

/* ---------------------------------------------------------------- traffic (Administration -> Traffic) */
.traffic-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.field-inline { display: inline-flex; align-items: center; gap: 8px; }
.traffic-chart { display: flex; align-items: flex-end; gap: 2px; height: 180px; padding: 12px 16px 0; overflow: hidden; }
.tc-col { flex: 1 1 0; min-width: 2px; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 1px; border-radius: 3px 3px 0 0; }
.tc-col:hover { background: var(--surface-2); }
.tc-col.has-errors { box-shadow: inset 0 -2px 0 var(--err); }
.tc-bar { flex: 1 1 0; max-width: 14px; min-height: 1px; border-radius: 2px 2px 0 0; transition: height 0.3s ease; }
.tc-in, .tl-in { background: var(--accent); }
.tc-out, .tl-out { background: var(--accent-2); opacity: 0.75; }
.traffic-axis { display: flex; justify-content: space-between; padding: 4px 16px 12px; }
.traffic-legend { display: flex; align-items: center; gap: 6px; }
.traffic-legend span { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 8px; }
.traffic-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 16px; }
.traffic-split > .card { margin: 0; min-width: 0; }
.traffic-table td:first-child { min-width: 140px; max-width: 280px; }
.traffic-table tr.is-picked td { background: var(--accent-soft); }
.traffic-table tfoot th { border-top: 2px solid var(--border); font-weight: 600; }
.traffic-key { display: block; max-width: 100%; text-align: left; }
.traffic-key strong { display: block; }
.traffic-meter { display: block; height: 3px; margin-top: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.traffic-meter span { display: block; height: 100%; background: var(--accent); transform-origin: left; }
.status-mix { display: inline-flex; flex-wrap: wrap; gap: 6px; }
@media (prefers-reduced-motion: reduce) { .tc-bar { transition: none; } }

/* thumbnails of the image queue (core/image-queue.js): nothing - not even the alt text - until the source is set */
.mcard-img:not([src]) { visibility: hidden; }

/* ---------------------------------------------------------------- resources (Administration -> Resources, dashboard) */
.recs { list-style: none; margin: 0; padding: 6px 16px 14px; display: grid; gap: 10px; }
.rec { padding: 12px 14px; border-radius: calc(var(--radius) * 0.7); background: var(--surface-2); border-left: 3px solid var(--border); }
.rec.is-critical { border-left-color: var(--err); }
.rec.is-warn { border-left-color: var(--warn); }
.rec.is-info { border-left-color: var(--accent); }
.rec-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rec-text { margin: 6px 0 8px; color: var(--text-muted); max-width: 90ch; }
.rec-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.lchart-grid-wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 18px; padding: 8px 16px 16px; }
.lchart { margin: 0; min-width: 0; }
.lchart-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; margin-bottom: 6px; }
.lchart-title { font-weight: 600; }
.lchart-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.82rem; }
.lchart-key::before { content: ""; display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; background: currentColor; }
.lchart svg { display: block; width: 100%; height: 130px; border-radius: 6px; background: var(--surface-2); }
.lchart-grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.lchart-line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.c-a { color: var(--accent); stroke: var(--accent); }
.c-b { color: var(--accent-2); stroke: var(--accent-2); }
.c-c { color: var(--warn); stroke: var(--warn); }
.lchart-key.c-a, .lchart-key.c-b, .lchart-key.c-c { stroke: none; }
.lchart-empty { margin: 4px 0 0; }

/* ======================================================================= listing tools (category / genre / person pages) */
.listing-tools {
  display: grid;
  gap: var(--s2);
  margin: var(--s3) 0 var(--s4);
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.listing-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
}

.listing-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  max-width: 420px;
  min-width: 0;
}

.listing-search > .icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.listing-search .input {
  width: 100%;
  padding-left: 36px;
}

.listing-tools .segmented-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.seg-count,
.chip-count {
  color: var(--text-muted);
  font-size: calc(11.5px * var(--font-scale));
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.listing-label {
  margin-right: 2px;
  color: var(--text-muted);
  font-size: calc(12px * var(--font-scale));
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.listing-chips .listing-label:not(:first-child) {
  margin-left: var(--s3);
}

.chip-filter {
  min-height: 30px;
  padding: 0 10px;
  cursor: pointer;
  font-size: calc(13px * var(--font-scale));
  transition: border-color var(--dur-fast, 0.15s) ease, background-color var(--dur-fast, 0.15s) ease, transform 0.1s ease;
}

.chip-filter:active {
  transform: scale(0.97);
}

.chip-filter.is-active .chip-count {
  color: inherit;
}

.listing-summary {
  justify-content: space-between;
  min-height: 24px;
}

.listing-tools .select-sm {
  width: auto;
}

@media (max-width: 640px) {
  .listing-tools {
    padding: var(--s2);
  }

  .listing-search {
    flex-basis: 100%;
    max-width: none;
  }

  .listing-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .listing-chips::-webkit-scrollbar {
    display: none;
  }

  .listing-chips .chip-filter,
  .listing-chips .listing-label {
    flex: none;
  }
}

/* a heading per group (provider, quality, type, length) */
.grouped-grid {
  display: grid;
  gap: var(--s5);
}

.grouped-title {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin: 0 0 var(--s3);
  font-size: calc(17px * var(--font-scale));
  font-weight: 700;
}

/* ======================================================================= directories: people, genres */
.dir-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--s3);
  margin: 0 0 var(--s4);
  padding: 0;
  list-style: none;
}

.dir-card {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-width: 0;
  height: 100%;
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: border-color var(--dur-fast, 0.15s) ease, transform var(--dur-fast, 0.15s) ease, box-shadow var(--dur-fast, 0.15s) ease;
}

.dir-card:hover,
.dir-card:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--shadow-1);
  text-decoration: none;
  transform: translateY(-1px);
}

.dir-card .avatar-img {
  flex: none;
  border-radius: 50%;
}

.dir-card-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.dir-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.genre-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  margin: 0 0 var(--s4);
  padding: 0;
  list-style: none;
}

.genre-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 34px;
  padding: 0 var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  transition: border-color var(--dur-fast, 0.15s) ease, background-color var(--dur-fast, 0.15s) ease;
}

.genre-chip:hover,
.genre-chip:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

.genre-chip.is-w0 { color: var(--text-muted); font-size: calc(13px * var(--font-scale)); }
.genre-chip.is-w1 { font-size: calc(13.5px * var(--font-scale)); }
.genre-chip.is-w2 { font-size: calc(15px * var(--font-scale)); }
.genre-chip.is-w3 { font-size: calc(16.5px * var(--font-scale)); font-weight: 600; }
.genre-chip.is-w4 { min-height: 40px; font-size: calc(18px * var(--font-scale)); font-weight: 700; }

.genre-links {
  margin: 0 0 var(--s2);
}

.genre-links summary {
  cursor: pointer;
  margin-bottom: var(--s2);
}

/* performers / genres matching the search text: a link to their page and "+" to filter by them */
.directory-hits .chip-static {
  border-style: dashed;
  background: var(--surface);
}

/* Administration -> Preloader */
/* ==========================================================================================
   Administration menu: full width, or icons only with tooltips (the toggle at the top; remembered in this browser)
   ========================================================================================== */
.admin-nav-toggle { color: var(--text-faint); font-weight: 500; }
.admin-nav-toggle:hover { color: var(--text); }
.admin-nav .sidebar-title { display: flex; align-items: center; gap: var(--s2); }
.admin-nav .sidebar-title::after { content: ""; flex: 1; height: 1px; background: var(--border); opacity: 0.7; }
@media (max-width: 960px) { .admin-nav-toggle { display: none; } }
@media (min-width: 961px) {
  .app.is-admin.nav-collapsed { --sidebar-w: 72px; }
  .app.is-admin.nav-collapsed .sidebar { padding-left: 10px; padding-right: 10px; }
  .admin-nav.is-collapsed .side-link { justify-content: center; padding: 0; }
  .admin-nav.is-collapsed .side-link > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .admin-nav.is-collapsed .sidebar-title { margin: var(--s2) var(--s1); }
  .admin-nav.is-collapsed .sidebar-title > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .admin-nav.is-collapsed .drawer-close { display: none; }
}
.admin-nav-tip {
  position: fixed; z-index: 400; transform: translateY(-50%); padding: 6px 10px; border-radius: var(--radius);
  background: var(--text); color: var(--bg); font-size: calc(12.5px * var(--font-scale)); font-weight: 600; white-space: nowrap;
  box-shadow: var(--shadow-2); pointer-events: none; animation: tip-in 0.12s var(--ease);
}
.admin-nav-tip::before { content: ""; position: absolute; top: 50%; left: -5px; width: 10px; height: 10px; transform: translateY(-50%) rotate(45deg); background: inherit; border-radius: 2px; }
@keyframes tip-in { from { opacity: 0; transform: translate(-4px, -50%); } to { opacity: 1; transform: translateY(-50%); } }

/* ==========================================================================================
   Administration -> Preloader: the form (labels with icons, grouped), the live side, cached files
   ========================================================================================== */
.pl-stats .stat-label { display: inline-flex; align-items: center; gap: 6px; }
.pl-stats .stat .btn { justify-self: start; margin-top: 6px; }
.pl-stats .stat-of { color: var(--text-faint); font-size: 0.6em; font-weight: 500; }
.pl-layout { display: grid; gap: var(--s4); grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: start; }
@media (max-width: 1279px) { .pl-layout { grid-template-columns: minmax(0, 1fr); } }
.pl-form-body { display: grid; gap: var(--s4); padding: var(--s4); }
.pl-group { display: grid; gap: var(--s3); margin: 0; padding: 0; border: 0; min-width: 0; }
.pl-group-head {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 0 0 6px; border-bottom: 1px solid var(--border);
  color: var(--text-muted); font-size: calc(11.5px * var(--font-scale)); font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
}
.pl-group-head .badge { margin-left: 4px; }
.pl-grid { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.pl-field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.pl-label { display: flex; align-items: center; gap: 6px; min-height: 22px; color: var(--text); font-weight: 600; font-size: calc(13px * var(--font-scale)); }
.pl-label > .icon { color: var(--text-muted); flex: none; }
.pl-label .pl-mode { margin-left: auto; }
.pl-span2 { grid-column: span 2; }
@media (max-width: 640px) { .pl-span2 { grid-column: auto; } }
.pl-field .field-help { margin-top: -2px; }
.pl-field .sg-ac { width: 100%; }
.pl-field .sg-ac .input { width: 100%; padding-right: 34px; }
.pl-unit { position: relative; display: block; }
.pl-unit > .input { width: 100%; padding-right: 64px; }
.pl-unit > span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: calc(12px * var(--font-scale)); pointer-events: none; }
.pl-steps { display: grid; gap: var(--s2); grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.pl-step { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: 8px 10px 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-sunken); }
.pl-step-name { display: inline-flex; align-items: center; gap: 8px; font-size: calc(13px * var(--font-scale)); font-weight: 600; }
.pl-step-name > .icon { color: var(--text-muted); }
.pl-overrides { display: grid; gap: var(--s2); }
.pl-overrides > summary { cursor: pointer; list-style: none; }
.pl-overrides > summary::-webkit-details-marker { display: none; }
.pl-overrides > summary::before { content: "▸"; font-size: 11px; transition: transform 0.15s var(--ease); }
.pl-overrides[open] > summary::before { transform: rotate(90deg); }
.pl-override { display: grid; gap: 6px; align-items: center; grid-template-columns: minmax(150px, 1.3fr) 1fr 1fr minmax(130px, 0.9fr) 84px auto auto; }
@media (max-width: 900px) { .pl-override { grid-template-columns: 1fr 1fr; } }
.pl-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); padding-top: var(--s3); border-top: 1px solid var(--border); }

/* the live side */
.pl-live .card-title, .pl-cache .card-title { display: inline-flex; align-items: center; gap: 8px; }
.pl-live-body { display: grid; gap: var(--s2); padding: var(--s3) var(--s4) var(--s4); }
.pl-ws { display: inline-flex; align-items: center; gap: 6px; }
.pl-ws-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 var(--ok-soft); animation: pl-pulse 2s infinite; }
@keyframes pl-pulse { 0% { box-shadow: 0 0 0 0 var(--ok-soft); } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.pl-sub { display: flex; align-items: center; gap: 8px; margin: var(--s2) 0 2px; color: var(--text-muted); font-size: calc(12.5px * var(--font-scale)); font-weight: 700; letter-spacing: 0.03em; }
.pl-sub .badge { padding: 0 7px; min-height: 18px; font-size: 11px; }
.pl-queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pl-queue li { display: flex; align-items: center; gap: var(--s2); padding: 6px 8px 6px 10px; border: 1px dashed var(--border); border-radius: var(--radius); }
.pl-pos { display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); font-size: 12px; font-weight: 700; }
.pl-run { display: grid; gap: var(--s2); padding: var(--s3); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border)); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.pl-run-head { display: flex; align-items: center; gap: var(--s2); }
.pl-run-pulse { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: pl-pulse 1.6s infinite; }
.pl-stepper { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.pl-stepper > li { display: grid; gap: 5px; justify-items: center; color: var(--text-faint); font-size: calc(11px * var(--font-scale)); text-align: center; }
.pl-stepper > li > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.pl-dot { display: block; width: 100%; height: 5px; border-radius: 3px; background: var(--surface-3); }
.pl-stepper > li.is-done { color: var(--text-muted); }
.pl-stepper > li.is-done .pl-dot { background: var(--ok); }
.pl-stepper > li.is-now { color: var(--text); font-weight: 600; }
.pl-stepper > li.is-now .pl-dot { background: var(--accent); animation: pl-breathe 1.4s ease-in-out infinite; }
@keyframes pl-breathe { 50% { opacity: 0.45; } }
.pl-note { margin: 0; }
.pl-counters { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pl-counter { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); font-size: calc(12.5px * var(--font-scale)); }
.pl-counter > .icon { color: var(--text-muted); }
.pl-counter strong { font-variant-numeric: tabular-nums; }
.pl-jobkinds { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.pl-jobkind { display: grid; gap: 5px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.pl-jobkind .row { gap: 6px; }
.pl-jobkind-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--surface-3); }
.pl-jobkind-bar > i { display: block; height: 100%; transition: width 0.4s var(--ease); }
.pl-jobkind-bar > .is-done, .pl-jobkind-legend .is-done { background: var(--ok); }
.pl-jobkind-bar > .is-running, .pl-jobkind-legend .is-running { background: var(--accent); }
.pl-jobkind-bar > .is-failed, .pl-jobkind-legend .is-failed { background: var(--err); }
.pl-jobkind-bar > .is-pending { background: var(--text-faint); opacity: 0.5; }
.pl-jobkind-bar > .is-cancelled { background: var(--warn); }
.pl-jobkind-legend { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.pl-jobkind-legend > span { background: none !important; }
.pl-jobkind-legend .is-done { color: var(--ok); }
.pl-jobkind-legend .is-running { color: var(--accent-strong); }
.pl-jobkind-legend .is-failed { color: var(--err); }
.pl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 340px; overflow: auto; }
.pl-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: var(--radius); background: var(--bg-sunken); font-size: calc(12.5px * var(--font-scale)); }
.pl-row > .icon { color: var(--text-muted); }
.pl-row .link-btn { padding: 0; font-size: inherit; color: var(--text); }
.pl-mini-progress { width: 90px; }
.pl-totals { margin: 0 0 4px; }
.pl-calls { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.pl-calls .table { font-size: calc(12.5px * var(--font-scale)); }
.pl-calls .table th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.pl-url { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-url strong { font-weight: 600; }
.pl-xfers { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pl-xfer { display: grid; gap: 5px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.pl-xfer .row { gap: 8px; }
.pl-xfer .row > .icon { color: var(--text-muted); flex: none; }
.pl-speed { color: var(--accent-strong); font-weight: 600; font-variant-numeric: tabular-nums; }
.pl-empty { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; padding: var(--s3); border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text-faint); font-size: calc(13px * var(--font-scale)); text-align: center; }
.pl-empty-lg { padding: var(--s5) var(--s3); }

/* cached files */
.pl-cache-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); }
.pl-cache-bar .sg-select { min-width: 170px; }
.pl-cache-search { min-width: 220px; }
.pl-cache-search > .input { width: 100%; min-width: 0; }
.pl-cache-table.is-loading { opacity: 0.6; }
.pl-file > a, .pl-file > strong, .pl-file > div { display: block; max-width: 340px; }   /* a cell ignores max-width: its blocks keep it */
.pl-pct { display: grid; gap: 3px; min-width: 150px; }
.pl-detail { display: grid; gap: var(--s2); padding: var(--s2) var(--s1, 4px); }
.card-foot { display: flex; justify-content: center; padding: var(--s3) var(--s4); border-top: 1px solid var(--border); }
.btn.is-active { color: var(--accent-strong); }

/* ------------------------------------------------------------------------------ admin: provider playback test */
.table tr.row-best td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.callout {
  margin-top: var(--s3); padding: var(--s3) var(--s4);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}
.callout p { margin: 0 0 var(--s2); }
.callout ul { margin: 0 0 var(--s2); padding-left: 1.2em; }

/* ------------------------------------------------------------------------------ MusicBox owner pages (/my/musicbox)
   The admin settings layout (.settings: a side nav that turns into a scrolling chip row under 960 px) holding cards
   built from .card-head / .card-body / .setting-list / .table-wrap, with a .card-actions footer for the form buttons. */
.th-sort { all: unset; cursor: pointer; font: inherit; color: inherit; white-space: nowrap; }
.th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.page-musicbox .block, .page-musicbox .field-help.block { display: block; }
.page-musicbox .toolbar .input[type="search"] { min-width: min(14rem, 100%); flex: 1 1 14rem; }
.page-musicbox h4 { margin: 0; }
.page-musicbox .table-wrap { position: relative; } /* keeps the .sr-only header cells inside the scroller (no page-wide overflow on phones) */
.mb-layout { padding-bottom: 0; }
.mb-layout .settings-nav .side-link > .icon { flex: none; }
.mb-section { min-width: 0; }
.card-actions {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s2);
  padding: var(--s3) var(--s4); border-top: 1px solid var(--border);
}
.card-actions.is-start { justify-content: flex-start; }
.card > :is(.card-body, .setting-list, .table-wrap) + :is(.card-body, .setting-list, .table-wrap) { border-top: 1px solid var(--border); }
.card > .card-head + .chips, .card > .chips { padding: var(--s3) var(--s4) 0; }
.card-head .toolbar { flex: 1 1 auto; justify-content: flex-end; }
.card-head > .toolbar:only-child { justify-content: flex-start; }
.card-head-text { display: grid; gap: 2px; min-width: 0; flex: 1 1 18rem; }
.card-head-text .card-title { flex-wrap: wrap; }
.fieldset-plain { min-width: 0; margin: 0; padding: 0; border: 0; }
.fieldset-plain > legend { margin-bottom: 6px; padding: 0; }
.mb-fields { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--s3) var(--s4); }
.mb-fields.is-end { align-items: flex-end; }
.mb-fields > .field { flex: 0 1 auto; }
.mb-fields > .field.grow { flex: 1 1 14rem; }
.mb-narrow { width: 100%; max-width: 7rem; }
.mb-short { width: 100%; max-width: 9rem; }
.mb-medium { width: 100%; max-width: 12rem; }
.mb-wide { width: 100%; max-width: 20rem; }
.mb-xwide { width: 100%; max-width: 24rem; }
.mb-checklist {
  display: grid; gap: 2px; max-height: 18rem; overflow: auto; padding: var(--s2) var(--s3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-sunken);
}
.mb-checklist > li { padding-left: calc(var(--depth, 0) * 1.25rem); }
.mb-checklist .check-row { align-items: center; min-height: 32px; }
.mb-checklist .check-row input { margin-top: 0; }
.mb-choice-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(11rem, 100%), 1fr)); gap: var(--s3); }
.mb-choice-card {
  display: grid; gap: var(--s2); align-content: start; padding: var(--s3);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.mb-choice-card:hover { border-color: var(--border-strong); }
.mb-choice-card.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mb-choice-card:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.mb-choice-card .check-row { align-items: center; }
.mb-choice-card .check-row input { margin-top: 0; }
.mb-preview-art { display: block; color: var(--accent); }
.mb-coef-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.mb-coef-row > .select { flex: 1 1 12rem; max-width: 18rem; }
.mb-coef-row > .input { width: 6rem; }
.is-stale { opacity: 0.55; transition: opacity 0.15s var(--ease); }
.mb-dim { opacity: 0.75; }
.mb-range { display: flex; align-items: center; gap: var(--s3); }
.mb-range input[type="range"] { flex: 0 1 16rem; min-width: 0; accent-color: var(--accent); }
.mb-range-full { width: 100%; accent-color: var(--accent); }
.mb-pct { min-width: 3.5em; text-align: right; }
.mb-now { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2); }
.mb-now-title { font-size: calc(17px * var(--font-scale)); }
.mb-progress { display: flex; align-items: center; gap: var(--s3); }
.mb-session { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s1); }
.mb-volume { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-left: auto; }
.mb-volume input[type="range"] { width: 9rem; accent-color: var(--accent); }
.mb-menu-form { display: flex; align-items: center; gap: var(--s2); padding: var(--s2); }
.mb-menu-form .input { width: 6rem; }
.mb-receiver.mb-dim { opacity: 0.75; }
.mb-copy-value { user-select: all; }
.mb-secret { font-size: calc(16px * var(--font-scale)); user-select: all; }
.mb-details > summary { cursor: pointer; width: fit-content; }
.mb-steps { margin: var(--s1) 0 0; padding-left: 1.25rem; list-style: decimal; }
ul.mb-steps { list-style: disc; }
.mb-thumb { flex: none; width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-sm, 6px); }
.mb-grip { display: inline-flex; color: var(--text-muted); cursor: grab; vertical-align: middle; }
.table tr.is-dragging { opacity: 0.5; }
.table tr.is-drop-target td { box-shadow: inset 0 2px 0 var(--accent); }
.mb-link { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); min-width: 0; }
.mb-link > a { min-width: 0; }
.mb-name-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s2) var(--s3); }
.mb-name-form > .field { flex: 1 1 16rem; max-width: 28rem; }
@media (max-width: 720px) {
  .card-actions { padding: var(--s3); }
  .card-actions > .grow { flex-basis: 0; }
  .card-head > .toolbar:only-child > :is(.input, .select, .inline-field) { flex: 1 1 100%; }
  .card-head > .toolbar:only-child .inline-field > .input { flex: 1 1 auto; }
  .mb-volume { width: 100%; }
  .mb-volume input[type="range"] { flex: 1 1 6rem; width: auto; }
}

/* ------------------------------------------------------------------------------ MusicBox owner: the receiver console
   (/my/musicbox/console, pages/musicbox-console.js) - the receiver list | the selected receiver in tabs. Two columns
   from 1280 px, else the list on top; the command palette's catalogue | form split is a container query on the main
   column (the owner nav takes part of the page). */
.mbcon { display: grid; gap: var(--s4); min-width: 0; }
.mbcon > * { min-width: 0; }
.mbcon-main { min-width: 0; container-type: inline-size; }
.mbcon-rx-list { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.mbcon-rx { display: grid; gap: 2px; padding: var(--s2) var(--s3) var(--s3); border-top: 1px solid var(--border); }
.mbcon-rx:first-child { border-top: 0; }
.mbcon-rx.is-active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.mbcon-rx-main {
  all: unset; display: grid; gap: 4px; min-width: 0; padding: var(--s1); border-radius: var(--radius-sm, 6px); cursor: pointer;
}
.mbcon-rx-main:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mbcon-rx-main .row { min-width: 0; }
.mbcon-rx-pick { align-items: center; padding: 0 var(--s1); }
.mbcon-rx-pick input { margin-top: 0; }
.mbcon-rx-metrics { display: flex; flex-wrap: wrap; gap: 2px var(--s3); color: var(--text-muted); }
.mbcon-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--text-muted); }
.mbcon-dot.is-on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.mbcon-caps { display: flex; flex-wrap: wrap; gap: 4px; }
.mbcon-cap {
  padding: 1px 6px; border: 1px dashed var(--border); border-radius: var(--radius-pill); color: var(--text-muted);
  font-size: calc(11.5px * var(--font-scale)); line-height: 1.5; text-decoration: line-through; opacity: 0.7;
}
.mbcon-cap.is-on { border-style: solid; border-color: transparent; background: var(--surface-3); color: var(--text); text-decoration: none; opacity: 1; }
.mbcon-inline { margin-left: var(--s2); }
.mbcon-force { margin-top: var(--s2); align-items: center; }
.mbcon-force input { margin-top: 0; }
.card > .card-body.mbcon-live:empty { display: none; }
.mbcon-tabs-wrap { padding-top: 0; padding-bottom: 0; overflow-x: auto; }
.mbcon-tabs-wrap .tabs { border-bottom: 0; }
.mbcon-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(17rem, 100%), 1fr)); gap: var(--s3); }
.mbcon-tiles > .card-inset { align-content: start; min-width: 0; }
.mbcon-tiles .card-title { margin: 0; font-size: calc(15px * var(--font-scale)); }
.mbcon-tiles .kv { grid-template-columns: minmax(90px, max-content) minmax(0, 1fr); }
.mbcon-palette { display: grid; gap: var(--s4); min-width: 0; }
.mbcon-palette > * { min-width: 0; }
.mbcon-group + .mbcon-group { margin-top: var(--s2); }
.mbcon-group-title { margin: 0 0 4px; color: var(--text-muted); font-size: calc(12px * var(--font-scale)); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.mbcon-cmds { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.mbcon-cmd {
  all: unset; box-sizing: border-box; display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--s2); width: 100%; min-width: 0;
  padding: 6px var(--s2); border-radius: var(--radius-sm, 6px); cursor: pointer;
}
.mbcon-cmd > .block { flex: 1 1 100%; min-width: 0; }
.mbcon-cmd:hover { background: var(--surface-2); }
.mbcon-cmd.is-active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.mbcon-cmd:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mbcon-type { margin-left: var(--s2); font-weight: 400; }
.mbcon-json { min-height: 8rem; font-size: calc(12.5px * var(--font-scale)); }
.mbcon-result { display: grid; gap: var(--s2); padding: var(--s3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-sunken); }
.mbcon-result.is-ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.mbcon-result.is-err { border-color: color-mix(in srgb, var(--err) 45%, var(--border)); }
.mbcon-args-sum { max-width: 22rem; }
.mbcon-log {
  display: grid; align-content: start; gap: 0; max-height: min(60vh, 34rem); min-height: 12rem; margin: var(--s2) 0 0; padding: 0; overflow: auto;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-sunken); list-style: none;
}
.mbcon-log:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mbcon-ev { display: grid; gap: var(--s1); padding: 0 var(--s2); border-left: 3px solid transparent; border-bottom: 1px solid var(--border); }
.mbcon-ev:last-child { border-bottom: 0; }
.mbcon-ev .codebox { margin-bottom: var(--s2); }
.mbcon-ev-command { border-left-color: var(--info); }
.mbcon-ev-report { border-left-color: var(--border-strong); }
.mbcon-ev-result { border-left-color: var(--ok); }
.mbcon-ev-error { border-left-color: var(--err); background: color-mix(in srgb, var(--err) 6%, transparent); }
.mbcon-ev-row { all: unset; display: flex; align-items: baseline; gap: var(--s2); min-width: 0; padding: 6px 0; cursor: pointer; }
.mbcon-ev-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mbcon-ev-time { flex: none; }
.mbcon-ev-sum { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mbcon-ev-empty { padding: var(--s3); }
.chip.mbcon-kind-command.is-active { border-color: var(--info); background: var(--info-soft); color: var(--info); }
.chip.mbcon-kind-report.is-active { border-color: var(--border-strong); background: var(--surface-3); color: var(--text); }
.chip.mbcon-kind-result.is-active { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.chip.mbcon-kind-error.is-active { border-color: var(--err); background: var(--err-soft); color: var(--err); }
.mbcon-check { width: 2.25rem; }
.mbcon-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.mbcon-key { max-width: 16rem; }
.mbcon-cell-title { display: block; max-width: 22rem; padding: 0; font-weight: 600; text-align: left; overflow-wrap: anywhere; }
.mbcon-file { max-height: 60vh; white-space: pre-wrap; }
.mbcon-file.is-hex { white-space: pre; overflow-wrap: normal; }
.mbcon-drift { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr)); gap: var(--s3); margin: 0; padding: var(--s3) var(--s4) var(--s4); list-style: none; }
.mbcon-drift > li { align-content: start; min-width: 0; }
.mbcon-drift .kv { grid-template-columns: minmax(80px, max-content) minmax(0, 1fr); }
.mbcon-drift-bar { position: relative; height: 10px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.mbcon-drift-zero { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: var(--text-muted); }
.mbcon-drift-fill { position: absolute; top: 0; bottom: 0; transition: width 0.3s var(--ease); }
.mbcon-drift-fill.is-pos { left: 50%; }
.mbcon-drift-fill.is-neg { right: 50%; }
.mbcon-drift-fill.is-ok { background: var(--ok); }
.mbcon-drift-fill.is-warn { background: var(--warn); }
.mbcon-drift-fill.is-err { background: var(--err); }
.mbcon-spark { display: block; width: 100%; height: 28px; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.mbcon-spark polyline { vector-effect: non-scaling-stroke; }
.mbcon-spark-zero { stroke: var(--border-strong); stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
@container (min-width: 720px) {
  .mbcon-palette { grid-template-columns: minmax(14rem, 18rem) minmax(0, 1fr); align-items: start; }
}
.mbcon { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1280px) {
  .mbcon { grid-template-columns: minmax(15rem, 19rem) minmax(0, 1fr); align-items: start; }
  .mbcon-list { position: sticky; top: calc(var(--topbar-h, 64px) + var(--s3)); max-height: calc(100vh - var(--topbar-h, 64px) - var(--s5)); overflow: auto; }
}
@media (max-width: 1279px) {
  .mbcon-rx-list { grid-template-columns: repeat(auto-fill, minmax(min(16rem, 100%), 1fr)); }
  .mbcon-rx:nth-child(n) { border-top: 1px solid var(--border); }
}
@media (prefers-reduced-motion: reduce) {
  .mbcon-drift-fill { transition: none; }
}

/* ------------------------------------------------------------------------------ MusicBox owner: the jukebox layout designer
   (/my/musicbox/layout, pages/musicbox-layout.js) - tree | live preview | inspector; under 1400 px the tree and the
   inspector share a column beside the preview; under 900 px everything is stacked (tree, inspector, preview). */
.mbl-bar-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.mbl-bar-group { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1); }
.mbl-flip .icon { transform: scaleX(-1); }
.mbl-errors { margin: var(--s1) 0 0; padding-left: 1.1rem; }
.mbl-grid { display: grid; gap: var(--s4); align-items: start; grid-template-columns: 17rem minmax(0, 1fr) 21rem; grid-template-areas: "tree preview insp"; }
.mbl-tree-card { grid-area: tree; }
.mbl-preview-card { grid-area: preview; min-width: 0; }
.mbl-inspector { grid-area: insp; min-width: 0; }
.mbl-grid > .card { margin: 0; }
@media (min-width: 1400px) {
  .mbl-tree-card, .mbl-inspector { position: sticky; top: calc(var(--topbar-h, 64px) + var(--s3)); max-height: calc(100vh - var(--topbar-h, 64px) - var(--s5)); overflow: auto; }
}
@media (max-width: 1399px) {
  .mbl-grid { grid-template-columns: minmax(0, 1fr) 20rem; grid-template-areas: "preview tree" "preview insp"; }
}
@media (max-width: 899px) {
  .mbl-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "tree" "insp" "preview"; }
}

/* the tree */
.mbl-tree, .mbl-group { list-style: none; margin: 0; padding: 0; }
.mbl-group { padding-left: var(--s3); border-left: 1px solid var(--border); margin-left: 10px; }
.mbl-tree [role="treeitem"] { outline: none; }
.mbl-node {
  display: flex; align-items: center; gap: var(--s2); min-height: 40px; padding: 4px var(--s2); margin: 2px 0;
  border-radius: var(--radius-sm, 6px); cursor: pointer; user-select: none;
}
.mbl-node:hover { background: var(--bg-sunken); }
.mbl-node.is-selected { background: var(--accent-soft, var(--bg-sunken)); box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
.mbl-node.is-off > .grow { opacity: 0.55; text-decoration: line-through; text-decoration-thickness: 1px; }
.mbl-tree [role="treeitem"]:focus-visible > .mbl-node { outline: 2px solid var(--accent); outline-offset: 1px; }
.mbl-ico { display: inline-flex; flex: none; color: var(--text-muted); }
.mbl-grip { display: inline-grid; place-items: center; width: 28px; height: 32px; margin-left: -4px; flex: none; color: var(--text-muted); cursor: grab; touch-action: none; }
.mbl-grip:active { cursor: grabbing; }
.mbl-node .badge { flex: none; }
.mbl-node > .grow { min-width: 3.5rem; }
.mbl-dot { width: 12px; height: 12px; flex: none; border-radius: 50%; background: var(--dot); box-shadow: 0 0 0 1px var(--border-strong); }
.mbl-group > .is-ghost > .mbl-node { opacity: 0.4; }
.is-dragging > .mbl-node { background: var(--surface); box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, .25)); }

/* the preview */
.mbl-stage { padding: var(--s3); background: var(--bg-sunken); border-top: 1px solid var(--border); overflow: hidden; display: flex; justify-content: center; border-radius: 0 0 var(--radius) var(--radius); }
.mbl-device { position: relative; overflow: hidden; border-radius: 18px; background: #0b0712; box-shadow: 0 0 0 1px var(--border-strong), 0 12px 40px rgba(0, 0, 0, .25); }
.mbl-device.is-phone { border-radius: 28px; }
.mbl-frame { display: block; border: 0; transform-origin: 0 0; background: #0b0712; }

/* the inspector */
.mbl-sub { margin: 0; font-size: calc(12px * var(--font-scale)); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.mbl-setting { padding: 0; border: 0; }
.mbl-radios { display: grid; gap: var(--s1); }
.mbl-pos { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.mbl-pos-text { min-width: 4.5rem; font-variant-numeric: tabular-nums; }
.mbl-count { display: flex; gap: var(--s2); }
.mbl-order { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mbl-order > li { display: flex; align-items: center; gap: var(--s2); min-height: 40px; padding: 0 var(--s1); border-radius: var(--radius-sm, 6px); }
.mbl-order > li:nth-child(odd) { background: var(--bg-sunken); }
.mbl-order > li.is-off .mbl-order-name { opacity: 0.55; text-decoration: line-through; }
.mbl-order-pos { width: 1.5rem; text-align: center; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.mbl-order-name { flex: 1 1 auto; text-align: left; font-size: inherit; color: var(--text); }
.mbl-color-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.mbl-picker { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm, 6px); background: var(--surface); cursor: pointer; }
.mbl-hex { width: 7.5rem; }
.mbl-swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s2); }
.mbl-swatch { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--sw); cursor: pointer; padding: 0; }
.mbl-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.mbl-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.mbl-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.mbl-icon-opt { display: grid; place-items: center; height: 44px; border: 1px solid var(--border); border-radius: var(--radius-sm, 6px); cursor: pointer; color: var(--text-muted); }
.mbl-icon-opt:hover { border-color: var(--border-strong); color: var(--text); }
.mbl-icon-opt.is-active { border-color: var(--accent); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.mbl-icon-opt:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 720px) {
  .mbl-bar-row > .grow { display: none; }
  .mbl-stage { padding: var(--s2); }
}

/* ------------------------------------------------------------------------------ receiver: Musicbox announcements */
.receiver-pip {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); z-index: 20;
  width: min(36vw, 480px); aspect-ratio: 16 / 9; object-fit: cover; border-radius: 12px; background: #000;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55); outline: 2px solid rgba(255, 255, 255, 0.18);
}
.receiver-announce { display: none; }

/* ------------------------------------------------------------------------------ receiver settings: splash, overlay, blocker
   (msa/web/js/pages/receiver-overlay.js; the animation lengths match ANIM_MS of receiver-settings.js) */
.receiver-splash { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; overflow: hidden; background: #000; perspective: 1200px; }
.receiver-splash-media { width: 100%; height: 100%; object-fit: contain; display: block; }
.receiver.has-splash .receiver-unlock { background: linear-gradient(to top, rgba(5, 7, 10, 0.7), transparent 40%); }
.splash-hidden { opacity: 0; }
.splash-in-fade { animation: splash-fade-in 700ms ease-out both; }
.splash-out-fade { animation: splash-fade-in 700ms ease-in reverse both; }
.splash-in-slide { animation: splash-slide-in 650ms cubic-bezier(.2, .8, .2, 1) both; }
.splash-out-slide { animation: splash-slide-out 650ms cubic-bezier(.6, 0, .8, .2) both; }
.splash-in-zoom { animation: splash-zoom-in 700ms cubic-bezier(.2, .8, .2, 1) both; }
.splash-out-zoom { animation: splash-zoom-out 700ms ease-in both; }
.splash-in-bang { animation: splash-bang-in 600ms cubic-bezier(.34, 1.56, .64, 1) both; }
.splash-out-bang { animation: splash-bang-out 600ms ease-in both; }
.splash-in-flip { animation: splash-flip-in 750ms ease-out both; backface-visibility: hidden; }
.splash-out-flip { animation: splash-flip-out 750ms ease-in both; backface-visibility: hidden; }
@keyframes splash-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes splash-slide-in { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: none; } }
@keyframes splash-slide-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(-100%); } }
@keyframes splash-zoom-in { from { opacity: 0; transform: scale(1.35); } to { opacity: 1; transform: none; } }
@keyframes splash-zoom-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(0.7); } }
@keyframes splash-bang-in {
  0% { opacity: 0; transform: scale(0.2); filter: brightness(3); }
  60% { opacity: 1; transform: scale(1.12); filter: brightness(1.6); }
  100% { opacity: 1; transform: none; filter: none; }
}
@keyframes splash-bang-out {
  0% { opacity: 1; transform: none; filter: none; }
  30% { opacity: 1; transform: scale(1.08); filter: brightness(2); }
  100% { opacity: 0; transform: scale(1.8); filter: brightness(4) blur(8px); }
}
@keyframes splash-flip-in { from { opacity: 0; transform: rotateY(-90deg); } to { opacity: 1; transform: none; } }
@keyframes splash-flip-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: rotateY(90deg); } }
@media (prefers-reduced-motion: reduce) {
  .receiver-splash [class*='splash-in-'], .receiver-splash [class*='splash-out-'] { animation-duration: 1ms; }
}

/* the receiver's own controls replace the player's chrome */
.receiver.own-controls .msap-top, .receiver.own-controls .msap-bottom, .receiver.own-controls .msap-bar { display: none !important; }
.receiver-controls {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; display: flex; flex-direction: column; gap: 14px;
  padding: 28px max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: linear-gradient(to top, rgba(5, 7, 10, 0.92), rgba(5, 7, 10, 0.6) 60%, transparent); color: #fff;
  opacity: 0; transform: translateY(16px); pointer-events: none; transition: opacity 220ms ease, transform 220ms ease;
}
.receiver-controls.is-visible, .receiver-controls:focus-within { opacity: 1; transform: none; pointer-events: auto; }
.receiver-controls-title { margin: 0; font-size: clamp(16px, 2.2vw, 24px); font-weight: 600; }
.receiver-controls-position { display: flex; align-items: center; gap: 14px; font-size: clamp(14px, 1.6vw, 18px); }
.receiver-controls-position input { flex: 1; min-width: 0; height: 32px; accent-color: var(--accent); }
.receiver-controls-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px; }
.receiver-controls-btn {
  display: inline-grid; place-items: center; width: 76px; height: 76px; border: 2px solid rgba(255, 255, 255, 0.22); border-radius: 50%;
  background: rgba(255, 255, 255, 0.1); color: #fff; cursor: pointer; transition: background 150ms ease, transform 150ms ease;
}
.receiver-controls-btn:hover { background: rgba(255, 255, 255, 0.2); }
.receiver-controls-btn:focus-visible { outline: 4px solid var(--accent); outline-offset: 3px; transform: scale(1.08); background: rgba(255, 255, 255, 0.24); }
.receiver-controls-btn.is-busy { opacity: 0.55; }
.receiver-controls-volume { display: inline-flex; align-items: center; gap: 10px; min-width: 200px; }
.receiver-controls-volume input { width: 180px; height: 32px; accent-color: var(--accent); }
.receiver-controls input:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
@media (max-width: 600px) { .receiver-controls-btn { width: 60px; height: 60px; } .receiver-controls-volume input { width: 120px; } }

/* the controls are off (receiver settings `controls`): nothing below reacts to a touch, a click or the pointer */
.receiver-blocker { position: absolute; inset: 0; z-index: 4; background: transparent; cursor: none; touch-action: none; }

/* ------------------------------------------------------------------------------ receiver settings editor (components/receiver-settings-editor.js) */
.rxset-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s2); }
.rxset-option { align-items: flex-start; padding: var(--s2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.rxset-grid { align-items: flex-start; gap: var(--s4); }
.rxset-sub { margin: var(--s2) 0 0; font-size: 1rem; }
.rxset-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.rxset-item {
  display: grid; grid-template-columns: auto 96px 1fr auto; gap: var(--s3); align-items: start; padding: var(--s2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.rxset-item.is-over { outline: 2px dashed var(--accent); outline-offset: 2px; }
.rxset-grip { cursor: grab; color: var(--muted); padding-top: 28px; }
.rxset-thumb { width: 96px; aspect-ratio: 16 / 9; display: grid; place-items: center; overflow: hidden; border-radius: var(--radius-sm); background: #000; color: #889; cursor: pointer; margin-top: 22px; }
.rxset-thumb img, .rxset-thumb video { width: 100%; height: 100%; object-fit: cover; }
.rxset-fields { min-width: 0; display: flex; flex-direction: column; gap: var(--s2); }
.rxset-fields .row { align-items: flex-start; gap: var(--s3); }
.rxset-num { width: 7em; }
.rxset-actions { display: flex; flex-direction: column; gap: 2px; padding-top: 22px; }
.rxset-pick { max-width: 280px; }
.rxset-preview { position: fixed; right: 24px; bottom: 24px; z-index: 1000; width: min(360px, 60vw); aspect-ratio: 16 / 9; overflow: hidden; border-radius: 12px; background: #000; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); perspective: 900px; }
.rxset-preview img { width: 100%; height: 100%; object-fit: contain; }
@media (max-width: 640px) {
  .rxset-item { grid-template-columns: 1fr; }
  .rxset-grip, .rxset-thumb, .rxset-actions { padding-top: 0; margin-top: 0; }
  .rxset-actions { flex-direction: row; }
}
.rxset-status { flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--s2); }
