/* ============================================
   Visual Transfer — SPA Layout Stylesheet
   Desktop: split view (code left, settings right)
   Mobile: full-screen code + sidebar settings
   ============================================ */

/* --- CSS Variables (Light Theme / Default) --- */
:root {
  --color-primary: #0d9488;
  --color-primary-light: #14b8a6;
  --color-primary-dark: #0f766e;
  --color-primary-bg: #f0fdfa;
  --color-primary-border: #99f6e4;

  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-surface-hover: #f1f5f9;

  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-text-muted: #94a3b8;

  --color-border: #e2e8f0;
  --color-border-focus: #0d9488;

  --color-success: #22c55e;
  --color-success-bg: #f0fdf4;
  --color-warning: #f59e0b;
  --color-warning-bg: #fffbeb;
  --color-danger: #ef4444;
  --color-danger-bg: #fef2f2;

  --color-dark: #0f172a;
  --color-dark-surface: #1e293b;

  --color-cimbar: #d97706;
  --color-cimbar-bg: #fffbeb;
  --color-cimbar-border: #fde68a;

  --color-jab: #e11d48;
  --color-jab-bg: #fff1f2;
  --color-jab-border: #fecdd3;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;

  --header-height: 48px;
  --bottom-nav-height: 56px;
  --sidebar-width: 340px;
}

/* --- Dark Theme --- */
[data-theme="dark"] {
  --color-primary: #14b8a6;
  --color-primary-light: #2dd4bf;
  --color-primary-dark: #0d9488;
  --color-primary-bg: #042f2e;
  --color-primary-border: #115e59;

  --color-bg: #0f1117;
  --color-surface: #1e293b;
  --color-surface-hover: #334155;

  --color-text: #e2e8f0;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;

  --color-border: #334155;
  --color-border-focus: #14b8a6;

  --color-success: #22c55e;
  --color-success-bg: #052e16;
  --color-warning: #f59e0b;
  --color-warning-bg: #422006;
  --color-danger: #ef4444;
  --color-danger-bg: #450a0a;

  --color-dark: #020617;
  --color-dark-surface: #0f172a;

  --color-cimbar: #fbbf24;
  --color-cimbar-bg: #422006;
  --color-cimbar-border: #854d0e;

  --color-jab: #fb7185;
  --color-jab-bg: #4c0519;
  --color-jab-border: #9f1239;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; height: 100dvh; }
body {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  height: 100dvh;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-secondary); }

/* --- Loading Overlay --- */
#loading-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: var(--color-surface); display: flex; align-items: center; justify-content: center;
  z-index: 9999; transition: opacity 0.4s ease;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; display: none; }
.loading-content { text-align: center; padding: 2rem; max-width: 320px; width: 100%; }
.loading-text { font-size: 1rem; font-weight: 500; color: var(--color-text); margin-top: 1rem; margin-bottom: 1rem; }
.loading-detail { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.5rem; min-height: 1.2em; }

/* Loading spinner — replaced with pulsing QR icon */
.spinner {
  display: none; /* hidden, using .loading-logo instead */
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-logo {
  font-size: 2.5rem;
  color: var(--color-primary);
  animation: pulse-logo 1.8s ease-in-out infinite;
  display: inline-block;
}
@keyframes pulse-logo {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 1; }
}

/* ============================================
   APP CONTAINER — Full Viewport SPA
   ============================================ */
.app-container {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg);
}

/* ============================================
   HEADER — Compact with inline tabs
   ============================================ */
.app-header {
  display: flex;
  align-items: center;
  height: var(--header-height);
  padding: 0 0.75rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  z-index: 100;
  gap: 0.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
  margin-right: 0.5rem;
}
.logo-icon { font-size: 1.25rem; color: var(--color-primary); }
.logo-text { font-size: 0.875rem; font-weight: 700; color: var(--color-text); letter-spacing: -0.01em; white-space: nowrap; }

/* Header tabs (desktop only, inline in header) */
.header-tabs {
  display: none;
  align-items: center;
  gap: 0;
  height: 100%;
  flex: 1;
}
.header-tab {
  display: flex; align-items: center; gap: 0.25rem;
  padding: 0 0.75rem; border: none; background: none;
  color: var(--color-text-secondary); font-family: var(--font-family);
  font-size: 0.8125rem; font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap; height: 100%;
}
.header-tab:hover { color: var(--color-primary); }
.header-tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }
.header-tab i { font-size: 1rem; }

/* Status dot + text in header */
.header-status {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}
.header-status-text {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
  display: none; /* shown on desktop */
}
.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.status-dot.idle { background: var(--color-text-muted); }
.status-dot.active { background: var(--color-success); box-shadow: 0 0 0 3px rgba(34,197,94,0.2); animation: pulse-dot 2s ease infinite; }
.status-dot.error { background: var(--color-danger); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Theme toggle button */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 1.25rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--color-surface-hover); color: var(--color-primary); }
.theme-toggle:active { transform: scale(0.95); }

/* Keyboard shortcuts help button */
.shortcuts-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  font-family: var(--font-family);
}
.shortcuts-toggle:hover { background: var(--color-surface-hover); color: var(--color-primary); }
.shortcuts-toggle:active { transform: scale(0.95); }

/* Shortcuts dropdown panel */
.shortcuts-dropdown {
  position: absolute;
  top: calc(var(--header-height) - 2px);
  right: 0.5rem;
  width: 240px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0.625rem 0;
  z-index: 200;
  display: none;
}
.shortcuts-dropdown.open {
  display: block;
  animation: fadeIn 0.15s ease;
}
.shortcuts-dropdown-title {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 0.75rem 0.375rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.25rem;
}
.shortcut-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.75rem;
  gap: 0.5rem;
}
.shortcut-label {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}
.shortcut-key {
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.1rem 0.375rem;
  white-space: nowrap;
}

