/*
  AIVS Pitch Site
  Static, Netlify-ready
  Design language: Calm authority, structured truth, controlled signal.

  v8.1 — Design System Consolidation
  - Unified badge/pill/chip system
  - Simplified breakpoint system (4 breakpoints)
  - WCAG AA color contrast fixes
  - Reduced-motion support
  - Skip-to-main accessibility
*/

/* ========== Reduced Motion ========== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ========== Fonts ========== */
@font-face {
  font-family: "Space Grotesk";
  src: url("fonts/SpaceGrotesk-VariableFont_wght.ttf") format("truetype");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/Inter-VariableFont_opsz,wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/Inter-Italic-VariableFont_opsz,wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans Mono";
  src: url("fonts/NotoSansMono-VariableFont_wdth,wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ========== Tokens ========== */
:root {
  /* Brand */
  --brand-navy: #0b1f2a;
  --brand-cream: #f1f2ee;
  --brand-gold: #d38b2b;

  /* Neutrals */
  --ink: #0b1f2a;
  --ink-2: rgba(11, 31, 42, 0.72);
  --ink-3: rgba(11, 31, 42, 0.52);
  --paper: #ffffff;

  /* Dark neutrals */
  --night: #07141b;
  --night-2: #0b1f2a;
  --night-3: #0f2a36;

  /* Radii */
  --r-xs: 10px;
  --r-sm: 14px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* Standardized breakpoints */
  --bp-sm: 640px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;

  /* Semantic colors (WCAG AA compliant) */
  --color-success: #1a9f6b;
  --color-success-bg: rgba(26, 159, 107, 0.14);
  --color-success-border: rgba(26, 159, 107, 0.38);
  --color-warning: #c27a1a;
  --color-warning-bg: rgba(194, 122, 26, 0.14);
  --color-warning-border: rgba(194, 122, 26, 0.38);
  --color-error: #d93025;
  --color-error-bg: rgba(217, 48, 37, 0.14);
  --color-error-border: rgba(217, 48, 37, 0.38);

  /* Touch target minimum (44px for WCAG) */
  --touch-min: 44px;

  /* Spacing */
  --s-1: 6px;
  --s-2: 10px;
  --s-3: 14px;
  --s-4: 18px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 44px;
  --s-8: 64px;

  /* Type */
  --font-display: "Space Grotesk", system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial;
  --font-ui: "Inter", system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial;
  --font-mono: "Noto Sans Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* UI shadow (subtle, calm) */
  --shadow-1: 0 10px 40px rgba(11, 31, 42, 0.08);
  --shadow-2: 0 22px 80px rgba(11, 31, 42, 0.12);
  --shadow-3: 0 32px 140px rgba(11, 31, 42, 0.18);

  /* Slide base */
  --slide-w: 1280;
  --slide-h: 720;

  /* Theatre frame */
  --topbar-h: 68px;
  --deck-footer-h: 72px;
  --stage-pad-x: var(--s-6);
  --stage-pad-top: var(--s-6);
  --stage-pad-bottom: var(--s-5);
}

/* ========== Theme ========== */
body.theme-light {
  --ui-bg: #f6f5f0;
  --ui-surface: rgba(255, 255, 255, 0.7);
  --ui-surface-solid: #ffffff;
  --ui-border: rgba(11, 31, 42, 0.12);
  --ui-border-strong: rgba(11, 31, 42, 0.18);
  --ui-text: var(--ink);
  --ui-text-muted: var(--ink-2);
  --ui-text-dim: var(--ink-3);
  --ui-accent: var(--brand-gold);
  --ui-accent-ink: #2a1b07;
  --ui-focus: rgba(211, 139, 43, 0.35);
  --ui-shadow: var(--shadow-1);
}
body.theme-dark {
  --ui-bg: radial-gradient(1200px 900px at 15% 10%, rgba(211, 139, 43, 0.10) 0%, rgba(11, 31, 42, 0) 60%),
            radial-gradient(1100px 700px at 85% 20%, rgba(255, 255, 255, 0.06) 0%, rgba(11, 31, 42, 0) 55%),
            linear-gradient(180deg, #06131a 0%, #07141b 100%);
  --ui-surface: rgba(15, 42, 54, 0.72);
  --ui-surface-solid: #0f2a36;
  --ui-border: rgba(255, 255, 255, 0.10);
  --ui-border-strong: rgba(255, 255, 255, 0.14);
  --ui-text: rgba(241, 242, 238, 0.96);
  --ui-text-muted: rgba(241, 242, 238, 0.72);
  --ui-text-dim: rgba(241, 242, 238, 0.52);
  --ui-accent: var(--brand-gold);
  --ui-accent-ink: #1a1207;
  --ui-focus: rgba(211, 139, 43, 0.38);
  --ui-shadow: 0 18px 80px rgba(0, 0, 0, 0.34);
}

/* ========== Base ========== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--ui-bg);
  color: var(--ui-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== Skip Link (Accessibility) ========== */
.skip-link {
  position: fixed;
  top: -100px;
  left: var(--s-4);
  z-index: 10000;
  padding: 12px 18px;
  background: var(--ui-accent);
  color: var(--ui-accent-ink);
  font-weight: 700;
  font-size: 14px;
  border-radius: var(--r-sm);
  text-decoration: none;
  box-shadow: var(--shadow-2);
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: var(--s-4);
  outline: 3px solid var(--ui-text);
  outline-offset: 2px;
}

/* ========== Focus Visible (Global) ========== */
:focus-visible {
  outline: 3px solid var(--ui-focus);
  outline-offset: 2px;
}
:focus:not(:focus-visible) {
  outline: none;
}

/* ========== Unified Badge System (v8.1) ==========
   Use .badge for all status indicators. Variants:
   - .badge-success (green)
   - .badge-warning (amber)
   - .badge-error (red)
   - .badge-muted (neutral/dim)
   Also compatible with legacy: .pill-ok, .pill-warn, .pill-bad
*/
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-success,
.badge.badge-success {
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: var(--color-success);
}

.badge-warning,
.badge.badge-warning {
  background: var(--color-warning-bg);
  border-color: var(--color-warning-border);
  color: var(--color-warning);
}

.badge-error,
.badge.badge-error {
  background: var(--color-error-bg);
  border-color: var(--color-error-border);
  color: var(--color-error);
}

.badge-muted,
.badge.badge-muted {
  opacity: 0.7;
}

/* ========== Auto-Save Indicator (Editor) ========== */
.save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: opacity 0.2s ease, background 0.2s ease;
}

.save-indicator[data-state="saved"] {
  color: var(--color-success);
  background: var(--color-success-bg);
}

.save-indicator[data-state="saving"] {
  color: var(--color-warning);
  background: var(--color-warning-bg);
}

.save-indicator[data-state="error"] {
  color: var(--color-error);
  background: var(--color-error-bg);
}

.save-indicator .indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.save-indicator[data-state="saving"] .indicator-dot {
  animation: pulse-dot 1s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* ========== Preview Mode (v8.1) ==========
   Clean view without editing UI. Allows editors to see
   how the deck will appear to viewers without publishing.
*/
body.preview-mode .sidebar { display: none !important; }
body.preview-mode .inspector { display: none !important; }
body.preview-mode .layout.editor-shell { grid-template-columns: 1fr !important; }

/* Hide editing hints and status in preview mode */
body.preview-mode .save-indicator { display: none !important; }
body.preview-mode .kbd-hint { display: none !important; }
body.preview-mode .brand-pill { display: none !important; }

/* Simplify topbar in preview mode */
body.preview-mode .topbar-right > *:not(.icon-btn) { display: none !important; }
body.preview-mode .topbar-right .icon-btn { display: none !important; }
body.preview-mode .topbar-right .icon-btn[aria-label="Preview mode"],
body.preview-mode .topbar-right .icon-btn[aria-label="Menu"] { display: inline-flex !important; }

/* Hide footer editing controls in preview mode */
body.preview-mode .deck-footer-right > *:not(.btn-menu) { display: none !important; }

/* Active state for preview button */
.icon-btn.active {
  background: var(--color-brand);
  color: var(--ui-bg);
}
.icon-btn.active:hover {
  background: var(--color-brand-hover);
}

/* Disable editing interactions in preview mode */
body.preview-mode .slide [data-edit] {
  pointer-events: none !important;
  cursor: default !important;
}
body.preview-mode .slide [data-edit]:hover {
  outline: none !important;
  background: transparent !important;
}

/* ========== Global Navigation Sidebar (v8.1) ==========
   Persistent sidebar for Editor/Admin pages providing
   quick navigation between main sections.
*/
.nav-sidebar {
  position: fixed;
  left: 0;
  top: var(--topbar-h);
  bottom: 0;
  width: 220px;
  background: var(--ui-surface);
  border-right: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  padding: var(--s-4) 0;
  z-index: 100;
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}

.nav-sidebar.open {
  transform: translateX(0);
}

.nav-sidebar-section {
  padding: var(--s-2) var(--s-4);
}

.nav-sidebar-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ui-text-dim);
  margin-bottom: var(--s-2);
}

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

.nav-sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--ui-text-muted);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-sidebar-link:hover {
  background: var(--ui-surface);
  color: var(--ui-text);
}

.nav-sidebar-link.active {
  background: rgba(211, 139, 43, 0.12);
  color: var(--ui-text);
  font-weight: 600;
}

.nav-sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-sidebar-link.active svg {
  opacity: 1;
}

.nav-sidebar-divider {
  height: 1px;
  background: var(--ui-border);
  margin: var(--s-3) var(--s-4);
}

/* When sidebar is open, offset main content */
body.has-nav-sidebar .container,
body.has-nav-sidebar .home-main {
  margin-left: 220px;
}

/* Mobile: overlay instead of push */
@media (max-width: 768px) {
  .nav-sidebar {
    width: 280px;
    box-shadow: var(--shadow-2);
  }
  body.has-nav-sidebar .container,
  body.has-nav-sidebar .home-main {
    margin-left: 0;
  }
  .nav-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 99;
  }
  .nav-sidebar-backdrop.open {
    opacity: 1;
    visibility: visible;
  }
}

/* Toggle button for sidebar */
.nav-toggle {
  display: none;
  width: var(--touch-min);
  height: var(--touch-min);
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--ui-text);
  cursor: pointer;
}

@media (max-width: 768px) {
  .nav-toggle {
    display: inline-flex;
  }
}

/* Deck-like modes should not scroll the page (mobile browser chrome changes can otherwise
   create "phantom" whitespace and alignment drift). Keep scroll on content pages like Downloads. */
body.mode-viewer,
body.mode-presenter,
body.mode-present,
body.mode-editor {
  overflow: hidden;
  overscroll-behavior: none;
}
img { max-width: 100%; display: block; }
a { color: inherit; }

.noscript {
  padding: 20px;
  margin: 20px;
  border: 1px solid var(--ui-border);
  border-radius: var(--r-md);
  background: var(--ui-surface-solid);
}

/* ========== App Layout ========== */
.app {
  height: calc(var(--vh, 1vh) * 100);
  display: flex;
  flex-direction: column;
}

/* Prefer dynamic viewport units where available (better behaviour on iOS/Safari). */
@supports (height: 100dvh) {
  .app { height: 100dvh; }
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-5);
  padding: 0 calc(var(--s-5) + env(safe-area-inset-right)) 0 calc(var(--s-5) + env(safe-area-inset-left));
  border-bottom: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
body.theme-dark .topbar { background: rgba(7, 20, 27, 0.55); }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 210px;
}
.brand img {
  height: 26px;
  width: auto;
  display: block;
}

/* Theme-aware logo swapping */
.brand img.logo-dark { display: none; }
body.theme-dark .brand img.logo-dark { display: block; }
body.theme-dark .brand img.logo-light { display: none; }
.brand-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand-pill.pill-ok {
  border-color: rgba(211, 139, 43, 0.55);
  color: var(--brand-gold);
}

