/* ═══════════════════════════════════════════════════════════════════════
   STEVESOCIAL  ·  Pure White + Emerald design system
   Clean editorial flat UI — no glassmorphism, no gradients.
   One stylesheet skins every page. Class names are a stable contract.
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── Tokens ─────────────────────────────────────────────────────────── */
:root {
  /* ── Surfaces ── */
  --white:     #ffffff;
  --bg:        #f9fafb;
  --surface-1: #f9fafb;
  --surface-2: #f3f4f6;
  --surface-3: #e5e7eb;

  /* Semantic aliases kept for backward-compat with JS CSS-var references */
  --panel:     #ffffff;
  --card-bg:   #ffffff;
  --input-bg:  #f9fafb;
  --hover-bg:  #ecfdf5;
  --tab-bg:    #ffffff;
  --tab-hover-bg: #f9fafb;
  --bg-color:  #f9fafb;
  --surface-bg: #f9fafb;

  /* ── Borders ── */
  --bd:              #e5e7eb;
  --bd-light:        #f3f4f6;
  --border-color:    #e5e7eb;
  --border-light:    #f3f4f6;
  --border-lighter:  #f3f4f6;
  --card-border:     #e5e7eb;
  --grid-line:       rgba(0,0,0,0.04);

  /* ── Text ── */
  --t1: #111827;
  --t2: #6b7280;
  --t3: #9ca3af;
  --text-color:     #111827;
  --text-primary:   #111827;
  --text-secondary: #6b7280;
  --text-tertiary:  #9ca3af;
  --text-tab:       #ffffff;

  /* ── Emerald accent ── */
  --em:        #10b981;
  --em-h:      #059669;
  --em-soft:   #ecfdf5;
  --em-bd:     #a7f3d0;
  --accent-color:      #10b981;
  --accent-soft:       #ecfdf5;
  --accent-bd:         #a7f3d0;
  --accent-line:       rgba(16,185,129,0.25);
  --primary-color:     #10b981;
  --primary-hover:     #059669;
  --primary-light-bg:  #ecfdf5;
  --primary-rgb:       16,185,129;
  --positive-color:    #10b981;
  --positive-bg:       #ecfdf5;

  /* ── Signal colors ── */
  --warn:         #f59e0b;
  --warn-soft:    #fffbeb;
  --warn-bd:      #fde68a;
  --err:          #ef4444;
  --err-soft:     #fff5f5;
  --err-bd:       #fecaca;
  --negative-color: #ef4444;
  --negative-bg:    #fff5f5;
  --warning-color:  #f59e0b;
  --warning-bg:     #fffbeb;
  --warning-border: #fde68a;
  --cyan:           #0891b2;
  --cyan-soft:      #ecfeff;
  --kind-short:     #7c3aed;
  --kind-video:     #0891b2;

  --spinner-bg:         #e5e7eb;
  --overlay-background: rgba(0,0,0,0.30);

  --r-sm: 3px;
  --r:    8px;

  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --font-sans: 'Be Vietnam Pro', ui-sans-serif, system-ui, -apple-system, sans-serif;

  /* ── Full-height shell + reading scale (Editorial Full-Height redesign) ── */
  --navh: 52px;            /* fixed top navbar height — shells fill the rest */
  --rscale: 1;             /* A−/A+ reading zoom (persisted to localStorage)  */

  /* ── Type scale ("to rõ") ── */
  --fs-eyebrow: 0.68rem;   /* mono caps label                                */
  --fs-body:    0.95rem;   /* base body                                      */
  --fs-content: 1.02rem;   /* text inside pane bodies                        */
  --fs-lg:      1.18rem;   /* pane titles / chips                            */
  --fs-read:    calc(1.1rem * var(--rscale)); /* long-form reading zones     */
}

/* ─── Reset & base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  color: var(--t1);
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.55;
  min-height: 100vh;
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--em); }
img { display: block; max-width: 100%; }

::selection { background: var(--em-soft); color: var(--t1); }

* { scrollbar-width: thin; scrollbar-color: #d1d5db transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ─── Page wrapper ───────────────────────────────────────────────────── */
.page-wrapper {
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 24px 72px;
}

