/* ==========================================================================
   Signage Manager — design system
   One source of truth for color, type, spacing, and components.
   ========================================================================== */

:root {
  /* palette */
  --bg: #0a0d14;
  --surface: #11151f;
  --surface-2: #171c29;
  --surface-3: #1d2333;
  --border: #232a3b;
  --border-strong: #2f3850;
  --text: #e6eaf2;
  --text-muted: #8b94a7;
  --text-faint: #5b6478;
  --accent: #6366f1;
  --accent-hover: #4f52e0;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --cyan: #22d3ee;
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.13);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --grad: linear-gradient(135deg, #6366f1 0%, #22d3ee 100%);

  /* shape + depth */
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 24px -12px rgba(0,0,0,.5);
  --shadow-pop: 0 12px 40px -8px rgba(0,0,0,.65);

  /* type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --sidebar-w: 228px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(99,102,241,.35); }

/* subtle app-wide backdrop glow */
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(600px 300px at 15% -5%, rgba(99,102,241,.08), transparent 60%),
    radial-gradient(500px 300px at 95% 0%, rgba(34,211,238,.05), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ========================= layout ========================= */

.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: rgba(17,21,31,.85);
  backdrop-filter: blur(8px);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--grad);
  display: grid; place-items: center;
  color: #fff; flex-shrink: 0;
  box-shadow: 0 4px 14px -4px rgba(99,102,241,.6);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-weight: 700; font-size: 14.5px; letter-spacing: .01em; }
.brand-sub { font-size: 11px; color: var(--text-faint); margin-top: -2px; }

.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--text-faint); padding: 12px 10px 5px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500; font-size: 13.5px;
  cursor: pointer; border: 1px solid transparent;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: #c7cbff; border-color: rgba(99,102,241,.25); }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .9; }
.nav-item .count {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--surface-3); color: var(--text-muted);
  border-radius: 999px; padding: 0 7px; line-height: 18px;
}
.nav-item .count.alert { background: var(--danger-soft); color: var(--danger); }

.sidebar-foot { padding: 12px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-faint); display: flex; align-items: center; gap: 8px; }
.sidebar-foot .spacer { flex: 1; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--border);
  background: rgba(10,13,20,.7);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 40;
  min-height: 62px;
}
.topbar h1 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.topbar .crumb { color: var(--text-faint); font-weight: 500; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; }

.content { padding: 24px 26px 60px; max-width: 1240px; width: 100%; }

/* ========================= components ========================= */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 650; color: var(--text);
}
.card-header > svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.card-header .sub { color: var(--text-faint); font-weight: 400; font-size: 12px; }
.card-header .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; border: 1px solid transparent;
  background: var(--surface-3); color: var(--text);
  transition: background .12s, border-color .12s, opacity .12s, transform .05s;
  white-space: nowrap; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 14px -6px rgba(99,102,241,.7); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: rgba(248,113,113,.22); }