/* Sidebar toggle button (mobile + desktop) */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 1.25rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  margin-left: auto;
}
.sidebar-toggle:hover { background: var(--color-surface-hover); color: var(--color-primary); }
.sidebar-toggle:active { transform: scale(0.95); }

/* About button in header */
.about-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 1.125rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}
.about-btn:hover { background: var(--color-surface-hover); color: var(--color-primary); }
.about-btn:active { transform: scale(0.95); }

/* About modal */
.about-modal {
  max-width: 400px;
  width: 90vw;
}
.about-body {
  text-align: center;
  overflow-y: auto;
  max-height: 60vh;
}
.about-logo {
  font-size: 2.5rem;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}
.about-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.125rem;
}
.about-version {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}
.about-author {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.75rem;
}
.about-desc {
  text-align: left;
  margin-bottom: 0.75rem;
}
.about-desc p {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin-bottom: 0.375rem;
}
.about-section {
  text-align: left;
  border-top: 1px solid var(--color-border);
  padding-top: 0.5rem;
}
.about-section h4 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.375rem;
}
.about-links {
  list-style: none;
  padding: 0;
  margin: 0;
}
.about-links li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--color-border);
}
.about-links li:last-child {
  border-bottom: none;
}
.about-links strong {
  font-size: 0.75rem;
  color: var(--color-text);
  min-width: 120px;
  text-align: left;
  flex-shrink: 0;
}
.about-links a {
  font-size: 0.6875rem;
  color: var(--color-primary);
  text-decoration: none;
  word-break: break-all;
}
.about-links a:hover {
  text-decoration: underline;
}

/* ============================================
   MAIN LAYOUT — Split View
   ============================================ */
.app-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

/* ============================================
   DISPLAY PANEL — Left Side (Code / Camera)
   ============================================ */
.display-panel {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--color-bg);
  min-width: 0;
}

/* Dot grid pattern background */
.display-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, var(--color-border) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}
[data-theme="dark"] .display-panel::before {
  opacity: 0.2;
}

/* Tab panels inside display */
.display-panel .tab-panel {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 1;
}
.display-panel .tab-panel.active {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Code display — centered in panel */
.code-display-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0.75rem;
  z-index: 1;
  overflow: hidden;
}

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

.code-display img,
.code-display canvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  object-fit: contain;
}

/* Cimbar canvas — fill code-display container */
#cimbar-canvas {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  border-radius: var(--radius-md);
}

/* ArGRID canvas — fill code-display container */
#argrid-canvas {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  border-radius: var(--radius-md);
}

.code-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem;
  color: var(--color-text-muted);
  text-align: center;
}
.code-placeholder.hidden { display: none; }
.placeholder-icon { font-size: 3rem; opacity: 0.2; }
.code-placeholder p { font-size: 0.8125rem; }