@media (max-width: 768px) { .page-wrapper { padding: 20px 16px 48px; } }
@media (max-width: 480px) { .page-wrapper { padding: 16px 12px 36px; } }

/* ─── Navbar ─────────────────────────────────────────────────────────── */
/* z-index scale: nav 10000 < dropdown 10001 < fullscreen overlays 10010 (.sc-fs,
   .sc-rec-overlay) < modal 10020 < toast 20000. Any new fullscreen overlay MUST be >=
   10010 or the sticky navbar paints over it (the bug that hid the recorder at z-index 60);
   confirm dialogs sit above overlays so they're never buried. */
.navbar {
  position: sticky;
  top: 0;
  z-index: 10000;
  /* Clear the notch/Dynamic Island under viewport-fit=cover (env() is 0 on pages
     without it, so this is a no-op elsewhere). */
  height: calc(52px + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) calc(20px + env(safe-area-inset-right, 0px)) 0 calc(20px + env(safe-area-inset-left, 0px));
  background: var(--white);
  border-bottom: 1px solid var(--bd);
  display: flex;
  align-items: center;
  gap: 0;
}

.nav-brand { flex-shrink: 0; margin-right: 24px; }

.brand-link { display: inline-flex; align-items: center; gap: 8px; }

.brand-dot {
  width: 7px; height: 7px;
  background: var(--em);
  border-radius: 50%;
  flex-shrink: 0;
  animation: livePulse 2.4s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.brand-text {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--t1);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-text em { color: var(--em); font-style: normal; }

.nav-items {
  display: flex; align-items: center;
  list-style: none; margin: 0; padding: 0;
  gap: 2px; flex: 1;
}
.nav-items li { display: block; }

.nav-item {
  display: inline-block;
  color: var(--t2);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 6px;
  transition: color 0.14s ease, background 0.14s ease;
  white-space: nowrap;
}

.nav-item:hover { color: var(--t1); background: var(--bg); }
.nav-item.active { color: var(--em); background: var(--em-soft); }

.nav-actions {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto; flex-shrink: 0;
}

/* Status pill in nav (populated by page-control.js on dashboard) */
.nav-status-pill {
  display: none;
  align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px;
  background: var(--em-soft); border: 1px solid var(--em-bd);
  font-size: 0.72rem; font-weight: 500; color: var(--em);
  white-space: nowrap;
}
.nav-status-pill.visible { display: flex; }
.nav-status-pill.paused  { background: var(--warn-soft); border-color: var(--warn-bd); color: #b45309; }
.nav-status-pill.offline { background: var(--err-soft); border-color: var(--err-bd); color: var(--err); }

.nav-status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  animation: livePulse 2s ease-in-out infinite;
}
.nav-status-pill.paused .nav-status-dot,
.nav-status-pill.offline .nav-status-dot { animation: none; }

.nav-pause-btn {
  display: none;
  padding: 5px 12px; border-radius: 6px; border: 1px solid var(--bd);
  background: var(--white); font-size: 0.75rem; font-weight: 500; color: var(--t2);
  cursor: pointer;
}
.nav-pause-btn.visible { display: inline-flex; align-items: center; }
.nav-pause-btn:hover { border-color: var(--t3); color: var(--t1); }

/* ─── Section header ─────────────────────────────────────────────────── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--bd);
}

.section-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--t1);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--em);
  border-radius: 50%;
  flex-shrink: 0;
}

.section-block { margin-bottom: 40px; }

.subsection-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 24px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--bd-light);
}

/* ─── Panels & cards ─────────────────────────────────────────────────── */
.panel,
.card,
.card-flat,
.stat-card,
.chart-card,
.account-card,
.queue-item,
.settings-section {
  background: var(--white);
  border: 1px solid var(--bd);
  border-radius: var(--r);
  position: relative;
  transition: border-color 0.18s ease;
}

.card:hover,
.stat-card:hover,
.chart-card:hover,
.account-card:hover {
  border-color: #d1d5db;
}

.card-flat,
.stat-card,
.chart-card,
.queue-item,
.settings-section { padding: 20px; }

.card-flat,
.queue-item { margin-bottom: 12px; }

/* ─── Metric / stat ──────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 768px) { .stats-grid { grid-template-columns: 1fr; gap: 10px; } }

.stat-value,
.metric {
  font-family: var(--font-mono);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--t1);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--t2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ─── Status light ───────────────────────────────────────────────────── */
.status-light {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.03em;
}
.status-light::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--t3);
  flex-shrink: 0;
}
.status-light.online  { color: var(--em); }
.status-light.online::before  { background: var(--em); animation: livePulse 2s ease-in-out infinite; }
.status-light.stale   { color: var(--warn); }
.status-light.stale::before   { background: var(--warn); }
.status-light.offline { color: var(--err); }
.status-light.offline::before { background: var(--err); }
.status-light.info    { color: var(--cyan); }
.status-light.info::before    { background: var(--cyan); }

