/* CTR Chicken — screen control panel.
   Plain CSS, no framework, so every rule can be read and changed directly.

   Design notes
   - One typeface (Onest, has Cyrillic for Uzbek/Russian names).
   - Light, cool neutrals + CTR pink for actions/highlights.
   - The "screen wall" (16:9 TV cards + the row of tiny screens in the
     overview) is the one bold element; everything around it stays quiet:
     thin borders instead of heavy shadows, sentence-case labels. */

:root {
  --bg: #f5f4f7;
  --surface: #ffffff;
  --ink: #1b1720;
  --muted: #6d6675;
  --faint: #a39cab;
  --line: #e6e2ea;
  --line-strong: #d4cdda;

  --pink: #e6007a;
  --pink-ink: #b8005f;
  --pink-wash: #fdeaf3;

  --live: #13a456;
  --live-wash: #e3f6ea;
  --warn: #a86400;
  --warn-wash: #fff3dc;
  --bad: #cc2a3d;
  --bad-wash: #fde8ea;

  --bezel: #1b1720;

  --r-s: 8px;
  --r-m: 12px;
  --r-l: 16px;

  --font: "Onest", "Segoe UI", system-ui, -apple-system, sans-serif;

  /* Older names still used inline by a few scripts */
  --text: var(--ink);
  --text-muted: var(--muted);
  --border: var(--line);
  --white: var(--surface);
  --green: var(--live);
  --red: var(--bad);
  --pink-light: var(--pink-wash);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
  font-feature-settings: "tnum" 1;
}

a { color: var(--pink-ink); }

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

code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.92em;
  background: rgba(27, 23, 32, 0.06);
  padding: 1px 5px;
  border-radius: 5px;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn-primary,
.btn-small,
.btn-secondary,
.btn-danger,
.btn-logout {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--r-s);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary {
  width: 100%;
  background: var(--pink);
  color: #fff;
  border: 1px solid var(--pink);
  padding: 11px 16px;
}
.btn-primary:hover { background: var(--pink-ink); border-color: var(--pink-ink); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-small {
  background: var(--pink);
  color: #fff;
  border: 1px solid var(--pink);
  padding: 9px 14px;
}
.btn-small:hover { background: var(--pink-ink); border-color: var(--pink-ink); }

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  padding: 8px 12px;
  font-weight: 500;
}
.btn-secondary:hover { border-color: var(--ink); }
.btn-secondary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-danger {
  background: transparent;
  color: var(--bad);
  border: 1px solid transparent;
  padding: 8px 10px;
  font-weight: 500;
}
.btn-danger:hover { background: var(--bad-wash); }

.btn-link {
  background: none;
  border: none;
  color: var(--pink-ink);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.btn-link:hover { background: var(--pink-wash); }
.btn-link:disabled { color: var(--faint); cursor: default; background: none; }

.btn-logout {
  width: 100%;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 9px 12px;
  font-weight: 500;
  justify-content: flex-start;
}
.btn-logout:hover { color: var(--ink); border-color: var(--line-strong); }

.icon { width: 18px; height: 18px; flex-shrink: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ============================================================
   Forms
   ============================================================ */

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea,
.select-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-s);
  font: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
}
.field textarea { resize: vertical; }

.field input:focus,
.field select:focus,
.field textarea:focus,
.select-input:focus {
  outline: none;
  border-color: var(--pink);
  box-shadow: 0 0 0 3px var(--pink-wash);
}

.field-row { display: flex; gap: 16px; }
.field-row .field { flex: 1; }

.error-message {
  background: var(--bad-wash);
  color: var(--bad);
  padding: 10px 12px;
  border-radius: var(--r-s);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.error-message.visible { display: block; }

/* ============================================================
   Login
   ============================================================ */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  padding: 36px 32px 32px;
}

.login-card .brand { margin-bottom: 28px; }

.login-card h1 {
  font-size: 22px;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}

.login-card p {
  color: var(--muted);
  margin: 0 0 24px;
}

