/* ═══════════════════════════════════════════════════════════════════════════
   NIRA SOFTWARE — Design System v3.0
   Professional dark theme
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Google Fonts ────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  /* Accent */
  --color-primary:       #6366f1;
  --color-primary-hover: #4f52d9;
  --color-primary-muted: rgba(99,102,241,.1);
  --color-primary-glow:  rgba(99,102,241,.18);

  --color-success:       #22c55e;
  --color-success-hover: #16a34a;
  --color-success-muted: rgba(34,197,94,.1);

  --color-danger:        #ef4444;
  --color-danger-hover:  #dc2626;
  --color-danger-muted:  rgba(239,68,68,.1);

  --color-warning:       #f59e0b;
  --color-warning-muted: rgba(245,158,11,.1);

  /* Surfaces */
  --bg-body:   transparent;
  --bg-base:   rgba(10,10,18,.97);
  --bg-raised: rgba(14,14,22,.97);
  --bg-inset:  rgba(7,7,14,.97);
  --bg-hover:  rgba(20,20,32,.97);

  /* Text */
  --text-primary:   #dde1f0;
  --text-secondary: #6b6f88;
  --text-tertiary:  #3e415c;

  /* Borders */
  --border-default: #1c1c2e;
  --border-subtle:  #141422;
  --border-strong:  #272740;

  /* Radius — tighter, more refined */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,.45);
  --shadow-lg: 0 8px 28px rgba(0,0,0,.55);

  /* Motion */
  --ease-out:    cubic-bezier(.2,0,0,1);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --duration-fast:   .12s;
  --duration-normal: .2s;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;

  /* Z-index layers */
  --z-sticky:  100;
  --z-overlay: 500;
  --z-modal:   1000;
  --z-toast:   2000;

  color-scheme: dark;

  /* Compat aliases */
  --accent:     var(--color-primary);
  --accent-600: var(--color-primary-hover);
  --bg:         var(--bg-body);
  --panel:      var(--bg-raised);
  --panel-2:    var(--bg-inset);
  --text:       var(--text-primary);
  --muted:      var(--text-secondary);
  --border:     var(--border-default);
  --success:    var(--color-success);
  --danger:     var(--color-danger);
}

/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-body);
  min-height: 100vh;
}

/* Background — minimal, clean */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 70% 50% at 50% -5%, rgba(99,102,241,.04) 0%, transparent 55%),
    url('/static/bg.jpg') center / cover no-repeat fixed;
  pointer-events: none;
}

/* ── Stars Background ───────────────────────────────────────────────────── */
.stars {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  opacity: .07;
  animation: twinkle var(--d, 4s) ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: .07; }
  50%       { opacity: .25; }
}

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a58; }

/* ── Typography ─────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -.015em;
}

h1 {
  font-size: 1.45rem;
  color: var(--text-primary);
  letter-spacing: -.025em;
}

h1::after { display: none; }

h2 { font-size: 1.05rem; color: var(--text-primary); }
h3 { font-size: .95rem;  color: var(--text-primary); }

code {
  font-family: var(--font-mono);
  font-size: .85em;
  padding: 2px 6px;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--color-primary);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}
a:hover { color: var(--color-primary-hover); }

small, .muted { color: var(--text-secondary); }

/* ── Layout Containers ──────────────────────────────────────────────────── */

/* Top navigation bar */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: rgba(10,10,18,.92);
  backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border-subtle);
}

.nav-bar .nav-brand {
  font-weight: 700;
  font-size: .75rem;
  color: var(--text-tertiary);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.nav-bar .nav-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--duration-fast) var(--ease-out);
}
.nav-bar .nav-back:hover { color: var(--text-primary); }

.nav-bar .nav-spacer { flex: 1; }

.nav-bar .nav-title {
  font-weight: 600;
  font-size: .88rem;
  color: var(--text-primary);
}

/* Page wrappers */
.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.page-narrow {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px;
}

/* Centered screen */
.centered-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

/* Card / Panel */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: 16px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.card-header h2 { margin: 0; }
.card-header h2::after { display: none; }
.card-header h3 { margin: 0; }
.card-header h3::after { display: none; }

/* Dashboard grid */
.dashboard-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.dashboard-card {
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
}

.dashboard-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.dashboard-card h2 { margin: 0; font-size: .98rem; }
.dashboard-card h2::after { display: none; }

.dashboard-card p {
  color: var(--text-secondary);
  font-size: .85rem;
  margin: 0;
  flex: 1;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: .82rem;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              opacity var(--duration-fast) var(--ease-out);
}
.btn:active { opacity: .82; }
.btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* Primary */
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

/* Success */
.btn-success {
  background: var(--color-success);
  color: #fff;
  border-color: var(--color-success);
}
.btn-success:hover {
  background: var(--color-success-hover);
  border-color: var(--color-success-hover);
}

/* Danger */
.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn-danger:hover {
  background: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}

/* Secondary */
.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Small */
.btn-sm { padding: 4px 9px; font-size: .76rem; }

/* Icon button */
.btn-icon { padding: 6px; min-width: 30px; min-height: 30px; }

/* Disabled */
.btn:disabled, .btn[disabled] {
  opacity: .38;
  pointer-events: none;
}

/* ── Form Elements ──────────────────────────────────────────────────────── */
label {
  display: block;
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
  letter-spacing: .01em;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="search"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: .85rem;
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

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

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-muted);
}

/* Range slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border-strong);
  border: none;
  border-radius: 99px;
  padding: 0;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--bg-base);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-spring);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--bg-base);
  cursor: pointer;
}

/* Checkbox */
input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}

input[type="checkbox"]:checked {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

input[type="checkbox"]:checked::after {
  content: '✓';
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

/* Radio */
input[type="radio"] {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}

input[type="radio"]:checked {
  border-color: var(--color-primary);
}

input[type="radio"]:checked::after {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-primary);
}

/* Form groups */
.form-group { margin-bottom: 16px; }
.form-group > label { margin-bottom: 5px; }

.form-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.form-row > * { flex: 1; min-width: 0; }

.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.actions-end {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ── Table ──────────────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

th {
  background: var(--bg-inset);
  font-weight: 600;
  font-size: .72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.015); }

.actions-cell {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Badges & Tags ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 600;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  letter-spacing: .02em;
}

.badge-primary { background: var(--color-primary-muted); color: var(--color-primary); border-color: transparent; }
.badge-success { background: var(--color-success-muted); color: var(--color-success); border-color: transparent; }
.badge-danger  { background: var(--color-danger-muted);  color: var(--color-danger);  border-color: transparent; }
.badge-warning { background: var(--color-warning-muted); color: var(--color-warning); border-color: transparent; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: .75rem;
  font-weight: 600;
  background: var(--color-primary-muted);
  color: var(--color-primary);
}

.tag-warn {
  background: var(--color-danger-muted);
  color: var(--color-danger);
}

/* ── Toast / Notification ───────────────────────────────────────────────── */
.toast-host {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--color-primary);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: .84rem;
  pointer-events: auto;
  animation: toast-in .2s var(--ease-out) forwards;
}