/* ─── Account card ───────────────────────────────────────────────────── */
.account-card {
  padding: 14px 18px;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 14px;
}
.account-platform {
  font-family: var(--font-mono);
  font-size: 0.62rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--t3);
}
.account-name { font-size: 0.92rem; font-weight: 600; color: var(--t1); }
.account-status { margin-left: auto; font-family: var(--font-mono); font-size: 0.64rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.account-status.active   { color: var(--em); }
.account-status.inactive { color: var(--err); }

/* ─── Queue item / comment quote ─────────────────────────────────────── */
.queue-meta {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--t2);
  letter-spacing: 0.02em;
}
.queue-meta a { color: var(--cyan); }
.queue-meta a:hover { text-decoration: underline; }
.meta-sep { color: var(--t3); }

.comment-quote {
  color: var(--t2);
  font-size: 0.875rem;
  line-height: 1.55;
  padding: 10px 14px;
  border-left: 2px solid var(--bd);
  margin: 0 0 14px 0;
  background: var(--bg);
  border-radius: 0 4px 4px 0;
}

.queue-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ─── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--font-sans); font-weight: 600;
  cursor: pointer; border-radius: 6px; line-height: 1;
  padding: 8px 16px; min-height: 36px; font-size: 0.8rem;
  background: var(--em); color: #ffffff; border: 1px solid var(--em);
  transition: background 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
.btn:hover { background: var(--em-h); border-color: var(--em-h); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--font-sans); font-weight: 500;
  cursor: pointer; border-radius: 6px; line-height: 1;
  padding: 8px 14px; min-height: 36px; font-size: 0.8rem;
  background: var(--white);
  color: var(--t2); border: 1px solid var(--bd);
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.btn-ghost:hover { color: var(--t1); border-color: #d1d5db; background: var(--bg); }
.btn-icon { padding: 5px 8px; min-height: 28px; font-size: 0.72rem; }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--font-sans); font-weight: 600;
  cursor: pointer; border-radius: 6px; line-height: 1;
  padding: 9px 18px; min-height: 38px; font-size: 0.8rem;
  background: var(--em); color: #ffffff; border: 1px solid var(--em);
  transition: background 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
.btn-primary:hover { background: var(--em-h); border-color: var(--em-h); box-shadow: 0 0 0 3px #d1fae5; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--font-sans); font-weight: 500;
  cursor: pointer; border-radius: 6px; line-height: 1;
  padding: 8px 16px; min-height: 38px; font-size: 0.8rem;
  background: var(--white); border: 1px solid var(--bd); color: var(--t1);
  transition: border-color 0.14s ease, color 0.14s ease;
}
.btn-secondary:hover { border-color: var(--em-bd); color: var(--em); }

.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--font-sans); font-weight: 500;
  cursor: pointer; border-radius: 6px; line-height: 1;
  padding: 8px 16px; min-height: 38px; font-size: 0.8rem;
  background: transparent; color: var(--err); border: 1px solid #fca5a5;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.btn-danger:hover { background: var(--err-soft); border-color: var(--err); }

.btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--font-sans); font-weight: 500;
  cursor: pointer; border-radius: 5px; line-height: 1;
  padding: 5px 10px; min-height: 30px; font-size: 0.72rem;
  background: var(--white); border: 1px solid var(--bd); color: var(--t2);
  transition: color 0.14s ease, border-color 0.14s ease;
}
.btn-outline:hover { color: var(--em); border-color: var(--em-bd); }