/* Protocol quick-select badge (top-left of sender display) */
.protocol-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  z-index: 10;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}
.protocol-badge:hover {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.protocol-badge i {
  font-size: 0.875rem;
}

/* Fullscreen button (bottom-left of display, avoids overlapping codes) */
.fullscreen-btn {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 1.125rem;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.fullscreen-btn.visible { display: flex; }
.fullscreen-btn:hover { background: var(--color-primary); color: white; border-color: var(--color-primary); }

/* Export/download QR button (top-right) */
.export-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 1.125rem;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.export-btn.visible { display: flex; }
.export-btn:hover { background: var(--color-primary); color: white; border-color: var(--color-primary); }

/* Stats overlay (HUD below code display, no overlap) */
.stats-overlay {
  display: none;
  gap: 0.375rem;
  z-index: 10;
  padding: 0.25rem 0.5rem;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
  width: 100%;
  overflow: hidden;
  justify-content: center;
}
.stats-overlay.visible { display: flex; }
[data-theme="dark"] .stats-overlay {
  background: var(--color-dark-surface);
  border-top-color: var(--color-border);
}

/* ============================================
   SETTINGS PANEL — Right Side / Sidebar
   ============================================ */
.settings-panel {
  width: var(--sidebar-width);
  border-left: 1px solid var(--color-border);
  background: var(--color-surface);
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.625rem;
  position: relative;
}

/* Settings panel scroll shadow — top and bottom fade */
.settings-panel-wrapper {
  position: relative;
  flex-shrink: 0;
  display: flex;
  overflow: hidden;
}
.settings-panel-wrapper::before,
.settings-panel-wrapper::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 16px;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.settings-panel-wrapper::before {
  top: 0;
  background: linear-gradient(to bottom, var(--color-surface), transparent);
}
.settings-panel-wrapper::after {
  bottom: 0;
  background: linear-gradient(to top, var(--color-surface), transparent);
}
.settings-panel-wrapper.scrolled-top::before { opacity: 1; }
.settings-panel-wrapper.scrolled-bottom::after { opacity: 1; }

/* Settings content sections — only one visible at a time */
.settings-content {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
}
.settings-content.active {
  display: flex;
}

/* Sidebar header (mobile only — inside settings-panel) */
.sidebar-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.25rem;
}
.sidebar-header h2 {
  font-size: 0.9375rem;
  font-weight: 700;
}
.sidebar-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 1.125rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-close:hover { background: var(--color-danger-bg); color: var(--color-danger); border-color: var(--color-jab-border); }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 190;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================
   FULLSCREEN MODE
   ============================================ */
.app-container.fullscreen-active .app-header,
.app-container.fullscreen-active .bottom-nav,
.app-container.fullscreen-active .sidebar-overlay {
  display: none !important;
}

.app-container.fullscreen-active .settings-panel {
  display: none !important;
}

.app-container.fullscreen-active .app-main {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: #ffffff;
}
[data-theme="dark"] .app-container.fullscreen-active .app-main {
  background: #0f1117;
}

.app-container.fullscreen-active .display-panel {
  background: #ffffff;
}
[data-theme="dark"] .app-container.fullscreen-active .display-panel {
  background: #0f1117;
}

.app-container.fullscreen-active .display-panel::before {
  display: none;
}

.app-container.fullscreen-active .code-display img,
.app-container.fullscreen-active .code-display canvas {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  box-shadow: none;
  border-radius: 0;
}
/* Stats overlay hidden in fullscreen mode */
.app-container.fullscreen-active .stats-overlay {
  display: none !important;
}

/* Fullscreen button — dark style in fullscreen mode */
.app-container.fullscreen-active .fullscreen-btn {
  background: rgba(0,0,0,0.6);
  border: none;
  color: #fff;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.app-container.fullscreen-active .fullscreen-btn:hover {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
}

.app-container.fullscreen-active .code-placeholder {
  background: #ffffff;
}
[data-theme="dark"] .app-container.fullscreen-active .code-placeholder {
  background: #0f1117;
}

/* Fullscreen exit button — removed (sender-fullscreen-btn toggles state) */

/* ============================================
   BOTTOM NAV (Mobile)
   ============================================ */
.bottom-nav {
  display: flex;
  height: var(--bottom-nav-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.1rem; padding: 0.375rem 0.25rem; border: none; background: none;
  color: var(--color-text-muted); font-family: var(--font-family);
  font-size: 0.5625rem; font-weight: 500; cursor: pointer;
  transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent; min-height: 44px;
  position: relative;
}
.bottom-nav-btn i { font-size: 1.125rem; }
.bottom-nav-btn.active { color: var(--color-primary); }
.bottom-nav-btn:hover { color: var(--color-primary); }

/* Bottom nav active indicator dot */
.bottom-nav-btn::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-primary);
  opacity: 0;
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.bottom-nav-btn.active::after {
  opacity: 1;
}

/* ============================================
   CARD — Compact for settings panel
   ============================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.625rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.card-title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.375rem;
}
.card-title i { font-size: 0.9375rem; color: var(--color-primary); }
.card-desc {
  font-size: 0.6875rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

/* Protocol-specific accent borders */
.card-accent-cimbar {
  border-left: 3px solid var(--color-cimbar);
}
.card-accent-jab {
  border-left: 3px solid var(--color-jab);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.25rem;
  padding: 0.3rem 0.5rem; border: 1px solid transparent;
  border-radius: var(--radius-md); font-family: var(--font-family);
  font-size: 0.75rem; font-weight: 500; cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent; min-height: 32px; line-height: 1.25;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn i { font-size: 0.875rem; }
.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: #fff; border-color: transparent;
  box-shadow: 0 1px 3px rgba(13, 148, 136, 0.3);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary));
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.4);
}
.btn-primary:active:not(:disabled) { transform: scale(0.97); box-shadow: 0 1px 2px rgba(13, 148, 136, 0.2); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover:not(:disabled) { background: var(--color-surface-hover); border-color: var(--color-text-muted); }
.btn-danger {
  background: linear-gradient(135deg, var(--color-danger), #f87171);
  color: #fff; border-color: transparent;
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.3);
}
.btn-danger:hover:not(:disabled) { background: #dc2626; box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4); }
.btn-sm { padding: 0.2rem 0.5rem; font-size: 0.6875rem; min-height: 28px; }
.btn-sm i { font-size: 0.75rem; }
.btn-full { width: 100%; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.25rem; border: 1px solid transparent; border-radius: var(--radius-md);
  background: none; cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 28px; min-height: 28px; -webkit-tap-highlight-color: transparent;
}
.btn-icon:hover { background: var(--color-surface-hover); }
.btn-remove { color: var(--color-text-muted); background: none; border: none; }
.btn-remove:hover { color: var(--color-danger); background: var(--color-danger-bg); }

/* ============================================
   PROTOCOL BUTTONS
   ============================================ */
.protocol-grid { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 0.375rem; }
.protocol-grid-full { margin-bottom: 0.375rem; }
.protocol-grid-full .btn { width: 100%; }
.resolution-group {
  margin-top: 0.75rem;
}
.resolution-group .settings-label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 0.375rem;
}
.btn-protocol {
  background: var(--color-surface); color: var(--color-text);
  border-color: var(--color-border); font-weight: 600; flex: 1; min-width: 44px;
}
.btn-protocol:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-protocol.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-protocol-wide { flex: unset; }
.btn-scan-mode {
  background: var(--color-surface); color: var(--color-text);
  border-color: var(--color-border); font-weight: 600; flex: 1; min-width: 44px;
}
.btn-scan-mode:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-scan-mode.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* Auto-detect button in receiver settings (prominent, full-width) */
.btn-autodetect {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.625rem 1rem;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark, var(--color-primary)));
  color: #fff;
  border: none;
  border-radius: var(--radius, 0.5rem);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.btn-autodetect:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
}
.btn-autodetect:active {
  transform: translateY(0);
}
.btn-autodetect:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}
.btn-autodetect.detecting {
  pointer-events: none;
}
.btn-autodetect.detecting i {
  animation: autoDetectBtnSpin 0.8s linear infinite;
}
@keyframes autoDetectBtnSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Sub-option buttons (density, engine, etc.) — clear selected state */
.btn-option {
  background: var(--color-bg);
  color: var(--color-text-secondary);
  border-color: var(--color-border);
  font-weight: 500;
}
.btn-option:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-bg);
}
.btn-option.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  box-shadow: 0 1px 4px rgba(13, 148, 136, 0.3);
  font-weight: 600;
}

/* ============================================
   PROTOCOL SETTINGS
   ============================================ */
.protocol-settings { margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--color-border); }
.settings-header { display: flex; align-items: center; gap: 0.375rem; margin-bottom: 0.375rem; font-size: 0.75rem; font-weight: 600; }
.settings-header i { color: var(--color-cimbar); }
.settings-desc { font-size: 0.6875rem; color: var(--color-text-secondary); margin-top: 0.25rem; line-height: 1.4; }
.badge-row { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.375rem; }
.badge {
  display: inline-flex; align-items: center; padding: 0.1rem 0.375rem;
  font-size: 0.625rem; font-weight: 600; border-radius: 9999px;
  background: var(--color-bg); color: var(--color-text-secondary);
  border: 1px solid var(--color-border); white-space: nowrap;
  font-family: var(--font-mono);
}