.brand-pill.pill-warn {
  border-color: rgba(211, 139, 43, 0.35);
  color: rgba(211, 139, 43, 0.9);
}

.brand-pill.pill-bad {
  border-color: rgba(180, 72, 72, 0.55);
  color: rgba(180, 72, 72, 0.95);
}

/* Phase 2: Live session status pill */
.session-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}
.session-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--ui-accent);
  box-shadow: 0 0 0 6px rgba(231, 161, 93, 0.12);
}
.session-pill .dot.muted {
  background: var(--ui-border-strong);
  box-shadow: none;
  opacity: 0.9;
}
.session-pill .label {
  opacity: 0.9;
}
.session-pill .code {
  font-family: var(--font-mono);
  letter-spacing: 0.22em;
}

.session-pill .count,
.session-pill .lock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  min-width: 18px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--ui-border);
  background: rgba(255, 255, 255, 0.04);
  font-size: 11px;
  letter-spacing: 0.14em;
  opacity: 0.9;
}

.session-pill .lock {
  padding: 0 6px;
  letter-spacing: 0;
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: center;
  min-width: 0;
}

.deck-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  min-width: 0;
  max-width: 600px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow);
  cursor: pointer;
  appearance: none;
  font: inherit;
}
.deck-pill > div { min-width: 0; }
.deck-pill:hover { border-color: var(--ui-border-strong); }
.deck-pill:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--ui-focus), var(--ui-shadow);
}
.deck-pill .title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.deck-pill .sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ui-text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 240px;
}

/* Buttons — Minimum touch target 44px for accessibility */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}
.btn:hover { transform: translateY(-1px); border-color: var(--ui-border-strong); }
.btn:active { transform: translateY(0px); }
.btn:focus-visible { outline: 3px solid var(--ui-focus); outline-offset: 2px; }
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Loading state for buttons */
.btn[data-loading="true"] {
  position: relative;
  pointer-events: none;
  opacity: 0.8;
}
.btn[data-loading="true"]::before {
  content: "";
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn-primary {
  background: linear-gradient(180deg, rgba(211, 139, 43, 0.95) 0%, rgba(211, 139, 43, 0.82) 100%);
  border-color: rgba(211, 139, 43, 0.55);
  color: var(--ui-accent-ink);
}
.btn-primary:hover {
  border-color: rgba(211, 139, 43, 0.7);
}

/* Ghost button (minimal style) */
.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--ui-surface);
  border-color: var(--ui-border);
}

/* Secondary button (neutral gray) */
.btn-secondary {
  background: var(--ui-surface);
  border-color: var(--ui-border-strong);
  color: var(--ui-text-secondary);
}
.btn-secondary:hover {
  background: var(--ui-elevated);
  border-color: var(--ui-border-strong);
  color: var(--ui-text);
}

/* Danger button - solid red for destructive actions */
.btn-danger {
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.92) 0%, rgba(239, 68, 68, 0.78) 100%);
  border-color: rgba(239, 68, 68, 0.55);
  color: #fef2f2;
}
.btn-danger:hover {
  background: linear-gradient(180deg, rgba(239, 68, 68, 1) 0%, rgba(239, 68, 68, 0.88) 100%);
  border-color: rgba(239, 68, 68, 0.7);
}

/* Danger ghost (for less critical destructive actions) */
.btn-danger-ghost {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
  color: #ef4444;
}
.btn-danger-ghost:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
}

/* Small button variant (still meets 44px touch target via padding) */
.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn svg { width: 20px; height: 20px; display: block; }
.icon-btn:hover { border-color: var(--ui-border-strong); }
.icon-btn:focus-visible { outline: 3px solid var(--ui-focus); outline-offset: 2px; }

/* Theme toggle icons (show appropriate icon based on theme) */
#themeToggle .icon-sun { display: none; }
#themeToggle .icon-moon { display: block; }
body.theme-light #themeToggle .icon-sun { display: block; }
body.theme-light #themeToggle .icon-moon { display: none; }

.kbd-hint {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ui-text-dim);
  border: 1px solid var(--ui-border);
  background: rgba(0,0,0,0.04);
  padding: 4px 8px;
  border-radius: 10px;
}
body.theme-dark .kbd-hint { background: rgba(255,255,255,0.06); }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: 0;
}

/* v5.0 — Editor shell
   3-column layout: slides / stage / inspector.
   The inspector is desktop-only; mobile uses the overlay drawer. */
.layout.editor-shell {
  grid-template-columns: 300px 1fr 420px;
}

.inspector {
  border-left: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.42);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: auto;
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  min-width: 0;
}

.inspector-inner {
  flex: 1;
  min-height: 0;
}

body.theme-dark .inspector { background: rgba(7, 20, 27, 0.45); }

/* Docked editor drawer (inside the inspector) */
.drawer.docked {
  width: 100%;
  max-width: none;
  height: 100%;
  background: transparent;
  border-left: none;
  box-shadow: none;
  transform: none;
}

.drawer.docked .drawer-header {
  padding: 0 0 12px;
  border-bottom: 1px solid var(--ui-border);
  background: transparent;
}

.drawer.docked .drawer-body {
  padding: 14px 0;
}

.drawer.docked .drawer-actions {
  padding: 12px 0 0;
  border-top: 1px solid var(--ui-border);
  margin-top: 4px;
}

.drawer.docked .drawer-close {
  display: none;
}

.sidebar {
  border-right: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.42);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: auto;
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
body.theme-dark .sidebar { background: rgba(7, 20, 27, 0.45); }

.sidebar.hidden { display: none; }

/* When the sidebar is hidden (toggled in viewer), ensure the main stage spans the full grid. */
/* When the sidebar is hidden (toggled in viewer/editor), ensure the stage uses the space.
   In the editor shell we keep the inspector column, so we adjust the grid instead. */
.layout:not(.editor-shell) .sidebar.hidden + .main { grid-column: 1 / -1; }

.layout.editor-shell.sidebar-hidden {
  grid-template-columns: 1fr 420px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sidebar-head h3 {
  margin: 0;
  font-size: 13px;
  font-family: var(--font-mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ui-text-dim);
}

.sidebar-filter {
  display: flex;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.pill[aria-pressed="true"] {
  border-color: rgba(211, 139, 43, 0.45);
  box-shadow: 0 0 0 3px rgba(211, 139, 43, 0.16);
}

.thumb-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.thumb {
  border: 1px solid var(--ui-border);
  border-radius: 16px;
  background: var(--ui-surface);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 140ms ease, transform 140ms ease;
}
.thumb:hover { transform: translateY(-1px); border-color: var(--ui-border-strong); }
.thumb.active { border-color: rgba(211, 139, 43, 0.6); }

/* Phase 8: Drag reorder (Editor only) */
.thumb.reorderable { cursor: grab; }
.thumb.dragging { opacity: 0.58; cursor: grabbing; }
.thumb.drop-before { box-shadow: inset 0 3px 0 0 var(--ui-border-strong); }
.thumb.drop-after { box-shadow: inset 0 -3px 0 0 var(--ui-border-strong); }

.sidebar-hint {
  margin-top: -6px;
  margin-bottom: -4px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ui-text-dim);
  opacity: 0.75;
}

.thumb-canvas {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0b1f2a;
  position: relative;
  overflow: hidden;
}
.thumb-canvas.light { background: #f1f2ee; }

/* Real slide previews inside thumbnails */
.thumb-canvas .thumb-surface {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  border: none;
  box-shadow: none;
  border-radius: 0;
  pointer-events: none;
}
.thumb-meta {
  padding: 10px 12px 12px;
}
.thumb-meta .num {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ui-text-dim);
}
.thumb-meta .t {
  margin-top: 6px;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.25;
}

.main {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Fixed theatre layout: stage + footer rows (prevents layout shift between slides) */
.deck-main {
  display: grid;
  grid-template-rows: 1fr minmax(var(--deck-footer-h), auto);
  min-height: 0;
  gap: 0;
}

.deck-main > .stage {
  min-height: 0;
}

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--stage-pad-top) var(--stage-pad-x) var(--stage-pad-bottom);
}