.btn-success { background: var(--success-soft); color: var(--success); }
.btn-success:hover:not(:disabled) { background: rgba(52,211,153,.22); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-icon { padding: 6px; }

/* badges + status dots */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 650; letter-spacing: .02em;
}
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-amber { background: var(--warn-soft); color: var(--warn); }
.badge-blue { background: var(--accent-soft); color: #a5a8ff; }
.badge-gray { background: var(--surface-3); color: var(--text-muted); }
.badge svg { width: 11px; height: 11px; }
.queue-chip svg { width: 13px; height: 13px; flex-shrink: 0; }
.file-card .dur svg { width: 11px; height: 11px; vertical-align: -1px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-green { background: var(--success); box-shadow: 0 0 8px rgba(52,211,153,.8); }
.dot-red { background: var(--danger); }
.dot-amber { background: var(--warn); }
.dot-gray { background: var(--text-faint); }
.pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
/* a switch inside a field is still a switch — keep the track beside its text */
.field label.switch { display: inline-flex; width: auto; }
.field .hint { font-weight: 400; color: var(--text-faint); }
.input, .select, textarea.input {
  width: 100%; padding: 8px 11px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text); font-size: 13.5px; font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.18);
}
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b94a7' fill='none' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 30px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* toggle switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; color: var(--text-muted); user-select: none; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 36px; height: 20px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); transition: background .15s; flex-shrink: 0; position: relative; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-muted); transition: transform .15s, background .15s; }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); background: #fff; }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; padding: 10px 16px;
  color: var(--text-faint); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .07em;
  border-bottom: 1px solid var(--border);
}
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
}
.stat-icon { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.indigo { background: var(--accent-soft); color: #a5a8ff; }
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.red { background: var(--danger-soft); color: var(--danger); }
.stat-icon.cyan { background: rgba(34,211,238,.12); color: var(--cyan); }
.stat-value { font-size: 19px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 11.5px; color: var(--text-faint); font-weight: 500; }

/* content thumbnail grid */
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
}
.file-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .12s, transform .12s, box-shadow .12s;
  position: relative;
}
.file-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.file-card.dragging { opacity: .4; }
.file-card.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.file-card .thumb {
  aspect-ratio: 16/9; width: 100%;
  background: var(--bg);
  display: grid; place-items: center;
  color: var(--text-faint);
  position: relative;
  cursor: grab;
}
.file-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-card .thumb svg { width: 30px; height: 30px; }
.file-card .order-chip {
  position: absolute; top: 7px; left: 7px;
  background: rgba(10,13,20,.82); backdrop-filter: blur(4px);
  color: #fff; font-size: 11px; font-weight: 700;
  min-width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center; padding: 0 6px;
  border: 1px solid rgba(255,255,255,.14);
}
.file-card .type-chip {
  position: absolute; top: 7px; right: 7px;
  background: rgba(10,13,20,.82); backdrop-filter: blur(4px);
  border-radius: 6px; padding: 3px 6px;
  display: flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600; color: var(--text-muted);
  border: 1px solid rgba(255,255,255,.1);
}
.file-card .type-chip svg { width: 12px; height: 12px; }
.file-card .meta { padding: 9px 11px; }
.file-card .fname {
  font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-card .fsub { display: flex; align-items: center; gap: 7px; margin-top: 5px; }
.file-card .dur {
  font-size: 11px; font-weight: 650; color: var(--text-muted);
  background: var(--surface-3); border-radius: 5px; padding: 1px 7px;
  cursor: pointer; border: 1px solid transparent;
}
.file-card .dur:hover { border-color: var(--border-strong); color: var(--text); }
.file-card .fsize { font-size: 11px; color: var(--text-faint); }
.file-card .rowactions { margin-left: auto; display: flex; gap: 2px; }
.file-card .rowactions .mob-move { display: none; }
.file-card .rowactions .mob-move:disabled { opacity: .3; pointer-events: none; }
.file-card .rowactions button {
  background: none; border: none; cursor: pointer; color: var(--text-faint);
  padding: 3px; border-radius: 5px; display: grid; place-items: center;
}
.file-card .rowactions button:hover { color: var(--text); background: var(--surface-3); }
.file-card .rowactions button.del:hover { color: var(--danger); background: var(--danger-soft); }
.file-card .rowactions svg { width: 14px; height: 14px; }

/* upload dropzone */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 26px 20px;
  text-align: center; color: var(--text-faint);
  transition: border-color .15s, background .15s;
  cursor: pointer;
  margin-bottom: 16px;
  font-size: 13px;
}
.dropzone svg { width: 26px; height: 26px; margin-bottom: 6px; opacity: .7; }
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text-muted); }
.dropzone .strong { color: var(--text); font-weight: 600; }
.upload-progress { height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: -6px 0 16px; }
.upload-progress > div { height: 100%; background: var(--grad); width: 0; transition: width .2s; }