/* Protocol info list */
.protocol-info-list { margin-top: 0.5rem; }
.protocol-info-list p {
  font-size: 0.625rem; color: var(--color-text-secondary);
  line-height: 1.5; margin-bottom: 0.125rem;
  word-wrap: break-word; overflow-wrap: break-word;
}
.info-cimbar { color: var(--color-cimbar); }
.info-jab { color: var(--color-jab); }

/* ============================================
   FORM ELEMENTS
   ============================================ */
.input-textarea {
  width: 100%; padding: 0.5rem 0.625rem;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  font-family: var(--font-family); font-size: 0.75rem; color: var(--color-text);
  background: var(--color-surface); resize: none; min-height: 60px;
  transition: border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  line-height: 1.5;
  user-select: text !important;
  -webkit-user-select: text !important;
}
.input-textarea:focus { outline: none; border-color: var(--color-border-focus); box-shadow: 0 0 0 3px rgba(13,148,136,0.1); }
.input-textarea::placeholder { color: var(--color-text-muted); }
.input-textarea.font-mono { font-family: var(--font-mono); font-size: 0.6875rem; }
.input-label { display: block; font-size: 0.75rem; font-weight: 500; color: var(--color-text); margin-bottom: 0.125rem; }
.input-hint { font-size: 0.6875rem; color: var(--color-text-muted); margin-top: 0.125rem; }

/* Drag & Drop overlay */
#sender-settings {
  position: relative;
}
.drag-drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 148, 136, 0.06);
  border: 2px dashed var(--color-primary, #0d9488);
  border-radius: var(--radius-md, 0.5rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.drag-drop-overlay.active {
  opacity: 1;
}
.drag-drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  padding: 1.25rem;
  border-radius: var(--radius-lg, 0.75rem);
  background: var(--color-surface, #fff);
  box-shadow: 0 4px 24px rgba(13, 148, 136, 0.15), 0 0 0 1px rgba(13, 148, 136, 0.1);
}
.drag-drop-overlay-inner i {
  font-size: 1.75rem;
  color: var(--color-primary, #0d9488);
}
.drag-drop-overlay-inner span {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text, #1e293b);
}

/* Data size counter */
.data-size-counter {
  display: flex;
  justify-content: flex-end;
  font-size: 0.625rem;
  color: var(--color-text-muted);
  margin-top: 0.125rem;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Checkbox */
.checkbox-group { margin: 0.375rem 0; }
.checkbox-label {
  display: inline-flex; align-items: center; gap: 0.375rem;
  cursor: pointer; font-size: 0.75rem; color: var(--color-text);
  -webkit-tap-highlight-color: transparent;
}
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--color-primary); cursor: pointer; }

/* ============================================
   FILE UPLOAD
   ============================================ */
.file-upload-row { display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; margin-top: 0.375rem; }
.file-info-inline {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.2rem 0.375rem; background: var(--color-primary-bg);
  border: 1px solid var(--color-primary-border); border-radius: var(--radius-sm);
  font-size: 0.6875rem; max-width: 100%;
}
.file-info-inline i { color: var(--color-primary); font-size: 0.875rem; flex-shrink: 0; }
.file-info-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-info-size { color: var(--color-text-muted); flex-shrink: 0; }

/* Image Preview */
.image-preview {
  position: relative; display: inline-block; margin-top: 0.375rem;
  border-radius: var(--radius-md); overflow: hidden;
  border: 1px solid var(--color-border); max-width: 100%;
}
.image-preview img { display: block; max-width: 100%; max-height: 120px; object-fit: contain; }

/* Compression Card */
.compression-card {
  margin-top: 0.375rem; padding: 0.5rem;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--radius-md);
}
[data-theme="dark"] .compression-card {
  background: #172554; border-color: #1e3a5f;
}
.compression-header { display: flex; align-items: center; gap: 0.25rem; font-size: 0.75rem; font-weight: 600; color: #1d4ed8; margin-bottom: 0.25rem; }
[data-theme="dark"] .compression-header { color: #60a5fa; }
.compression-header i { font-size: 0.875rem; }

/* ============================================
   SLIDER
   ============================================ */
.slider-group { margin-bottom: 0.5rem; }
.slider-label { display: block; font-size: 0.6875rem; font-weight: 500; color: var(--color-text-secondary); margin-bottom: 0.125rem; }
.slider-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%;
  height: 4px; background: var(--color-border); border-radius: 2px;
  outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--color-primary); border: 2px solid var(--color-surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--color-primary); border: 2px solid var(--color-surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2); cursor: pointer;
}

/* ============================================
   DATA INFO / STATUS
   ============================================ */
.data-info {
  font-size: 0.6875rem; color: var(--color-text-secondary);
  padding: 0.375rem 0.5rem; background: var(--color-bg);
  border-radius: var(--radius-sm); margin-top: 0.375rem;
  word-wrap: break-word; overflow-wrap: break-word;
}
.data-info strong { color: var(--color-text); }

.status-badge { display: inline-flex; align-items: center; gap: 0.375rem; font-size: 0.75rem; font-weight: 500; color: var(--color-text-secondary); }

/* ============================================
   STATS GRID (HUD Overlay)
   ============================================ */
.stats-grid { display: flex; gap: 0.375rem; }
.stat-item {
  display: flex; flex-direction: column; gap: 0;
  padding: 0.15rem 0.35rem; background: rgba(255,255,255,0.9);
  border-radius: var(--radius-sm); text-align: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}
[data-theme="dark"] .stat-item {
  background: rgba(30, 41, 59, 0.9);
}
.stat-label { font-size: 0.5rem; font-weight: 500; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value { font-size: 0.625rem; font-weight: 700; color: var(--color-text); font-variant-numeric: tabular-nums; }

/* Sender stats — even more compact */
.stats-overlay .stat-item {
  padding: 0.1rem 0.3rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}
[data-theme="dark"] .stats-overlay .stat-item {
  background: rgba(15, 23, 42, 0.8);
}
.stats-overlay .stat-label { font-size: 0.4375rem; }
.stats-overlay .stat-value { font-size: 0.5625rem; }

/* ============================================
   CONTROLS
   ============================================ */
.controls-row { display: flex; align-items: center; justify-content: space-between; gap: 0.375rem; flex-wrap: wrap; }
.controls-buttons { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.camera-controls { display: flex; gap: 0.375rem; margin-top: 0.375rem; flex-wrap: wrap; }

/* ============================================
   ERROR MESSAGE
   ============================================ */
.error-message {
  margin-top: 0.375rem; padding: 0.375rem 0.5rem;
  background: var(--color-danger-bg); border: 1px solid #fecaca;
  border-radius: var(--radius-sm); color: var(--color-danger);
  font-size: 0.6875rem; font-weight: 500;
  word-wrap: break-word; overflow-wrap: break-word;
}
[data-theme="dark"] .error-message {
  border-color: #7f1d1d;
}

/* ============================================
   CAMERA (Receiver)
   ============================================ */
.receiver-camera-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-dark);
  overflow: hidden;
}

.camera-placeholder {
  position: absolute;
  width: 65%;
  height: 65%;
  background: transparent;
  overflow: hidden;
}
.camera-placeholder.hidden { display: none; }
.viewfinder {
  position: absolute; inset: 0;
}
.viewfinder-corner { position: absolute; width: 24px; height: 24px; border-color: var(--color-primary-light); border-style: solid; border-width: 0; }
.viewfinder-corner.top-left { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-radius: 4px 0 0 0; }
.viewfinder-corner.top-right { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-radius: 0 4px 0 0; }
.viewfinder-corner.bottom-left { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-radius: 0 0 0 4px; }
.viewfinder-corner.bottom-right { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 4px 0; }
.scan-line {
  position: absolute; left: 10%; right: 10%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-primary-light), transparent);
  animation: scanLine 2.5s ease-in-out infinite; opacity: 0.7;
}
@keyframes scanLine { 0%, 100% { top: 10%; } 50% { top: 85%; } }
.viewfinder-icon { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 2.5rem; color: rgba(255,255,255,0.15); }