.toast.error, .toast--err { border-left-color: var(--color-danger); }
.toast.success { border-left-color: var(--color-success); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.notification {
  position: fixed;
  top: 14px;
  right: 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  padding: 9px 14px;
  border-radius: var(--radius-md);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .18s var(--ease-out), transform .18s var(--ease-out);
  z-index: var(--z-toast);
  font-size: .84rem;
  box-shadow: var(--shadow-md);
}
.notification.show { opacity: 1; transform: translateY(0); }

/* ── Modal / Overlay ────────────────────────────────────────────────────── */
.modal, .overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
}

.modal.active, .overlay.open { display: flex; }

.modal-card, .panel {
  width: min(560px, 92vw);
  max-height: 88vh;
  overflow: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  animation: modal-enter .2s var(--ease-out) forwards;
}

@keyframes modal-enter {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 { margin: 0; font-size: 1rem; }
.modal-header h3::after { display: none; }

.modal-close {
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 16px;
  cursor: pointer;
  transition: color var(--duration-fast), background var(--duration-fast);
}
.modal-close:hover { color: var(--color-danger); background: var(--color-danger-muted); }

.modal-footer, .actions-panel {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

/* ── Progress Bar ───────────────────────────────────────────────────────── */
.progress {
  height: 4px;
  width: 100%;
  background: var(--bg-inset);
  border-radius: 99px;
  overflow: hidden;
}

.progress .bar {
  height: 100%;
  width: 0%;
  background: var(--color-primary);
  transition: width .3s var(--ease-out);
  border-radius: 99px;
}

/* ── Status Indicators ──────────────────────────────────────────────────── */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
  flex-shrink: 0;
}
.status-dot.connected    { background: var(--color-success); box-shadow: 0 0 5px rgba(34,197,94,.35); }
.status-dot.disconnected { background: var(--color-danger); }

.ok  { color: var(--color-success); font-weight: 600; }
.err { color: var(--color-danger);  font-weight: 600; }

/* ── Error message ──────────────────────────────────────────────────────── */
.error {
  background: var(--color-danger-muted);
  color: var(--color-danger);
  border: 1px solid rgba(239,68,68,.18);
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: .84rem;
  margin-bottom: 12px;
}

/* ── Dropzone ───────────────────────────────────────────────────────────── */
.dropzone {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 22px;
  text-align: center;
  color: var(--text-secondary);
  font-size: .84rem;
  transition: border-color var(--duration-fast), background var(--duration-fast);
  margin-top: 10px;
}
.dropzone.drag {
  border-color: var(--color-primary);
  background: var(--color-primary-muted);
  color: var(--color-primary);
}

/* ── Password toggle ────────────────────────────────────────────────────── */
.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 40px; }
.toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 14px;
  user-select: none;
  opacity: .45;
  transition: opacity var(--duration-fast);
}
.toggle-password:hover { opacity: .85; }

/* Remember checkbox */
.remember-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .84rem;
  color: var(--text-secondary);
  cursor: pointer;
}
.remember-wrapper input { margin: 0; }

/* ── Container (legacy compat) ──────────────────────────────────────────── */
.container {
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

/* ── Permissions ────────────────────────────────────────────────────────── */
details summary { list-style: none; }
details summary::-webkit-details-marker { display: none; }
details > summary.btn { display: inline-flex; }

.perm-box {
  margin-top: 8px;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  padding: 12px;
  border-radius: var(--radius-md);
  max-width: 500px;
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px 14px;
  margin-bottom: 10px;
}

.perm-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .84rem;
  color: var(--text-primary);
  cursor: pointer;
}

.perm-actions { display: flex; gap: 6px; }

/* ── Video Management ───────────────────────────────────────────────────── */
body[data-ui="files"] { padding: 20px; }

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.video-card {
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
}

.video-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.thumb-container {
  aspect-ratio: 16/9;
  background: #000;
  overflow: hidden;
}

.thumb { width: 100%; height: 100%; object-fit: cover; }
.thumb.loading { opacity: .3; }
.mpv-thumb.loading { opacity: .3; }

.video-card .card-body { padding: 12px; }

.video-card .info h4 {
  margin: 0 0 3px;
  font-size: .88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-card .info p {
  margin: 0;
  font-size: .76rem;
  color: var(--text-secondary);
}

.video-card .actions {
  margin-top: 8px;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.video-card .actions button {
  font-family: var(--font-sans);
  padding: 4px 9px;
  font-size: .74rem;
  font-weight: 500;
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast);
}

.video-card .actions button:hover {
  background: var(--color-primary-muted);
  border-color: rgba(99,102,241,.25);
  color: var(--color-primary);
}

/* Upload form */
#uploadForm {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 14px;
}

#uploadForm button { font-family: var(--font-sans); }

#progressBarContainer {
  display: none;
  height: 4px;
  width: 100%;
  background: var(--bg-inset);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 10px;
}

#progressBar {
  height: 100%;
  width: 0%;
  background: var(--color-primary);
  transition: width .3s var(--ease-out);
}

/* Video preview modal */
#previewModal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
}

#previewModal .modal-content { max-width: 90vw; max-height: 90vh; }

#previewModal .modal-header {
  display: flex;
  justify-content: flex-end;
  padding: 0;
  border: none;
  margin-bottom: 8px;
}

.close-modal {
  font-size: 22px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--duration-fast);
}
.close-modal:hover { color: var(--text-primary); }

.video-preview {
  max-width: 80vw;
  max-height: 80vh;
  border-radius: var(--radius-md);
}

#storageInfo { color: var(--text-secondary); font-size: .84rem; margin-top: 6px; }

/* ── Screenshot Container (menu) ────────────────────────────────────────── */
.main-wrapper {
  display: grid;
  gap: 16px;
  grid-template-columns: 320px 1fr;
  max-width: 1400px;
  width: 100%;
  align-items: flex-start;
}

/* ── Editor Page ────────────────────────────────────────────────────────── */
.editor-page {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

#preview-container {
  flex: 1;
  overflow: auto;
  background: var(--bg-body);
  position: relative;
}

#preview-wrapper {
  transform-origin: center center;
  position: relative;
  margin: auto;
}

#preview {
  position: relative;
  background: repeating-conic-gradient(rgba(255,255,255,.015) 0% 25%, transparent 0% 50%) 0 0 / 20px 20px;
  border: 1px solid var(--border-default);
  overflow: hidden;
}

.preview-box {
  position: absolute;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
  background: rgba(99,102,241,.06);
  cursor: move;
  transition: border-color var(--duration-fast);
}

.preview-box.selected { border-color: #fff; background: rgba(255,255,255,.06); }

.box-info {
  position: absolute;
  bottom: 3px;
  left: 3px;
  right: 3px;
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  font-family: var(--font-mono);
  color: rgba(255,255,255,.5);
  background: rgba(0,0,0,.55);
  padding: 2px 5px;
  border-radius: 3px;
}

#editor-panel {
  width: 320px;
  min-width: 320px;
  height: 100vh;
  background: var(--bg-raised);
  border-left: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.panel-header h2 { font-size: 1rem; margin: 0; }
.panel-header h2::after { display: none; }

.panel-title { display: flex; align-items: center; justify-content: space-between; }

.live-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .8rem;
  margin-top: 7px;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  font-size: .72rem;
  font-weight: 600;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  transition: background var(--duration-fast);
}
.dot.on { background: var(--color-success); animation: pulse 2s infinite; }
.dot.saving { background: var(--color-warning); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,.35); }
  50%       { box-shadow: 0 0 0 3px rgba(34,197,94,.08); }
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
}