.slide-viewport {
  width: 100%;
  max-width: 1420px;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.slide-surface {
  width: calc(var(--slide-w) * 1px);
  height: calc(var(--slide-h) * 1px);
  border-radius: var(--r-lg);
  border: 1px solid var(--ui-border);
  box-shadow: var(--ui-shadow);
  overflow: hidden;
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  /* Safe-frame overlay defaults (used in Editor to prevent overflow regressions) */
  --sf-x: 78px;
  --sf-top: 70px;
  --sf-bottom: 62px;
  --sf-radius: 18px;
  background: #f1f2ee;
  color: #0b1f2a;
}

/* Safe-frame tuning per template / density.
   Note: we set data-template on .slide-surface in JS so these stay reliable. */
.slide-surface[data-template="gallery"] {
  --sf-x: 70px;
  --sf-top: 62px;
  --sf-bottom: 62px;
}
.slide-surface[data-density="dense"] { --sf-top: 64px; }
.slide-surface[data-density="x-dense"] { --sf-top: 60px; }

/* Safe-frame overlay (Editor-only). Shows the stage safe area + thirds grid.
   This is a QA tool, not a design element — it must never ship to viewers by accident. */
.mode-editor.safe-frame-on .slide-surface::before {
  content: "";
  position: absolute;
  inset: var(--sf-top) var(--sf-x) var(--sf-bottom) var(--sf-x);
  border: 1px dashed rgba(255, 255, 255, 0.26);
  border-radius: var(--sf-radius);
  pointer-events: none;
  z-index: 40;
}
.mode-editor.safe-frame-on .slide-surface::after {
  content: "";
  position: absolute;
  inset: var(--sf-top) var(--sf-x) var(--sf-bottom) var(--sf-x);
  pointer-events: none;
  z-index: 39;
  /* Thirds grid: 2 vertical + 2 horizontal lines */
  background:
    linear-gradient(to right,
      transparent 0,
      transparent calc(33.333% - 0.5px),
      rgba(255, 255, 255, 0.14) calc(33.333% - 0.5px),
      rgba(255, 255, 255, 0.14) calc(33.333% + 0.5px),
      transparent calc(33.333% + 0.5px),
      transparent calc(66.666% - 0.5px),
      rgba(255, 255, 255, 0.14) calc(66.666% - 0.5px),
      rgba(255, 255, 255, 0.14) calc(66.666% + 0.5px),
      transparent calc(66.666% + 0.5px),
      transparent 100%),
    linear-gradient(to bottom,
      transparent 0,
      transparent calc(33.333% - 0.5px),
      rgba(255, 255, 255, 0.14) calc(33.333% - 0.5px),
      rgba(255, 255, 255, 0.14) calc(33.333% + 0.5px),
      transparent calc(33.333% + 0.5px),
      transparent calc(66.666% - 0.5px),
      rgba(255, 255, 255, 0.14) calc(66.666% - 0.5px),
      rgba(255, 255, 255, 0.14) calc(66.666% + 0.5px),
      transparent calc(66.666% + 0.5px),
      transparent 100%);
  opacity: 0.9;
}

/* Light slides need dark overlay lines. */
.mode-editor.safe-frame-on .slide-surface.tone-light::before,
.mode-editor.safe-frame-on .slide-surface.tone-cream::before {
  border-color: rgba(11, 31, 42, 0.22);
}
.mode-editor.safe-frame-on .slide-surface.tone-light::after,
.mode-editor.safe-frame-on .slide-surface.tone-cream::after {
  background:
    linear-gradient(to right,
      transparent 0,
      transparent calc(33.333% - 0.5px),
      rgba(11, 31, 42, 0.14) calc(33.333% - 0.5px),
      rgba(11, 31, 42, 0.14) calc(33.333% + 0.5px),
      transparent calc(33.333% + 0.5px),
      transparent calc(66.666% - 0.5px),
      rgba(11, 31, 42, 0.14) calc(66.666% - 0.5px),
      rgba(11, 31, 42, 0.14) calc(66.666% + 0.5px),
      transparent calc(66.666% + 0.5px),
      transparent 100%),
    linear-gradient(to bottom,
      transparent 0,
      transparent calc(33.333% - 0.5px),
      rgba(11, 31, 42, 0.14) calc(33.333% - 0.5px),
      rgba(11, 31, 42, 0.14) calc(33.333% + 0.5px),
      transparent calc(33.333% + 0.5px),
      transparent calc(66.666% - 0.5px),
      rgba(11, 31, 42, 0.14) calc(66.666% - 0.5px),
      rgba(11, 31, 42, 0.14) calc(66.666% + 0.5px),
      transparent calc(66.666% + 0.5px),
      transparent 100%);
}

/* Never show safe-frame overlays inside thumbnails. */
.thumb-surface::before,
.thumb-surface::after {
  content: none !important;
}

/* slide tones */
.slide-surface.tone-dark {
  background: radial-gradient(900px 520px at 20% 15%, rgba(211, 139, 43, 0.16) 0%, rgba(11, 31, 42, 0) 55%),
              linear-gradient(180deg, #07141b 0%, #0b1f2a 100%);
  color: rgba(241, 242, 238, 0.96);
  border-color: rgba(255,255,255,0.12);
}
.slide-surface.tone-light,
.slide-surface.tone-cream {
  background: linear-gradient(180deg, #ffffff 0%, #f1f2ee 100%);
  color: #0b1f2a;
}

/* Stage overlay navigation (desktop) */
.stage-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ui-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ui-text);
  cursor: pointer;
  box-shadow: var(--ui-shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.stage-nav svg { width: 20px; height: 20px; }

.stage-nav-left { left: 18px; }
.stage-nav-right { right: 18px; }

.stage:hover .stage-nav,
.slide-viewport:hover .stage-nav,
.slide-viewport:focus-within .stage-nav {
  opacity: 1;
  pointer-events: auto;
}

.stage-nav:active {
  transform: translateY(-50%) scale(0.98);
}

@media (hover: none) {
  .stage-nav {
    opacity: 0;
    pointer-events: none;
  }
}

/* In present mode, the slide should be edge-to-edge */
.mode-present .app, .mode-present .main, .mode-present .stage { padding: 0; }
.mode-present .slide-viewport { max-width: none; }
.mode-present .slide-surface {
  border-radius: 0;
  border: none;
  box-shadow: none;
}

.navbar {
  width: 100%;
  max-width: 1420px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 4px 0;
  color: var(--ui-text-muted);
}

/* Deck footer (viewer/editor): stable "theatre" frame */
.navbar.deck-footer {
  padding: 14px 28px 18px;
  gap: 12px;
  min-height: var(--deck-footer-h);
  flex-shrink: 0;
}

.navbar.deck-footer .slide-count {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52vw;
}

/* Footer anatomy: left / nav / right (keeps controls stable) */
.deck-footer-left,
.deck-footer-center,
.deck-footer-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.deck-footer-left { flex: 1; }
.deck-footer-center { flex: 0 0 auto; }
.deck-footer-right { flex: 0 0 auto; }

/* Compact footer navigation buttons (replaces legacy big prev/next) */
.deck-nav-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
}

.deck-nav-btn svg {
  width: 18px;
  height: 18px;
}

.slide-count {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ========== Slide typography + components ========== */
.slide {
  position: absolute;
  inset: 0;
  /* Keep a consistent safe-area across all slides.
     (Copy density affects typography, not baseline alignment.) */
  --pad-x: 78px;
  --pad-top: 70px;
  --pad-bottom: 62px;
  padding: var(--pad-top) var(--pad-x) var(--pad-bottom);
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Inner container that can be auto-fitted without shifting the footer */
.slide-fit {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 26px;
  transform-origin: top left;
}

/* Corner brand mark (A) — present on every slide. */
.slide-mark {
  position: absolute;
  left: 22px;
  top: 22px;
  width: 34px;
  height: auto;
  opacity: 0.7;
  pointer-events: none;
  user-select: none;
}

.slide-surface.tone-light .slide-mark,
.slide-surface.tone-cream .slide-mark {
  /* Light slides need a slightly stronger mark to remain legible
     on bright projectors and smaller screens. */
  opacity: 0.52;
}

/* Editor WYSIWYG: on-canvas editable hotspots */
.mode-editor .slide [data-edit] {
  cursor: text;
}
.mode-editor .slide [data-edit]:hover {
  outline: 1px dashed var(--ui-border-strong);
  outline-offset: 6px;
  border-radius: 10px;
}
.mode-editor .slide [data-edit].inline-editing {
  outline: 2px solid var(--ui-accent);
  outline-offset: 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}
.mode-editor.theme-light .slide [data-edit].inline-editing {
  background: rgba(0, 0, 0, 0.04);
}

/* Density presets — keeps slides resilient when copy runs long.
   These are subtle (not a different design), just tighter type/spacing. */
.slide.dense {
  --pad-top: 64px;
}
.slide.x-dense {
  --pad-top: 60px;
}

.slide.dense .slide-fit { gap: 20px; }
.slide.x-dense .slide-fit { gap: 16px; }

.slide.dense h1 { font-size: 64px; line-height: 1.02; }
.slide.x-dense h1 { font-size: 58px; line-height: 1.02; }

.slide.dense p,
.slide.dense li,
.slide.dense .lede { font-size: 18px; }

.slide.x-dense p,
.slide.x-dense li,
.slide.x-dense .lede { font-size: 17px; }

.slide.dense .card { padding: 20px; }
.slide.x-dense .card { padding: 18px; }

.slide.dense .grid { gap: 28px; }
.slide.x-dense .grid { gap: 22px; }

/* Cover gets an explicit wordmark lockup. */
.cover-lockup {
  display: inline-flex;
  align-items: center;
}
.cover-wordmark {
  height: 42px;
  width: auto;
}

/* Layout tuning for the proof gallery so nothing spills outside the slide. */
.slide[data-template="gallery"] {
  padding: 62px 70px;
  gap: 18px;
}
.slide[data-template="gallery"] h1 {
  font-size: 66px;
}
.slide[data-template="gallery"] .lede {
  font-size: 20px;
  max-width: 74ch;
}
.slide[data-template="gallery"] .grid-3 {
  gap: 18px;
  grid-auto-rows: 1fr;
  flex: 1;
  min-height: 0;
  align-content: stretch;
}
.slide[data-template="gallery"] .card {
  padding: 18px;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.slide[data-template="gallery"] .card .badge {
  height: 26px;
  font-size: 11px;
}
.slide[data-template="gallery"] .gallery-title {
  font-size: 20px;
  margin-top: 10px;
}
.slide[data-template="gallery"] .card-desc {
  font-size: 15px;
  line-height: 1.4;
  /* No clamping / ellipses: keep copy short instead, and let auto-fit handle edge cases. */
  overflow: visible;
}
.slide[data-template="gallery"] .card.inset {
  padding: 14px;
  border-radius: 16px;
  margin-top: auto;
}
.slide[data-template="gallery"] .card.inset .badge {
  height: 24px;
}
.slide[data-template="gallery"] .card.inset .card-desc {
  /* Example line: single-line capsule (no ellipsis) */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.kicker {
  font-family: var(--font-mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 12px;
  opacity: 0.78;
}

h1, h2, h3 { margin: 0; }

.slide h1 {
  font-family: var(--font-display);
  font-size: 72px;
  line-height: 1.02;
  letter-spacing: -0.02em;
}
.slide h2 {
  font-family: var(--font-display);
  font-size: 44px;
  line-height: 1.06;
  letter-spacing: -0.01em;
}
.slide p {
  margin: 0;
  font-size: 20px;
  line-height: 1.45;
  color: currentColor;
  opacity: 0.88;
  max-width: 66ch;
}
.slide .lede { font-size: 22px; opacity: 0.88; }

.slide .grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: start;
}
.slide .grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

.card {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  border-radius: 22px;
  padding: 22px;
}

/* Smaller, more 'system' copy inside cards */
.card-desc {
  margin-top: 10px;
  font-size: 16px;
  line-height: 1.45;
  opacity: 0.86;
  max-width: none;
}

.gallery-title {
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.12;
  letter-spacing: -0.01em;
  font-weight: 800;
}
.slide-surface.tone-light .card,
.slide-surface.tone-cream .card {
  border-color: rgba(11, 31, 42, 0.12);
  background: rgba(11, 31, 42, 0.03);
}

.card.inset {
  margin-top: 14px;
  border-radius: 18px;
  padding: 16px;
  background: rgba(255,255,255,0.05);
}
.slide-surface.tone-light .card.inset,
.slide-surface.tone-cream .card.inset { background: rgba(11, 31, 42, 0.02); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.slide-surface.tone-light .badge,
.slide-surface.tone-cream .badge {
  border-color: rgba(11,31,42,0.18);
  background: rgba(11,31,42,0.03);
}

.badge.signal {
  border-color: rgba(211, 139, 43, 0.55);
  box-shadow: 0 0 0 3px rgba(211, 139, 43, 0.14);
}

ul {
  margin: 0;
  padding-left: 22px;
  font-size: 20px;
  line-height: 1.55;
  max-width: 66ch;
}
li { margin: 10px 0; }

.table {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  overflow: hidden;
}
.slide-surface.tone-light .table,
.slide-surface.tone-cream .table { border-color: rgba(11,31,42,0.12); }
.table .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.table .cell {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.slide-surface.tone-light .table .cell,
.slide-surface.tone-cream .table .cell { border-bottom-color: rgba(11,31,42,0.10); }
.table .row:last-child .cell { border-bottom: none; }
.table .head .cell {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  background: rgba(255,255,255,0.05);
}
.slide-surface.tone-light .table .head .cell,
.slide-surface.tone-cream .table .head .cell { background: rgba(11,31,42,0.03); }

.big-numbers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.big-numbers.cols-2 { grid-template-columns: repeat(2, 1fr); }
.big-numbers .num {
  font-family: var(--font-display);
  font-size: 54px;
  letter-spacing: -0.02em;
}
.big-numbers .label {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.78;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.timeline .step {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  border-radius: 20px;
  padding: 18px;
}
.slide-surface.tone-light .timeline .step,
.slide-surface.tone-cream .timeline .step {
  border-color: rgba(11,31,42,0.12);
  background: rgba(11,31,42,0.03);
}
.timeline .when {
  font-family: var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  opacity: 0.78;
}
.timeline .t {
  margin-top: 10px;
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: -0.01em;
}
.timeline .d {
  margin-top: 10px;
  font-size: 18px;
  line-height: 1.45;
  opacity: 0.88;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
.person {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  border-radius: 20px;
  padding: 18px;
}
.slide-surface.tone-light .person,
.slide-surface.tone-cream .person {
  border-color: rgba(11,31,42,0.12);
  background: rgba(11,31,42,0.03);
}
.person .name { font-weight: 800; }
.person .role {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.78;
}
.person .bio { margin-top: 12px; font-size: 16px; line-height: 1.45; opacity: 0.86; }

.footer-note {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.70;
}



/* --- Additional slide components (deck-specific) --- */
.slide h3 {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.12;
  letter-spacing: -0.01em;
}

.slide-footnote {
  margin-top: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.70;
}

.ladder {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ladder-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
}
.slide-surface.tone-light .ladder-step,
.slide-surface.tone-cream .ladder-step {
  border-color: rgba(11,31,42,0.12);
  background: rgba(11,31,42,0.03);
}
.ladder-step.active {
  border-color: rgba(211, 139, 43, 0.55);
  box-shadow: 0 0 0 3px rgba(211, 139, 43, 0.14);
}
.ladder-label {
  font-weight: 800;
  font-size: 18px;
}
.ladder-dot {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand-gold);
  opacity: 0.95;
}

.funds {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.fund-row {
  display: grid;
  grid-template-columns: 240px 1fr 64px;
  gap: 12px;
  align-items: center;
}
.fund-label {
  font-weight: 700;
  font-size: 16px;
  opacity: 0.90;
}
.fund-value {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.72;
}
.fund-bar {
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.slide-surface.tone-light .fund-bar,
.slide-surface.tone-cream .fund-bar {
  border-color: rgba(11,31,42,0.10);
  background: rgba(11,31,42,0.06);
}
.fund-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(211,139,43,0.95) 0%, rgba(211,139,43,0.60) 100%);
}


/* Mini bars (market slide) */
.mini-bars {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mini-row {
  display: grid;
  grid-template-columns: 150px 1fr 56px;
  gap: 12px;
  align-items: center;
}
.mini-label {
  font-weight: 700;
  font-size: 14px;
  opacity: 0.90;
}
.mini-value {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.72;
}
.mini-bar {
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.slide-surface.tone-light .mini-bar,
.slide-surface.tone-cream .mini-bar {
  border-color: rgba(11,31,42,0.10);
  background: rgba(11,31,42,0.06);
}
.mini-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(211,139,43,0.95) 0%, rgba(211,139,43,0.60) 100%);
}

/* Moat stack */
.moat-stack {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.moat-layer {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  border-radius: 18px;
  padding: 14px;
}
.slide-surface.tone-light .moat-layer,
.slide-surface.tone-cream .moat-layer {
  border-color: rgba(11,31,42,0.12);
  background: rgba(11,31,42,0.03);
}
.moat-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.moat-num {
  width: 40px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.92;
}
.slide-surface.tone-light .moat-num,
.slide-surface.tone-cream .moat-num {
  border-color: rgba(11,31,42,0.12);
  background: rgba(11,31,42,0.02);
}
.moat-name {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: -0.01em;
  font-weight: 800;
}
.moat-desc {
  margin-top: 8px;
  font-size: 16px;
  line-height: 1.45;
  opacity: 0.86;
}

/* ========== Modals ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  z-index: 60;
}
.modal-overlay.open { display: flex; }
.modal {
  width: min(900px, 96vw);
  max-height: 86vh;
  overflow: auto;
  border-radius: 22px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface-solid);
  color: var(--ui-text);
  box-shadow: var(--shadow-2);
}
body.theme-dark .modal { background: rgba(7,20,27,0.82); }
.modal .modal-head {
  position: sticky;
  top: 0;
  background: inherit;
  border-bottom: 1px solid var(--ui-border);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.modal .modal-head h3 {
  margin: 0;
  font-family: var(--font-mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--ui-text-dim);
}
.modal .modal-body {
  padding: 18px;
}
.modal .muted { color: var(--ui-text-muted); }
/* Modal footer + actions */
.modal-foot {
  padding: 14px 16px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  justify-content: flex-end;
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-text {
  color: var(--ui-text-muted);
  line-height: 1.5;
}

.modal-action-text {
  color: var(--ui-text-muted);
  font-size: 13px;
}

/* Keyboard shortcuts modal */
.shortcut-list {
  display: grid;
  gap: 12px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.035);
}

.shortcut-keys {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.shortcut-desc {
  flex: 1;
  color: var(--ui-text-muted);
  text-align: right;
  line-height: 1.35;
}

.shortcut-note {
  display: block;
  font-size: 12px;
  color: var(--ui-text-muted);
  opacity: 0.9;
  margin-top: 4px;
}

@media (max-width: 520px) {
  .shortcut-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .shortcut-desc {
    text-align: left;
  }
}

/* Narrow modal variant (used for Session info) */
.modal.modal-narrow {
  width: min(560px, 96vw);
}

/* Menu layout (main menu) */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 720px) {
  .menu-grid { grid-template-columns: 1fr; }
}

.menu-card {
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 12px;
}

.menu-card-title {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ui-text-muted);
}

.menu-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(0,0,0,0.08);
  color: var(--ui-text);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

.menu-btn:hover {
  background: rgba(255,255,255,0.06);
}

.menu-btn:active {
  transform: translateY(1px);
}

.menu-btn-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.menu-btn-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--ui-text);
  opacity: 0.92;
}

.menu-btn-label {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-btn-hint {
  font-size: 12px;
  color: var(--ui-text-muted);
  opacity: 0.9;
  white-space: nowrap;
}

.menu-card .menu-btn + .menu-btn {
  margin-top: 8px;
}


.command-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--ui-border);
  background: rgba(0,0,0,0.02);
  color: var(--ui-text);
  font-size: 14px;
}
body.theme-dark .command-input { background: rgba(255,255,255,0.06); }
.command-input:focus { outline: none; box-shadow: 0 0 0 4px var(--ui-focus); border-color: rgba(211,139,43,0.55); }

.command-results { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.command-item {
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ui-text);
  -webkit-appearance: none;
  appearance: none;
  text-align: left;
}
.command-item:hover { border-color: var(--ui-border-strong); }
.command-item .label { font-weight: 700; }
.command-item .hint { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ui-text-dim); }

/* Command item internal layout (used by the menu sheet) */
.command-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.command-icon { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.command-icon svg { width: 24px; height: 24px; display: block; }
.command-name { font-weight: 700; }
.command-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.command-hint { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ui-text-dim); }

/* Menu sheet tweaks (so it feels less "blank" / more intentional) */
.modal-menu .modal-card { max-width: 560px; }
.menu-section-title {
  margin: 16px 6px 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ui-text-dim);
}
.command-results .menu-section-title:first-child { margin-top: 0; }

/* Keyboard hints don't help on touch devices */
@media (hover: none) and (pointer: coarse) {
  .command-hint { display: none; }
}

/* ========== Downloads page ========== */
.downloads-page {
  min-height: 100vh;
  padding: calc(var(--s-6) + env(safe-area-inset-top)) calc(var(--s-6) + env(safe-area-inset-right)) var(--s-6) calc(var(--s-6) + env(safe-area-inset-left));
}
.downloads-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-5);
}
.downloads-actions { display: flex; gap: 10px; }
.downloads-main { margin-top: var(--s-7); }
.downloads-hero h1 {
  font-family: var(--font-display);
  font-size: 54px;
  letter-spacing: -0.02em;
  margin: 0;
}
.downloads-hero .lede { margin-top: 10px; font-size: 18px; color: var(--ui-text-muted); }

.download-grid {
  margin-top: var(--s-7);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.download-card {
  border: 1px solid var(--ui-border);
  border-radius: 22px;
  background: var(--ui-surface-solid);
  padding: 18px;
  box-shadow: var(--ui-shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}
.download-card h2 { margin: 6px 0 0; font-family: var(--font-display); font-size: 24px; letter-spacing: -0.01em; }
.download-card .muted { color: var(--ui-text-muted); margin-top: 8px; }
.download-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.downloads-notes {
  margin-top: var(--s-7);
  border-top: 1px solid var(--ui-border);
  padding-top: var(--s-6);
}
.downloads-notes h3 {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0 0 10px;
}
.kbd {
  font-family: var(--font-mono);
  border: 1px solid var(--ui-border);
  padding: 2px 8px;
  border-radius: 10px;
}
.downloads-footer {
  margin-top: var(--s-8);
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--ui-border);
  padding-top: var(--s-4);
}

/* ========== Presenter theatre (v3.6) ========== */
.mode-presenter .presenter-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.mode-presenter .presenter-topbar { flex-shrink: 0; }

.mode-presenter .presenter-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 16px;
  padding: 16px;
}

.mode-presenter .presenter-stage {
  min-height: 0;
  border: 1px solid var(--ui-border);
  border-radius: 22px;
  background: var(--ui-surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mode-presenter .presenter-stage .slide-viewport {
  max-width: none;
  width: 100%;
  flex: 1;
  min-height: 0;
}

.mode-presenter .presenter-rail {
  min-height: 0;
  border: 1px solid var(--ui-border);
  border-radius: 22px;
  background: var(--ui-surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mode-presenter .presenter-tabs {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ui-border);
}

.mode-presenter .tab-btn {
  flex: 1;
  border: 1px solid var(--ui-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ui-text);
  padding: 10px 12px;
  border-radius: 14px;
  font-family: var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 11px;
  cursor: pointer;
}

.mode-presenter .tab-btn.active {
  background: rgba(211, 139, 43, 0.18);
  border-color: rgba(211, 139, 43, 0.38);
}

.mode-presenter .tab-toggle {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--ui-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ui-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mode-presenter .tab-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 160ms ease;
}

.mode-presenter .presenter-shell.rail-open .tab-toggle svg {
  transform: rotate(180deg);
}

.mode-presenter .presenter-rail-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.mode-presenter .presenter-rail-panel {
  border: 1px solid var(--ui-border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  padding: 12px;
}

.mode-presenter .rail-label {
  font-family: var(--font-mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--ui-text-dim);
  margin-bottom: 10px;
}

.mode-presenter .rail-box {
  border: 1px solid var(--ui-border);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.10);
}

.mode-presenter .presenter-next-viewport {
  height: 220px;
  max-width: none;
}

.mode-presenter .rail-notes {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.mode-presenter .rail-notes .notes {
  flex: 1;
  min-height: 0;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.55;
  color: var(--ui-text-muted);
}

.mode-presenter .presenter-footer {
  flex-shrink: 0;
  min-height: 64px;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 calc(var(--s-5) + env(safe-area-inset-right)) calc(env(safe-area-inset-bottom)) calc(var(--s-5) + env(safe-area-inset-left));
  border-top: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.mode-presenter .presenter-footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mode-presenter .presenter-footer-left .slide-count {
  max-width: 44vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.theme-dark .presenter-footer { background: rgba(7, 20, 27, 0.55); }

.mode-presenter .presenter-footer-actions {
  display: none;
  gap: 10px;
}

/* Presenter responsive: bottom dock on mobile */
@media (max-width: 1024px) {
  .mode-presenter { --rail-collapsed: 66px; --rail-open: min(46vh, 380px); }

  .mode-presenter .presenter-body {
    grid-template-columns: 1fr;
    padding: 14px;
    padding-bottom: calc(var(--rail-collapsed) + 22px + env(safe-area-inset-bottom));
  }
  .mode-presenter .presenter-shell.rail-open .presenter-body {
    padding-bottom: calc(var(--rail-open) + 22px + env(safe-area-inset-bottom));
  }

  .mode-presenter .presenter-rail {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    height: var(--rail-collapsed);
    border-radius: 18px;
    z-index: 70;
    box-shadow: var(--shadow-3);
  }
  .mode-presenter .presenter-shell.rail-open .presenter-rail {
    height: var(--rail-open);
  }

  .mode-presenter .presenter-tabs {
    display: flex;
  }

  .mode-presenter .presenter-shell:not(.rail-open) .presenter-rail-body {
    display: none;
  }

  /* In dock mode, show one panel at a time */
  .mode-presenter .presenter-rail-panel { display: none; }
  .mode-presenter .presenter-rail[data-tab="next"] .rail-next { display: block; }
  .mode-presenter .presenter-rail[data-tab="notes"] .rail-notes { display: flex; }
  .mode-presenter .presenter-rail[data-tab="qa"] .rail-qa { display: flex; }

  .mode-presenter .rail-next .presenter-next-viewport {
    height: calc(var(--rail-open) - 132px);
    min-height: 180px;
  }

  .mode-presenter .presenter-footer-actions {
    display: flex;
  }

  /* Tighten presenter topbar on small screens */
  .mode-presenter .presenter-topbar .btn-text { display: none; }
}

@media (max-width: 520px) {
  .mode-presenter .presenter-body { padding: 12px; padding-bottom: calc(var(--rail-collapsed) + 18px + env(safe-area-inset-bottom)); }
  .mode-presenter .presenter-shell.rail-open .presenter-body { padding-bottom: calc(var(--rail-open) + 18px + env(safe-area-inset-bottom)); }
}

/* ========== Responsive ========== */
@media (max-width: 1024px) {
  :root {
    --topbar-h: 64px;
    --stage-pad-top: 18px;
    --stage-pad-x: 16px;
    --stage-pad-bottom: 12px;
  }

  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .inspector { display: none; }
  .topbar-center { justify-content: flex-end; }
  .topbar-right { min-width: 0; }
  .brand { min-width: 0; }
  .navbar { padding: 12px 0 0; }
  .download-grid { grid-template-columns: 1fr; }
  .team-grid { grid-template-columns: repeat(2, 1fr); }

  /* Presenter: stack panels for smaller screens */
  .mode-presenter .presenter-layout { grid-template-columns: 1fr; }
  .mode-presenter .presenter-main { grid-template-rows: 1fr minmax(120px, 0.24fr); }
}

/* Mobile-only: expose a Menu button in the footer bar for discoverability */
.deck-footer .btn-menu {
  display: none;
}

@media (max-width: 520px) {
  :root {
    --topbar-h: 60px;
    --stage-pad-top: var(--s-3);
    --stage-pad-x: 14px;
    --stage-pad-bottom: var(--s-5);
  }

  .deck-footer .btn-menu { display: inline-flex; }
  .topbar { padding-left: 14px; padding-right: 14px; }
  .deck-pill { display: none; }

  /* Viewer mobile: show either the session code (room) or the deck title (no session). */
  .mode-viewer .deck-pill {
    display: inline-flex;
    max-width: 70vw;
  }
  .mode-viewer .session-pill.has-code + .deck-pill {
    display: none;
  }

  /* Keep footer controls readable on small screens. */
  .navbar.deck-footer .slide-count { max-width: 38vw; }

  /* Mobile: keep the header calm; use the footer as the thumb-zone. */
  .mode-viewer .topbar-right { display: none; }

  /* Presenter: tighten spacing and avoid overflow */
  .mode-presenter .presenter-layout { padding: 14px; gap: 12px; }
  .mode-presenter .presenter-main { gap: 12px; }
  .mode-presenter .presenter-panel header { flex-wrap: wrap; gap: 10px; }
  .mode-presenter .presenter-panel header .btn-text { display: none; }

  /* Reduce “dead space” above the slide in portrait. */
  .stage { justify-content: flex-start; }

  /* Session pill: show code first (hide LIVE/role label once in a session). */
  .session-pill.has-code .label { display: none; }

  /* Respect iOS safe-area for bottom controls. */
  .navbar.deck-footer {
    padding: 12px 14px max(12px, env(safe-area-inset-bottom));
  }

  /* Make the footer nav thumb-friendly */
  .deck-nav-btn { width: 46px; height: 46px; }
}


/* -----------------------------
   WYSIWYG editor drawer (Phase 4, Option 1)
   ----------------------------- */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  z-index: 90;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  width: 420px;
  max-width: 94vw;
  height: 100%;
  background: var(--ui-surface-solid);
  border-left: 1px solid var(--ui-border);
  box-shadow: var(--shadow-3);
  transform: translateX(100%);
  transition: transform 200ms ease;
  display: flex;
  flex-direction: column;
}

.drawer-overlay.open .drawer {
  transform: translateX(0);
}

.drawer-header {
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--ui-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.drawer-title {
  font-family: var(--font-sans);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.drawer-subtitle {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.72;
}

.drawer-close {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-text);
  display: grid;
  place-items: center;
}

.drawer-close:hover { filter: brightness(1.06); }

.drawer-body {
  padding: 16px 18px 18px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.drawer-card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 18px;
  box-shadow: var(--shadow-1);
  padding: 14px;
}

.drawer-card h3 {
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.78;
}

/* Collapsible drawer card */
.drawer-card-collapsible {
  padding: 0;
}

.drawer-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  cursor: pointer;
  user-select: none;
}

.drawer-card-header h3 {
  margin: 0;
}

.drawer-card-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  color: var(--ui-text-dim);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.drawer-card-toggle:hover {
  background: var(--ui-hover);
  color: var(--ui-text);
}

.drawer-card-body {
  padding: 0 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: all 0.2s ease;
  overflow: hidden;
}

.drawer-card-collapsible.collapsed .drawer-card-body {
  display: none;
}

.drawer-card-collapsible.collapsed {
  border-color: var(--ui-border-dim);
}

/* Enhanced guardrail status card */
.guardrail-status {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4);
  border-radius: 10px;
  background: var(--ui-elevated);
  border: 2px solid transparent;
  transition: all 0.2s ease;
  margin-bottom: var(--s-3);
}

.guardrail-status[data-state="safe"] {
  border-color: var(--color-success);
  background: rgba(34, 197, 94, 0.08);
}

.guardrail-status[data-state="tight"] {
  border-color: var(--color-warning);
  background: rgba(251, 191, 36, 0.08);
}

.guardrail-status[data-state="overflow"] {
  border-color: var(--color-error);
  background: rgba(239, 68, 68, 0.08);
}

.guardrail-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
}

.guardrail-status[data-state="safe"] .guardrail-icon {
  background: rgba(34, 197, 94, 0.12);
  border-color: var(--color-success);
  color: var(--color-success);
}

.guardrail-status[data-state="tight"] .guardrail-icon {
  background: rgba(251, 191, 36, 0.12);
  border-color: var(--color-warning);
  color: var(--color-warning);
}

.guardrail-status[data-state="overflow"] .guardrail-icon {
  background: rgba(239, 68, 68, 0.12);
  border-color: var(--color-error);
  color: var(--color-error);
}

.guardrail-content {
  flex: 1;
  min-width: 0;
}

.guardrail-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--ui-text);
  margin-bottom: 2px;
  font-family: var(--font-display);
}

.guardrail-summary {
  font-size: 12px;
  color: var(--ui-text-dim);
  line-height: 1.4;
}

/* Inspector tab navigation */
.drawer-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-surface);
  padding: 0 var(--s-3);
}

.drawer-tab {
  flex: 1;
  padding: var(--s-3) var(--s-4);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--ui-text-dim);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.15s ease;
}