/* activity log */
.log-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.log-list { font-family: var(--mono); font-size: 12px; }
.log-row {
  display: flex; gap: 10px; padding: 5px 16px;
  border-bottom: 1px solid rgba(35,42,59,.5);
  align-items: baseline;
}
.log-row:hover { background: var(--surface-2); }
.log-ts { color: var(--text-faint); flex-shrink: 0; font-size: 11px; }
.log-folder { color: var(--cyan); flex-shrink: 0; font-size: 11px; min-width: 90px; }
.log-msg { word-break: break-word; color: var(--text-muted); }
.log-row.warn .log-msg { color: var(--warn); }
.log-row.error .log-msg { color: var(--danger); }
.log-lvl { flex-shrink: 0; width: 46px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.log-row.info .log-lvl { color: var(--text-faint); }
.log-row.warn .log-lvl { color: var(--warn); }
.log-row.error .log-lvl { color: var(--danger); }

/* error banners */
.error-file {
  background: var(--danger-soft);
  border: 1px solid rgba(248,113,113,.3);
  border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px;
  display: flex; gap: 10px; align-items: flex-start;
}
.error-file svg { width: 17px; height: 17px; color: var(--danger); flex-shrink: 0; margin-top: 1px; }
.error-file .ename { font-weight: 650; font-size: 13px; color: var(--danger); }
.error-file .ebody { font-size: 12px; color: var(--text-muted); margin-top: 3px; white-space: pre-wrap; font-family: var(--mono); max-height: 130px; overflow-y: auto; }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5,7,12,.72); backdrop-filter: blur(3px);
  /* flex, not grid: a centred grid item sizes its implicit column to the
     modal's 440px, so max-width:100% resolves against 440 and the dialog
     overflows narrow phones. Flex resolves it against the viewport. */
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .12s ease-out;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  width: 440px; max-width: 100%;
  max-height: 90vh; overflow-y: auto;
  animation: popIn .14s ease-out;
}
.modal.wide { width: 620px; }
.modal-header { padding: 16px 20px 0; }
.modal-header h3 { font-size: 15.5px; font-weight: 650; }
.modal-header .sub { color: var(--text-faint); font-size: 12.5px; margin-top: 2px; }
.modal-body { padding: 16px 20px; }
.modal-foot { padding: 0 20px 18px; display: flex; gap: 9px; justify-content: flex-end; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(6px); } }

/* toasts */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 9px; max-width: 360px; }
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
  padding: 11px 14px;
  font-size: 13px; font-weight: 500;
  display: flex; gap: 9px; align-items: flex-start;
  animation: toastIn .18s ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.toast.success svg { color: var(--success); }
.toast.error svg { color: var(--danger); }
.toast.leaving { opacity: 0; transform: translateX(12px); transition: all .2s; }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } }

/* misc */
.empty { text-align: center; padding: 48px 20px; color: var(--text-faint); }
.empty svg { width: 34px; height: 34px; margin-bottom: 10px; opacity: .5; }
.empty .t { font-weight: 600; color: var(--text-muted); margin-bottom: 3px; }
.spinner {
  width: 18px; height: 18px; flex-shrink: 0;
  border: 2px solid var(--surface-3); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-view { display: grid; place-items: center; padding: 80px 0; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--mono); }
.mb0 { margin-bottom: 0; }
.section-gap { height: 8px; }
.inline-note { font-size: 12px; color: var(--text-faint); display: flex; align-items: center; gap: 6px; }
.inline-note svg { width: 13px; height: 13px; flex-shrink: 0; }

/* split side tabs */
.side-tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.side-tabs button {
  background: none; border: none; color: var(--text-muted); font-weight: 600; font-size: 12.5px;
  font-family: inherit; padding: 5px 14px; border-radius: 5px; cursor: pointer;
}
.side-tabs button.active { background: var(--accent); color: #fff; }

/* Poster builder */
.poster-grid { display: grid; grid-template-columns: 1fr 1.15fr; gap: 20px; align-items: start; }
.tpl-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.tpl-picker button {
  padding: 7px 12px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 600;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
  cursor: pointer; transition: all .15s;
}
.tpl-picker button:hover { color: var(--text); border-color: var(--border-strong); }
.tpl-picker button.active { background: var(--primary-soft); color: var(--primary-bright); border-color: var(--primary); }
.poster-canvas {
  position: relative; width: 100%; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border); /* font-size set from JS to 2.2% of width */
}
input[type="color"].input { padding: 4px; height: 38px; cursor: pointer; }
.lib-strip { display: flex; gap: 7px; flex-wrap: wrap; }
.lib-strip button {
  width: 74px; height: 46px; padding: 0; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-2); border: 2px solid var(--border); cursor: pointer;
  color: var(--text-faint); font-size: 11.5px; font-weight: 600;
}
.lib-strip button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-strip button:hover { border-color: var(--border-strong); }
.lib-strip button.active { border-color: var(--primary); }

