/* ============================================================
   eVision — Design System
   Theme: Resume (Monochrome · JetBrains Mono · Minimal)
   ============================================================ */

:root {
  /* Color System — Pure monochrome from Resume theme */
  --clr-bg: #000000;
  --clr-bg-alt: #0a0a0a;
  --clr-bg-card: #111111;
  --clr-bg-hover: #1a1a1a;
  --clr-surface: #181818;

  --clr-text: #ffffff;
  --clr-text-secondary: #a0a0a0;
  --clr-text-muted: #666666;

  --clr-border: #2a2a2a;
  --clr-border-light: #333333;

  --clr-accent: #ffffff;
  --clr-accent-muted: #888888;

  /* Detection colors — refined for monochrome theme */
  --clr-detection-object: #88ccff;
  --clr-detection-face: #88ffaa;
  --clr-detection-motion: #ffcc44;
  --clr-detection-tracked: #ff6666;

  /* Terminal dots */
  --clr-dot-red: #ff5f56;
  --clr-dot-yellow: #ffbd2e;
  --clr-dot-green: #27c93f;

  /* Typography — JetBrains Mono (matching Resume) */
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --font-sans: var(--font-mono);

  --fs-xs: 0.6875rem;    /* 11px */
  --fs-sm: 0.75rem;      /* 12px */
  --fs-base: 0.8125rem;  /* 13px */
  --fs-lg: 0.9375rem;    /* 15px */
  --fs-xl: 1.125rem;     /* 18px */
  --fs-2xl: 1.5rem;      /* 24px */

  --fw-light: 300;
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-extrabold: 800;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.6);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.7);
  --shadow-glow: 0 0 20px rgba(255,255,255,0.05);
  --shadow-card: 0 12px 40px rgba(255, 255, 255, 0.03);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Layout */
  --header-height: 52px;
  --controls-height: 52px;
  --footer-height: 52px;
  --panel-width: 320px;
  --cam-max-height-mobile: 50dvh;

  /* Safe area (notch phones) */
  --sa-top: env(safe-area-inset-top, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);
  --sa-left: env(safe-area-inset-left, 0px);
  --sa-right: env(safe-area-inset-right, 0px);
}

/* ======================== LIGHT MODE ======================== */
[data-theme="light"] {
  --clr-bg: #ffffff;
  --clr-bg-alt: #f5f5f7;
  --clr-bg-card: #efeff1;
  --clr-bg-hover: #e5e5e7;
  --clr-surface: #f0f0f2;

  --clr-text: #1a1a1a;
  --clr-text-secondary: #555555;
  --clr-text-muted: #999999;

  --clr-border: #d4d4d8;
  --clr-border-light: #c0c0c4;

  --clr-accent: #1a1a1a;
  --clr-accent-muted: #666666;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --shadow-glow: 0 0 20px rgba(0,0,0,0.03);
  --shadow-card: 0 12px 40px rgba(0, 0, 0, 0.04);
}

/* ======================== RESET ======================== */
*,*::before,*::after { margin:0; padding:0; box-sizing:border-box; }
html { font-size:16px; -webkit-text-size-adjust:100%; }
body {
  font-family: var(--font-mono);
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.6;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

::selection { background: var(--clr-text); color: var(--clr-bg); }

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 100vw;
  overflow: hidden;
}

/* ======================== HEADER ======================== */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  padding: var(--sa-top) var(--space-4) 0;
  background: var(--clr-bg);
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
}

.logo { display: flex; align-items: center; gap: var(--space-3); }
.logo-icon { 
  color: var(--clr-accent); 
  filter: drop-shadow(0 0 12px rgba(255,255,255,0.12));
}
.logo-text { 
  font-size: var(--fs-lg); 
  font-weight: var(--fw-bold); 
  letter-spacing: -0.03em;
}
.logo-accent { 
  color: var(--clr-text-muted);
  font-weight: var(--fw-light);
}

.header-center { display: none; }
@media (min-width: 768px) {
  .header-center { display: flex; align-items: center; }
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 3px 12px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--clr-border);
  background: var(--clr-bg-card);
  transition: all var(--transition-base);
}
.status-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-offline { color: var(--clr-text-muted); }
.status-offline::before { background: var(--clr-text-muted); }
.status-loading { color: var(--clr-dot-yellow); animation: pulse-badge 1.5s infinite; }
.status-loading::before { background: var(--clr-dot-yellow); }
.status-online { color: var(--clr-dot-green); }
.status-online::before { background: var(--clr-dot-green); animation: pulse-dot 1.5s ease-in-out infinite; }