.drawer-tab:hover {
  color: var(--ui-text);
  background: var(--ui-hover);
}

.drawer-tab.active {
  color: var(--brand-gold);
  border-bottom-color: var(--brand-gold);
  background: transparent;
}

/* Tab panels */
.drawer-panel {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.drawer-panel.active {
  display: flex;
}

.form-grid { display: grid; gap: 12px; }

.field-wrap { display: flex; flex-direction: column; }

/* v6.3 — Inspector field label row with per-field Reset */
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.field-label-row .field-label {
  margin-bottom: 0;
}

.field-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  width: 26px;
  border-radius: 10px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-text-dim);
  cursor: pointer;
  flex: 0 0 auto;
}

.field-reset svg {
  width: 14px;
  height: 14px;
}

.field-reset:hover {
  color: var(--ui-text);
  border-color: var(--ui-border-strong);
}

.field-reset:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--ui-focus);
}

.field-label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.72;
  margin-bottom: 6px;
}

.field {
  width: 100%;
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.06);
  color: var(--ui-text);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
}

/* Legacy alias: some pages use .input (lobby + deck manager). Keep it visually consistent. */
.input {
  width: 100%;
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.06);
  color: var(--ui-text);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
}

body.theme-light .field {
  background: rgba(0,0,0,0.04);
  color: var(--ui-text);
}