.panel-content h3 { font-size: .84rem; margin-bottom: 7px; color: var(--text-secondary); }
.panel-content h3::after { display: none; }

.empty-message {
  color: var(--text-tertiary);
  text-align: center;
  padding: 22px;
  font-size: .84rem;
}

#box-list { list-style: none; padding: 0; margin: 8px 0; }

#box-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: .83rem;
  transition: background var(--duration-fast);
}

#box-list li:hover { background: var(--bg-hover); }
#box-list li.selected { background: var(--color-primary-muted); color: var(--color-primary); }

/* Zoom controls */
.zoom-controls {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 3px;
  box-shadow: var(--shadow-md);
  z-index: var(--z-sticky);
}

.zoom-btn {
  padding: 5px 10px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 600;
  transition: background var(--duration-fast);
}
.zoom-btn:hover { background: var(--bg-hover); }

/* Snap controls */
.snap-controls {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  gap: 2px;
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 3px;
  box-shadow: var(--shadow-md);
  z-index: var(--z-sticky);
}

.snap-btn {
  padding: 5px 10px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: .76rem;
  font-weight: 500;
  transition: all var(--duration-fast);
}
.snap-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.snap-btn.active { background: var(--color-primary-muted); color: var(--color-primary); }

/* Snap guides */
.snap-guide {
  position: absolute;
  background: var(--color-primary);
  opacity: .35;
  z-index: 10;
  pointer-events: none;
}

/* ── Calendar Page ──────────────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.main { display: flex; gap: 16px; align-items: flex-start; }

#calendar { flex: 1; min-width: 0; }

.palinsesti-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 7px;
}

.palinsesto-item {
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 9px 11px;
  transition: border-color var(--duration-fast);
}

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

.palinsesto-name {
  font-weight: 500;
  font-size: .84rem;
  cursor: grab;
  display: block;
  margin-bottom: 5px;
}

.palinsesto-actions { display: flex; gap: 5px; }

.btn-xs {
  padding: 2px 7px;
  font-size: .7rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.btn-xs:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger-xs { color: var(--color-danger); border-color: rgba(239,68,68,.18); }
.btn-danger-xs:hover { background: var(--color-danger-muted); color: var(--color-danger); }

.overlay .panel { width: min(460px, 92vw); }

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 7px 0 14px;
}

.radio-group .option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .84rem;
  cursor: pointer;
  color: var(--text-primary);
}

.row { display: flex; gap: 10px; margin: 10px 0; }
.col { flex: 1; }

/* ── FullCalendar Dark Theme Override ───────────────────────────────────── */
.fc {
  --fc-border-color:           var(--border-default);
  --fc-page-bg-color:          var(--bg-raised);
  --fc-neutral-bg-color:       var(--bg-inset);
  --fc-neutral-text-color:     var(--text-secondary);
  --fc-today-bg-color:         rgba(99,102,241,.05);
  --fc-event-bg-color:         var(--color-primary);
  --fc-event-border-color:     var(--color-primary-hover);
  --fc-event-text-color:       #fff;
  --fc-button-bg-color:        var(--bg-inset);
  --fc-button-border-color:    var(--border-default);
  --fc-button-text-color:      var(--text-primary);
  --fc-button-hover-bg-color:  var(--bg-hover);
  --fc-button-hover-border-color: var(--border-strong);
  --fc-button-active-bg-color: var(--color-primary-muted);
  --fc-button-active-border-color: var(--color-primary);
}

.fc .fc-toolbar-title { font-size: 1.05rem; font-weight: 600; }
.fc .fc-button { border-radius: var(--radius-sm); font-family: var(--font-sans); font-size: .8rem; font-weight: 500; }
.fc .fc-daygrid-day-number { font-size: .8rem; padding: 3px 7px; color: var(--text-secondary); }
.fc th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }

/* ── Audio Page ─────────────────────────────────────────────────────────── */
.audio-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 10px 0;
}

.audio-row label { min-width: 90px; }

.vb-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

/* ── Monitor Config ─────────────────────────────────────────────────────── */
.monitor-card {
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.monitor-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: .95rem;
}
.monitor-card h3::after { display: none; }

.monitor-card label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

.monitor-card select { width: 100%; }

#screen-layout {
  width: 100%;
  height: 180px;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  margin: 14px 0;
}

#monitors {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.warning {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--color-warning);
  font-size: .82rem;
  padding: 7px 11px;
  background: var(--color-warning-muted);
  border-radius: var(--radius-sm);
}

.toast#toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: var(--z-toast);
}

.toast .t {
  padding: 9px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: .82rem;
  margin-bottom: 5px;
  transition: opacity .25s, transform .25s;
}
.toast .t.ok  { border-left: 2px solid var(--color-success); }
.toast .t.err { border-left: 2px solid var(--color-danger); }

/* ── Palinsesti ─────────────────────────────────────────────────────────── */
.timeline {
  margin: 14px 0;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-raised);
}

.timeline__head {
  background: var(--bg-raised);
  color: var(--text-primary);
  padding: 9px 13px;
  font-weight: 600;
  font-size: .86rem;
  border-bottom: 1px solid var(--border-default);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.timeline__body {
  padding: 12px;
  background: var(--bg-inset);
  position: relative;
  touch-action: none;
}

.ruler {
  height: 28px;
  background: rgba(99,102,241,.06);
  position: relative;
  border: 1px solid rgba(99,102,241,.14);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}

.tick {
  position: absolute;
  bottom: 0;
  height: 18px;
  border-left: 1px solid rgba(99,102,241,.2);
  font-size: 10px;
  padding-left: 5px;
  white-space: nowrap;
  color: var(--text-tertiary);
  display: flex;
  align-items: flex-end;
  font-family: var(--font-mono);
}

.tick--right {
  left: auto;
  right: 0;
  border-left: none;
  border-right: 1px solid rgba(99,102,241,.2);
  padding-left: 0;
  padding-right: 5px;
  text-align: right;
}

.lane {
  position: relative;
  height: 50px;
  margin-top: 7px;
}

.item {
  position: absolute;
  inset-block: 0;
  background: rgba(99,102,241,.75);
  border: 1px solid rgba(99,102,241,.5);
  border-radius: var(--radius-md);
  padding: 5px 8px;
  min-width: 40px;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow-sm);
  will-change: left, width;
  z-index: 1;
  transition: filter var(--duration-fast);
}

.item:hover { filter: brightness(1.1); }
.item.dragging { opacity: .9; box-shadow: var(--shadow-md); }

.item__header { display: flex; justify-content: space-between; align-items: flex-start; margin: -2px -3px 2px; }
.item__delete {
  background: rgba(255,255,255,.18);
  border: none;
  border-radius: 3px;
  color: #fff;
  font-size: 9px;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background var(--duration-fast);
}
.item__delete:hover { background: var(--color-danger); }