#receiver-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--color-dark);
}

/* Receiver overlay controls */
.receiver-overlay-controls {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  gap: 0.375rem;
  z-index: 10;
}
.receiver-overlay-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.receiver-overlay-btn:hover { background: var(--color-primary); color: white; border-color: var(--color-primary); }

/* In-window camera toggle button */
.receiver-cam-toggle {
  position: absolute;
  bottom: 4.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  border: 2px solid rgba(255,255,255,0.3);
  color: #fff;
  cursor: pointer;
  font-size: 1.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.receiver-cam-toggle:hover {
  background: rgba(0,0,0,0.7);
  border-color: rgba(255,255,255,0.5);
  transform: translateX(-50%) scale(1.05);
}
.receiver-cam-toggle.scanning {
  background: rgba(239,68,68,0.6);
  border-color: rgba(255,255,255,0.3);
}
.receiver-cam-toggle.scanning:hover {
  background: rgba(220,38,38,0.7);
}

/* Auto-detect suggestion badge on scanner overlay */
.autodetect-badge {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.625rem;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 9999px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  z-index: 10;
  white-space: nowrap;
  animation: autodetectBadgeIn 0.3s ease;
}
.autodetect-badge i.ph-eye {
  color: var(--color-primary, #22c55e);
  font-size: 0.875rem;
}
.autodetect-switch-btn,
.autodetect-dismiss-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75rem;
  transition: background 0.2s;
}
.autodetect-switch-btn {
  background: var(--color-primary, #22c55e);
  color: #fff;
}
.autodetect-switch-btn:hover {
  background: var(--color-primary-dark, #16a34a);
}
.autodetect-dismiss-btn {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
}
.autodetect-dismiss-btn:hover {
  background: rgba(255,255,255,0.25);
  color: #fff;
}
@keyframes autodetectBadgeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Auto-detect countdown overlay (visible on scanning display) */
.autodetect-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  pointer-events: none;
}
.autodetect-countdown-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 1rem;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  animation: countdownPulse 1s ease-in-out infinite;
  pointer-events: auto;
}
.autodetect-countdown-inner i {
  font-size: 1.25rem;
  animation: autoDetectBtnSpin 0.8s linear infinite;
}
@keyframes countdownPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.03); opacity: 0.9; }
}

/* Manual auto-detect button (compact, in scanner overlay) */
.autodetect-manual-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  z-index: 100;
  transition: background 0.2s, transform 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.autodetect-manual-btn:hover {
  background: rgba(0,0,0,0.8);
  transform: scale(1.1);
}
.autodetect-manual-btn.detecting {
  animation: autoDetectSpin 1s linear infinite;
  background: var(--color-primary, #22c55e);
}
@keyframes autoDetectSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Debug overlay canvas — matches video object-fit:cover */
#receiver-debug-canvas {
  object-fit: cover;
}

/* ============================================
   CIMBAR SCAN CROSSHAIR (Corner Brackets)
   ============================================ */
.cimbar-crosshair {
  display: none;
  position: absolute;
  inset: 10%;
  z-index: 8;
  pointer-events: none;
}
.cimbar-crosshair.visible { display: block; }

.ch-bracket {
  position: absolute;
  width: 32px;
  height: 32px;
  border-color: rgba(255, 255, 255, 0.35);
  border-style: solid;
  border-width: 0;
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}
.ch-tl { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-radius: 6px 0 0 0; }
.ch-tr { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-radius: 0 6px 0 0; }
.ch-bl { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-radius: 0 0 0 6px; }
.ch-br { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 6px 0; }