body.theme-light .input {
  background: rgba(0,0,0,0.04);
  color: var(--ui-text);
}

.field.mono { font-family: var(--font-mono); }

.input.mono { font-family: var(--font-mono); }

textarea.field { resize: vertical; min-height: 92px; }

.field:focus {
  border-color: rgba(211, 139, 43, 0.72);
  box-shadow: 0 0 0 3px rgba(211, 139, 43, 0.18);
}

.input:focus {
  border-color: rgba(211, 139, 43, 0.72);
  box-shadow: 0 0 0 3px rgba(211, 139, 43, 0.18);
}

.drawer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.drawer-actions .btn {
  height: 40px;
  padding: 0 12px;
}

.small-btn {
  height: 34px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-text);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.small-btn:hover { filter: brightness(1.06); }

.small-btn.danger {
  border-color: rgba(255, 95, 95, 0.38);
  color: rgba(255, 180, 180, 1);
}

body.theme-light .small-btn.danger {
  color: rgba(160, 20, 20, 1);
  border-color: rgba(160, 20, 20, 0.22);
}

.repeater {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.repeater-item {
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow-1);
}

body.theme-light .repeater-item {
  background: rgba(0,0,0,0.03);
}

.repeater-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.repeater-title {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.8;
}

.repeater-controls { display: flex; gap: 6px; }

/* Deck assets preview (Editor) */
.thumb-preview-wrap {
  margin-top: 10px;
  border: 1px dashed var(--ui-border);
  border-radius: 16px;
  padding: 10px;
  background: rgba(255,255,255,0.04);
}

body.theme-light .thumb-preview-wrap {
  background: rgba(0,0,0,0.03);
}

.thumb-preview-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--ui-border);
  display: block;
}


@media (max-width: 760px) {
  .drawer { width: 100%; max-width: 100%; }
}

/* Drawer helpers */
.drawer-meta,
.drawer-muted {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.72;
}

/* ========== Phase 7: Layout guardrails (Editor) ========== */
.health-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.health-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--ui-border);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.health-pill.health-safe {
  background: rgba(28, 166, 107, 0.14);
  border-color: rgba(28, 166, 107, 0.34);
}

.health-pill.health-tight {
  background: rgba(211, 139, 43, 0.14);
  border-color: rgba(211, 139, 43, 0.38);
}

.health-pill.health-overflow {
  background: rgba(230, 70, 90, 0.14);
  border-color: rgba(230, 70, 90, 0.38);
}

.health-issues {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0 12px;
}

.health-ok {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.05);
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ui-text);
}

body.theme-light .health-ok {
  background: rgba(0,0,0,0.03);
}

.health-issue {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.05);
}

body.theme-light .health-issue {
  background: rgba(0,0,0,0.03);
}

.health-issue .t {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.86;
}

.health-issue .d {
  margin-top: 6px;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.35;
  color: var(--ui-text);
  opacity: 0.9;
}

.health-issue.health-tight {
  border-color: rgba(211, 139, 43, 0.32);
}

.health-issue.health-overflow {
  border-color: rgba(230, 70, 90, 0.32);
}

/* v8.1: Guardrail intro text */
.guardrail-intro {
  margin-bottom: 12px;
  line-height: 1.45;
}

/* v8.1: Improve health pill cursor for tooltip hint */
.health-pill {
  cursor: help;
}

/* ========== v8.1: Breadcrumb Navigation (Editor) ========== */
.breadcrumb {
  display: none; /* Hidden by default, shown only in editor */
  align-items: center;
  margin-left: 16px;
}

body.mode-editor .breadcrumb {
  display: flex;
}

.breadcrumb-list {
  display: flex;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 13px;
}

.breadcrumb-item:not(:last-child)::after {
  content: "/";
  margin: 0 8px;
  color: var(--ui-text-dim);
  opacity: 0.5;
}

.breadcrumb-link {
  color: var(--ui-text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.breadcrumb-link:hover {
  color: var(--ui-text);
}

.breadcrumb-current {
  color: var(--ui-text);
  font-weight: 500;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Hide breadcrumbs on mobile (topbar is cramped) */
@media (max-width: 900px) {
  .breadcrumb { display: none !important; }
}

/* Hide breadcrumbs in preview mode */
body.preview-mode .breadcrumb { display: none !important; }

/* ========== Phase 8: QA checklist (Editor) ========== */
.qa-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.qa-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.05);
}

body.theme-light .qa-item {
  background: rgba(0,0,0,0.03);
}

.qa-item .l { min-width: 0; }

.qa-item .t {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.86;
}

.qa-item .d {
  margin-top: 6px;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.35;
  color: var(--ui-text);
  opacity: 0.9;
}

/* Version history (Phase 2) */
.version-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.version-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.05);
}

body.theme-light .version-row {
  background: rgba(0,0,0,0.03);
}

.version-left { min-width: 0; }

.version-id {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.86;
}

.version-meta {
  margin-top: 4px;
  font-family: var(--font-sans);
  font-size: 13px;
  opacity: 0.74;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.version-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.84;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--ui-accent);
}

