/* =====================================================================
 * SlideMaker — base.css
 * Modern design system: refined tokens, polished components,
 * subtle depth, OKLCH-aware palette, dark/light themes.
 * ===================================================================== */

/* ---------- Design tokens ---------- */
:root {
  /* Brand — Indigo, refined */
  --brand-50:  #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-300: #a5b4fc;
  --brand-400: #818cf8;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --brand-800: #3730a3;
  --brand-900: #312e81;

  /* Aliases */
  --c-accent:        var(--brand-600);
  --c-accent-hover:  var(--brand-700);
  --c-accent-soft:   rgba(99, 102, 241, 0.10);
  --c-accent-ring:   rgba(99, 102, 241, 0.30);

  /* Status */
  --c-success:   #10b981;
  --c-success-soft: rgba(16, 185, 129, 0.10);
  --c-warning:   #f59e0b;
  --c-warning-soft: rgba(245, 158, 11, 0.12);
  --c-danger:    #ef4444;
  --c-danger-soft:  rgba(239, 68, 68, 0.10);
  --c-info:      #06b6d4;
  --c-info-soft: rgba(6, 182, 212, 0.10);

  /* Light theme */
  --bg-app:      #f8fafc;
  --bg-app-grad: radial-gradient(1200px 600px at 100% -10%, rgba(99,102,241,.06), transparent 60%),
                 radial-gradient(900px 500px at -10% 110%, rgba(16,185,129,.04), transparent 60%);
  --bg-card:     #ffffff;
  --bg-elev:     #ffffff;
  --bg-input:    #ffffff;
  --bg-muted:    #f1f5f9;
  --bg-subtle:   #f8fafc;
  --bg-hover:    #f1f5f9;
  --bg-active:   #e2e8f0;
  --bg-overlay:  rgba(15, 23, 42, 0.45);
  --bg-glass:    rgba(255, 255, 255, 0.72);

  --fg-default:  #0f172a;
  --fg-strong:   #020617;
  --fg-muted:    #64748b;
  --fg-soft:     #94a3b8;
  --fg-disabled: #cbd5e1;
  --fg-on-accent:#ffffff;

  --border:        #e2e8f0;
  --border-strong: #cbd5e1;
  --border-input:  #d1d5db;
  --c-border: var(--border);
  --c-text-dim: var(--fg-muted);
  --c-success-bg: var(--c-success-soft);

  --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.06);
  --shadow-md: 0 4px 6px -1px rgba(15,23,42,.06), 0 2px 4px -2px rgba(15,23,42,.04);
  --shadow-lg: 0 10px 15px -3px rgba(15,23,42,.08), 0 4px 6px -4px rgba(15,23,42,.04);
  --shadow-xl: 0 20px 25px -5px rgba(15,23,42,.10), 0 8px 10px -6px rgba(15,23,42,.06);
  --shadow-2xl:0 25px 50px -12px rgba(15,23,42,.25);
  --shadow-glow: 0 0 0 1px var(--c-accent-ring), 0 8px 24px -8px rgba(99,102,241,.4);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius:    8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl:20px;
  --radius-full: 9999px;

  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-norm: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);

  --ff-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ff-mono: ui-monospace, 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace;
  --ff-display: 'Inter', system-ui, sans-serif;

  --font-feature: "cv02", "cv03", "cv04", "cv11", "ss01";
}

[data-theme="dark"] {
  --bg-app:      #0a0a0f;
  --bg-app-grad: radial-gradient(1200px 600px at 100% -10%, rgba(99,102,241,.12), transparent 60%),
                 radial-gradient(900px 500px at -10% 110%, rgba(16,185,129,.06), transparent 60%);
  --bg-card:     #131318;
  --bg-elev:     #1a1a21;
  --bg-input:    #131318;
  --bg-muted:    #1f1f27;
  --bg-subtle:   #16161d;
  --bg-hover:    #1f1f27;
  --bg-active:   #292932;
  --bg-overlay:  rgba(0, 0, 0, 0.65);
  --bg-glass:    rgba(19, 19, 24, 0.72);

  --fg-default:  #f1f5f9;
  --fg-strong:   #ffffff;
  --fg-muted:    #94a3b8;
  --fg-soft:     #64748b;
  --fg-disabled: #334155;

  --border:        #262630;
  --border-strong: #353541;
  --border-input:  #2e2e38;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.35);
  --shadow-md: 0 4px 12px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 24px rgba(0,0,0,.5);
  --shadow-xl: 0 20px 40px rgba(0,0,0,.55);
  --shadow-2xl:0 32px 64px rgba(0,0,0,.7);
  --shadow-glow: 0 0 0 1px rgba(129, 140, 248, .35), 0 8px 32px -4px rgba(99,102,241,.45);

  --c-accent-soft: rgba(129, 140, 248, 0.14);
  --c-accent-ring: rgba(129, 140, 248, 0.35);
}