@keyframes pulse-badge { 0%,100% { opacity:1 } 50% { opacity:0.5 } }
@keyframes pulse-dot { 0%,100% { opacity:1; transform:scale(1) } 50% { opacity:0.5; transform:scale(0.8) } }

.header-right { display: flex; align-items: center; gap: var(--space-2); }

/* ======================== CONTROLS ======================== */
#controls {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--clr-bg-alt);
  border-bottom: 1px solid var(--clr-border);
  min-height: var(--controls-height);
  flex-shrink: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--clr-border) transparent;
}
#controls::-webkit-scrollbar { height: 3px; }
#controls::-webkit-scrollbar-track { background: transparent; }
#controls::-webkit-scrollbar-thumb { background: var(--clr-border); border-radius: var(--radius-full); }
#controls::-webkit-scrollbar-thumb:hover { background: var(--clr-text-muted); }
.controls-group { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; flex-wrap: nowrap; }
.controls-group + .controls-group { margin-left: auto; }
/* Ensure controls never wrap on mobile — single scrollable row */
#controls { flex-wrap: nowrap; }

/* Controls scroll indicator — subtle fade edge hint */
@media (max-width: 767px) {
  #controls::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(to right, transparent, var(--clr-bg-alt));
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-base);
  }
  /* Only show when content can scroll */
  #controls.can-scroll::after { opacity: 1; }
  #controls.scrolled-end::after { opacity: 0; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 14px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  min-height: 44px;
  font-family: var(--font-mono);
  line-height: 1;
  background: var(--clr-bg-card);
  color: var(--clr-text);
  touch-action: manipulation;
}
/* Compact button variant for crowded toolbars */
.btn-compact { padding: 6px 10px; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:hover:not(:disabled) {
  background: var(--clr-bg-hover);
  border-color: var(--clr-text);
}
.btn-primary {
  background: var(--clr-text);
  color: var(--clr-bg);
  border-color: var(--clr-text);
}
.btn-primary:hover:not(:disabled) {
  background: var(--clr-bg);
  color: var(--clr-text);
  box-shadow: var(--shadow-card);
}
.btn-secondary { background: var(--clr-bg-card); color: var(--clr-text); }
.btn-ghost { background: transparent; color: var(--clr-text-secondary); border-color: transparent; padding: 4px 10px; }
.btn-ghost:hover { color: var(--clr-text); background: var(--clr-bg-card); border-color: var(--clr-border); }
.btn-sm { padding: 4px 10px; font-size: var(--fs-xs); min-height: 28px; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--clr-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 44px;
}
.btn-icon:hover { background: var(--clr-bg-card); color: var(--clr-text); border-color: var(--clr-border); }
.btn-icon-svg { flex-shrink: 0; }

/* Toggle group */
.toggle-group {
  display: inline-flex;
  background: var(--clr-bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--clr-border);
  padding: 2px;
  gap: 1px;
}
.toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border: none;
  border-radius: calc(var(--radius-md) - 2px);
  background: transparent;
  color: var(--clr-text-muted);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  min-height: 36px;
  font-family: var(--font-mono);
  touch-action: manipulation;
}
.toggle-btn.active {
  background: var(--clr-text);
  color: var(--clr-bg);
}
.toggle-btn:not(.active):hover { color: var(--clr-text); }

.select-input {
  display: inline-flex;
  align-items: center;
  padding: 4px 28px 4px 10px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  background: var(--clr-bg-card);
  color: var(--clr-text);
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
  cursor: pointer;
  min-height: 44px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  touch-action: manipulation;
}
.select-input:disabled { opacity: 0.35; cursor: not-allowed; }
.select-input:focus { outline: none; border-color: var(--clr-text); }

/* ======================== MAIN LAYOUT ======================== */
#mainContent {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

@media (min-width: 768px) {
  #mainContent { flex-direction: row; }
}

/* ======================== CAMERA SECTION ======================== */
#cameraSection {
  position: relative;
  flex: none;
  height: var(--cam-max-height-mobile);
  min-height: 0;
  background: var(--clr-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 768px) {
  #cameraSection { height: auto; flex: 1; }
}

#cameraContainer {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--clr-bg);
  max-width: 100%;
  max-height: 100%;
}