/* Scanning state — extraction found (amber/yellow) */
.cimbar-crosshair.scanning .ch-bracket {
  border-color: #f59e0b;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

/* Decoded state — success (green) */
.cimbar-crosshair.decoded .ch-bracket {
  border-color: #22c55e;
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.5);
}

/* Cimbar scan status badge */
.cimbar-scan-badge {
  display: none;
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  gap: 0.25rem;
  align-items: center;
  pointer-events: none;
  transition: background 0.3s ease, color 0.3s ease;
}
.cimbar-scan-badge.visible { display: flex; }
.cimbar-scan-badge.scanning {
  background: rgba(245, 158, 11, 0.7);
  color: #fff;
}
.cimbar-scan-badge.decoded {
  background: rgba(34, 197, 94, 0.75);
  color: #fff;
}

/* Receiver bottom info — top-right corner */
.receiver-overlay-info {
  position: absolute;
  top: 0.75rem;
  left: auto;
  right: 3.25rem;
  display: flex;
  gap: 0.25rem;
  z-index: 10;
}

/* ============================================
   PROGRESS
   ============================================ */
.progress-container {
  width: 100%; height: 6px; background: var(--color-border);
  border-radius: 3px; overflow: hidden; margin-top: 0.375rem;
}
.progress-container .progress-bar {
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
  height: 100%; border-radius: 3px; transition: width 0.3s;
}
.progress-text { font-size: 0.6875rem; color: var(--color-text-secondary); margin-top: 0.125rem; text-align: center; font-weight: 500; }

/* ============================================
   RESULT
   ============================================ */
.result-content { display: flex; flex-direction: column; gap: 0.5rem; }
.result-text {
  font-family: var(--font-mono); font-size: 0.6875rem; color: var(--color-text);
  white-space: pre-wrap; word-break: break-word; line-height: 1.5;
  max-height: 200px; overflow-y: auto; padding: 0.5rem;
  background: var(--color-bg); border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}
.result-image { max-width: 100%; max-height: 200px; border-radius: var(--radius-md); object-fit: contain; display: block; margin: 0 auto; }
.result-actions { display: flex; gap: 0.25rem; flex-wrap: wrap; }

/* JAB Test */
.jab-test-buttons { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-bottom: 0.25rem; }
.jab-test-result { white-space: pre-wrap; word-break: break-word; font-size: 0.6875rem; }

/* ============================================
   SIMULATION
   ============================================ */
.card-empty { text-align: center; padding: 1.5rem; }
.empty-icon { font-size: 2.5rem; color: var(--color-text-muted); opacity: 0.2; margin-bottom: 0.5rem; }
.empty-title { font-size: 0.875rem; font-weight: 600; color: var(--color-text); margin-bottom: 0.125rem; }
.empty-desc { font-size: 0.75rem; color: var(--color-text-secondary); line-height: 1.4; }
.card-success { border-color: #bbf7d0; background: #f0fdf4; }
[data-theme="dark"] .card-success { border-color: #166534; background: #052e16; }

/* Sim Chart */
.sim-chart {
  display: flex; align-items: flex-end; gap: 2px; height: 150px;
  padding: 0.375rem 0.25rem; border-bottom: 1px solid var(--color-border);
  border-left: 1px solid var(--color-border); margin-bottom: 0.375rem;
}
.sim-chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.sim-chart-value { font-size: 0.5625rem; font-weight: 600; color: var(--color-text); margin-bottom: 2px; font-family: var(--font-mono); }
.sim-chart-bar { width: 100%; border-radius: 3px 3px 0 0; transition: height 0.5s; min-height: 2px; }
.sim-chart-labels { display: flex; gap: 2px; margin-bottom: 0.375rem; }
.sim-chart-labels span { flex: 1; text-align: center; font-size: 0.5625rem; color: var(--color-text-muted); }
.sim-chart-title { font-size: 0.625rem; color: var(--color-text-muted); text-align: center; margin-bottom: 0.75rem; }

/* Sim Table */
.sim-table { width: 100%; border-collapse: collapse; font-size: 0.6875rem; overflow-x: auto; display: block; }
.sim-table th, .sim-table td { padding: 0.25rem 0.375rem; text-align: left; border-bottom: 1px solid var(--color-border); }
.sim-table th { font-weight: 600; color: var(--color-text-secondary); background: var(--color-bg); white-space: nowrap; }
.sim-table tr:last-child td { border-bottom: none; }
.sim-table td { font-family: var(--font-mono); }
.sim-table td.center, .sim-table th.center { text-align: center; }

/* ============================================
   TOAST
   ============================================ */
#toast-container {
  position: fixed; bottom: calc(var(--bottom-nav-height) + 12px); right: 0.5rem;
  z-index: 1000; display: flex; flex-direction: column-reverse; gap: 0.25rem;
  max-width: 300px; pointer-events: none;
}
@media (min-width: 768px) { #toast-container { bottom: 1rem; right: 1rem; } }
.toast {
  display: flex; align-items: center; gap: 0.375rem;
  padding: 0.5rem 0.75rem; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); font-size: 0.75rem; color: var(--color-text);
  pointer-events: auto; animation: toastIn 0.3s ease;
}
.toast.removing { animation: toastOut 0.3s ease; }
.toast-success { border-left: 3px solid var(--color-success); }
.toast-error { border-left: 3px solid var(--color-danger); }
.toast-warning { border-left: 3px solid var(--color-warning); }
.toast-info { border-left: 3px solid var(--color-primary); }
@keyframes toastIn { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100%); } }

/* ============================================
   RESULT MODAL
   ============================================ */