.btn-sm { padding: 6px 12px; font-size: 0.76rem; min-height: 32px; }

.btn-pill {
  padding: 5px 12px; background: var(--white); border: 1px solid var(--bd);
  border-radius: 999px; color: var(--t2);
  font-family: var(--font-sans); font-size: 0.72rem; font-weight: 500;
  cursor: pointer; transition: all 0.14s ease;
  display: inline-flex; align-items: center; gap: 5px; line-height: 1;
}
.btn-pill:hover,
.btn-pill.active { background: var(--em-soft); color: var(--em); border-color: var(--em-bd); }

/* ─── Form fields ────────────────────────────────────────────────────── */
.form-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 18px; }

.form-label {
  font-family: var(--font-mono);
  font-size: 0.67rem;
  font-weight: 600;
  color: var(--t2);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.form-input,
.form-textarea,
.form-select {
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--t1);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
  width: 100%;
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--t3); }

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  background: var(--white);
  border-color: var(--em);
  box-shadow: 0 0 0 3px #d1fae5;
}

:focus-visible { outline: 2px solid var(--em); outline-offset: 2px; }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}
.form-select option { background: #fff; color: var(--t1); }

.form-textarea { min-height: 92px; resize: vertical; line-height: 1.5; }

.form-hint  { font-size: 0.74rem; color: var(--t3); line-height: 1.4; margin: 0; }
.form-error { font-family: var(--font-mono); font-size: 0.7rem; color: var(--err); margin: 0; }

/* ─── Badges / pills ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.5;
}
.badge-positive { background: var(--em-soft);  color: var(--em);   border: 1px solid var(--em-bd); }
.badge-negative { background: var(--err-soft); color: var(--err);  border: 1px solid var(--err-bd); }
.badge-neutral  { background: var(--surface-2); color: var(--t2);  border: 1px solid var(--bd); }
.badge-info     { background: #ecfeff; color: var(--cyan);          border: 1px solid #a5f3fc; }
.badge-warning  { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-bd); }

/* ─── Data tables ────────────────────────────────────────────────────── */
.data-table-wrapper {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--bd);
  border-radius: var(--r);
  background: var(--white);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table thead th {
  background: var(--bg);
  color: var(--t3);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--bd);
  text-align: left;
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--bd-light);
  transition: background 0.10s ease;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg); }

.data-table tbody td {
  padding: 10px 14px;
  color: var(--t2);
  vertical-align: middle;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.data-table tbody td.td-overflow { white-space: normal; word-break: break-word; }

.data-table tbody tr.row-link { cursor: pointer; }
.data-table tbody tr.row-link:hover { box-shadow: inset 3px 0 0 var(--em); }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ─── Charts ─────────────────────────────────────────────────────────── */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chart-title {
  font-family: var(--font-mono);
  font-size: 0.7rem; font-weight: 600;
  color: var(--t2);
  text-transform: uppercase; letter-spacing: 0.1em;
  margin: 0 0 14px 0;
}
@media (max-width: 768px) { .charts-grid { grid-template-columns: 1fr; } }

/* ─── Modal ──────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--overlay-background);
  display: flex; align-items: center; justify-content: center;
  z-index: 10020; padding: 20px; /* above fullscreen overlays (10010) so confirm dialogs are never buried */
}
.modal-card {
  position: relative;
  background: var(--white);
  border: 1px solid var(--bd);
  border-top: 2px solid var(--em);
  border-radius: var(--r);
  padding: 28px 32px;
  max-width: 480px; width: 100%;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
}