/* Desktop: maintain 4:3 framing */
@media (min-width: 768px) {
  #cameraContainer { aspect-ratio: 4 / 3; }
}

/* Terminal window frame around camera */
#cameraContainer::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid var(--clr-border);
  border-radius: 0;
  pointer-events: none;
  z-index: 15;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  position: relative;
  z-index: 1;
}

#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* Crosshair — refined */
.crosshair { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); pointer-events:none; z-index:10; }
.crosshair.hidden { display:none; }
.crosshair-ring {
  position:absolute; top:50%; left:50%;
  width:68px; height:68px; transform:translate(-50%,-50%);
  border:1.5px solid var(--clr-detection-tracked); border-radius:50%;
  animation:crosshair-pulse 1.5s ease-in-out infinite;
  box-shadow:0 0 20px rgba(255,102,102,0.15);
}
.crosshair-dot { position:absolute; top:50%; left:50%; width:3px; height:3px; transform:translate(-50%,-50%); background:var(--clr-detection-tracked); border-radius:50%; }
.crosshair-line-h,.crosshair-line-v { position:absolute; background:var(--clr-detection-tracked); opacity:0.35; }
.crosshair-line-h { top:50%; left:50%; width:32px; height:1px; transform:translate(-50%,-50%); }
.crosshair-line-v { top:50%; left:50%; width:1px; height:32px; transform:translate(-50%,-50%); }
@keyframes crosshair-pulse {
  0%,100%{transform:translate(-50%,-50%) scale(1);opacity:1}
  50%{transform:translate(-50%,-50%) scale(1.08);opacity:0.6}
}

/* Status overlay */
.status-overlay {
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  background:rgba(0,0,0,0.92); z-index:20; transition:opacity var(--transition-slow);
}
.status-overlay.hidden { opacity:0; pointer-events:none; }
.status-content { text-align:center; max-width:280px; padding:var(--space-6); width:100%; }
.status-spinner { margin-bottom:var(--space-5); display:flex; justify-content:center; }
.spinner-ring {
  width:36px; height:36px; border:2px solid var(--clr-border);
  border-top-color:var(--clr-text); border-radius:50%;
  animation:spin 0.8s linear infinite;
}
@keyframes spin { to { transform:rotate(360deg); } }
.status-message { font-size:var(--fs-lg); font-weight:var(--fw-bold); margin-bottom:var(--space-3); }
.status-detail { font-size:var(--fs-sm); color:var(--clr-text-muted); margin-top:var(--space-2); }
.progress-container { width:100%; height:3px; background:var(--clr-border); border-radius:var(--radius-full); overflow:hidden; margin-top:var(--space-3); }
.progress-bar { height:100%; width:0%; background:var(--clr-text); border-radius:var(--radius-full); transition:width .3s; }
.retry-btn { margin-top:var(--space-5); }
.retry-btn.hidden { display:none; }
.status-overlay.error .status-spinner { display:none; }
.status-overlay.error .status-message { color:var(--clr-detection-tracked); }
.status-overlay.error .status-detail { color:var(--clr-detection-tracked); opacity:0.7; }

/* Mode badge */
.mode-badge {
  position:absolute; top:var(--space-2); left:var(--space-2); z-index:10;
  display:inline-flex; align-items:center; gap:var(--space-2);
  padding:3px 10px; background:rgba(0,0,0,0.8);
  border:1px solid var(--clr-border);
  border-radius:var(--radius-full);
  font-size:10px; font-weight:var(--fw-semibold);
  pointer-events:none;
  letter-spacing:0.04em;
}
.mode-badge.hidden { display:none; }

/* FPS */
.fps-counter {
  position:absolute; top:var(--space-2); right:var(--space-2); z-index:10;
  padding:3px 8px; background:rgba(0,0,0,0.8);
  border:1px solid var(--clr-border);
  border-radius:var(--radius-full);
  font-size:10px; color:var(--clr-text-muted);
  pointer-events:none;
}
.fps-counter.hidden { display:none; }

/* ======================== RESULTS PANEL ======================== */
.results-panel {
  width: 100%;
  background: var(--clr-bg-alt);
  border-top: 1px solid var(--clr-border);
  display: flex;
  flex-direction: column;
  flex: 1; /* fills remaining space — no gap */
  min-height: 0;
  overflow: hidden;
}