.item__content { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.item__time    { font-size: 10px; opacity: .85; font-family: var(--font-mono); color: #fff; }
.item__name    { font-weight: 600; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }

.handle {
  position: absolute;
  top: 0;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
  background: rgba(255,255,255,.06);
  z-index: 2;
  border-radius: var(--radius-md);
}
.handle.left  { left: 0; }
.handle.right { right: 0; }

.hud {
  position: absolute;
  top: -22px;
  transform: translateX(-50%);
  padding: 2px 7px;
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-family: var(--font-mono);
  pointer-events: none;
  box-shadow: var(--shadow-sm);
}

/* Library */
.library {
  margin-top: 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.library__head {
  background: var(--bg-inset);
  color: var(--text-secondary);
  padding: 9px 13px;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border-default);
}

.library__grid {
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  background: var(--bg-inset);
}

.libitem {
  background: transparent;
  padding: 9px 11px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--duration-fast), background var(--duration-fast), color var(--duration-fast);
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.libitem:hover {
  background: var(--color-primary-muted);
  border-color: rgba(99,102,241,.25);
  color: var(--color-primary);
}

/* Palinsesti modal */
.modalCard {
  width: min(560px, 92vw);
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 22px;
  position: relative;
  box-shadow: var(--shadow-lg);
  max-height: 88vh;
  overflow: auto;
}

.modalHeader { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding-bottom: 11px; border-bottom: 1px solid var(--border-subtle); }
.modalTitle  { margin: 0; font-size: .98rem; color: var(--text-primary); }
.modalClose {
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  transition: color var(--duration-fast), background var(--duration-fast);
}
.modalClose:hover { color: var(--color-danger); background: var(--color-danger-muted); }

.modalBody   { margin-bottom: 12px; }
.modalFooter { display: flex; gap: 8px; justify-content: flex-end; }
.modalBtn {
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: .82rem;
}
.modalBtn--primary   { background: var(--color-primary); color: #fff; }
.modalBtn--secondary { background: var(--border-strong); color: var(--text-primary); }

.timeInputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.timeInputGroup { display: flex; flex-direction: column; gap: 5px; }
.timeInputGroup label { font-size: .76rem; color: var(--text-secondary); }

.vbSelection { margin-top: 12px; }
.vbSelectionTitle { margin: 0 0 8px; font-size: .82rem; color: var(--text-secondary); }

.vbCheckboxList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
  max-height: 190px;
  overflow: auto;
  padding: 10px;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.vbCheckboxItem {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .82rem;
}

/* Toast host (palinsesti) */
.toastHost {
  position: fixed;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: var(--z-toast);
}

.toast.show { opacity: 1; transform: translateY(0); }

/* ── Editor Preset Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s var(--ease-out);
}

.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal-overlay .modal-content {
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 22px;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(8px);
  transition: transform .2s var(--ease-out);
  box-shadow: var(--shadow-lg);
}

.modal-overlay.active .modal-content { transform: translateY(0); }

/* Presets */
.presets .input-row { display: flex; gap: 7px; margin-bottom: 14px; }

.preset-list {
  list-style: none;
  padding: 6px;
  margin: 0;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-inset);
}

.preset-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  margin-bottom: 4px;
  background: var(--bg-hover);
  transition: border-color var(--duration-fast);
}

.preset-list li:hover { border-color: var(--border-default); }
.preset-list .meta { opacity: .5; font-size: .74rem; margin-left: 7px; }

.preset-actions { display: flex; gap: 5px; }
.preset-button  { margin-top: 14px; }

/* ── Backup page ────────────────────────────────────────────────────────── */
.hint {
  margin-top: 7px;
  color: var(--text-secondary);
  font-size: .8rem;
}

.out {
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: .8rem;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  padding: 12px;
  border-radius: var(--radius-md);
  margin-top: 10px;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .main-wrapper { grid-template-columns: 1fr; }
  .main { flex-direction: column; }
  .sidebar { width: 100%; min-width: 0; }
  .editor-page { flex-direction: column; height: auto; }
  #editor-panel { width: 100%; min-width: 0; height: auto; border-left: none; border-top: 1px solid var(--border-default); }
  #preview-container { min-height: 50vh; }
}

@media (max-width: 768px) {
  .page, .page-narrow { padding: 14px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .video-grid { grid-template-columns: 1fr; }
  #monitors { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .actions, .actions-end { flex-direction: column; }
  .actions > .btn, .actions-end > .btn { width: 100%; }
  .nav-bar { padding: 10px 14px; }
  .controls { flex-direction: column; }
}

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

/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT EDITOR
   ═══════════════════════════════════════════════════════════════════════════ */

body.editor-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: #07080d;
}
body.editor-page::before { display: none; }

/* Top toolbar */
.ed-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
  z-index: 50;
}

.ed-toolbar .nav-back { font-size: .8rem; color: var(--text-secondary); margin-right: 7px; }
.ed-toolbar .nav-back:hover { color: var(--text-primary); }

.ed-toolbar-title {
  font-weight: 600;
  font-size: .86rem;
  color: var(--text-primary);
  margin-right: auto;
}

.ed-toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border-default);
  margin: 0 3px;
}

.ed-toolbar .tb-group {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 2px;
}

.tb-btn {
  padding: 4px 9px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: .78rem;
  font-weight: 500;
  font-family: var(--font-sans);
  transition: background var(--duration-fast), color var(--duration-fast);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.tb-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tb-btn.active  { background: var(--color-primary-muted); color: var(--color-primary); }
.tb-btn.primary { background: var(--color-primary); color: #fff; }
.tb-btn.primary:hover { background: var(--color-primary-hover); }
.tb-btn.success { background: var(--color-success); color: #fff; }
.tb-btn.success:hover { background: var(--color-success-hover); }
.tb-btn.danger  { background: var(--color-danger-muted); color: var(--color-danger); }
.tb-btn.danger:hover { background: var(--color-danger); color: #fff; }

.tb-label {
  font-size: .7rem;
  color: var(--text-tertiary);
  font-weight: 500;
  margin-right: 2px;
}

.tb-input {
  width: 64px;
  padding: 3px 7px;
  background: var(--bg-body);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: .76rem;
  text-align: center;
}
.tb-input:focus { outline: none; border-color: var(--color-primary); }

/* Live sync toggle */
.live-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--duration-fast);
  user-select: none;
}
.live-pill:hover { border-color: var(--border-strong); }
.live-pill.on { background: rgba(34,197,94,.08); border-color: rgba(34,197,94,.25); }
.live-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-tertiary); transition: background var(--duration-fast); }
.live-pill.on .dot { background: var(--color-success); box-shadow: 0 0 5px rgba(34,197,94,.4); }
.live-pill.saving .dot { background: var(--color-warning); }

/* Main area */
.ed-main { display: flex; flex: 1; overflow: hidden; }

/* Canvas viewport */
.ed-viewport {
  flex: 1;
  overflow: auto;
  position: relative;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(255,255,255,.008) 39px, rgba(255,255,255,.008) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(255,255,255,.008) 39px, rgba(255,255,255,.008) 40px),
    #06070b;
}

.ed-viewport-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 100%;
  min-height: 100%;
}

.ed-canvas-frame {
  flex-shrink: 0;
  transform-origin: center center;
  padding: 36px;
}

/* Canvas frame */
.ed-canvas {
  position: relative;
  overflow: hidden;
  background:
    repeating-conic-gradient(rgba(255,255,255,.012) 0% 25%, transparent 0% 50%) 0 0 / 20px 20px;
  border: 1px solid #232336;
  border-radius: 3px;
  box-shadow:
    0 0 0 1px rgba(0,0,0,.7),
    0 0 0 5px #0c0c14,
    0 0 0 6px #232336,
    0 16px 50px rgba(0,0,0,.55);
}