/* ─── Empty state ────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 48px 24px; gap: 8px;
  color: var(--t2);
}
.empty-icon {
  width: 48px; height: 48px; border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--bd);
  display: flex; align-items: center; justify-content: center;
  color: var(--t3); margin-bottom: 8px;
}
.empty-title { font-size: 0.92rem; font-weight: 600; color: var(--t1); margin: 0; }
.empty-description { font-size: 0.82rem; color: var(--t2); line-height: 1.5; margin: 0 0 12px 0; max-width: 320px; }

/* ─── Alerts ─────────────────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-radius: var(--r);
  font-size: 0.875rem; line-height: 1.5; margin: 14px 0;
}
.alert-icon { flex-shrink: 0; margin-top: 1px; }
.alert-error   { background: var(--err-soft);  color: #991b1b; border: 1px solid var(--err-bd); }
.alert-warning { background: var(--warn-soft); color: #92400e; border: 1px solid var(--warn-bd); }
.alert-success { background: var(--em-soft);   color: #065f46; border: 1px solid var(--em-bd); }
.alert-info    { background: var(--bg);        color: var(--t2); border: 1px solid var(--bd); }

/* ─── Spinner + skeleton ─────────────────────────────────────────────── */
.loading-block { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px 0; }
.spinner, .spinner-sm {
  border-radius: 50%;
  border-style: solid;
  border-color: var(--spinner-bg);
  border-top-color: var(--em);
  animation: spin 0.9s linear infinite;
}
.spinner    { width: 28px; height: 28px; border-width: 3px; }
.spinner-sm { width: 15px; height: 15px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-family: var(--font-mono); font-size: 0.76rem; color: var(--t2); margin: 0; letter-spacing: 0.04em; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
.skeleton-line  { height: 14px; width: 100%; margin-bottom: 8px; }
.skeleton-title { height: 20px; width: 70%; margin-bottom: 12px; }
.skeleton-card  { height: 80px; width: 100%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ─── Avatar ─────────────────────────────────────────────────────────── */
.avatar {
  border-radius: 6px;
  background: var(--em);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0; width: 32px; height: 32px;
}
.avatar-fallback { font-family: var(--font-mono); font-size: 0.7rem; font-weight: 600; color: #fff; }

/* ─── Meta row ───────────────────────────────────────────────────────── */
.meta-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem; color: var(--t2);
  letter-spacing: 0.02em; margin-bottom: 10px;
}
.meta-author { font-weight: 500; color: var(--cyan); }
.meta-date   { color: var(--t3); }

/* ─── Login ──────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--white);
  border: 1px solid var(--bd);
  border-top: 2px solid var(--em);
  border-radius: var(--r);
  padding: 40px 36px; width: 100%; max-width: 380px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  position: relative;
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand-dot {
  display: inline-block; width: 8px; height: 8px;
  background: var(--em); border-radius: 50%; margin-bottom: 10px;
}
.auth-brand-name {
  display: block;
  font-family: var(--font-sans);
  font-size: 1rem; font-weight: 700; color: var(--t1);
  letter-spacing: -0.01em; line-height: 1.2; margin-bottom: 4px;
}
.auth-brand-sub { font-family: var(--font-mono); font-size: 0.72rem; color: var(--t3); letter-spacing: 0.04em; }

/* ─── Pagination ─────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 12px; margin-top: 18px; justify-content: center; }
.page-indicator { font-family: var(--font-mono); font-size: 0.74rem; color: var(--t2); font-variant-numeric: tabular-nums; }

/* ─── Settings ───────────────────────────────────────────────────────── */
.settings-section { padding: 22px; margin-bottom: 16px; }
.settings-section-title {
  font-family: var(--font-mono);
  font-size: 0.7rem; font-weight: 600;
  color: var(--t2);
  text-transform: uppercase; letter-spacing: 0.1em;
  margin: 0 0 18px 0; padding-bottom: 10px;
  border-bottom: 1px solid var(--bd-light);
}

/* ─── Dropdown ───────────────────────────────────────────────────────── */
.dropdown-container { position: relative; display: inline-flex; }
.dropdown-menu {
  position: absolute; top: calc(100% + 4px); right: 0;
  background: var(--white);
  border: 1px solid var(--bd);
  border-top: 2px solid var(--em);
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  min-width: 180px; z-index: 10001; overflow: hidden;
  border-radius: 0 0 var(--r) var(--r);
  animation: dropdownFadeIn 0.16s ease;
}
@keyframes dropdownFadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.dropdown-item {
  display: flex; align-items: center;
  padding: 9px 14px;
  background: none; border: none; border-left: 2px solid transparent;
  color: var(--t2);
  font-family: var(--font-sans);
  font-size: 0.82rem; font-weight: 500; cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  white-space: nowrap; width: 100%; text-align: left;
}
.dropdown-item:hover { background: var(--bg); color: var(--t1); border-left-color: var(--em); }

/* ─── Misc helpers ───────────────────────────────────────────────────── */
.muted { color: var(--t3); font-size: 0.82rem; }
code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--surface-2);
  border: 1px solid var(--bd-light);
  padding: 1px 5px; border-radius: 3px;
  color: var(--cyan);
}