@media (min-width: 768px) {
  .results-panel {
    width: var(--panel-width);
    flex: none;
    border-top: none;
    border-left: 1px solid var(--clr-border);
    height: calc(100dvh - var(--header-height) - var(--controls-height) - var(--footer-height));
  }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
}
.panel-title {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--clr-text-muted);
}
.result-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: transparent;
  border: 1px solid var(--clr-border);
  color: var(--clr-text);
  font-size: 10px;
  font-weight: var(--fw-bold);
}

.stats-row {
  display: flex;
  gap: 1px;
  background: var(--clr-border);
  flex-shrink: 0;
}
.stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: var(--space-2);
  background: var(--clr-bg-alt);
  text-align: center;
}
.stat-label {
  font-size: 9px;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: var(--fw-semibold);
}
.stat-value {
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--clr-text);
  min-height: 1.5em;
}

.detection-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-1);
}
.detection-list::-webkit-scrollbar { width: 4px; }
.detection-list::-webkit-scrollbar-track { background: transparent; }
.detection-list::-webkit-scrollbar-thumb { background: var(--clr-border); border-radius: var(--radius-full); }
.detection-list::-webkit-scrollbar-thumb:hover { background: var(--clr-text-muted); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-6) var(--space-4);
  color: var(--clr-text-muted);
}
.empty-title { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--clr-text-secondary); margin-bottom: var(--space-1); }
.empty-desc { font-size: 11px; max-width: 240px; opacity: 0.7; }

.detection-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 1px;
  min-height: 44px;
  border: 1px solid transparent;
}

/* Compact cards on mobile — less padding */
@media (max-width: 479px) {
  .detection-card { padding: var(--space-1) var(--space-2); min-height: 38px; gap: var(--space-2); }
  .detection-card .card-label { font-size: var(--fs-xs); }
  .detection-card .card-confidence { font-size: var(--fs-xs); }
}
.detection-card:hover { background: var(--clr-bg-card); border-color: var(--clr-border); }
.detection-card.active { background: var(--clr-bg-card); border-color: var(--clr-text-muted); }
.detection-card .card-color { width: 3px; height: 22px; border-radius: 1px; flex-shrink: 0; }
.detection-card .card-info { flex: 1; min-width: 0; }
.detection-card .card-label { font-size: var(--fs-sm); font-weight: var(--fw-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detection-card .card-sub { font-size: 10px; color: var(--clr-text-muted); }
.detection-card .card-confidence { font-family: var(--font-mono); font-size: var(--fs-sm); font-weight: var(--fw-bold); flex-shrink: 0; }
.detection-card .card-badge {
  display: inline-flex; align-items: center; padding: 1px 6px;
  border-radius: var(--radius-sm); font-size: 9px; font-weight: var(--fw-bold);
  text-transform: uppercase; letter-spacing: 0.04em; flex-shrink: 0;
  border: 1px solid;
}
.badge-object { border-color: rgba(136,204,255,0.3); color: var(--clr-detection-object); background: rgba(136,204,255,0.06); }
.badge-face { border-color: rgba(136,255,170,0.3); color: var(--clr-detection-face); background: rgba(136,255,170,0.06); }

.follow-info {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-2) var(--space-4); background: var(--clr-bg-card);
  border-top: 1px solid var(--clr-border); flex-shrink: 0;
}
.follow-info.hidden { display:none; }
.follow-indicator { display:flex; align-items:center; gap:var(--space-2); font-size:var(--fs-sm); color:var(--clr-detection-tracked); }
.follow-pulse { width:6px; height:6px; border-radius:50%; background:var(--clr-detection-tracked); animation:pulse-dot 1s ease-in-out infinite; }

/* ======================== FOOTER ======================== */
#footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  padding-bottom: var(--sa-bottom);
  min-height: var(--footer-height);
  background: var(--clr-bg);
  border-top: 1px solid var(--clr-border);
  flex-shrink: 0;
}
.footer-text {
  font-size: var(--fs-xs);
  color: var(--clr-text-muted);
  font-weight: var(--fw-regular);
}
.footer-credit {
  font-size: var(--fs-xs);
  color: var(--clr-text-muted);
  opacity: 0.6;
}
.footer-credit strong {
  color: var(--clr-text-secondary);
  font-weight: var(--fw-semibold);
}