.ed-canvas::after {
  content: attr(data-size);
  position: absolute;
  bottom: 7px;
  right: 9px;
  font-size: 9px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  opacity: .35;
  pointer-events: none;
  background: rgba(0,0,0,.4);
  padding: 2px 5px;
  border-radius: 3px;
}

.ed-canvas::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  border: 1px solid rgba(99,102,241,.04);
  border-radius: 2px;
}

/* Preview boxes */
.ed-canvas .preview-box {
  position: absolute;
  border: 1px solid rgba(99,102,241,.4);
  border-radius: 2px;
  background: rgba(99,102,241,.03);
  cursor: move;
  transition: border-color .1s, background .1s;
  contain: layout;
}
.ed-canvas .preview-box:hover {
  border-color: rgba(99,102,241,.7);
  background: rgba(99,102,241,.06);
}
.ed-canvas .preview-box.selected {
  border-color: #a5b4fc;
  background: rgba(165,180,252,.05);
  box-shadow: 0 0 0 1px rgba(165,180,252,.18), inset 0 0 0 1px rgba(165,180,252,.06);
}
.ed-canvas .preview-box.selected::before {
  content: '';
  position: absolute;
  inset: -4px;
  border: 1px dashed rgba(165,180,252,.15);
  border-radius: 4px;
  pointer-events: none;
}

.ed-canvas .box-info {
  position: absolute;
  bottom: 3px;
  left: 3px;
  right: 3px;
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  font-family: var(--font-mono);
  color: rgba(255,255,255,.4);
  background: rgba(0,0,0,.5);
  padding: 2px 5px;
  border-radius: 2px;
  pointer-events: none;
  backdrop-filter: blur(4px);
}
.ed-canvas .preview-box.selected .box-info {
  color: rgba(255,255,255,.75);
  background: rgba(99,102,241,.3);
}

/* Snap guides */
.ed-canvas .snap-guide { position: absolute; z-index: 10; pointer-events: none; }
.ed-canvas .snap-guide.horizontal { background: rgba(239,68,68,.45); height: 1px; }
.ed-canvas .snap-guide.vertical   { background: rgba(239,68,68,.45); width: 1px; }

/* Side panel */
.ed-panel {
  width: 300px;
  min-width: 300px;
  height: 100%;
  background: var(--bg-raised);
  border-left: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ed-panel-header {
  padding: 12px 15px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.ed-panel-header h2 {
  font-size: .88rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}
.ed-panel-header h2::after { display: none; }

.ed-panel-body { flex: 1; overflow-y: auto; padding: 10px 14px; }

/* Box list */
.box-list-section h3 {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-tertiary);
  margin: 0 0 6px;
}
.box-list-section h3::after { display: none; }

.ed-panel #box-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ed-panel #box-list li {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .79rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  transition: background var(--duration-fast), color var(--duration-fast);
  border: 1px solid transparent;
}
.ed-panel #box-list li:hover { background: var(--bg-hover); color: var(--text-primary); }
.ed-panel #box-list li.selected {
  background: var(--color-primary-muted);
  color: var(--color-primary);
  border-color: rgba(99,102,241,.15);
  font-weight: 600;
}

.box-list-num {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  font-weight: 700;
  flex-shrink: 0;
}
.ed-panel #box-list li.selected .box-list-num {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* Box editor form */
.box-editor-section .form-group { margin-bottom: 12px; }
.box-editor-section label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}
.box-editor-section .input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.box-editor-section input { font-family: var(--font-mono); font-size: .8rem; padding: 6px 9px; }
.box-editor-section .id-preview { font-size: .72rem; color: var(--text-tertiary); margin-top: 3px; }

/* Panel buttons */
.panel-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.panel-btn {
  flex: 1;
  min-width: 0;
  padding: 6px 7px;
  font-size: .74rem;
  font-weight: 500;
  font-family: var(--font-sans);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  transition: background var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast);
}
.panel-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); color: var(--text-primary); }
.panel-btn.accent { background: var(--color-primary-muted); color: var(--color-primary); border-color: rgba(99,102,241,.18); }
.panel-btn.accent:hover { background: rgba(99,102,241,.15); }
.panel-btn.save { background: var(--color-success-muted); color: var(--color-success); border-color: rgba(34,197,94,.18); }
.panel-btn.save:hover { background: rgba(34,197,94,.15); }
.panel-btn.del { color: var(--color-danger); border-color: rgba(239,68,68,.13); }
.panel-btn.del:hover { background: var(--color-danger-muted); }

/* Zoom bar */
.ed-zoom-bar {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(calc(-50% - 150px));
  display: flex;
  align-items: center;
  gap: 1px;
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 2px;
  box-shadow: var(--shadow-md);
  z-index: 40;
}
.ed-zoom-bar .tb-btn { padding: 4px 9px; font-size: .78rem; }

/* Preset modal */
.preset-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s var(--ease-out);
}
.preset-overlay.active { opacity: 1; pointer-events: all; }

.preset-card {
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 22px;
  width: 90%;
  max-width: 520px;
  max-height: 78vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(8px);
  transition: transform .18s var(--ease-out);
}
.preset-overlay.active .preset-card { transform: translateY(0); }

.preset-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.preset-header h3 { margin: 0; font-size: .98rem; }
.preset-header h3::after { display: none; }

.preset-close {
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 16px;
  cursor: pointer;
  transition: color var(--duration-fast), background var(--duration-fast);
}
.preset-close:hover { color: var(--color-danger); background: var(--color-danger-muted); }

.preset-save-row { display: flex; gap: 7px; margin-bottom: 14px; }
.preset-save-row input { flex: 1; font-family: var(--font-sans); }

.ed-panel .preset-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
}
.ed-panel .preset-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  transition: border-color var(--duration-fast);
}
.ed-panel .preset-list li:hover { border-color: var(--border-strong); }
.ed-panel .preset-list .meta { opacity: .45; font-size: .72rem; margin-left: 7px; }

/* Active preset indicator */
.preset-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px 3px 7px;
  border-radius: 99px;
  background: rgba(99,102,241,.07);
  border: 1px solid rgba(99,102,241,.18);
  font-size: .72rem;
  font-weight: 500;
  color: rgba(165,180,252,.85);
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all var(--duration-fast);
}
.preset-badge .badge-icon     { font-size: .65rem; flex-shrink: 0; opacity: .6; }
.preset-badge .badge-active-name { color: rgba(165,180,252,.9); }
.preset-badge .badge-arrow    { color: var(--text-tertiary); font-size: .62rem; margin: 0 1px; flex-shrink: 0; }
.preset-badge .badge-pending-name { color: rgba(245,158,11,.85); font-style: italic; }
.preset-badge.has-pending {
  border-color: rgba(245,158,11,.2);
  background: rgba(245,158,11,.05);
}
.preset-badge.no-active {
  background: rgba(245,158,11,.07);
  border-color: rgba(245,158,11,.2);
  color: rgba(245,158,11,.85);
}
.preset-badge .badge-dismiss {
  margin-left: 2px;
  cursor: pointer;
  opacity: .4;
  font-size: .68rem;
  transition: opacity .12s;
  padding: 0 2px;
  flex-shrink: 0;
}
.preset-badge .badge-dismiss:hover { opacity: .9; }