[data-theme="midnight"] {
  --brand-400: #22d3ee;
  --brand-500: #06b6d4;
  --brand-600: #0891b2;
  --brand-700: #0e7490;
  --bg-app: #080b13;
  --bg-app-grad: radial-gradient(900px 420px at 90% -10%, rgba(8,145,178,.16), transparent 60%),
                 radial-gradient(720px 380px at 0% 110%, rgba(245,158,11,.08), transparent 60%);
  --bg-card: #101722;
  --bg-elev: #172232;
  --bg-input: #101722;
  --bg-muted: #1d2a3a;
  --bg-subtle: #121c2a;
  --bg-hover: #1c2a3d;
  --bg-active: #25374f;
  --bg-overlay: rgba(2, 6, 23, .72);
  --bg-glass: rgba(16, 23, 34, .74);
  --fg-default: #e5f1f7;
  --fg-strong: #ffffff;
  --fg-muted: #95a8b8;
  --fg-soft: #6f8292;
  --border: #273548;
  --border-strong: #35485e;
  --border-input: #34465b;
  --c-accent: var(--brand-500);
  --c-accent-hover: var(--brand-400);
  --c-accent-soft: rgba(6, 182, 212, .14);
  --c-accent-ring: rgba(34, 211, 238, .32);
}

[data-theme="forest"] {
  --brand-400: #34d399;
  --brand-500: #10b981;
  --brand-600: #059669;
  --brand-700: #047857;
  --bg-app: #f4f7f2;
  --bg-app-grad: radial-gradient(900px 420px at 100% 0%, rgba(16,185,129,.12), transparent 60%),
                 radial-gradient(700px 360px at 0% 100%, rgba(14,116,144,.08), transparent 60%);
  --bg-card: #ffffff;
  --bg-elev: #ffffff;
  --bg-input: #ffffff;
  --bg-muted: #e9efe7;
  --bg-subtle: #f7faf5;
  --bg-hover: #eaf3eb;
  --bg-active: #dceadf;
  --bg-glass: rgba(255,255,255,.78);
  --fg-default: #173126;
  --fg-strong: #071a13;
  --fg-muted: #617269;
  --fg-soft: #87958d;
  --border: #d7e1d8;
  --border-strong: #bdcfc0;
  --border-input: #c5d4c7;
  --c-accent: var(--brand-600);
  --c-accent-hover: var(--brand-700);
  --c-accent-soft: rgba(16, 185, 129, .12);
  --c-accent-ring: rgba(5, 150, 105, .28);
}

[data-theme="sunset"] {
  --brand-400: #fb923c;
  --brand-500: #f97316;
  --brand-600: #ea580c;
  --brand-700: #c2410c;
  --bg-app: #171313;
  --bg-app-grad: radial-gradient(900px 420px at 100% 0%, rgba(249,115,22,.16), transparent 58%),
                 radial-gradient(740px 420px at 0% 105%, rgba(20,184,166,.10), transparent 58%);
  --bg-card: #211b1a;
  --bg-elev: #2a2321;
  --bg-input: #211b1a;
  --bg-muted: #332a27;
  --bg-subtle: #251f1d;
  --bg-hover: #332a27;
  --bg-active: #43352f;
  --bg-overlay: rgba(12, 10, 9, .7);
  --bg-glass: rgba(33, 27, 26, .76);
  --fg-default: #f7efe8;
  --fg-strong: #fffaf5;
  --fg-muted: #c2aaa0;
  --fg-soft: #8d756d;
  --border: #3f312d;
  --border-strong: #57423a;
  --border-input: #4a3933;
  --c-accent: var(--brand-500);
  --c-accent-hover: var(--brand-400);
  --c-accent-soft: rgba(249, 115, 22, .15);
  --c-accent-ring: rgba(251, 146, 60, .34);
}