/* ======================== TOAST ======================== */
.toast-container {
  position: fixed;
  bottom: calc(var(--footer-height) + var(--space-4));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
}
@media (min-width: 768px) {
  .toast-container { bottom: var(--space-6); }
}
.toast {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--clr-bg-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  font-family: var(--font-mono);
  pointer-events: auto;
  animation: toast-in .3s ease;
  max-width: 360px;
}
.toast.toast-out { animation: toast-out .3s ease forwards; }
.toast-success { border-color: var(--clr-dot-green); }
.toast-error { border-color: var(--clr-dot-red); }
.toast-info { border-color: var(--clr-border-light); }
@keyframes toast-in { from { opacity:0; transform:translateY(10px) } to { opacity:1; transform:translateY(0) } }
@keyframes toast-out { from { opacity:1; transform:translateY(0) } to { opacity:0; transform:translateY(10px) } }

/* ======================== MODAL ======================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  padding: var(--space-4);
}
.modal-overlay.hidden { display: none; }
.modal-content {
  background: var(--clr-bg-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--clr-border);
}
.modal-header h2 {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
}
.modal-body { padding: var(--space-5); }
.modal-body p {
  font-size: var(--fs-sm);
  color: var(--clr-text-secondary);
  line-height: 1.7;
  margin-bottom: var(--space-3);
}

.info-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--clr-border);
}
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-sm);
}
.info-label {
  color: var(--clr-text-muted);
  font-weight: var(--fw-regular);
}
.info-value {
  color: var(--clr-text);
  font-weight: var(--fw-semibold);
}
.info-value .pi { margin-right: var(--space-1); }

.version-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-full);
  font-size: 10px;
  color: var(--clr-text-muted);
  font-family: var(--font-mono);
}

/* Terminal dots decoration for modal title */
.modal-terminal {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--space-3);
}
.modal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.modal-dot-red { background: var(--clr-dot-red); }
.modal-dot-yellow { background: var(--clr-dot-yellow); }
.modal-dot-green { background: var(--clr-dot-green); }

/* ============================================================
   RESPONSIVE — Mobile-First Breakpoints
   ============================================================ */

/* Small phones (320px - 479px): most compact layout */
@media (max-width: 479px) {
  /* Hide button text labels, show only icons */
  .btn-text { display: none; }
  :root { --cam-max-height-mobile: 45dvh; }
  #controls { padding: var(--space-1) var(--space-2); gap: var(--space-1); }
  .btn { padding: 6px 8px; min-height: 44px; }
  .btn-primary { padding: 6px 10px; } /* Start button needs slightly more room */
  .select-input { max-width: 80px; font-size: 9px; padding: 4px 18px 4px 6px; }
  .toggle-btn { padding: 4px 8px; font-size: 9px; min-height: 34px; }
  .controls-group { gap: var(--space-1); }
  .controls-group + .controls-group { margin-left: var(--space-1); }
  #footer { gap: var(--space-2); padding: 0 var(--space-2); }
  .footer-credit { display: block; font-size: 10px; }
  .footer-text { font-size: 10px; }
  /* Compact stats row */
  .stats-row { gap: 0; }
  .stat-item { padding: var(--space-1) var(--space-2); }
  .stat-value { font-size: var(--fs-base); }
}

/* Large phones (480px - 639px): slightly more room */
@media (min-width: 480px) and (max-width: 639px) {
  /* Keep .btn-text visible for key actions, hide for secondary */
  #controls { padding: var(--space-1) var(--space-3); gap: var(--space-1); }
  .select-input { max-width: 100px; }
  .controls-group + .controls-group { margin-left: var(--space-2); }
  #footer { gap: var(--space-2); padding: 0 var(--space-3); }
}

/* Tablet bridge (640px - 767px) */
@media (min-width: 640px) and (max-width: 767px) {
  :root { --cam-max-height-mobile: 55dvh; }
  #controls { padding: var(--space-2) var(--space-4); }
}

/* Desktop (768px+) */
@media (min-width: 768px) {
  #controls { padding: var(--space-2) var(--space-4); }
  .controls-group + .controls-group { margin-left: auto; }
}

/* Wide desktop (1440px+) */
@media (min-width: 1440px) {
  :root { --panel-width: 360px; }
}

/* Footer safe area on mobile */
@media (max-width: 767px) {
  #footer { padding-bottom: calc(var(--space-3) + var(--sa-bottom)); }
}

/* ======================== ACCESSIBILITY ======================== */
:focus-visible {
  outline: 1px solid var(--clr-text);
  outline-offset: 2px;
}

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