/* ============================================================
   Brand mark
   ============================================================ */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--pink);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.brand-mark svg { width: 20px; height: 20px; color: #fff; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--muted); }

/* ============================================================
   App shell: sidebar + main
   ============================================================ */

.app-shell { display: flex; min-height: 100vh; }

@media (min-width: 861px) {
  /* keeps the white sidebar column running the full height of long pages */
  body:has(.app-shell) {
    background: linear-gradient(90deg, var(--surface) 0 231px, var(--line) 231px 232px, var(--bg) 232px);
  }
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand { padding: 0 6px 22px; }

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

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}
.sidebar nav a:hover { color: var(--ink); background: var(--bg); }
.sidebar nav a.active { color: var(--pink-ink); background: var(--pink-wash); font-weight: 600; }

.sidebar-foot { margin-top: auto; padding-top: 16px; }

.main {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 56px;
  max-width: 1320px;
}

/* Mobile top bar (hidden on desktop) */
.mobile-bar { display: none; }
.nav-scrim { display: none; }

/* ============================================================
   Page header
   ============================================================ */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.topbar h1 {
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0;
}

.page-sub {
  color: var(--muted);
  margin-top: 6px;
  max-width: 64ch;
}

/* ============================================================
   Panels
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  padding: 20px;
  margin-bottom: 20px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 16px;
  font-weight: 650;
  margin: 0;
}

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

.info-note {
  background: var(--bg);
  border-left: 3px solid var(--pink);
  color: var(--ink);
  border-radius: 0 var(--r-s) var(--r-s) 0;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  max-width: 90ch;
}

.empty-note { color: var(--muted); font-size: 13px; padding: 8px 0; }

.empty-state {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  max-width: 52ch;
  margin: 0 auto;
}

/* ============================================================
   Overview ("right now")
   ============================================================ */

.overview {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 20px 32px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  padding: 22px 24px;
  margin-bottom: 24px;
}

.overview-headline {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 0 0 12px;
}
.overview-headline .num-live { color: var(--live); }

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

/* One tiny TV per screen */
.mini-tv {
  width: 30px;
  height: 18px;
  border-radius: 3px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  position: relative;
}
.mini-tv::after { /* stand */
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 8px;
  height: 2px;
  margin-left: -4px;
  background: var(--line-strong);
  border-radius: 1px;
}
.mini-tv.on { border-color: var(--live); background: var(--live); }
.mini-tv.on::after { background: var(--live); }
.mini-tv.unpaired { border-color: var(--pink); background: var(--pink-wash); }
.mini-tv.unpaired::after { background: var(--pink); }
.mini-tv.problem { border-color: var(--bad); background: var(--bad-wash); }

.screen-strip-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--muted);
}
.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}

.overview-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
  border-left: 1px solid var(--line);
  padding-left: 28px;
}
.fact { display: flex; flex-direction: column; color: inherit; text-decoration: none; border-radius: 6px; }
.fact-label { font-size: 12.5px; color: var(--muted); }
.fact-value { margin-top: 2px; font-size: 17px; font-weight: 650; }
.fact-value small { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.fact-value.is-bad { color: var(--bad); }
.fact:hover .fact-value { color: var(--pink-ink); }

/* ============================================================
   Status pills + badges
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-count { background: var(--pink-wash); color: var(--pink-ink); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.pill-ok { background: var(--live-wash); color: var(--live); }
.pill-busy { background: var(--warn-wash); color: var(--warn); }
.pill-bad { background: var(--bad-wash); color: var(--bad); }
.pill-none { background: var(--bg); color: var(--muted); }
.pill-pink { background: var(--pink-wash); color: var(--pink-ink); }

/* ============================================================
   Tables (turn into stacked rows on phones)
   ============================================================ */

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fbfafc; }

.cell-title { font-weight: 650; font-size: 15px; }
.cell-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.cell-actions { text-align: right; white-space: nowrap; }
.cell-actions > * + * { margin-left: 6px; }

/* Branch photo: rounded square in front of each branch name */
.branch-cell { display: flex; align-items: center; gap: 14px; }

.branch-photo {
  position: relative;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 14px;
  border: 1.5px dashed var(--line-strong);
  background: var(--bg);
  color: var(--muted);
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  display: grid;
  place-items: center;
  font: inherit;
}
.branch-photo.has-photo { border: 1px solid var(--line); }
.branch-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.branch-initials { font-weight: 650; font-size: 15px; color: var(--muted); }

.branch-photo-cam {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(27, 23, 32, 0.55);
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s;
}
.branch-photo-cam svg { width: 20px; height: 20px; }
.branch-photo:not(.has-photo) .branch-photo-cam { /* empty: small camera badge in the corner */
  inset: auto -1px -1px auto;
  width: 22px;
  height: 22px;
  border-radius: 8px 0 12px 0;
  background: var(--pink);
  opacity: 1;
}
.branch-photo:not(.has-photo) .branch-photo-cam svg { width: 13px; height: 13px; }
.branch-photo:hover { border-color: var(--pink); }
.branch-photo.has-photo:hover .branch-photo-cam,
.branch-photo:focus-visible .branch-photo-cam { opacity: 1; }
.branch-photo.is-uploading { opacity: 0.5; cursor: progress; }