/* Screen groups */
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.group-card .card-body { display: flex; flex-direction: column; gap: 10px; }
.grow-k { font-size: 11px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.grow-v { display: flex; gap: 5px; flex-wrap: wrap; font-size: 12.5px; }
.pl-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.pl-chip {
  padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
}
.pl-chip:hover { border-color: var(--border-strong); color: var(--text); }
.pl-chip.on { background: var(--primary-soft); color: var(--primary-bright); border-color: var(--primary); }

/* Playlist editor */
.pl-toolbar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.pl-item {
  display: flex; gap: 10px; align-items: center; padding: 8px 11px; margin-bottom: 6px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; cursor: grab;
}
.pl-item.dragging { opacity: .45; }
.pl-item[draggable="false"] { cursor: default; }
.pl-num { min-width: 22px; color: var(--text-faint); font-size: 12px; font-weight: 600; }
.pl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-dur { display: inline-flex; gap: 5px; align-items: center; color: var(--text-muted); font-size: 12px; cursor: pointer; }
.pl-dur:hover { color: var(--primary-bright); }
.pl-dur svg { width: 13px; height: 13px; }
.pl-picker-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 380px; overflow-y: auto; }
.pl-pick {
  display: flex; flex-direction: column; gap: 6px; align-items: center; padding: 8px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-muted); font-size: 11px; text-align: center; overflow: hidden;
}
.pl-pick img { width: 100%; height: 70px; object-fit: cover; border-radius: 3px; }
.pl-pick-icon svg { width: 26px; height: 26px; }
.pl-pick span { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-pick:hover { border-color: var(--border-strong); color: var(--text); }
.pl-pick.added { border-color: var(--success); color: var(--success); }

/* Media library */
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.asset-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.asset-thumb { height: 110px; flex-shrink: 0; background: #05070f; display: flex; align-items: center; justify-content: center; color: var(--text-faint); }
.asset-thumb img { width: 100%; height: 100%; object-fit: cover; }
.asset-thumb svg { width: 30px; height: 30px; }
.asset-meta { display: flex; gap: 8px; align-items: center; padding: 8px 10px; margin-top: auto; }
.asset-name { flex: 1; min-width: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-tags { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 10px 0; }
.asset-tags:empty { display: none; }
.asset-tags .badge { font-size: 10px; padding: 1px 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Label chips (asset categories) */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  font: inherit; font-size: 12px; line-height: 1; padding: 6px 11px; border-radius: 999px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); transition: all .12s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.on { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: var(--accent); color: var(--accent); }
.list-compact { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.list-compact .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 2px; border-bottom: 1px solid var(--border); }
.list-compact .row:last-child { border-bottom: 0; }

/* Layout templates */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.tpl-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: border-color .15s; }
.tpl-card:hover { border-color: var(--border-strong); }
.tpl-preview { min-height: 110px; background: #05070f; display: flex; align-items: center; justify-content: center; padding: 10px; }
/* Height-driven so portrait templates render tall and narrow instead of being
   squashed into a landscape box (aspect-ratio + max-height keeps the width). */
.tpl-mini { position: relative; height: 118px; width: auto; max-width: 100%; background: #0a0d1a; border-radius: 3px; }
.tpl-meta { display: flex; gap: 8px; align-items: center; padding: 10px 12px; }
.tpl-name { flex: 1; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lt-toolbar { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.lt-add {
  padding: 5px 11px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; cursor: pointer;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
}
.lt-add.used { background: color-mix(in srgb, var(--zc) 18%, transparent); color: var(--text); border-color: var(--zc); }
#lt-canvas-wrap { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; }
/* Exact pixel size is set from JS so the ratio always holds — portrait
   layouts must render tall, not squashed into the available width. */
#lt-canvas {
  position: relative; margin: 0 auto; background: #05070f;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 10% 10%; border-radius: 3px; touch-action: none;
}
.lt-zone {
  position: absolute; border: 2px solid var(--zc); background: color-mix(in srgb, var(--zc) 20%, transparent);
  border-radius: 3px; cursor: move; user-select: none;
}
.lt-zone .lt-label { position: absolute; top: 4px; left: 7px; font-size: 12px; font-weight: 700; color: var(--zc); pointer-events: none; }
.lt-zone .lt-remove {
  position: absolute; top: 2px; right: 4px; background: none; border: none; color: var(--text-faint);
  font-size: 15px; cursor: pointer; line-height: 1; padding: 2px;
}
.lt-zone .lt-remove:hover { color: var(--danger); }
.lt-zone .lt-handle {
  position: absolute; right: -1px; bottom: -1px; width: 14px; height: 14px; cursor: nwse-resize;
  background: var(--zc); border-radius: 3px 0 3px 0; opacity: .85;
}
.lt-tickerbar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 7%; min-height: 16px;
  background: rgba(255,255,255,.12); border-top: 1px dashed var(--text-faint);
  color: var(--text-faint); font-size: 11px; text-align: center; pointer-events: none;
}

/* Maintenance runner */
.mt-confirm {
  display: flex; gap: 12px; align-items: center; margin-bottom: 12px;
  padding: 11px 13px; border-radius: var(--radius-sm); font-size: 13px;
  background: var(--primary-soft); border: 1px solid var(--primary);
}
.mt-confirm.danger { background: var(--danger-soft); border-color: var(--danger); }
.mt-row { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); padding: 10px 12px; margin-bottom: 8px; }
.mt-head { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.mt-out {
  margin: 8px 0 0; padding: 8px 10px; max-height: 220px; overflow: auto;
  background: #05070f; border-radius: 3px; font-size: 11.5px; line-height: 1.5;
  color: var(--text-muted); white-space: pre-wrap; word-break: break-word;
}

/* Player screenshots */
.player-card .pshot {
  position: relative; aspect-ratio: 16/9; background: #05070f; cursor: pointer;
  border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
}
.player-card .pshot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.player-card .pshot .pshot-hint { color: var(--text-faint); font-size: 12px; display: flex; gap: 7px; align-items: center; z-index: 1; }
.player-card .pshot:hover .pshot-hint { color: var(--text-muted); }
.player-card .pshot svg { width: 15px; height: 15px; }

/* Emergency banner */
.em-banner {
  display: flex; gap: 12px; align-items: center; margin-bottom: 16px;
  padding: 12px 16px; border-radius: var(--radius); font-size: 13.5px;
  background: var(--danger-soft); border: 1px solid var(--danger); color: var(--text);
}
.em-banner svg { width: 18px; height: 18px; color: var(--danger); flex-shrink: 0; }

/* Native scheduling */
.sched-group { padding: 13px 15px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: 12px; }
.sched-gname { display: flex; gap: 8px; align-items: center; font-size: 13.5px; margin-bottom: 12px; }
.sched-gname svg { width: 16px; height: 16px; color: var(--text-muted); }
.sched-group .field label.switch {
  display: inline-flex; align-items: center; gap: 8px; width: auto;
  font-size: 12.5px; font-weight: 600; color: var(--text-muted); text-transform: none; letter-spacing: 0;
}

/* Web streams */
.stream-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.stream-row {
  display: flex; gap: 12px; align-items: center; text-align: left; width: 100%;
  padding: 11px 13px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.stream-row:hover { border-color: var(--border-strong); }
.stream-row.active { border-color: var(--primary); background: var(--primary-soft); }
.stream-row .s-main { flex: 1; min-width: 0; }
.stream-row .s-title { font-weight: 600; font-size: 13.5px; display: flex; gap: 8px; align-items: center; }
.stream-row .s-desc { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.stream-row .s-url { color: var(--text-faint); font-size: 11px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stream-row .s-dur { color: var(--text-faint); font-size: 12px; flex-shrink: 0; }

/* Web streams page — rendered page previews */
.stream-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.stream-card { display: flex; flex-direction: column; overflow: hidden; }
.stream-shot {
  aspect-ratio: 16 / 9; background: #05070f; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.stream-shot.portrait { aspect-ratio: 4 / 3; }
.stream-shot img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.stream-shot.portrait img { object-fit: contain; }
.shot-none { display: flex; flex-direction: column; align-items: center; gap: 7px; color: var(--text-faint); font-size: 12px; }
.shot-none svg { width: 24px; height: 24px; }
.stream-card .card-body { flex: 1; }
.stream-title { font-weight: 600; font-size: 13.5px; display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.stream-desc { color: var(--text-muted); font-size: 12.5px; margin-top: 4px; }
.stream-url { color: var(--text-faint); font-size: 11px; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) {
  .poster-grid { grid-template-columns: 1fr; }
}

/* README editor */
.readme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pane-label { font-size: 11px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 7px; }
.readme-grid textarea { height: 560px; resize: vertical; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
.md-preview {
  height: 560px; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 18px; font-size: 13.5px;
}
.md-preview h1, .md-preview h2, .md-preview h3 { margin: 14px 0 8px; line-height: 1.3; }
.md-preview h1:first-child { margin-top: 0; }
.md-preview p, .md-preview ul, .md-preview ol { margin-bottom: 10px; }
.md-preview ul, .md-preview ol { padding-left: 22px; }
.md-preview code { background: var(--surface-3); border-radius: 4px; padding: 1px 5px; font-family: var(--mono); font-size: 12px; }
.md-preview pre { background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: 12px; overflow-x: auto; margin-bottom: 10px; }
.md-preview pre code { background: none; padding: 0; }
.md-preview table { border-collapse: collapse; margin-bottom: 10px; }
.md-preview th, .md-preview td { border: 1px solid var(--border-strong); padding: 5px 10px; font-size: 12.5px; }
.md-preview hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.md-preview blockquote { border-left: 3px solid var(--border-strong); padding-left: 12px; color: var(--text-muted); }

/* player cards */
.player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.player-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.player-card .ph { display: flex; align-items: center; gap: 10px; padding: 13px 15px; border-bottom: 1px solid var(--border); }
.player-card .ph .pname { font-weight: 650; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-card .ph .badge { margin-left: auto; }
.player-card .pb { padding: 11px 15px; display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; }
.player-card .prow { display: flex; justify-content: space-between; gap: 10px; }
.player-card .prow .k { color: var(--text-faint); }
.player-card .prow .v { color: var(--text-muted); font-weight: 500; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* card footer — player, group and stream cards all end in one */
.pf { padding: 10px 12px; border-top: 1px solid var(--border); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* login screen */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; position: relative; z-index: 1; }
.login-card {
  width: 380px; max-width: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-pop);
  padding: 34px 32px 30px;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 26px; text-align: center; }
.login-brand .brand-mark { width: 52px; height: 52px; border-radius: 14px; }
.login-brand .brand-mark svg { width: 26px; height: 26px; }
.login-brand h1 { font-size: 19px; font-weight: 700; }
.login-brand p { font-size: 12.5px; color: var(--text-faint); margin-top: -6px; }
.login-error {
  background: var(--danger-soft); border: 1px solid rgba(248,113,113,.3);
  color: var(--danger); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 12.5px; margin-bottom: 14px;
}

/* folder table niceties */
.folder-name-cell { display: flex; align-items: center; gap: 10px; }
.folder-name-cell .ficon { width: 32px; height: 32px; border-radius: 8px; background: var(--accent-soft); color: #a5a8ff; display: grid; place-items: center; flex-shrink: 0; }
.folder-name-cell .ficon svg { width: 16px; height: 16px; }
.folder-name-cell .fmain { font-weight: 650; }
.folder-name-cell .fsub { font-size: 11.5px; color: var(--text-faint); }
.clickable { cursor: pointer; }

/* watcher queue chips */
.queue-chip { display: inline-flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: 12px; color: var(--text-muted); }
.queue-chip b { color: var(--text); }

/* responsive */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; z-index: 90; left: 0; top: 0;
    transform: translateX(-100%); transition: transform .2s ease-out;
    box-shadow: var(--shadow-pop);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: inline-flex; }
  .content { padding: 18px 16px 60px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; row-gap: 10px; }
  .topbar h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .topbar-actions { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .form-row, .form-row-3, .readme-grid { grid-template-columns: 1fr; }
  .readme-grid textarea, .md-preview { height: 380px; }
  .hide-sm { display: none; }
  .file-card .rowactions .mob-move { display: inline-flex; }
}
.scrim { display: none; }
@media (max-width: 900px) {
  .scrim.show { display: block; position: fixed; inset: 0; z-index: 80; background: rgba(5,7,12,.6); }
}
