/* * LIGHT PREMIUM THEME VARIABLES */
    :root {
      --primary: #D94A27;
      --primary-dark: #bf3f1f;
      --bg-base: #f8fafc; 
      --shell: #ffffff; 
      --surface: #f1f5f9; 
      --surface-2: #e2e8f0;
      --text: #0f172a; 
      --muted: #64748b;
      --border: #e2e8f0;
      --border-strong: #cbd5e1;
      --success: #059669;
      --danger: #dc2626;
      --shadow: 0 25px 50px -12px rgba(0,0,0,0.15);
      --radius: 32px;
      --radius-lg: 24px;
      --radius-md: 16px;
    }

    * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
    html { scroll-behavior: smooth; }

    body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: var(--text);
  overflow: hidden;
  background: #000;
  position: relative;
  height: 100dvh;
  width: 100vw;
  display: flex;
  flex-direction: column;
}

    /* LANGUAGE SWITCHER */
    .lang-switcher {
  position: absolute; top: 24px; right: 24px; z-index: 1000; padding: 8px 16px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.3); background: rgba(0,0,0,0.3); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  font-family: inherit; font-weight: 700; font-size: 13px; color: #fff; cursor: pointer; outline: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2); transition: all 0.2s ease; text-shadow: 0 1px 3px rgba(0,0,0,0.5); pointer-events: auto;
}
    .lang-switcher:hover { background: rgba(0,0,0,0.5); border-color: rgba(255,255,255,0.5); }

    h1, h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: -0.03em; position: relative; z-index: 1; }
    p { line-height: 1.6; color: var(--muted); position: relative; z-index: 1; }

    /* APP DEMO SECTION */
    .app-section { padding: 0; display: flex; justify-content: center; align-items: center; position: relative; z-index: 10; width: 100%; height: 100%; }

    .shell {
  width: 100%; height: 100%;
  background: transparent; border-radius: 0;
  display: flex; flex-direction: column; position: relative;
  border: none; overflow: hidden; box-shadow: none;
}
    
    .shell:hover { box-shadow: none; }

    .shell header {
  padding: 22px 22px 18px; display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0) 100%);
  border-bottom: none; z-index: 20; position: absolute; top: 0; left: 0; width: 100%; pointer-events: none;
}

    .brand { display: flex; flex-direction: column; gap: 4px; }
    .brand a { text-decoration: none; color: inherit; }
    .logo { font-weight: 800; font-size: 22px; color: #fff; letter-spacing: -1px; line-height: 1; text-shadow: 0 2px 10px rgba(0,0,0,0.5); pointer-events: auto; }
    
    .subtle { font-size: 12px; color: rgba(255,255,255,0.9); text-shadow: 0 1px 5px rgba(0,0,0,0.5); pointer-events: auto; }

    .badge {
  font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  color: #fff; background: rgba(16, 185, 129, 0.4); border: 1px solid rgba(16, 185, 129, 0.5);
  padding: 7px 10px; border-radius: 999px; white-space: nowrap; backdrop-filter: blur(5px);
  transition: all 0.3s ease; text-shadow: 0 1px 3px rgba(0,0,0,0.5); pointer-events: auto;
}

    /* Dynamic Badge States */
    .badge.processing {
      color: #eab308;
      background: rgba(234, 179, 8, 0.1);
      border-color: rgba(234, 179, 8, 0.2);
    }
    .badge.badge-error {
      color: var(--danger);
      background: rgba(220, 38, 38, 0.1);
      border-color: rgba(220, 38, 38, 0.2);
    }

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

    .viewport {
  position: absolute; inset: 0; margin: 0; border-radius: 0;
  background: #000; border: none; z-index: 0; box-shadow: none; display: flex; align-items: center; justify-content: center; overflow: hidden;
}

    #preview { width: 100%; height: 100%; object-fit: cover; display: none; position: absolute; inset: 0; }

    .grid-overlay {
      position: absolute; inset: 0; background-image: radial-gradient(rgba(217, 74, 39, 0.3) 1px, transparent 1px);
      background-size: 20px 20px; opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 4;
    }

    /* Hardware-Accelerated Scanline Fix */
    .scan-bar {
      position: absolute; 
      top: -100%; 
      left: 0; 
      width: 100%; 
      height: 100%;
      border-bottom: 2px solid var(--primary);
      box-shadow: 0 10px 20px rgba(217, 74, 39, 0.4);
      display: none;
      z-index: 10; 
      animation: scanMove 1.5s infinite ease-in-out;
    }

    @keyframes scanMove { 
      0% { transform: translateY(0); opacity: 0; } 
      10% { opacity: 1; } 
      90% { opacity: 1; } 
      100% { transform: translateY(100%); opacity: 0; } 
    }

    .placeholder { text-align: center; color: rgba(255,255,255,0.8); position: relative; z-index: 3; padding: 28px; text-shadow: 0 2px 10px rgba(0,0,0,0.8); pointer-events: none; }
    .placeholder .icon { font-size: 42px; margin-bottom: 12px; opacity: 0.85; animation: float 3s ease-in-out infinite; }
    .placeholder .title { font-weight: 700; font-size: 15px; color: #fff; }
    .placeholder .desc { font-size: 12px; opacity: 0.75; margin-top: 6px; line-height: 1.5; }
    @keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

    /* SHRUNKEN OVERLAY PANEL */
    .stream-overlay {
  position: absolute; bottom: 180px; left: 16px; right: 16px; 
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.08); border: 1px solid rgba(255,255,255,0.5);
  z-index: 8; display: none; flex-direction: column; justify-content: flex-end; padding: 12px; pointer-events: auto;
}

    /* SHRUNKEN EXPLANATORY CARDS (WITH QUEUE AND SPRING ANIMATION) */
    .stream-list { 
      max-height: 110px; 
      overflow-y: auto; 
      overflow-x: hidden; 
      -webkit-overflow-scrolling: touch; 
      display: flex; 
      flex-direction: column; 
      gap: 6px; 
      padding-right: 2px;
      
      scrollbar-width: none; 
      -ms-overflow-style: none; 
    }
    
    .stream-list::-webkit-scrollbar {
      display: none; 
    }

    /* STREAM LOADING DOTS */
    .stream-loader {
      display: flex; gap: 5px; align-items: center; justify-content: center; padding: 16px 0;
      animation: fadeUp 0.3s ease;
    }
    .stream-loader .dot {
      width: 7px; height: 7px; background: var(--primary); border-radius: 50%;
      animation: streamBounce 1.4s infinite ease-in-out both;
      box-shadow: 0 2px 6px rgba(217, 74, 39, 0.4);
    }
    .stream-loader .dot:nth-child(1) { animation-delay: -0.32s; }
    .stream-loader .dot:nth-child(2) { animation-delay: -0.16s; }
    
    @keyframes streamBounce {
      0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
      40% { transform: scale(1); opacity: 1; }
    }

    .stream-line {
      display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-radius: 10px;
      background: rgba(255, 255, 255, 0.95); border: 1px solid rgba(0, 0, 0, 0.04); 
      box-shadow: 0 2px 8px rgba(0,0,0,0.03);
      opacity: 0; 
      transform-origin: bottom center; 
      
      animation: popIn 0.55s ease-out forwards; 

      /* GPU acceleration lock using 3D */
      transform: translate3d(0, 0, 0); 
      backface-visibility: hidden;
      -webkit-font-smoothing: antialiased;
      will-change: transform, opacity;
    }

    @keyframes popIn { 
      0% { 
        opacity: 0; 
        transform: translate3d(0, 20px, 0) scale(0.95); 
      } 
      65% {
        opacity: 1;
        transform: translate3d(0, -6px, 0) scale(1.02);
      }
      100% { 
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1) rotate(0.001deg); 
      } 
    }

    @keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

    .stream-dot { width: 6px; height: 6px; margin-top: 5px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 10px rgba(217,74,39,0.35); flex: 0 0 auto; }
    .stream-text { flex: 1; min-width: 0; }
    .stream-key { color: var(--primary); font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; font-size: 9px; display: block; margin-bottom: 2px; }
    .stream-val { color: var(--text); font-size: 11px; word-break: break-word; line-height: 1.3; }

    /* COLLAPSIBLE CONTROLS SECTION */
    .controls {
  position: absolute; bottom: 0; left: 0; width: 100%;
  padding: 20px 22px 40px;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
  z-index: 20; transition: all 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  max-height: 400px; opacity: 1; overflow: hidden; pointer-events: none;
}

    /* Collapse controls when analysis finishes */
    .shell.analyzed .controls {
      max-height: 0; padding-top: 0; padding-bottom: 0; margin: 0; opacity: 0; pointer-events: none;
    }

    .btn-group { display: flex; gap: 10px; margin-bottom: 10px; pointer-events: auto; }
    .btn-group .btn { flex: 1; 
  width: 100%; padding: 18px; border-radius: 16px; border: none; font-weight: 800; font-size: 16px;
  cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); min-height: 48px; position: relative; overflow: hidden; z-index: 1; pointer-events: auto;
}
    .btn:active { transform: scale(0.98); }
    .btn:disabled { opacity: 0.65; cursor: not-allowed; }
    .btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 12px rgba(217, 74, 39, 0.25), inset 0 1px 0 rgba(255,255,255,0.2); }
    .btn-primary:hover { background: var(--primary-dark); box-shadow: 0 6px 16px rgba(217, 74, 39, 0.3), inset 0 1px 0 rgba(255,255,255,0.2); }
    .btn-secondary { background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.3); backdrop-filter: blur(10px); flex: 1; text-shadow: 0 1px 3px rgba(0,0,0,0.5); pointer-events: auto; }
    .btn-secondary:hover { background: rgba(255,255,255,0.25); border-color: rgba(255,255,255,0.4); }
    .btn-ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.3); margin-top: 10px; text-shadow: 0 1px 3px rgba(0,0,0,0.5); pointer-events: auto; }
    .btn-ghost:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.5); }

    .status-wrap { display: none;  margin-top: 15px; height: 20px; overflow: hidden; position: relative; text-align: center; min-height: 20px; }
    .status { font-size: 11px; color: rgba(255,255,255,0.7); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; animation: fadeUp 0.3s ease-out; text-shadow: 0 1px 3px rgba(0,0,0,0.5); pointer-events: auto; }

    /* DRAWER WITH PEEK GESTURE */
    .drawer {
      position: absolute; bottom: 0; left: 0; width: 100%; height: 75%;
      background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
      padding: 18px 22px 22px; border-radius: 32px 32px 0 0;
      transform: translateY(105%); transition: transform 0.75s cubic-bezier(0.22, 1, 0.36, 1);
      z-index: 100; box-shadow: 0 -20px 50px rgba(0,0,0,0.08); border-top: 1px solid rgba(0, 0, 0, 0.08);
      display: flex; flex-direction: column; overflow: hidden;
    }

    .drawer.active { transform: translateY(0); }
    .drawer.peek { transform: translateY(calc(100% - 48px)); cursor: pointer; }

    .drawer-handle-zone {
      width: 100%; padding: 12px 0; margin-top: -10px; cursor: pointer; display: flex; justify-content: center; align-items: center; z-index: 10;
      touch-action: none;
    }
    .drawer-handle { width: 54px; height: 5px; background: var(--border-strong); border-radius: 999px; transition: background 0.3s ease, transform 0.3s ease; }
    
    /* Hover effects unified for both peek and active positions */
    .drawer.peek:hover .drawer-handle,
    .drawer.active .drawer-handle-zone:hover .drawer-handle { background: var(--primary); transform: scaleX(1.2); }

    .drawer-body { overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; padding-bottom: 4px; }
    .res-species { font-size: 13px; font-weight: 800; color: var(--primary); text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 5px; }
    .hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
    .res-value { font-size: 56px; font-weight: 800; margin: 5px 0 8px; letter-spacing: -2px; line-height: 1; color: var(--text); }
    .unit { font-size: 20px; font-weight: 500; color: var(--muted); }
    .summary { color: var(--text); opacity: 0.8; font-size: 14px; line-height: 1.7; margin: 0; }
    .confidence-box { text-align: right; min-width: 100px; flex-shrink: 0; }
    .label { font-size: 10px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 4px; }
    .value { font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.3; }
    .footnote { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 8px; }

    .stat-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
    .stat-item { background: rgba(0,0,0,0.02); padding: 12px; border-radius: 14px; border: 1px solid rgba(0, 0, 0, 0.05); }
    .stat-label { font-size: 10px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
    .stat-num { font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.35; }

    .panel { border: 1px solid rgba(0, 0, 0, 0.06); border-radius: 18px; background: rgba(0,0,0,0.015); padding: 14px; margin-bottom: 12px; }
    .panel-title { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--primary); font-weight: 800; margin-bottom: 10px; }
    .meta-list, .obs-list { display: grid; gap: 8px; font-size: 13px; color: var(--text); line-height: 1.55; }
    .meta-list span, .obs-list span { color: var(--muted); }
    .chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
    .chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid rgba(217, 74, 39, 0.3); background: rgba(217, 74, 39, 0.08); color: var(--primary); font-size: 11px; font-weight: 700; padding: 7px 10px; border-radius: 999px; }
    .error { color: var(--danger); background: rgba(239, 68, 68, 0.05); border: 1px solid rgba(239, 68, 68, 0.2); padding: 12px 14px; border-radius: 14px; font-size: 13px; line-height: 1.55; }

    input[type="file"] { display: none; }
    #analysis-canvas { display: none; }

    /* Print Override */
    @media print { body { overflow: visible; background: white; color: black; } body::before { display: none; } .lang-switcher, .shell, .drawer, .controls, .viewport, header { display: none !important; } }

    /* MOBILE OPTIMIZATIONS */
    @media (max-width: 768px) {
      /* 1. Reduce vertical padding so the container has room to sit nicely on short screens */
      .app-section { padding: 0; }
      
      /* 2. Use dvh (Dynamic Viewport Height) and reduce the max scale from 90dvh down to 82dvh */
      .shell { height: 100%; border-radius: 0; }
      
      .shell header { padding: 22px 22px 18px; }
      .logo { font-size: 20px; }
      
      /* 3. Allow the viewport area to shrink flexibly if needed */
      .viewport { margin: 0; border-radius: 0; }
      
      .controls { padding: 0 16px 24px; }
      .btn { padding: 14px; font-size: 15px; }
      .drawer { height: 85%; padding: 16px 16px 20px; border-radius: 24px 24px 0 0; }
      .hero-top { flex-direction: column; gap: 16px; }
      .confidence-box { text-align: left; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
      .confidence-box .footnote { margin-top: 0; width: 100%; }
      .res-value { font-size: 48px; }
      .stat-row { gap: 8px; margin: 16px 0; }
      .stat-item { padding: 10px; }
    }
    @media (max-width: 380px) { .res-value { font-size: 40px; } .unit { font-size: 16px; } .btn-group { flex-direction: column; } }