.screen-strip + .cell-sub { margin-top: 8px; }

/* ============================================================
   Screen wall (Devices page)
   ============================================================ */

.screen-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 20px;
}

.screen-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.screen-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--bezel);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.screen-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.screen-frame.is-offline img { filter: grayscale(1) brightness(0.7); }

.screen-blank {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: #b9b2c0;
  font-size: 13px;
  padding: 16px;
}

.screen-frame.unpaired { background: var(--pink-wash); }
.pair-code {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--pink-ink);
}
.pair-hint { font-size: 12.5px; color: var(--pink-ink); margin-top: 2px; }

.screen-status {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(27, 23, 32, 0.72);
  color: #fff;
  backdrop-filter: blur(4px);
}
.screen-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8e8795;
}
.screen-status.on::before { background: #3ee07f; }
.screen-status.pairing { background: var(--pink); }
.screen-status.pairing::before { background: #fff; }

.screen-body { padding: 14px 16px 6px; flex: 1; }

.screen-name {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 16px;
  font-weight: 650;
  margin: 0 0 8px;
}

.screen-facts { margin: 0; display: grid; gap: 4px; font-size: 13px; }
.screen-facts div { display: flex; justify-content: space-between; gap: 12px; }
.screen-facts dt { color: var(--muted); }
.screen-facts dd { margin: 0; text-align: right; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

.screen-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px 16px;
  align-items: center;
}
.screen-actions .btn-secondary { flex: 1; }

/* ============================================================
   Loading placeholders
   ============================================================ */

.skeleton {
  background: linear-gradient(90deg, #eeebf1 0%, #f7f5f9 50%, #eeebf1 100%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: 6px;
}
.skeleton-line { height: 12px; margin: 6px 0; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w80 { width: 80%; }
.skeleton-block { aspect-ratio: 16 / 9; border-radius: 0; }

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  * { transition: none !important; }
}

/* ============================================================
   Content page
   ============================================================ */

.upload-dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-m);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.15s, background-color 0.15s;
}
.upload-dropzone:hover,
.upload-dropzone.drag-over { border-color: var(--pink); background: var(--pink-wash); }

.upload-dropzone-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}
.upload-dropzone-text strong { font-size: 15px; }
.upload-dropzone-text span { font-size: 13px; color: var(--muted); }