.ed-panel .preset-list li.preset-active {
  border-color: rgba(99,102,241,.35);
  background: rgba(99,102,241,.05);
}

/* Layout Editor Responsive */
@media (max-width: 1024px) {
  .ed-main { flex-direction: column; }
  .ed-panel { width: 100%; min-width: 0; height: auto; max-height: 40vh; border-left: none; border-top: 1px solid var(--border-default); }
  .ed-viewport { min-height: 50vh; }
  .ed-zoom-bar { transform: translateX(-50%); }
}
@media (max-width: 768px) {
  .ed-toolbar { flex-wrap: wrap; gap: 5px; }
  .ed-toolbar .tb-group { flex-wrap: wrap; }
  .ed-toolbar-title { width: 100%; margin-bottom: 3px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PLAYLIST EDITOR
   ═══════════════════════════════════════════════════════════════════════════ */

body.playlist-page { padding: 14px; overflow-x: hidden; }

.mpv-wrapper {
  width: min(100%, 1720px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mpv-header,
.mpv-panel {
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.mpv-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 12px 16px;
  min-width: 0;
}
.mpv-header > a,
.mpv-header > label,
.mpv-header > select,
.mpv-header > .btn { flex: 0 1 auto; }
.mpv-header h1 { margin-right: auto; flex: 1 1 260px; min-width: 200px; font-size: 1.15rem; }
.mpv-header label,
.mpv-header small,
.mpv-item-sub,
#tab-ads p,
#tab-vars p { font-size: .78rem; }
.mpv-header small { min-width: 0; overflow-wrap: anywhere; color: var(--text-secondary); opacity: 1 !important; }

.mpv-container {
  display: flex;
  gap: 12px;
  align-items: stretch;
  min-height: min(76vh, 980px);
  min-width: 0;
}

.mpv-panel {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 340px;
  max-height: min(80vh, 980px);
}

.mpv-panel-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-inset);
  font-weight: 600;
  font-size: .8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .05em;
  flex-shrink: 0;
}

.mpv-panel-content,
.mpv-tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.mpv-tab-content { padding: 10px; }
.mpv-panel > .mpv-tab-content[style*="display:none"] { display: none !important; }

.mpv-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-gutter: stable;
  flex-shrink: 0;
}

.mpv-tab-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 11px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast);
  white-space: nowrap;
  flex: 0 0 auto;
  font: 500 .79rem var(--font-sans);
}
.mpv-tab-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.mpv-tab-btn.active {
  background: var(--bg-raised);
  color: var(--color-primary);
  border-color: var(--border-default);
  border-bottom-color: var(--bg-raised);
  font-weight: 600;
}

.mpv-list-container {
  flex: 1;
  min-height: 0;
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
}

.mpv-list { list-style: none; }
.mpv-list-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--duration-fast);
  cursor: pointer;
  min-width: 0;
}
.mpv-list-item:hover { background: rgba(255,255,255,.02); }

.mpv-thumb {
  width: 80px;
  height: 45px;
  background: #000;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--border-default);
  flex-shrink: 0;
}
.mpv-item-label { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .84rem; }
.mpv-item-sub   { font-size: .72rem; color: var(--text-secondary); }
.mpv-actions    { display: flex; gap: 5px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; flex: 0 0 auto; }

.mpv-search {
  width: 100%;
  padding: 8px 11px;
  min-height: 34px;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font: 400 .82rem var(--font-sans);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  margin-bottom: 10px;
}
.mpv-search::placeholder { color: var(--text-tertiary); }
.mpv-search:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-muted);
}

.mpv-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.mpv-modal-content {
  background: var(--bg-raised);
  padding: 16px;
  border-radius: var(--radius-xl);
  max-width: min(92vw, 1080px);
  max-height: 90vh;
  position: relative;
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-lg);
}
.mpv-modal-video { width: 100%; height: auto; max-height: 80vh; border-radius: var(--radius-md); background: #000; }
.mpv-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-inset);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.mpv-modal-close:hover { background: var(--color-danger-muted); color: var(--color-danger); }

#tab-ads,
#tab-vars { overflow-y: auto; overscroll-behavior: contain; }
#tab-ads > div:first-child,
#tab-vars > div:first-child { min-width: 0; }
#tab-ads label,
#tab-vars label { font-size: .74rem !important; color: var(--text-secondary) !important; font-weight: 500; }
#tab-ads > div,
#tab-vars > div { padding-top: 2px !important; }

.vars-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 99px;
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .03em;
  background: var(--color-success-muted);
  border: 1px solid rgba(34,197,94,.2);
  color: var(--color-success);
  white-space: nowrap;
  flex-shrink: 0;
}

.vars-card {
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.vars-card-header { display: flex; align-items: center; gap: 8px; }
.vars-card-name   { font-weight: 600; font-size: .84rem; flex: 1; }
.vars-card-url {
  font-size: .7rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vars-card-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: .72rem; color: var(--text-secondary); }
.vars-status-ok   { color: var(--color-success); }
.vars-status-err  { color: var(--color-danger); }
.vars-status-wait { color: var(--color-warning); }

.pulse { animation: mpv-pulse 2.5s ease-in-out infinite; }
@keyframes mpv-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .75; }
}
.spin { display: inline-block; animation: mpv-spin .8s linear infinite; }
@keyframes mpv-spin { to { transform: rotate(360deg); } }

/* Schedule */
.sched-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: 99px; font-size: .65rem; font-weight: 600;
  letter-spacing: .02em; white-space: nowrap; flex-shrink: 0;
  background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.2); color: var(--color-warning);
}
.sched-modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.7); backdrop-filter: blur(8px);
  align-items: center; justify-content: center; padding: 20px;
}
.sched-modal-overlay.open { display: flex; }
.sched-modal {
  background: var(--bg-raised); border: 1px solid var(--border-default);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  width: min(92vw, 440px); padding: 22px; position: relative;
}
.sched-modal h3 { font-size: 1rem; margin-bottom: 3px; }
.sched-modal .sched-filename { font-size: .78rem; color: var(--text-secondary); margin-bottom: 16px; word-break: break-all; }
.sched-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.sched-field label { font-size: .72rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .06em; }
.sched-field .sched-row { display: flex; gap: 8px; align-items: center; }
.sched-field input[type="time"],
.sched-field input[type="number"] {
  padding: 8px 10px; background: var(--bg-inset); border: 1px solid var(--border-default);
  border-radius: var(--radius-md); color: var(--text-primary); font: 400 .84rem var(--font-sans);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  color-scheme: dark;
}
.sched-field input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 2px var(--color-primary-muted); }
.sched-field input[type="time"] { flex: 1; }
.sched-field input[type="number"] { width: 82px; text-align: center; }
.sched-field .sched-hint { font-size: .7rem; color: var(--text-tertiary); }
.sched-actions { display: flex; gap: 7px; margin-top: 18px; }
.sched-actions .btn { flex: 1; }
.sched-close {
  position: absolute; top: 11px; right: 11px; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border-default);
  background: transparent; color: var(--text-secondary); cursor: pointer; font-size: .9rem;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.sched-close:hover { background: var(--color-danger-muted); color: var(--color-danger); }