.btn.danger {
  border-color: rgba(255, 87, 87, 0.35) !important;
  color: rgba(255, 87, 87, 0.95) !important;
}

.btn.danger:hover {
  filter: brightness(1.02);
}

/* Toast (Phase 1 polish) */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(6, 22, 29, 0.88);
  color: rgba(229,236,239,0.92);
  box-shadow: 0 14px 34px rgba(0,0,0,0.36);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0;
  translate: 0 6px;
  transition: opacity 160ms ease, translate 160ms ease;
  z-index: 400;
}

body.theme-light .toast {
  background: rgba(11, 31, 42, 0.92);
  border-color: rgba(11,31,42,0.14);
  box-shadow: 0 16px 34px rgba(0,0,0,0.18);
}

.toast.show {
  opacity: 1;
  translate: 0 0;
}

/* Diagnostics modal */
.diag-pre {
  margin: 0;
  border: 1px solid var(--ui-border);
  border-radius: 16px;
  padding: 12px;
  background: rgba(0,0,0,0.16);
  color: var(--ui-text);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  overflow: auto;
  max-height: 45vh;
}
body.theme-light .diag-pre {
  background: rgba(11,31,42,0.06);
}
.diag-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}


/* Session / room info */
.meta-grid {
  display: grid;
  gap: 8px;
}

.meta-grid .row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid var(--ui-border);
}

.meta-grid .row:last-child {
  border-bottom: 0;
}

.meta-grid .k {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  opacity: 0.6;
  padding-top: 6px;
}

.meta-grid .v {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pill-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

.help {
  font-size: 12px;
  opacity: 0.7;
  line-height: 1.3;
}


/* =========================================================
   Home / Entry
   ========================================================= */

body.mode-home {
  overflow: auto;
}

.home-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.home-topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s-5);
  border-bottom: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
body.theme-dark .home-topbar {
  background: rgba(7, 20, 27, 0.55);
}

.home-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-main {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--s-8) var(--s-5) var(--s-9);
}

.home-hero {
  margin-bottom: var(--s-7);
}

.home-kicker {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 12px;
  opacity: 0.65;
  margin-bottom: 10px;
}

.home-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(38px, 5vw, 58px);
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin: 0;
}

.home-hero p {
  margin: var(--s-4) 0 0;
  max-width: 66ch;
  color: var(--ui-text-muted);
  line-height: 1.55;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-6);
  align-items: start;
}

.home-card {
  border: 1px solid var(--ui-border);
  border-radius: var(--r-xl);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow);
  padding: var(--s-7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.home-card h2 {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  font-size: 24px;
  line-height: 1.1;
  margin: 8px 0 8px;
}

.home-card h3.home-subhead {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  font-size: 18px;
  line-height: 1.2;
  margin: 8px 0 8px;
}

.home-muted {
  color: var(--ui-text-muted);
  line-height: 1.55;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: var(--s-4);
}

.home-divider {
  height: 1px;
  background: var(--ui-border);
  margin: var(--s-6) 0;
}

.home-chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.35);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.85;
}
body.theme-dark .home-chip {
  background: rgba(255,255,255,0.08);
}

.home-join {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: var(--s-4);
}

.home-hint {
  margin: 10px 0 0;
  font-size: 12px;
  opacity: 0.75;
}

.home-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: var(--s-4);
}

.home-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.3);
}
body.theme-dark .home-shortcut {
  background: rgba(255,255,255,0.06);
}

.home-footer {
  margin-top: var(--s-7);
}

.home-footer-card {
  border: 1px dashed var(--ui-border);
  border-radius: var(--r-xl);
  padding: var(--s-5) var(--s-6);
  background: rgba(255,255,255,0.22);
}
body.theme-dark .home-footer-card {
  background: rgba(255,255,255,0.05);
}

/* v6.9: Recent rooms list (lobby) */
.recent-room-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
}
.recent-room-row .command-item {
  flex: 1 1 280px;
}
.recent-room-row .btn {
  height: 44px;
}
.recent-room-sub {
  font-size: 12px;
  color: var(--ui-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 56ch;
}

/* Deck library (v4.2) */
.home-decks {
  margin-top: var(--s-8);
}

.home-decks-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-6);
  flex-wrap: wrap;
  margin-bottom: var(--s-5);
}

.home-decks-title {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  font-size: 24px;
  line-height: 1.1;
  margin: 10px 0 6px;
}

.deck-count {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-left: 8px;
  vertical-align: middle;
}

.mono { font-family: var(--font-mono); }

.decks-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-6);
}

.deck-card {
  border: 1px solid var(--ui-border);
  border-radius: var(--r-xl);
  background: var(--ui-surface);
  box-shadow: var(--ui-shadow);
  padding: var(--s-6);
  display: flex;
  flex-direction: column;
  min-height: 340px;
}

.deck-thumb {
  border: 1px solid var(--ui-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: radial-gradient(120% 140% at 0% 0%, rgba(255,255,255,0.5), rgba(255,255,255,0.0) 60%),
              radial-gradient(120% 140% at 100% 0%, rgba(211,139,43,0.28), rgba(0,0,0,0) 55%),
              rgba(255,255,255,0.18);
  margin-bottom: var(--s-4);
}
body.theme-dark .deck-thumb {
  background: radial-gradient(120% 140% at 0% 0%, rgba(255,255,255,0.12), rgba(0,0,0,0) 55%),
              radial-gradient(120% 140% at 100% 0%, rgba(211,139,43,0.20), rgba(0,0,0,0) 55%),
              rgba(255,255,255,0.04);
}

.deck-thumb img.deck-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.deck-title {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  font-size: 18px;
  line-height: 1.12;
  margin: 0;
}

.deck-subtitle {
  margin: 10px 0 0;
  color: var(--ui-text-muted);
  line-height: 1.5;
  font-size: 14px;
  max-width: 64ch;
}

.deck-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: var(--s-4);
}

.deck-meta .tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.30);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.85;
}
body.theme-dark .deck-meta .tag {
  background: rgba(255,255,255,0.06);
}

.deck-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: auto;
  padding-top: var(--s-5);
}

/* Deck library polish (v4.3) */
.decks-empty-card {
  border: 1px dashed var(--ui-border);
  border-radius: var(--r-xl);
  padding: var(--s-6);
  background: rgba(255,255,255,0.22);
}
body.theme-dark .decks-empty-card {
  background: rgba(255,255,255,0.05);
}

.decks-empty-title {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  font-size: 18px;
  line-height: 1.15;
  margin: 10px 0 8px;
}

.decks-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: var(--s-4);
}

.decks-empty-foot {
  margin-top: 12px;
  font-size: 12px;
  opacity: 0.75;
}

.deck-thumb.is-fallback {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  text-align: center;
}

.thumb-fallback-mark {
  width: 46px;
  height: 46px;
  opacity: 0.85;
}

.thumb-fallback-cap {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ui-text-muted);
  opacity: 0.85;
  max-width: 32ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck-meta .tag.tag-visibility {
  opacity: 0.95;
}

.deck-meta .tag.tag-unlisted {
  border-color: rgba(211,139,43,0.32);
  background: rgba(211,139,43,0.10);
}
body.theme-dark .deck-meta .tag.tag-unlisted {
  border-color: rgba(211,139,43,0.28);
  background: rgba(211,139,43,0.12);
}

.deck-meta .tag.tag-private {
  border-color: rgba(239,68,68,0.30);
  background: rgba(239,68,68,0.08);
}
body.theme-dark .deck-meta .tag.tag-private {
  border-color: rgba(239,68,68,0.26);
  background: rgba(239,68,68,0.10);
}

.deck-meta .tag.tag-local {
  border-style: dashed;
  opacity: 0.9;
}

@media (max-width: 1100px) {
  .decks-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .decks-grid { grid-template-columns: 1fr; }
  .deck-card { min-height: 0; }
}

@media (max-width: 900px) {
  .home-grid { grid-template-columns: 1fr; }
  .home-main { padding: var(--s-7) var(--s-4) var(--s-8); }
  .home-topbar { padding: 0 var(--s-4); }
  .home-card { padding: var(--s-6); }
}

@media (max-width: 520px) {
  .home-topbar-right .btn { display: none; }
  .home-topbar-right .btn.btn-primary { display: inline-flex; }
  .home-join { grid-template-columns: 1fr; }
}


/* Menu sizing */
.modal.modal-menu {
  width: min(560px, 96vw);
}

/* Danger command item */
.command-item.danger {
  border-color: rgba(239, 68, 68, 0.25);
}

.command-item.danger:hover {
  background: rgba(239, 68, 68, 0.08);
}


/* Mobile tweaks */
@media (max-width: 640px) {
  .stage {
    padding: 16px 12px;
  }
  .deck-footer {
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom)) 14px;
  }
  .topbar {
    padding: 10px 12px;
  }
  .slide-count {
    font-size: 11px;
  }
}


/* Downloads page */
.page-downloads .home-main {
  max-width: 1100px;
}

.downloads-deck-row {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 18px;
  align-items: start;
}

.downloads-deck-picker .field {
  width: 100%;
}

.downloads-deck-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.downloads-deck-thumb {
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.downloads-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.downloads-thumb-fallback {
  width: 100%;
  height: 100%;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, rgba(211, 139, 43, 0.18), rgba(255, 255, 255, 0.02));
}

.downloads-thumb-mark {
  width: 42px;
  height: 42px;
  opacity: 0.95;
}

.downloads-thumb-title {
  font-weight: 700;
  font-size: 18px;
  line-height: 1.1;
}

.downloads-thumb-sub {
  font-size: 13px;
  opacity: 0.72;
}

.downloads-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.download-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  text-decoration: none;
  color: inherit;
}

.download-item:hover {
  border-color: rgba(211, 139, 43, 0.42);
  transform: translateY(-1px);
}

.download-meta {
  min-width: 0;
}

.download-label {
  font-weight: 700;
  margin-bottom: 4px;
}

.download-note {
  font-size: 13px;
  opacity: 0.75;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 740px;
}

.download-chip {
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(211, 139, 43, 0.35);
  background: rgba(211, 139, 43, 0.12);
  color: var(--text);
}

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

.preview-grid img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
}

.downloads-unlock-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.downloads-unlock-row .field {
  min-width: 260px;
  flex: 1;
}

@media (max-width: 900px) {
  .downloads-deck-row {
    grid-template-columns: 1fr;
  }

  .downloads-deck-thumb {
    order: -1;
  }

  .download-note {
    max-width: 100%;
  }
}

/* --------------------------------------------------------------------------
   v4.8 Diagnostics page
   -------------------------------------------------------------------------- */

.pill.pill-ok {
  border-color: rgba(39, 196, 133, 0.55);
  background: rgba(39, 196, 133, 0.10);
}
.pill.pill-warn {
  border-color: rgba(211, 139, 43, 0.55);
  background: rgba(211, 139, 43, 0.12);
}
.pill.pill-bad {
  border-color: rgba(255, 90, 95, 0.55);
  background: rgba(255, 90, 95, 0.10);
}

.qa-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.qa-item {
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: var(--ui-shadow);
}

.qa-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.qa-item-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.qa-item-title {
  font-family: var(--font-display);
  font-weight: 650;
  letter-spacing: -0.01em;
}

.qa-item-sub {
  font-size: 12px;
  color: var(--ui-text-dim);
}

.qa-item-body {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--ui-text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.qa-item-body code {
  font-family: inherit;
}


/* Generic code block (used by crash diagnostics / QA) */
.code {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--ui-border);
  background: rgba(0,0,0,.35);
  color: var(--ui-text);
}

/* =========================================================
   Docs page (v4.9)
   ========================================================= */

.docs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-6);
  align-items: start;
}

@media (max-width: 980px) {
  .docs-grid { grid-template-columns: 1fr; }
}

.docs-block {
  margin-top: var(--s-5);
}

.docs-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 8px;
}