.upload-queue { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.upload-queue:empty { display: none; }

.upload-queue-item { border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 14px; }
.upload-queue-item-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.upload-queue-item-status { font-weight: 500; color: var(--muted); }
.upload-queue-item.failed .upload-queue-item-status { color: var(--bad); }
.upload-queue-item.done .upload-queue-item-status { color: var(--live); }

.upload-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.upload-row .field { margin-bottom: 0; flex: 1; min-width: 200px; }

.progress-track {
  margin-top: 14px;
  background: var(--pink-wash);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
  display: none;
}
.progress-track.visible { display: block; }
.progress-fill { background: var(--pink); height: 100%; width: 0%; transition: width 0.2s ease; }

.progress-label { font-size: 12px; color: var(--muted); margin-top: 6px; display: none; }
.progress-label.visible { display: block; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.media-card {
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.media-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bezel);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.media-thumb img,
.media-thumb video { width: 100%; height: 100%; object-fit: cover; }

.media-info { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.media-name { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.media-meta { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.media-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; }
.media-actions button { flex: 1; }

.media-duration-label,
.playlist-duration-label {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.media-duration-input,
.playlist-duration-input {
  width: 58px;
  padding: 4px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
}

.radio-row { display: flex; gap: 16px; margin-bottom: 12px; }
.radio-row label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }

.assign-target-name {
  background: var(--pink-wash);
  color: var(--pink-ink);
  padding: 8px 12px;
  border-radius: var(--r-s);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Device checklist (legacy assign flow) */
.checklist-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.checklist-header .btn-link { padding: 0; }
.device-checklist { border: 1px solid var(--line); border-radius: var(--r-s); max-height: 180px; overflow-y: auto; padding: 4px 0; }
.device-checklist label { display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-size: 14px; cursor: pointer; }
.device-checklist label:hover { background: var(--bg); }
.device-checklist .empty-note { padding: 10px 12px; }

/* ============================================================
   Modals
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 23, 32, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--r-l);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(27, 23, 32, 0.25);
}
.modal-wide { max-width: 760px; }

.modal h2 { margin: 0 0 16px; font-size: 19px; letter-spacing: -0.01em; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.modal-actions button { flex: 1; min-width: 120px; }

/* Playlist builder */
.playlist-builder { display: flex; gap: 16px; margin-top: 8px; }
.playlist-column { flex: 1; min-width: 0; }
.playlist-column-header { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }

.playlist-library-list,
.playlist-current-list {
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  max-height: 340px;
  overflow-y: auto;
  padding: 2px 0;
}

.playlist-library-item,
.playlist-current-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.playlist-library-item:last-child,
.playlist-current-item:last-child { border-bottom: none; }

.playlist-thumb {
  width: 48px;
  height: 27px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bezel);
  flex-shrink: 0;
}
.playlist-item-order { font-weight: 700; color: var(--pink-ink); min-width: 16px; }
.playlist-item-name { flex: 1; min-width: 60px; overflow-wrap: anywhere; }

/* ============================================================
   Applications page + device info
   ============================================================ */

.version-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 4px 0; }
.version-name { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; letter-spacing: -0.01em; }
.version-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.version-notes { margin-top: 10px; font-size: 13px; white-space: pre-wrap; max-width: 80ch; }

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 24px;
  margin: 8px 0 4px;
}
.info-row { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.info-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.info-value { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }

.info-section-label { font-size: 13px; color: var(--muted); font-weight: 600; margin: 22px 0 8px; }

.screenshot-block { border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; background: var(--bg); }
.screenshot-img { display: block; width: 100%; max-height: 360px; object-fit: contain; background: var(--bezel); }
.screenshot-caption { padding: 8px 12px; font-size: 12.5px; color: var(--muted); }

.rollout-detail { font-size: 12.5px; margin-top: 4px; max-width: 70ch; }
.rollout-detail.bad { color: var(--bad); }
.rollout-detail.muted { color: var(--muted); }

/* ============================================================
   Phone + small tablet
   ============================================================ */

@media (max-width: 860px) {
  .app-shell { display: block; }

  .mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 10px 16px;
  }

  .menu-btn {
    background: none;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-s);
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    color: var(--ink);
    cursor: pointer;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: auto;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 40px rgba(27, 23, 32, 0.2);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(27, 23, 32, 0.4);
    z-index: 80;
  }

  .main { padding: 20px 16px 48px; }
  .topbar h1 { font-size: 22px; }
  .topbar .btn-small { width: 100%; padding: 11px 14px; }

  .card { padding: 16px; border-radius: var(--r-m); }

  .overview { grid-template-columns: 1fr; padding: 18px; }
  .overview-headline { font-size: 19px; }
  .overview-facts { border-left: none; padding-left: 0; border-top: 1px solid var(--line); padding-top: 16px; }

  .field-row { flex-direction: column; gap: 0; }

  /* Tables become stacked rows */
  table.responsive thead { display: none; }
  table.responsive,
  table.responsive tbody,
  table.responsive tr,
  table.responsive td { display: block; width: 100%; }
  table.responsive tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
  }
  table.responsive td:first-child,
  table.responsive .cell-actions { grid-column: 1 / -1; }
  table.responsive tr:last-child { border-bottom: none; }
  table.responsive td { border: none; padding: 4px 0; }
  table.responsive td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 1px;
  }
  table.responsive .cell-actions { text-align: left; padding-top: 10px; white-space: normal; }
  table.responsive .cell-actions > * { margin: 0 6px 6px 0; }
  tbody tr:hover td { background: none; }

  .screen-wall { grid-template-columns: 1fr; gap: 16px; }

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

  /* Pop-ups slide up from the bottom like a sheet */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal,
  .modal-wide {
    max-width: none;
    border-radius: var(--r-l) var(--r-l) 0 0;
    max-height: 92vh;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  }
  .playlist-builder { flex-direction: column; }
  .info-grid { grid-template-columns: 1fr; }
}

/* A copy of last time's list, shown instantly while live data loads (js/snap.js). */
[data-saved] { opacity: 0.7; transition: opacity 0.2s; }
[data-saved] * { pointer-events: none; }