[data-theme="contrast"] {
  --brand-400: #fde047;
  --brand-500: #facc15;
  --brand-600: #eab308;
  --brand-700: #ca8a04;
  --bg-app: #000000;
  --bg-app-grad: none;
  --bg-card: #0b0b0b;
  --bg-elev: #141414;
  --bg-input: #050505;
  --bg-muted: #1f1f1f;
  --bg-subtle: #111111;
  --bg-hover: #242424;
  --bg-active: #303030;
  --bg-overlay: rgba(0,0,0,.8);
  --bg-glass: rgba(10,10,10,.9);
  --fg-default: #f8fafc;
  --fg-strong: #ffffff;
  --fg-muted: #d1d5db;
  --fg-soft: #9ca3af;
  --border: #3f3f46;
  --border-strong: #71717a;
  --border-input: #71717a;
  --c-accent: var(--brand-500);
  --c-accent-hover: var(--brand-400);
  --c-accent-soft: rgba(250, 204, 21, .16);
  --c-accent-ring: rgba(250, 204, 21, .42);
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--ff-ui);
  background: var(--bg-app);
  background-image: var(--bg-app-grad);
  background-attachment: fixed;
  color: var(--fg-default);
  font-size: 14px;
  line-height: 1.55;
  font-feature-settings: var(--font-feature);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: var(--ff-display);
  color: var(--fg-strong);
  letter-spacing: -0.011em;
  line-height: 1.25;
  margin: 0 0 0.5em;
  font-weight: 600;
}
h1 { font-size: 28px; letter-spacing: -0.022em; font-weight: 700; }
h2 { font-size: 20px; letter-spacing: -0.017em; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }

p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

a {
  color: var(--c-accent);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--c-accent-hover); text-decoration: underline; text-underline-offset: 3px; }

::selection { background: var(--c-accent-soft); color: var(--fg-strong); }

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg-app); }
*::-webkit-scrollbar-thumb:hover { background: var(--fg-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--fg-default);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.2;
  white-space: nowrap;
  user-select: none;
  transition: background var(--t-fast), border-color var(--t-fast),
              color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  box-shadow: var(--shadow-xs);
}
.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--c-accent-ring);
}

.btn-primary {
  background: linear-gradient(180deg, var(--brand-500) 0%, var(--brand-600) 100%);
  border-color: var(--brand-600);
  color: var(--fg-on-accent);
  box-shadow: 0 1px 2px rgba(15,23,42,.1), inset 0 1px 0 rgba(255,255,255,.12);
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--brand-600) 0%, var(--brand-700) 100%);
  border-color: var(--brand-700);
  box-shadow: 0 4px 12px -2px rgba(99,102,241,.4), inset 0 1px 0 rgba(255,255,255,.12);
}
.btn-primary:focus-visible {
  box-shadow: 0 0 0 3px var(--c-accent-ring), inset 0 1px 0 rgba(255,255,255,.12);
}

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

.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--fg-muted);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: transparent;
  color: var(--fg-default);
}

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-xs { padding: 3px 7px; font-size: 11px; border-radius: var(--radius-xs); }
.btn-icon { padding: 7px; aspect-ratio: 1; }
.btn[disabled], .btn:disabled { opacity: .55; pointer-events: none; }
.btn.active { background: var(--bg-active); border-color: var(--border-strong); }