.code-block {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.18);
  color: var(--ui-text);
  white-space: pre-wrap;
  word-break: break-word;
  cursor: pointer;
  box-shadow: var(--ui-shadow);
}
body.theme-dark .code-block {
  background: rgba(255,255,255,0.06);
}

.docs-steps {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--ui-text);
}

.docs-steps li {
  margin: 10px 0;
  line-height: 1.5;
}

.docs-callout {
  margin-top: var(--s-6);
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.22);
  color: var(--ui-text-muted);
}
body.theme-dark .docs-callout {
  background: rgba(255,255,255,0.06);
}

.docs-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--ui-text-muted);
}

.docs-list li { margin: 8px 0; }


/* WYSIWYG inline editing (Editor only) */
.mode-editor .slide-viewport [data-edit],
.mode-editor .slide-viewport [data-edit] * {
  cursor: text;
}

.mode-editor .slide-viewport [data-edit]:hover {
  outline: 1px dashed var(--ui-border-strong);
  outline-offset: 3px;
}

.mode-editor .slide-viewport [data-edit][contenteditable="true"] {
  outline: 2px solid var(--ui-focus);
  outline-offset: 3px;
  border-radius: 8px;
}

@media (max-width: 360px) {
  /* Preserve navigation affordances in the bottom bar on very narrow devices. */
  .deck-footer .btn-menu .btn-text { display: none; }
}

/* v6.2 — Inline selection + micro-toolbar (Editor / desktop)
   The intent: selection first, editing second. Helps the editor feel calm + reliable. */
.mode-editor .slide-viewport [data-edit].inline-selected {
  outline: 2px solid var(--ui-border-strong);
  outline-offset: 4px;
  border-radius: 10px;
}

.mode-editor .slide-viewport [data-edit].inline-selected.inline-editing {
  outline-color: var(--ui-focus);
}

.aivs-inline-toolbar {
  position: fixed;
  z-index: 6000;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface-solid);
  color: var(--ui-text);
  box-shadow: var(--ui-shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.aivs-inline-toolbar-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ui-text-dim);
  padding-right: 8px;
  margin-right: 2px;
  border-right: 1px solid var(--ui-border);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aivs-inline-toolbar-btn {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-text);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
}

.aivs-inline-toolbar-btn:hover {
  border-color: var(--ui-border-strong);
}

.aivs-inline-toolbar-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.aivs-inline-toolbar-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--ui-focus);
}

/* =============================
   v7.9 UI primitives
   ============================= */

/* Generic chips (used across editor + presenter UI) */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: rgba(255, 255, 255, 0.86);
}

.chip-solid {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.22);
}

.chip-danger {
  background: rgba(255, 90, 90, 0.12);
  border-color: rgba(255, 90, 90, 0.26);
}

/* Segmented control (Active/Trash toggles) */
.segmented {
  display: inline-flex;
  align-items: stretch;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.segmented .seg {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.86);
  padding: 8px 12px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  cursor: pointer;
}

.segmented .seg:hover {
  background: rgba(255, 255, 255, 0.08);
}

.segmented .seg.seg-active {
  background: rgba(255, 255, 255, 0.16);
}

.segmented .seg:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.38);
  outline-offset: 2px;
}

/* =============================
   v8.1 — Unified Badge System
   Replaces: .pill, .brand-pill, .health-pill, .home-chip, .tag
   Usage: <span class="badge">Label</span>
          <span class="badge badge-success">OK</span>
   ============================= */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-success {
  border-color: rgba(39, 196, 133, 0.55);
  background: rgba(39, 196, 133, 0.12);
  color: #27c485;
}

.badge-warning {
  border-color: rgba(211, 139, 43, 0.55);
  background: rgba(211, 139, 43, 0.12);
  color: #d38b2b;
}

.badge-danger {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.10);
  color: #ef4444;
}

.badge-muted {
  opacity: 0.7;
}

/* Badge with dot indicator */
.badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.badge .dot-pulse {
  animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* =============================
   v8.1 — Form Inputs
   Improved accessibility + consistency
   ============================= */

.input, .field input, .field select, .field textarea {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-text);
  font-family: var(--font-ui);
  font-size: 14px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input:hover, .field input:hover, .field select:hover, .field textarea:hover {
  border-color: var(--ui-border-strong);
}

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

.input::placeholder {
  color: var(--ui-text-dim);
}

.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Field with label */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ui-text-muted);
}

.field-hint {
  font-size: 12px;
  color: var(--ui-text-dim);
}

.field-error {
  font-size: 12px;
  color: #ef4444;
}

/* =============================
   v8.1 — Card System
   Unified card component
   ============================= */

.card {
  padding: var(--s-5);
  border-radius: var(--r-lg);
  border: 1px solid var(--ui-border);
  background: var(--ui-surface-solid);
  box-shadow: var(--ui-shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-4);
}

.card-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.card-subtitle {
  font-size: 14px;
  color: var(--ui-text-muted);
  margin: 4px 0 0;
}

.card-body {
  margin-top: var(--s-4);
}

.card-footer {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: 1px solid var(--ui-border);
}

/* =============================
   v8.1 — Loading States
   Spinners and skeleton screens
   ============================= */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--ui-border);
  border-top-color: var(--ui-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm { width: 16px; height: 16px; }
.spinner-lg { width: 28px; height: 28px; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Button loading state */
.btn.is-loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.btn-primary.is-loading::after {
  border-color: var(--ui-accent-ink);
  border-top-color: transparent;
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg,
    var(--ui-surface) 25%,
    var(--ui-border) 50%,
    var(--ui-surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}

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

/* =============================
   v8.1 — Status Indicator
   For save states, sync status
   ============================= */

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ui-text-muted);
}

.status-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ui-text-dim);
}

.status-indicator.status-saving .dot {
  background: var(--ui-accent);
  animation: badge-pulse 1s infinite;
}

.status-indicator.status-saved .dot {
  background: #27c485;
}

.status-indicator.status-error .dot {
  background: #ef4444;
}

/* =============================
   v8.1 — Toast Improvements
   Better visibility + types
   ============================= */

.toast {
  position: fixed;
  bottom: calc(var(--s-5) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  z-index: 9999;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--ui-surface-solid);
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: transform 200ms ease, opacity 200ms ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.toast[data-kind="success"] {
  border-color: rgba(39, 196, 133, 0.55);
  background: rgba(39, 196, 133, 0.15);
  color: #27c485;
}

.toast[data-kind="warn"],
.toast[data-kind="warning"] {
  border-color: rgba(211, 139, 43, 0.55);
  background: rgba(211, 139, 43, 0.15);
  color: #d38b2b;
}

.toast[data-kind="error"] {
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* =============================
   v8.1 — Simplified Breakpoints
   sm: 640px, md: 768px, lg: 1024px, xl: 1280px
   ============================= */

/* Utility: Hide on mobile */
@media (max-width: 767px) {
  .hide-mobile { display: none !important; }
}

/* Utility: Hide on desktop */
@media (min-width: 768px) {
  .hide-desktop { display: none !important; }
}

/* Utility: Stack on mobile */
@media (max-width: 767px) {
  .stack-mobile {
    flex-direction: column !important;
  }
  .stack-mobile > * {
    width: 100% !important;
  }
}

/* =============================
   v8.1 — Admin/Editor Sidebar Navigation
   Persistent sidebar for power users
   ============================= */

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

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px;
  background: var(--ui-surface-solid);
  border-right: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 200ms ease;
}

.app-sidebar-header {
  padding: var(--s-4);
  border-bottom: 1px solid var(--ui-border);
}

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

.app-sidebar-brand img {
  height: 24px;
  width: auto;
}

.app-sidebar-nav {
  flex: 1;
  padding: var(--s-4);
  overflow-y: auto;
}

.app-sidebar-section {
  margin-bottom: var(--s-5);
}

.app-sidebar-section-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ui-text-dim);
  margin-bottom: var(--s-2);
  padding: 0 var(--s-3);
}

.app-sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--s-3);
  border-radius: var(--r-sm);
  text-decoration: none;
  color: var(--ui-text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: background 120ms ease, color 120ms ease;
}

.app-sidebar-link:hover {
  background: var(--ui-surface);
  color: var(--ui-text);
}

.app-sidebar-link.active {
  background: rgba(211, 139, 43, 0.12);
  color: var(--ui-accent);
}

.app-sidebar-link svg {
  width: 18px;
  height: 18px;
  opacity: 0.7;
}

.app-sidebar-link.active svg {
  opacity: 1;
}

.app-sidebar-footer {
  padding: var(--s-4);
  border-top: 1px solid var(--ui-border);
}

.app-sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ui-text-muted);
}

.app-sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ui-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
}

/* Main content area when sidebar is present */
.app-main {
  flex: 1;
  margin-left: 240px;
  min-height: 100vh;
}

/* Mobile sidebar: hidden by default, shown via toggle */
@media (max-width: 767px) {
  .app-sidebar {
    transform: translateX(-100%);
  }

  .app-sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow-3);
  }

  .app-main {
    margin-left: 0;
  }

  .app-sidebar-toggle {
    display: flex;
  }
}

@media (min-width: 768px) {
  .app-sidebar-toggle {
    display: none;
  }
}

/* Sidebar toggle button (mobile) */
.app-sidebar-toggle {
  position: fixed;
  top: var(--s-3);
  left: var(--s-3);
  z-index: 101;
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  border: 1px solid var(--ui-border);
  background: var(--ui-surface-solid);
  color: var(--ui-text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.app-sidebar-toggle svg {
  width: 20px;
  height: 20px;
}

/* Sidebar overlay (mobile) */
.app-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.app-sidebar-overlay.is-open {
  display: block;
}

/* =============================
   v8.2 — Unified Entry Point Styles
   Auth Gate + Enhanced App Shell
   ============================= */

/* ---- Auth Gate (Login Screen) ---- */
.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-5);
}

.auth-gate-wrap {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
}

.auth-gate-header {
  text-align: center;
}

.auth-gate-header .brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auth-gate-header .brand img {
  height: 32px;
  width: auto;
}

.auth-gate-main {
  flex: 1;
}

.auth-gate-card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  backdrop-filter: blur(12px);
}

.auth-gate-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 var(--s-2) 0;
}

.auth-gate-subtitle {
  font-size: 14px;
  color: var(--ui-text-muted);
  margin: 0 0 var(--s-5) 0;
}

.auth-gate-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.auth-gate-form .field {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.auth-gate-form .field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ui-text-muted);
}

.auth-gate-msg {
  margin-top: var(--s-3);
  font-size: 13px;
  color: var(--ui-text-muted);
  min-height: 20px;
}

.auth-gate-msg[data-kind="warn"] {
  color: var(--color-warning);
}

.auth-gate-msg[data-kind="error"] {
  color: var(--color-error);
}

.auth-gate-links {
  margin-top: var(--s-3);
  text-align: right;
}

.auth-gate-links a {
  font-size: 13px;
  color: var(--c-accent);
  text-decoration: none;
}

.auth-gate-links a:hover {
  text-decoration: underline;
}

.auth-gate-divider {
  height: 1px;
  background: var(--ui-border);
  margin: var(--s-5) 0;
}

.auth-gate-quick {
  text-align: center;
}

.auth-gate-muted {
  font-size: 13px;
  color: var(--ui-text-dim);
  margin: 0;
}

.auth-gate-footer {
  text-align: center;
}

.auth-gate-footer a {
  font-size: 13px;
  color: var(--ui-text-muted);
  text-decoration: none;
}

.auth-gate-footer a:hover {
  color: var(--ui-accent);
}

/* Full-width button variant */
.btn-block {
  width: 100%;
  justify-content: center;
}

/* ---- Enhanced App Sidebar ---- */
.app-sidebar-user {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-sidebar-email {
  font-size: 13px;
  font-weight: 500;
  color: var(--ui-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-sidebar-role {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ui-text-dim);
}

.app-sidebar-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ui-text-dim);
  padding: var(--s-3) var(--s-3) var(--s-1) var(--s-3);
}