.connect-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── Reduced motion ─────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .spinner, .spinner-sm { animation: none; border-top-color: var(--em); }
  .skeleton { animation: none; background: var(--surface-2); }
  .brand-dot, .nav-status-dot, .status-light.online::before { animation: none; }
  .card, .stat-card, .card-flat, .queue-item, .account-card, .chart-card { transition: none; }
  .vl-item, .btn, .btn-ghost, .btn-primary, .btn-secondary, .btn-danger,
  .btn-outline, .btn-pill, .form-input, .form-textarea, .form-select { transition: none; }
}

/* ─── Mobile ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .navbar { height: 48px; padding: 0 12px; overflow-x: auto; flex-wrap: nowrap; }
  .nav-items { flex-shrink: 0; gap: 0; }
  .nav-brand { flex-shrink: 0; margin-right: 10px; }
  .nav-actions { flex-shrink: 0; margin-left: 8px; }
  .data-table thead th, .data-table tbody td { padding: 8px 10px; font-size: 0.75rem; }
  .stat-value, .metric { font-size: 1.8rem; }
  .charts-grid { grid-template-columns: 1fr; }
  .queue-actions { flex-direction: column; }
  .queue-actions .btn-primary,
  .queue-actions .btn-secondary,
  .queue-actions .btn-danger { width: 100%; }
}

@media (max-width: 480px) {
  .auth-card { padding: 24px 18px; }
  .settings-section { padding: 14px; }
  .btn-primary, .btn-secondary { font-size: 0.74rem; padding: 7px 12px; }
}

/* ─── Toast ──────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 10px 18px; border-radius: var(--r); font-size: 0.85rem; font-weight: 500;
  z-index: 20000; opacity: 0; pointer-events: none; transition: opacity 0.18s ease;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12); max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; }
.toast.success { background: var(--em); color: #fff; }
.toast.error   { background: var(--err); color: #fff; }
.toast.warn    { background: var(--warn); color: #fff; }

/* ─── Toggle switch ──────────────────────────────────────────────────── */
.toggle { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  width: 34px; height: 18px; background: var(--surface-3); border-radius: 9px;
  transition: background 0.18s ease; position: relative; flex-shrink: 0;
}
.toggle-thumb {
  position: absolute; top: 3px; left: 3px; width: 12px; height: 12px;
  background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.20);
  transition: transform 0.18s ease; pointer-events: none;
}
.toggle input:checked + .toggle-track { background: var(--em); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }

/* ─── Refresh dot ────────────────────────────────────────────────────── */
.refresh-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--t3); display: inline-block; flex-shrink: 0;
  transition: background 0.3s ease;
}
.refresh-dot.live { background: var(--em); box-shadow: 0 0 0 3px var(--em-soft); }