/* ---------- Inputs ---------- */
.input, .select, .textarea {
  width: 100%;
  background: var(--bg-input);
  color: var(--fg-default);
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  box-shadow: var(--shadow-xs);
}
.input::placeholder, .textarea::placeholder { color: var(--fg-soft); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-ring);
  background: var(--bg-card);
}
.input-sm, .select-sm, .textarea-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.input-flat {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.input-flat:hover { background: var(--bg-hover); border-color: transparent; }
.input-flat:focus {
  background: var(--bg-input);
  border-color: var(--c-accent);
}
.textarea { min-height: 84px; resize: vertical; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M3 4.5l3 3 3-3' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

label {
  font-size: 12px;
  color: var(--fg-muted);
  font-weight: 500;
  display: block;
  margin-bottom: 4px;
}

/* Form helpers */
.form-grid { display: flex; flex-direction: column; gap: 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; color: var(--fg-muted); font-size: 12px; font-weight: 500; }
.field-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.inline-form { display: inline-flex; gap: 8px; align-items: center; }

/* Switch */
.switch { display: inline-block; position: relative; width: 38px; height: 22px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch::after {
  content: ''; position: absolute; inset: 0;
  background: var(--border-strong); border-radius: 999px;
  transition: background var(--t-norm);
}
.switch::before {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; background: #fff; border-radius: 50%;
  transition: transform var(--t-norm), box-shadow var(--t-norm);
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
  z-index: 1;
}
.switch:has(input:checked)::after { background: var(--c-accent); }
.switch:has(input:checked)::before { transform: translateX(16px); }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

/* ---------- Tables ---------- */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.table th, .table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table th {
  font-weight: 600;
  color: var(--fg-muted);
  background: var(--bg-subtle);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--bg-hover); }
.table code {
  font-family: var(--ff-mono);
  font-size: 12px;
  background: var(--bg-muted);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  color: var(--fg-default);
}

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 500;
  background: var(--bg-muted);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pill-ok, .pill-approved, .pill-success { background: var(--c-success-soft); color: var(--c-success); border-color: transparent; }
.pill-warn, .pill-pending  { background: var(--c-warning-soft); color: var(--c-warning); border-color: transparent; }
.pill-err, .pill-rejected, .pill-danger  { background: var(--c-danger-soft); color: var(--c-danger); border-color: transparent; }
.pill-info, .pill-ai { background: var(--c-info-soft); color: var(--c-info); border-color: transparent; }
.pill-admin    { background: var(--c-accent-soft); color: var(--c-accent); border-color: transparent; }
.pill-editor   { background: var(--c-info-soft); color: var(--c-info); border-color: transparent; }
.pill-user     { background: var(--bg-muted); color: var(--fg-muted); border-color: var(--border); }
.pill-frontend { background: var(--bg-muted); color: var(--fg-muted); }
.pill-ai     { background: linear-gradient(135deg, rgba(99,102,241,.12), rgba(168,85,247,.12)); color: var(--c-accent); border-color: transparent; }

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid transparent;
  margin-bottom: 12px;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-error   { background: var(--c-danger-soft); border-color: rgba(239,68,68,.25); color: var(--c-danger); }
.alert-success { background: var(--c-success-soft); border-color: rgba(16,185,129,.25); color: var(--c-success); }
.alert-warning { background: var(--c-warning-soft); border-color: rgba(245,158,11,.3); color: var(--c-warning); }
.alert-info    { background: var(--c-info-soft); border-color: rgba(6,182,212,.25); color: var(--c-info); }

/* ---------- Toast ---------- */
.toast-host {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  animation: toast-in .25s cubic-bezier(.2,.9,.3,1.4);
  max-width: 380px;
  pointer-events: auto;
  transition: opacity var(--t-norm), transform var(--t-norm);
  position: relative;
  padding-left: 18px;
}
.toast::before {
  content: '';
  position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--fg-muted);
}
.toast.ok::before { background: var(--c-success); }
.toast.err::before { background: var(--c-danger); }
.toast.warn::before { background: var(--c-warning); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Modal ---------- */
/* CRITICAL: respect HTML `hidden` attribute, otherwise overlay sits on page */
/* Modal — hidden by default, shown via .is-open class (no attribute dependency) */
.modal-host {
  display: none;
}
.modal-host.is-open {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(6px) saturate(1.2);
  -webkit-backdrop-filter: blur(6px) saturate(1.2);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
  padding: 16px;
  animation: modal-fade-in .18s ease;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: auto;
  padding: 24px;
  animation: modal-pop-in .22s cubic-bezier(.2, .9, .3, 1.2);
}
.modal h3 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.011em;
}
.modal hr { margin: 18px -24px; }
@keyframes modal-fade-in {
  from { opacity: 0; backdrop-filter: blur(0); }
  to   { opacity: 1; }
}
@keyframes modal-pop-in {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Layout utilities ---------- */
.row     { display: flex; gap: 12px; align-items: center; }
.row.wrap{ flex-wrap: wrap; }
.col     { display: flex; flex-direction: column; gap: 8px; }
.spacer  { flex: 1; }
.hidden  { display: none !important; }
.muted   { color: var(--fg-muted); }
.small   { font-size: 12px; }
.mono    { font-family: var(--ff-mono); }

/* Toolbar (shared) */
.toolbar {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.toolbar-spacer { flex: 1; }

/* Empty state */
.empty-state {
  padding: 56px 24px;
  text-align: center;
  color: var(--fg-muted);
  font-size: 14px;
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

/* Pager */
.pager {
  margin-top: 18px;
  display: flex; gap: 4px; justify-content: center; flex-wrap: wrap;
}

/* Loading dots / spinner */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ====================================================================
 * MOBILE: hamburger, drawer, bottom-sheet, body lock
 * Shared across admin + editor. Specific layout rules in admin.css and editor.css.
 * ==================================================================== */

/* Hamburger button (animated ☰ → ✕) */
.hamburger {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg-default);
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.hamburger:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.hamburger:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--c-accent-ring); }
.hamburger-icon {
  position: relative;
  width: 18px; height: 14px;
  display: block;
}
.hamburger-icon::before,
.hamburger-icon::after,
.hamburger-icon span {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform var(--t-norm), opacity var(--t-fast), top var(--t-norm);
}
.hamburger-icon::before { top: 0; }
.hamburger-icon span    { top: 6px; }
.hamburger-icon::after  { top: 12px; }
.hamburger.is-open .hamburger-icon::before { top: 6px; transform: rotate(45deg); }
.hamburger.is-open .hamburger-icon span    { opacity: 0; }
.hamburger.is-open .hamburger-icon::after  { top: 6px; transform: rotate(-45deg); }

/* Mobile drawer (slide-in panel, e.g. admin sidebar, editor actions)
   Wrapped in mobile-only media query so the transform: translateX(-105%) and
   width: 84vw don't push the desktop sidebar off-screen when the element has
   both .admin-side and .mobile-drawer classes. */
@media (max-width: 900px) {
  .mobile-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-norm);
  }
  .mobile-drawer-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 84vw;
    max-width: 320px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-2xl);
    z-index: 210;
    transform: translateX(-105%);
    transition: transform var(--t-norm);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  .mobile-drawer.is-open {
    transform: translateX(0);
  }
  .mobile-drawer.drawer-right {
    left: auto; right: 0;
    border-right: none;
    border-left: 1px solid var(--border);
    transform: translateX(105%);
  }
  .mobile-drawer.drawer-right.is-open { transform: translateX(0); }
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.drawer-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.drawer-close {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--fg-muted);
  border-radius: var(--radius-sm);
  font-size: 18px;
  line-height: 1;
}
.drawer-close:hover { background: var(--bg-hover); color: var(--fg-default); }
.drawer-body { padding: 12px; flex: 1; }