.sched-toggle {
  display: flex; align-items: center; gap: 9px; margin-bottom: 14px;
  padding: 9px 12px; border-radius: var(--radius-md);
  background: var(--bg-inset); border: 1px solid var(--border-default); cursor: pointer;
}
.sched-toggle input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--color-primary); }
.sched-toggle span { font-size: .84rem; font-weight: 500; }
.sched-body.disabled { opacity: .3; pointer-events: none; }

/* Playlist Editor Responsive */
@media (max-width: 1200px) {
  .mpv-container { flex-direction: column; }
  .mpv-panel { max-height: none; }
}
@media (max-width: 900px) {
  .mpv-header h1 { flex-basis: 100%; font-size: 1.1rem; }
  .mpv-list-item { align-items: flex-start; }
}
@media (max-width: 768px) {
  .mpv-wrapper { padding: 0; }
  .mpv-header { align-items: stretch; padding: 12px; }
  .mpv-header > a,
  .mpv-header > label,
  .mpv-header > select,
  .mpv-header > .btn { width: 100%; }
  .mpv-header > label { margin-bottom: -4px; }
  .mpv-panel { min-height: 300px; }
  .mpv-thumb { display: none; }
  .mpv-list-item { flex-wrap: wrap; }
  .mpv-item-label,
  .mpv-item-sub { white-space: normal; overflow: visible; text-overflow: initial; word-break: break-word; }
  .mpv-actions { width: 100%; margin-left: 0; }
  .mpv-tabs { padding-bottom: 5px; }
  .mpv-modal-content { width: min(100%, 1000px); max-width: 100%; padding: 10px; }
}
@media (max-width: 520px) {
  .mpv-tab-content { padding: 8px; }
  .mpv-tab-btn { padding: 6px 9px; }
  .vars-card-header,
  .vars-card-meta { flex-wrap: wrap; }
  .vars-card-url { white-space: normal; word-break: break-all; }
}

/* NIRAHUB CLIENT SHELL */
body.client-shell {
  --color-primary: #2f75ff;
  --color-primary-hover: #5b92ff;
  --color-primary-muted: rgba(47,117,255,.16);
  --color-success: #39c864;
  --color-danger: #ff4964;
  --color-warning: #ffc433;
  --bg-body: #07101d;
  --bg-base: rgba(10,20,35,.98);
  --bg-raised: rgba(16,31,51,.94);
  --bg-inset: rgba(8,18,32,.96);
  --bg-hover: rgba(31,56,91,.76);
  --text-primary: #eef5ff;
  --text-secondary: #9fb0ca;
  --text-tertiary: #677996;
  --border-default: rgba(123,154,197,.16);
  --border-subtle: rgba(123,154,197,.1);
  --border-strong: rgba(98,143,210,.34);
  --shadow-sm: 0 10px 30px rgba(0,0,0,.2);
  --shadow-md: 0 16px 44px rgba(0,0,0,.28);
  --shadow-lg: 0 28px 80px rgba(0,0,0,.38);
  min-height: 100vh;
  padding-left: 264px;
  color: var(--text-primary);
  background:
    radial-gradient(circle at 18% 18%, rgba(47,117,255,.14), transparent 28%),
    radial-gradient(circle at 78% 8%, rgba(99,102,241,.14), transparent 28%),
    linear-gradient(135deg, #07101d 0%, #0b1729 58%, #08111f 100%);
}

body.client-shell::before {
  display: block;
  background:
    linear-gradient(135deg, rgba(3,8,16,.86), rgba(6,13,24,.76)),
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
    radial-gradient(circle at 50% -10%, rgba(47,117,255,.16), transparent 35%),
    url('/static/bg.jpg') center / cover no-repeat fixed,
    linear-gradient(135deg, #07101d 0%, #0b1729 58%, #08111f 100%);
  background-size: auto, 44px 44px, 44px 44px, auto, cover, auto;
}

body.client-shell .stars { opacity: .35; }

.nira-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1200;
  width: 264px;
  padding: 22px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background:
    linear-gradient(180deg, rgba(7,17,31,.98), rgba(5,13,24,.99)),
    radial-gradient(circle at 30% 0%, rgba(47,117,255,.18), transparent 36%);
  border-right: 1px solid rgba(120,154,205,.16);
  box-shadow: 20px 0 54px rgba(0,0,0,.22);
}

.nira-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  min-height: 82px;
  padding: 6px 6px 18px;
  border-bottom: 1px solid rgba(123,154,197,.12);
}
.nira-brand:hover { color: #fff; }
.nira-brand-logo {
  display: block;
  width: min(100%, 218px);
  max-height: 64px;
  height: auto;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 10px 22px rgba(92, 84, 255, .22));
}
.nira-brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 14px;
  font-weight: 800;
  font-size: 1.42rem;
  line-height: 1;
  background: linear-gradient(135deg, #58d2ff 0%, #2f75ff 52%, #7965ff 100%);
  box-shadow: 0 14px 28px rgba(47,117,255,.32), inset 0 1px 0 rgba(255,255,255,.22);
}
.nira-brand-text { display: grid; line-height: 1; min-width: 0; }
.nira-brand-text strong {
  font-size: 1.15rem;
  letter-spacing: .03em;
  white-space: nowrap;
}
.nira-brand-text strong span {
  color: #d7e6ff;
}
.nira-brand-text small {
  margin-top: 7px;
  color: #8fa2bd;
  font-size: .56rem;
  font-weight: 700;
  letter-spacing: .17em;
  white-space: nowrap;
}

.nira-side-nav {
  display: grid;
  gap: 4px;
}
.nira-side-link {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  min-height: 43px;
  padding: 0 12px;
  border-radius: 12px;
  color: #a8b8d0;
  font-weight: 650;
  font-size: .88rem;
  border: 1px solid transparent;
  transition: background .16s, color .16s, border-color .16s, box-shadow .16s;
}
.nira-side-link::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: transparent;
}
.nira-side-icon {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 9px;
  border: 1px solid rgba(124,148,185,.24);
  background: rgba(124,148,185,.07);
}
.nira-side-icon::before,
.nira-side-icon::after {
  content: "";
  position: absolute;
  border-color: currentColor;
}
.nira-side-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nira-i-layout::before {
  inset: 6px;
  border: 2px solid currentColor;
  border-radius: 4px;
}
.nira-i-preview::before {
  left: 5px;
  top: 6px;
  width: 14px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 4px;
}
.nira-i-preview::after {
  left: 10px;
  top: 16px;
  width: 5px;
  height: 2px;
  background: currentColor;
  box-shadow: -3px 3px 0 currentColor, 3px 3px 0 currentColor;
}
.nira-i-files::before {
  left: 6px;
  top: 7px;
  width: 12px;
  height: 10px;
  border: 2px solid currentColor;
  border-top-left-radius: 2px;
  border-radius: 3px;
}
.nira-i-playlist::before {
  left: 6px;
  top: 7px;
  width: 11px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 5px 0 currentColor, 0 10px 0 currentColor;
}
.nira-i-schedule::before {
  left: 6px;
  top: 7px;
  width: 12px;
  height: 10px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}