/* ── Video master list (sidebar, shared by dashboard + chapters) ──────── */
.vl-toolbar { display:flex; flex-direction:column; gap:6px; padding: 0 12px 8px; }
.vl-search {
  width:100%; box-sizing:border-box;
  background: var(--bg);
  border:1px solid var(--bd); border-radius:6px;
  padding:6px 10px; font:inherit; font-size:0.78rem; color:var(--t1);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.vl-search:focus { border-color:var(--em); box-shadow:0 0 0 3px #d1fae5; outline:none; }
.vl-controls { display:flex; align-items:center; gap:6px; }
.vl-list {
  overflow:auto;
  display:flex; flex-direction:column;
  content-visibility:auto; contain-intrinsic-size:auto 400px;
  gap: 8px;
  padding: 8px 0;
}
.vl-item {
  display:flex;
  flex-direction:column;
  align-items:stretch;
  gap:6px;
  padding:10px 14px;
  margin:0 12px;
  border:1px solid var(--bd-light);
  border-radius:6px;
  background:var(--white);
  cursor:pointer;
  transition: background 0.10s ease, border-color 0.10s ease;
}
.vl-item:hover { background: var(--bg); border-color: var(--bd); }
.vl-item.sel  { background: var(--em-soft); border-color: var(--em-bd); }
.vl-item.vl-peer-hover { background: #fffbeb; }
.vl-item-meta-row { display:flex; align-items:center; gap:8px; }
.vl-item-meta-row .badge {
  font-size:0.6rem; font-weight:700; padding:1px 5px; border-radius:4px;
  text-transform:uppercase; letter-spacing:0.05em; display:inline-block;
}
.vl-item-meta-row .vl-date { font-family:var(--font-mono); font-size:0.68rem; color:var(--t3); }
.vl-item-meta-row .vl-counts {
  font-family:var(--font-mono); font-size:0.68rem;
  background: var(--warn); color: #fff;
  border-radius: 10px; padding: 1px 6px;
  font-weight: 700; flex-shrink: 0;
  margin-left: auto;
}
.vl-item-meta-row .vl-counts.em { background: var(--em); }
.vl-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size:0.8rem; color:var(--t1);
  line-height:1.4;
  white-space: normal;
  font-weight: 500;
}
.vl-title.muted { color: var(--t3); }
.vl-item.sel .vl-title { color: var(--em); font-weight: 600; }

/* "All videos" item */
.vl-all {
  display:flex; align-items:center; gap:8px; padding:8px 14px;
  cursor:pointer; transition: background 0.10s ease;
  border-bottom: 1px solid var(--bd-light);
}
.vl-all:hover { background: var(--bg); }
.vl-all.sel { background: var(--em-soft); }
.vl-all-label { flex:1; font-size:0.78rem; font-weight:600; color:var(--t2); }
.vl-all.sel .vl-all-label { color: var(--em); }
.vl-section-div { height:1px; background:var(--bd); margin:4px 12px; }

/* badge variants */
.vl-badge-short { background:rgba(124,58,237,0.10); color:var(--kind-short); border:1px solid rgba(124,58,237,0.20); }
.vl-badge-video { background:#ecfeff; color:var(--kind-video);  border:1px solid #a5f3fc; }

/* ── Dashboard layout ────────────────────────────────────────────────── */
.dash-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 52px);
}

.metrics-band {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--white);
  border-bottom: 1px solid var(--bd);
  flex-shrink: 0;
  height: 64px;
}

.mc-cell {
  display: flex; flex-direction: column; justify-content: center;
  padding: 0 20px; border-right: 1px solid var(--bd);
}
.mc-cell:last-child { border-right: none; }
.mc-label {
  font-size: 0.62rem; color: var(--t3); text-transform: uppercase;
  letter-spacing: .05em; font-weight: 600; line-height: 1;
}
.mc-row { display: flex; align-items: baseline; gap: 5px; margin-top: 4px; }
.mc-value {
  font-family: var(--font-mono); font-size: 1.4rem; font-weight: 700;
  line-height: 1; font-variant-numeric: tabular-nums;
}
.mc-value.em   { color: var(--em); }
.mc-value.warn { color: var(--warn); }
.mc-value.err  { color: var(--err); }
.mc-value.muted{ color: var(--t3); }
.mc-sub { font-size: 0.64rem; color: var(--t3); }

.dash-body {
  display: grid;
  grid-template-columns: 320px 1fr;
  flex: 1;
  overflow: hidden;
}

.dash-sidebar {
  border-right: 1px solid var(--bd);
  background: var(--white);
  overflow-y: auto;
  display: flex; flex-direction: column;
}

.dash-sidebar-top {
  padding: 12px 0 6px;
  flex-shrink: 0;
}

.sb-label {
  font-size: 0.6rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--t3); font-weight: 600; padding: 0 14px 6px;
  display: block;
}