.app-sidebar-logout {
  color: var(--ui-text-dim);
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.app-sidebar-logout:hover {
  color: var(--color-error);
  background: var(--color-error-bg);
}

/* ---- App Topbar ---- */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-surface);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.app-topbar-left {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.app-topbar-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.app-topbar-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: var(--r-pill);
  background: var(--ui-surface-solid);
  border: 1px solid var(--ui-border);
  color: var(--ui-text-dim);
}

.app-topbar-pill.pill-ok {
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: var(--color-success);
}

.app-topbar-pill.pill-warn {
  background: var(--color-warning-bg);
  border-color: var(--color-warning-border);
  color: var(--color-warning);
}

.app-topbar-pill.pill-bad {
  background: var(--color-error-bg);
  border-color: var(--color-error-border);
  color: var(--color-error);
}

.app-topbar-right {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* ---- App Content ---- */
.app-content {
  padding: var(--s-5);
  max-width: 1200px;
  margin: 0 auto;
}

/* ---- App Views ---- */
.app-view {
  display: none;
}

.app-view.active {
  display: block;
}

/* ---- View Components ---- */
.view-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--s-5);
  margin-bottom: var(--s-6);
}

.view-card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
}

.view-card h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: var(--s-2) 0 var(--s-2) 0;
}

.view-card-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ui-accent);
}

.view-card-muted {
  font-size: 14px;
  color: var(--ui-text-muted);
  margin: 0 0 var(--s-4) 0;
}

.view-card-form {
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
}

.view-card-form .input {
  flex: 1;
  min-width: 200px;
}

.view-card-options {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  margin-top: var(--s-3);
}

.view-card-option {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 14px;
  color: var(--ui-text-muted);
  cursor: pointer;
}

.view-card-option input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.view-card-field {
  margin-top: var(--s-2);
  padding-left: calc(20px + var(--s-2));
}

.view-card-field[hidden] {
  display: none;
}

.view-card-hint {
  font-size: 12px;
  color: var(--ui-text-dim);
  margin: var(--s-1) 0 0 0;
  line-height: 1.4;
}

/* ---- View Sections ---- */
.view-section {
  margin-bottom: var(--s-6);
}

.view-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-3);
  flex-wrap: wrap;
}

.view-section-header h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: var(--s-2) 0 0 0;
}

.view-section-header .input {
  width: 240px;
}

/* ---- Recent Rooms List ---- */
.recent-rooms-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin: var(--s-4) 0;
}

/* ---- Mobile Nav Toggle ---- */
.app-nav-toggle {
  display: none;
  position: fixed;
  top: var(--s-3);
  left: var(--s-3);
  z-index: 101;
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  border: 1px solid var(--ui-border);
  background: var(--ui-surface-solid);
  color: var(--ui-text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.app-nav-toggle svg {
  width: 20px;
  height: 20px;
}

.app-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.app-sidebar-backdrop.is-open {
  display: block;
}

@media (max-width: 767px) {
  .app-nav-toggle {
    display: flex;
  }

  .app-content {
    padding: var(--s-4);
    padding-top: calc(var(--s-4) + 56px); /* Account for nav toggle */
  }

  .app-topbar {
    padding-left: calc(var(--s-3) + 56px); /* Account for nav toggle */
  }

  .view-grid {
    grid-template-columns: 1fr;
  }

  .view-section-header {
    flex-direction: column;
  }

  .view-section-header .input {
    width: 100%;
  }
}

/* ---- Loading State ---- */
.auth-gate[data-loading="true"] .auth-gate-card {
  opacity: 0.6;
  pointer-events: none;
}


/* ===============================================
   Canvas Positioning Mode (Editor)
   =============================================== */

/* Canvas unlocked state */
body.canvas-unlocked [data-positionable="1"] {
  outline: 2px dashed var(--c-gold);
  outline-offset: 2px;
  cursor: move;
  transition: outline 0.2s ease;
}

body.canvas-unlocked [data-positionable="1"]:hover {
  outline-color: var(--c-gold-bright, #f4a940);
  background: rgba(211, 139, 43, 0.05);
}

.canvas-selected {
  outline: 2px solid var(--c-gold) !important;
  outline-offset: 2px;
  z-index: 100 !important;
  background: rgba(211, 139, 43, 0.08) !important;
}

.canvas-dragging {
  opacity: 0.85;
  cursor: grabbing !important;
  z-index: 101 !important;
}

.canvas-resizing {
  opacity: 0.9;
  user-select: none;
}

/* Resize handles */
.canvas-resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--c-gold);
  border: 1px solid var(--c-navy);
  border-radius: 50%;
  z-index: 102;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: auto;
}

.canvas-selected .canvas-resize-handle {
  opacity: 1;
}

.canvas-resize-handle:hover {
  background: var(--c-gold-bright, #f4a940);
  transform: scale(1.2);
}

/* Corner handles */
.canvas-resize-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.canvas-resize-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.canvas-resize-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.canvas-resize-se { bottom: -5px; right: -5px; cursor: nwse-resize; }

/* Edge handles */
.canvas-resize-n { top: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.canvas-resize-s { bottom: -5px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.canvas-resize-e { right: -5px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.canvas-resize-w { left: -5px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

/* Active canvas toggle button */
.icon-btn.active {
  background: var(--c-gold);
  color: var(--c-navy);
  border-color: var(--c-gold);
}

.icon-btn.active:hover {
  background: var(--c-gold-bright, #f4a940);
}

/* Canvas mode hint */
body.canvas-unlocked::before {
  content: "Canvas Unlocked - Drag elements to reposition";
  position: fixed;
  bottom: var(--s-4);
  right: var(--s-4);
  padding: var(--s-2) var(--s-3);
  background: var(--c-gold);
  color: var(--c-navy);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Upload image styling */
[data-canvas-element="image"] {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

body.canvas-unlocked [data-canvas-element="image"] {
  outline: 2px dashed var(--c-gold);
  outline-offset: 2px;
}

/* Positioning helpers */
body.canvas-unlocked .slide-content,
body.canvas-unlocked .viewport {
  position: relative;
}

/* Prevent text selection during drag */
body.canvas-unlocked {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

body.canvas-unlocked input,
body.canvas-unlocked textarea {
  user-select: text;
  -webkit-user-select: text;
}

/* ========== v10.0: Q&A System ========== */
.qa-modal {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  min-height: 400px;
  max-height: 70vh;
}

.modal-qa .modal {
  max-width: 680px;
}

.modal-qa .modal-body {
  max-height: 60vh;
  overflow-y: auto;
}

.qa-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--c-muted-fg);
}

.qa-textarea {
  width: 100%;
  padding: var(--s-2);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid var(--c-muted-fg);
  border-radius: var(--r-sm);
  background: var(--c-bg);
  color: var(--c-fg);
  resize: vertical;
}

.qa-textarea:focus {
  outline: 2px solid var(--c-gold);
  outline-offset: 2px;
}

.qa-anonymous-label {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 14px;
  color: var(--c-muted-fg);
  cursor: pointer;
}

.qa-anonymous-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.qa-char-count {
  font-size: 12px;
  color: var(--c-muted-fg);
  font-family: var(--font-mono);
}

.qa-section-header {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--c-fg);
}

.qa-questions-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  max-height: 400px;
  overflow-y: auto;
  padding-right: var(--s-1);
}

.qa-questions-list::-webkit-scrollbar {
  width: 6px;
}

.qa-questions-list::-webkit-scrollbar-track {
  background: transparent;
}

.qa-questions-list::-webkit-scrollbar-thumb {
  background: var(--c-muted-fg);
  border-radius: 3px;
}

.qa-questions-list::-webkit-scrollbar-thumb:hover {
  background: var(--c-gold);
}

.qa-empty {
  padding: var(--s-4);
  text-align: center;
  color: var(--c-muted-fg);
  font-size: 14px;
  font-style: italic;
}

.qa-question-card {
  padding: var(--s-3);
  border: 1px solid var(--c-muted-fg);
  border-radius: var(--r-sm);
  background: var(--c-bg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.qa-question-card:hover {
  border-color: var(--c-gold);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.qa-question-card.answered {
  background: rgba(211, 139, 43, 0.05);
  border-color: var(--c-gold);
}

.qa-question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--s-2);
  gap: var(--s-2);
}

.qa-question-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-muted-fg);
  font-family: var(--font-mono);
}

.qa-question-time {
  font-size: 11px;
  color: var(--c-muted-fg);
  font-family: var(--font-mono);
}

.qa-question-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--c-fg);
  margin-bottom: var(--s-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.qa-question-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-2);
}

.qa-upvote-btn {
  padding: var(--s-1) var(--s-2);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--c-muted-fg);
  border-radius: var(--r-sm);
  background: var(--c-bg);
  color: var(--c-fg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.qa-upvote-btn:hover:not(.voted) {
  border-color: var(--c-gold);
  background: rgba(211, 139, 43, 0.1);
}

.qa-upvote-btn.voted {
  border-color: var(--c-gold);
  background: var(--c-gold);
  color: var(--c-navy);
  cursor: default;
}

.qa-answered-badge {
  padding: var(--s-1) var(--s-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--c-navy);
  background: var(--c-gold);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
}

/* ========== Presenter Q&A Panel ========== */
.qa-count-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-navy);
  background: var(--c-gold);
  border-radius: 10px;
  font-family: var(--font-mono);
  min-width: 20px;
  text-align: center;
}

.qa-presenter-controls {
  padding-bottom: var(--s-3);
}

.qa-presenter-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  max-height: calc(100vh - 300px);
  overflow-y: auto;
  padding-right: var(--s-1);
}

.qa-presenter-list::-webkit-scrollbar {
  width: 6px;
}

.qa-presenter-list::-webkit-scrollbar-track {
  background: transparent;
}

.qa-presenter-list::-webkit-scrollbar-thumb {
  background: var(--c-muted-fg);
  border-radius: 3px;
}

.qa-presenter-list::-webkit-scrollbar-thumb:hover {
  background: var(--c-gold);
}

.qa-upvote-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-muted-fg);
}

/* Specific overrides for presenter panel - keep layout compact */
.rail-qa .qa-question-card {
  padding: var(--s-2);
}

.rail-qa .qa-question-header {
  gap: var(--s-1);
}

.rail-qa .qa-empty {
  padding: var(--s-3);
  font-size: 13px;
}

/* ========================================
   EMPTY STATE COMPONENT (UX Improvement)
   ======================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s-8) var(--s-5);
  text-align: center;
  min-height: 240px;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin-bottom: var(--s-4);
  opacity: 0.4;
  color: var(--ui-text-dim);
}

.empty-state-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ui-text);
  margin: 0 0 var(--s-2) 0;
}

.empty-state-message {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ui-text-dim);
  margin: 0 0 var(--s-5) 0;
  max-width: 400px;
}

.empty-state-actions {
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
  justify-content: center;
}

/* Empty state variants */
.empty-state-compact {
  min-height: 160px;
  padding: var(--s-6) var(--s-4);
}

.empty-state-compact .empty-state-icon {
  width: 48px;
  height: 48px;
  margin-bottom: var(--s-3);
}

.empty-state-compact .empty-state-title {
  font-size: 16px;
  margin-bottom: var(--s-2);
}

.empty-state-compact .empty-state-message {
  font-size: 13px;
  margin-bottom: var(--s-4);
}

/* Table empty state (for admin tables) */
.table-empty-state {
  padding: var(--s-7) var(--s-5);
  text-align: center;
  border-top: 1px solid var(--ui-border);
}

.table-empty-state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--s-3);
  opacity: 0.3;
  color: var(--ui-text-dim);
}

.table-empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ui-text);
  margin: 0 0 var(--s-2) 0;
}

.table-empty-state-message {
  font-size: 13px;
  color: var(--ui-text-dim);
  margin: 0 0 var(--s-4) 0;
}

.table-empty-state-actions {
  display: flex;
  gap: var(--s-3);
  justify-content: center;
}