.result-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.result-modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
.result-modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.result-modal-overlay.visible .result-modal {
  transform: translateY(0);
}
.result-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}
.result-modal-header h3 {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}
.result-modal-header h3 i { color: var(--color-success); font-size: 1.125rem; }
.result-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}
.result-modal-close:hover { background: var(--color-danger-bg); color: var(--color-danger); border-color: var(--color-jab-border); }
.result-modal-body {
  padding: 1rem;
  max-height: 40vh;
  overflow-y: auto;
}
.result-modal-text {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  max-height: 200px;
  overflow-y: auto;
  margin: 0;
}
.result-modal-file {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  color: var(--color-text);
}
.result-modal-file i { font-size: 1.5rem; color: var(--color-primary); }
.result-modal-filesize {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}
.result-modal-actions {
  display: flex;
  gap: 0.375rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--color-border);
}
.result-modal-actions .btn { flex: 1; }

/* ============================================
   RESULT MODAL PREVIEWS
   ============================================ */
.result-modal-preview {
  margin-top: 0.5rem;
}
.result-preview-image {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.result-preview-image:hover {
  border-color: var(--color-primary);
}
.result-preview-image::after {
  content: '⤢';
  position: absolute;
  top: 0.375rem;
  right: 0.375rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.result-preview-image:hover::after {
  opacity: 1;
}
.result-preview-image img {
  display: block;
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
  margin: 0 auto;
}
.result-preview-audio {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.result-preview-audio-icon {
  font-size: 2rem;
  color: var(--color-primary);
}
.result-preview-audio audio {
  width: 100%;
  max-width: 320px;
  height: 40px;
}
.result-preview-pdf {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
}
.result-preview-pdf iframe {
  width: 100%;
  height: 400px;
  border: none;
}
.result-preview-doc {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
}
.result-preview-doc iframe {
  width: 100%;
  height: 400px;
  border: none;
}

/* Image Fullscreen Overlay */
.result-image-fullscreen {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 6000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  cursor: pointer;
}
.result-image-fullscreen.visible {
  display: flex;
}
.result-image-fullscreen img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-md);
  cursor: default;
}
.result-image-fullscreen-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.result-image-fullscreen-close:hover {
  background: rgba(255,255,255,0.3);
}

/* ============================================
   SUCCESS ANIMATIONS — Dog + Fireworks (Lottie)
   ============================================ */

/* Fireworks: full-overlay background behind the modal */
.success-fireworks {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.success-fireworks #success-fireworks-lottie {
  width: 100%;
  height: 100%;
}

/* Dog container: positioned behind modal, slides up from behind top edge */
.success-dog-container {
  position: absolute;
  /* top is set dynamically via JS to align with the modal's top edge */
  top: 50%;
  left: 50%;
  /* z-index ALWAYS below modal (50) so modal background naturally covers the dog */
  z-index: 10;
  pointer-events: none;
  /* Start hidden behind the modal */
  transform: translate(-50%, 20%);
  opacity: 0;
  /* Show: instant, no CSS animation — Lottie handles the pop-out */
  /* Hide: smooth slide-down with easing (see .slide-down below) */
  transition: none;
}
.success-dog-container.slide-up {
  /* Slide UP — dog emerges from behind modal's top edge */
  /* NO z-index change — modal (z-index: 50) still covers the dog where they overlap */
  /* Only the part above the modal is visible → "peeking from behind" effect */
  /* translate(-50%, -100%) moves the dog up by its own height, so bottom edge = anchor point */
  transform: translate(-50%, -100%);
  opacity: 1;
  /* No transition on show — Lottie animation handles the reveal */
  transition: none;
}
.success-dog-container.slide-down {
  transform: translate(-50%, 20%);
  opacity: 0;
  /* Only the hide transition — smooth slide back down */
  transition: transform 0.6s cubic-bezier(0.55, 0, 1, 0.45), opacity 0.4s ease 0.15s;
}
.success-dog-container #success-dog-lottie {
  width: 220px;
  height: 220px;
  filter: drop-shadow(0 -6px 16px rgba(0, 0, 0, 0.3));
}

/* Ensure result-modal stays above fireworks but below dog */
.result-modal-overlay .result-modal {
  position: relative;
  z-index: 50;
}

/* ============================================
   SCAN STATUS / FPS
   ============================================ */
.scan-status-text { font-size: 0.6875rem; color: rgba(255,255,255,0.7); font-weight: 500; }
.receiver-overlay-info .scan-status-text { font-size: 0.625rem; }

/* ============================================
   DOG HELPER — Peek from right wall
   ============================================ */
.dog-helper {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%) translateX(80%);
  z-index: 50;
  cursor: pointer;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: none; /* shown only when receiver settings active */
}
.dog-helper.visible {
  display: block;
  transform: translateY(-50%) translateX(30%);
}
.dog-helper:hover {
  transform: translateY(-50%) translateX(20%);
}
.dog-helper-lottie {
  width: 80px;
  height: 80px;
  filter: drop-shadow(-4px 2px 8px rgba(0,0,0,0.2));
}
.dog-helper-label {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-primary);
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

@keyframes dogPeekIn {
  0% { transform: translateY(-50%) translateX(100%); }
  100% { transform: translateY(-50%) translateX(30%); }
}

/* ============================================
   HELP / GUIDE MODAL
   ============================================ */