.nira-i-schedule::after {
  left: 10px;
  top: 5px;
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-top: 2px solid currentColor;
}
.nira-i-calendar::before {
  left: 5px;
  top: 7px;
  width: 14px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 4px;
}
.nira-i-calendar::after {
  left: 8px;
  right: 8px;
  top: 5px;
  height: 5px;
  border-left: 2px solid currentColor;
  border-right: 2px solid currentColor;
}
.nira-i-sync::before {
  left: 6px;
  top: 6px;
  width: 11px;
  height: 11px;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
}
.nira-i-sync::after {
  right: 4px;
  top: 4px;
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}
.nira-side-link:hover {
  color: #fff;
  background: rgba(47,117,255,.08);
  border-color: rgba(84,138,255,.16);
}
.nira-side-link.active {
  color: #fff;
  background: rgba(47,117,255,.16);
  border-color: rgba(96,148,255,.24);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.nira-side-link.active::after {
  background: #58d2ff;
  box-shadow: 0 0 12px rgba(88,210,255,.65);
}
.nira-side-link.active .nira-side-icon {
  color: #dceaff;
  border-color: rgba(88,210,255,.34);
  background: rgba(88,210,255,.12);
}

.nira-side-footer {
  margin-top: auto;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid rgba(123,154,197,.13);
  border-radius: 14px;
  background: rgba(124,148,185,.06);
  color: #71839f;
}
.nira-user-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #39c864;
  box-shadow: 0 0 14px rgba(57,200,100,.45);
}
.nira-user-meta {
  display: grid;
  min-width: 0;
}
.nira-user-meta small {
  color: #71839f;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.nira-user-meta strong {
  color: #dbe8fb;
  font-size: .88rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.client-shell .nav-bar,
body.client-shell .ed-toolbar {
  min-height: 68px;
  padding: 0 28px;
  background: rgba(9,19,34,.82);
  border-bottom: 1px solid rgba(123,154,197,.13);
  box-shadow: 0 14px 38px rgba(0,0,0,.16);
  backdrop-filter: blur(22px) saturate(1.15);
}

body.client-shell .nav-bar .nav-back,
body.client-shell .ed-toolbar .nav-back,
body.client-shell .mpv-header > a[href^="/central_presets"] {
  display: none !important;
}

body.client-shell .nav-bar {
  position: sticky;
  top: 0;
}
body.client-shell .nav-bar::before { display: none; }
body.client-shell .nav-bar .nav-title,
body.client-shell .ed-toolbar-title {
  color: #f2f7ff;
  font-weight: 800;
  letter-spacing: .01em;
}

body.client-shell .page,
body.client-shell .central-page,
body.client-shell .pal-layout,
body.client-shell .mpv-wrapper {
  width: min(100%, 1580px);
  max-width: none;
  margin: 0 auto;
  padding: 28px;
}
body.client-shell .central-page { padding-top: 26px; }
body.client-shell .page { padding-top: 28px; }
body.client-shell.playlist-page { padding: 0 0 0 264px; }
body.client-shell[data-ui="files"] { padding: 0 0 0 264px; }
body.client-shell.playlist-page .mpv-wrapper { padding-top: 28px; }
body.client-shell.editor-page {
  padding-left: 264px;
  background: #07101d;
}
body.client-shell.editor-page .ed-main {
  min-width: 0;
  background: transparent;
}

body.client-shell .card,
body.client-shell .central-panel,
body.client-shell .mpv-header,
body.client-shell .mpv-panel,
body.client-shell .video-card,
body.client-shell .job-card,
body.client-shell .preset-app-card,
body.client-shell .pal-modal-card,
body.client-shell #calendar,
body.client-shell .sidebar,
body.client-shell .panel,
body.client-shell .ed-panel,
body.client-shell .ed-canvas {
  background: linear-gradient(180deg, rgba(17,33,55,.94), rgba(13,27,46,.94));
  border: 1px solid rgba(123,154,197,.15);
  box-shadow: 0 16px 40px rgba(0,0,0,.22);
}

body.client-shell .card,
body.client-shell .central-panel,
body.client-shell .mpv-header,
body.client-shell .mpv-panel,
body.client-shell .video-card,
body.client-shell .job-card,
body.client-shell .preset-app-card,
body.client-shell #calendar,
body.client-shell .sidebar {
  border-radius: 10px;
}

body.client-shell .central-grid { grid-template-columns: 320px minmax(0, 1fr); gap: 18px; }
body.client-shell .central-page h1,
body.client-shell h1 {
  color: #f4f8ff;
  font-weight: 800;
}
body.client-shell .top-tab,
body.client-shell .tab-btn,
body.client-shell .mpv-tab-btn {
  background: rgba(10,22,39,.75);
  border-color: rgba(123,154,197,.16);
  color: #a8b9d2;
}
body.client-shell .top-tab.active,
body.client-shell .tab-btn.active,
body.client-shell .mpv-tab-btn.active {
  background: rgba(47,117,255,.16);
  border-color: rgba(69,132,255,.48);
  color: #fff;
}

body.client-shell input,
body.client-shell select,
body.client-shell textarea,
body.client-shell .central-input,
body.client-shell .central-select,
body.client-shell .central-textarea,
body.client-shell .mpv-search {
  background: rgba(7,17,31,.92);
  border-color: rgba(123,154,197,.18);
  color: #edf5ff;
}

body.client-shell .btn,
body.client-shell button {
  border-radius: 8px;
}
body.client-shell .btn-primary,
body.client-shell .btn-success {
  background: linear-gradient(135deg, #2f75ff, #2563eb);
  border-color: rgba(106,158,255,.36);
  color: #fff;
  box-shadow: 0 10px 24px rgba(47,117,255,.22);
}
body.client-shell .btn-secondary {
  background: rgba(18,36,61,.92);
  border-color: rgba(123,154,197,.17);
  color: #dbe8fb;
}
body.client-shell .btn-danger {
  background: rgba(255,73,100,.14);
  border-color: rgba(255,73,100,.32);
  color: #ff9cac;
}

body.client-shell .preset-row,
body.client-shell .group-row,
body.client-shell .mpv-list-item,
body.client-shell .client-table-wrap,
body.client-shell .vars-card {
  background: rgba(8,19,34,.7);
  border-color: rgba(123,154,197,.12);
}
body.client-shell .preset-row:hover,
body.client-shell .preset-row.active,
body.client-shell .group-row:hover,
body.client-shell .group-row.active,
body.client-shell .mpv-list-item:hover {
  background: rgba(47,117,255,.11);
  border-color: rgba(73,132,255,.36);
}

body.client-shell .thumb-container,
body.client-shell .mpv-thumb {
  background: #08111f;
  border-color: rgba(123,154,197,.18);
}

@media (max-width: 1180px) {
  body.client-shell {
    padding-left: 0;
  }
  body.client-shell.playlist-page,
  body.client-shell.editor-page,
  body.client-shell[data-ui="files"] {
    padding-left: 0;
  }
  .nira-sidebar {
    position: static;
    width: auto;
    min-height: auto;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid rgba(120,154,205,.16);
  }
  .nira-side-nav {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
  .nira-side-footer {
    display: none;
  }
  body.client-shell .page,
  body.client-shell .central-page,
  body.client-shell .pal-layout,
  body.client-shell .mpv-wrapper {
    padding: 18px;
  }
}