/* Bottom sheet (rises from bottom on mobile, for editor panels)
   Wrapped in mobile-only media query for the same reason as .mobile-drawer. */
@media (max-width: 900px) {
  .bottom-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.3);
    z-index: 220;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-fast);
  }
  .bottom-sheet-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .bottom-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    max-height: 75vh;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.18);
    z-index: 230;
    transform: translateY(100%);
    transition: transform 280ms cubic-bezier(0.2, 0.9, 0.3, 1.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .bottom-sheet.is-open { transform: translateY(0); }
}

.sheet-handle {
  display: block;
  width: 36px; height: 4px;
  margin: 8px auto 4px;
  background: var(--border-strong);
  border-radius: 999px;
  flex: 0 0 auto;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.sheet-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}
.sheet-body {
  padding: 14px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* Body lock when drawer/sheet open */
body.is-locked,
html.is-locked {
  overflow: hidden;
  touch-action: none;
}

/* Visibility utilities — hide-only pattern.
   .mobile-only is hidden on desktop; on mobile, the element uses its natural display.
   .desktop-only is hidden on mobile.  */
@media (min-width: 901px) {
  .mobile-only { display: none !important; }
}
@media (max-width: 900px) {
  .desktop-only { display: none !important; }
}

/* Mobile: prevent scroll bubbling from sheet/drawer body to document */
@media (max-width: 900px) {
  .drawer-body,
  .sheet-body {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}