.help-modal {
  max-width: 440px;
  width: 92vw;
  overflow-y: hidden; /* Fix: prevent double scrollbar — help-body handles scrolling */
  display: flex;
  flex-direction: column;
}
.help-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 1rem;
}
.help-section {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}
.help-code-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color 0.2s ease, background 0.2s ease;
  cursor: pointer;
  overflow: hidden;
}
.help-code-item:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}
.help-code-preview {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.help-code-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
[data-theme="dark"] .help-code-preview {
  background: #1a1a2e;
}
.help-code-info {
  padding: 0.375rem 0.5rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.help-code-title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.help-code-info strong {
  font-size: 0.75rem;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.help-code-desc {
  margin: 0;
  font-size: 0.625rem;
  line-height: 1.35;
  color: var(--color-text-secondary, #888);
}
.help-mode-badge {
  display: inline-block;
  padding: 0.05rem 0.3rem;
  font-size: 0.5rem;
  font-weight: 600;
  border-radius: 9999px;
  background: var(--color-primary);
  color: #fff;
  flex-shrink: 0;
  white-space: nowrap;
}
.help-code-item.active-mode {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.help-autodetect-section {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}
.help-autodetect-result {
  padding: 0.5rem;
  background: var(--color-primary-bg);
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  color: var(--color-text);
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.help-autodetect-result .detected-mode {
  font-weight: 600;
  color: var(--color-primary);
}
.help-autodetect-result .switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.6875rem;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-family);
  transition: all 0.2s ease;
  white-space: nowrap;
  margin-left: auto;
  flex-shrink: 0;
}
.help-autodetect-result .switch-btn:hover {
  background: var(--color-primary-dark);
}

/* ============================================
   PRINT
   ============================================ */
@media print {
  .app-header, .bottom-nav, .sidebar-overlay, #loading-overlay, #toast-container,
  .fullscreen-btn, .sidebar-toggle, .theme-toggle, .shortcuts-toggle { display: none !important; }
  .app-container { height: auto; overflow: visible; }
  .app-main { display: block; height: auto; }
  .settings-panel { display: none !important; }
}

/* ============================================
   FOCUS
   ============================================ */
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ============================================
   DESKTOP (>=768px)
   ============================================ */
@media (min-width: 768px) {
  .header-tabs { display: flex; }
  .bottom-nav { display: none; }
  .sidebar-header { display: none !important; }

  .sidebar-toggle {
    display: flex;
  }

  .settings-panel {
    width: 340px;
  }

  /* Show status text in header on desktop */
  .header-status-text {
    display: inline;
  }

  /* Card hover effects on desktop */
  .card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
  }

  /* When sidebar is toggled off on desktop, settings panel hides */
  .settings-panel.panel-hidden {
    display: none;
  }

  /* When sidebar is hidden, display panel takes full width */
  .settings-panel.panel-hidden ~ .display-panel,
  .app-main:has(.settings-panel.panel-hidden) .display-panel {
    /* Can't use ~ here, handle in JS */
  }
}

/* ============================================
   MOBILE (<768px)
   ============================================ */
@media (max-width: 767px) {
  :root {
    --sidebar-width: min(320px, 85vw);
  }

  .sidebar-toggle {
    display: flex;
  }

  /* Settings panel becomes a slide-in sidebar */
  .settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    padding: 0;
    padding-top: 0.5rem;
  }

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

  .sidebar-header {
    display: flex !important;
    padding: 0.5rem 0.625rem 0.5rem;
  }

  /* Hide settings panel toggle text on mobile — use icon */
  .header-tabs { display: none; }

  /* Dog helper on mobile — peek from right edge of camera view */
  .dog-helper {
    right: 0;
    top: auto;
    bottom: 5rem;
    transform: translateX(75%);
  }
  .dog-helper.visible {
    display: block;
    transform: translateY(-50%) translateX(30%);
  }
  .dog-helper:hover {
    transform: translateY(-50%) translateX(20%);
  }
  .dog-helper-lottie {
    width: 64px;
    height: 64px;
  }
  .dog-helper-label {
    width: 18px;
    height: 18px;
    font-size: 0.625rem;
    bottom: 0;
  }

  /* Dark theme adjustments for floating buttons */
  [data-theme="dark"] .protocol-badge,
  [data-theme="dark"] .fullscreen-btn,
  [data-theme="dark"] .export-btn {
    background: rgba(30, 41, 59, 0.9);
  }
}

/* ============================================
   VIDEO EXPORT MODAL
   ============================================ */
.video-export-modal {
  max-width: 420px;
  width: 92vw;
}
.video-export-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.ve-section {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.ve-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text);
}
.ve-format-grid {
  display: flex;
  gap: 0.25rem;
}
.ve-format-grid .btn {
  flex: 1;
}
.ve-codec-info {
  font-size: 0.625rem;
  color: var(--color-text-muted);
  line-height: 1.3;
}
.ve-codec-info .unsupported {
  color: var(--color-warning);
}
.ve-redundancy-rec {
  font-size: 0.625rem;
  font-weight: 400;
  color: var(--color-primary);
  margin-left: 0.375rem;
}
.ve-redundancy-row {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.ve-redundancy-row .btn {
  flex: 1;
  min-width: 44px;
}
.ve-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.375rem;
}
.ve-info-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.25rem 0.375rem;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
}
.ve-info-label {
  font-size: 0.5625rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.ve-info-value {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text);
}
.ve-progress-section {
  padding: 0.5rem 0;
}
.ve-progress-label {
  font-size: 0.6875rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.375rem;
}
.ve-result-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--color-success-bg);
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-md);
}
.ve-result-info {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text);
}

/* ============================================
   BROADCAST MODAL
   ============================================ */
.broadcast-modal {
  max-width: 440px;
  width: 92vw;
}
.broadcast-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#broadcast-preview {
  max-height: 280px;
  object-fit: contain;
}

/* ============================================
   BROADCAST MJPEG URL STYLES
   ============================================ */
.broadcast-url-row {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}
.broadcast-url-input {
  flex: 1;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  min-width: 0;
}

/* ============================================
   VIDEO EXPORT — CUSTOM REDUNDANCY & LOOP
   ============================================ */
.ve-redundancy-sep {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  align-self: center;
  user-select: none;
}
.ve-custom-redundancy {
  width: 52px;
  padding: 0.2rem 0.375rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-align: center;
}
.ve-custom-redundancy:focus {
  outline: none;
  border-color: var(--color-primary);
}
.ve-custom-redundancy::placeholder {
  color: var(--color-text-muted);
  font-size: 0.5625rem;
}
.ve-loop-label {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  font-size: 0.6875rem;
  color: var(--color-text-secondary);
  -webkit-tap-highlight-color: none;
}
.ve-loop-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.unsupported {
  color: var(--color-danger);
  opacity: 0.8;
}