.sb-btn-row { display: flex; gap: 5px; padding: 0 12px 8px; }
.sb-btn {
  flex: 1; font-size: 0.68rem; padding: 5px 0; border: 1px solid var(--bd);
  border-radius: 5px; background: var(--white); color: var(--t2); cursor: pointer;
  text-align: center; font-family: var(--font-sans);
}
.sb-btn:hover { background: var(--bg); color: var(--t1); }
.sb-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.dash-main {
  overflow-y: auto;
  background: var(--bg);
  padding: 20px 22px;
}

/* ── Chapters layout (reuses sidebar pattern) ────────────────────────── */
.ch-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 52px);
  overflow: hidden;
}

.ch-sidebar {
  border-right: 1px solid var(--bd);
  background: var(--white);
  overflow-y: auto;
  padding: 12px 0;
}

.ch-workspace {
  overflow-y: auto;
  background: var(--bg);
  padding: 24px;
}

@media (max-width: 900px) {
  .dash-body { grid-template-columns: 1fr; }
  .dash-sidebar { border-right: none; border-bottom: 1px solid var(--bd); max-height: 240px; }
  .ch-layout { grid-template-columns: 1fr; }
  .ch-sidebar { border-right: none; border-bottom: 1px solid var(--bd); max-height: 220px; }
}

@media (max-width: 600px) {
  .metrics-band { grid-template-columns: repeat(2, 1fr); height: auto; }
  .mc-cell { padding: 10px 14px; border-right: none; border-bottom: 1px solid var(--bd); }
  .mc-cell:nth-child(odd) { border-right: 1px solid var(--bd); }
  .mc-cell:nth-child(3), .mc-cell:nth-child(4) { border-bottom: none; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Editorial Full-Height shell — shared primitives (2026-06-23 redesign)
   Generalised from Script Studio's .sc-pane* into a project-wide vocabulary.
   App shell fills the viewport below the 52px navbar; each pane is a fixed
   head + an independently scrolling body. Desktop only — stacks on mobile.
   ═══════════════════════════════════════════════════════════════════════ */
@media (min-width: 1025px) { html, body { overflow: hidden; } }

.app-shell {
  display: grid; gap: 12px; padding: 12px;
  height: calc(100vh - var(--navh)); box-sizing: border-box;
}
.app-shell--2 { grid-template-columns: 260px minmax(0, 1fr); }
.app-shell--3 { grid-template-columns: 250px minmax(0, 1.3fr) minmax(0, 1fr); }
/* Dashboard collapses the right detail pane until a video is selected */
.app-shell--3:not(.has-detail) { grid-template-columns: 250px minmax(0, 1fr); }
.app-shell--3:not(.has-detail) .pane--detail { display: none; }

.pane {
  display: flex; flex-direction: column; min-height: 0; height: 100%; overflow: hidden;
  background: var(--white); border: 1px solid var(--bd); border-radius: var(--r);
}
.pane-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-shrink: 0; padding: 13px 18px; border-bottom: 1px solid var(--bd);
}
.pane-body { flex: 1; min-height: 0; overflow: auto; padding: 18px; }
.pane-foot { flex-shrink: 0; border-top: 1px solid var(--bd); padding: 10px; }
.pane-tools { display: flex; align-items: center; gap: 6px; }

/* mono caps label with an emerald dot — the editorial eyebrow */
.eyebrow {
  font-family: var(--font-mono); font-size: var(--fs-eyebrow); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--t1);
  display: flex; align-items: center; gap: 9px; margin: 0;
}
.eyebrow::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--em); flex-shrink: 0; }

/* form content inside a pane stays readable — don't stretch full-bleed */
.pane-body .pane-form { max-width: 720px; }

@media (max-width: 1024px) {
  .app-shell, .app-shell--2, .app-shell--3,
  .app-shell--3:not(.has-detail) { grid-template-columns: 1fr; height: auto; gap: 12px; }
  .pane { height: auto; overflow: visible; }
  .pane-body { overflow: visible; }
  .app-shell--3:not(.has-detail) .pane--detail { display: flex; }
}
