/* =====================================================================
   styles.css — DrowsyGuard · Premium AI Monitoring Interface
   Inspired by Apple Vision Pro, Linear, Stripe, Awwwards winners.
   ===================================================================== */

/* ── Design tokens ───────────────────────────────────────────────────── */
:root {
  --bg:          #030711;
  --bg2:         rgba(8, 15, 30, 0.65);
  --bg3:         rgba(12, 21, 40, 0.55);
  --bg-card:     rgba(10, 18, 35, 0.55);
  --border:      rgba(0, 212, 255, 0.08);
  --border-b:    rgba(0, 212, 255, 0.30);
  --border-hover:rgba(0, 212, 255, 0.25);
  --cyan:        #00d4ff;
  --cyan-dim:    rgba(0, 212, 255, 0.15);
  --green:       #39ff14;
  --green-dim:   rgba(57, 255, 20, 0.15);
  --alert:       #ff2055;
  --alert-dim:   rgba(255, 32, 85, 0.12);
  --warn:        #ffd700;
  --warn-dim:    rgba(255, 215, 0, 0.12);
  --txt:         #c8ddff;
  --txt-dim:     rgba(160, 200, 255, 0.4);
  --txt-bright:  #e8f0ff;

  --glow-c:      0 0 20px rgba(0, 212, 255, 0.4), 0 0 60px rgba(0, 212, 255, 0.1);
  --glow-g:      0 0 20px rgba(57, 255, 20, 0.4), 0 0 60px rgba(57, 255, 20, 0.1);
  --glow-a:      0 0 30px rgba(255, 32, 85, 0.5), 0 0 80px rgba(255, 32, 85, 0.15);

  --radius-sm:   8px;
  --radius-md:   14px;
  --radius-lg:   20px;

  --font-display: 'Rajdhani', 'Inter', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;

  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ── Reset ───────────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--cyan);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 0 0 8px 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  z-index: 9999;
  transition: top 0.3s;
}
.skip-link:focus {
  top: 0;
}

/* ── Base ────────────────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--txt);
  font-family: var(--font-display);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ── Animated Background System ──────────────────────────────────────── */

/* Layer 1: Animated mesh gradient (aurora effect) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 40%, rgba(0, 212, 255, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 20%, rgba(57, 255, 20, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse 70% 60% at 50% 80%, rgba(100, 80, 255, 0.04) 0%, transparent 50%);
  animation: aurora 20s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

/* Layer 2: Subtle dot-grid with perspective */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(0, 212, 255, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, black, transparent);
  pointer-events: none;
  z-index: 0;
}

/* Particle canvas (behind everything) */
#particleCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.7;
}

/* ── Scrollbar ───────────────────────────────────────────────────────── */
::-webkit-scrollbar        { width: 4px; }
::-webkit-scrollbar-track  { background: rgba(0,0,0,0.2); }
::-webkit-scrollbar-thumb  {
  background: linear-gradient(180deg, var(--cyan-dim), var(--cyan));
  border-radius: 4px;
}

/* ── Keyframe Library ────────────────────────────────────────────────── */

@keyframes aurora {
  0%   { transform: scale(1) rotate(0deg); }
  50%  { transform: scale(1.1) rotate(2deg); }
  100% { transform: scale(1) rotate(-1deg); }
}

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

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

@keyframes scanLine {
  0%   { top: 0%;   opacity: 0; }
  4%   {            opacity: 0.6; }
  96%  {            opacity: 0.6; }
  100% { top: 100%; opacity: 0; }
}

@keyframes alertFlash {
  0%   { background: rgba(255, 32, 85, 0.03); }
  100% { background: rgba(255, 32, 85, 0.18); }
}

@keyframes popIn {
  from { transform: scale(0.7) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0);      opacity: 1; }
}

@keyframes shakeCam {
  0%, 100% { transform: translateX(0);   }
  25%      { transform: translateX(-5px); }
  75%      { transform: translateX(5px);  }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 15px rgba(0, 212, 255, 0.15), inset 0 0 15px rgba(0, 212, 255, 0.03); }
  50%      { box-shadow: 0 0 30px rgba(0, 212, 255, 0.25), inset 0 0 30px rgba(0, 212, 255, 0.05); }
}

@keyframes borderGlow {
  0%, 100% { border-color: rgba(0, 212, 255, 0.08); }
  50%      { border-color: rgba(0, 212, 255, 0.2); }
}

@keyframes dataFlow {
  0%   { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

@keyframes orbit {
  from { transform: rotate(0deg) translateX(14px) rotate(0deg); }
  to   { transform: rotate(360deg) translateX(14px) rotate(-360deg); }
}

@keyframes breathe {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%      { opacity: 0.8; transform: scale(1.05); }
}

@keyframes typewriter {
  from { width: 0; }
  to   { width: 100%; }
}

@keyframes cursorBlink {
  0%, 100% { border-color: var(--cyan); }
  50%      { border-color: transparent; }
}

@keyframes waveform {
  0%   { transform: scaleY(0.3); }
  50%  { transform: scaleY(1);   }
  100% { transform: scaleY(0.3); }
}

@keyframes ripple {
  0%   { transform: scale(0); opacity: 0.5; }
  100% { transform: scale(4); opacity: 0;   }
}

@keyframes warningStripe {
  0%   { background-position: 0 0; }
  100% { background-position: 40px 0; }
}

@keyframes glitch {
  0%   { clip-path: inset(20% 0 60% 0); transform: translateX(-3px); }
  20%  { clip-path: inset(50% 0 10% 0); transform: translateX(3px); }
  40%  { clip-path: inset(10% 0 70% 0); transform: translateX(-2px); }
  60%  { clip-path: inset(80% 0 5% 0);  transform: translateX(4px); }
  80%  { clip-path: inset(30% 0 40% 0); transform: translateX(-1px); }
  100% { clip-path: inset(0 0 0 0);     transform: translateX(0); }
}

@keyframes floatOrbit {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  33%      { transform: translateY(-6px) rotate(1deg); }
  66%      { transform: translateY(3px) rotate(-1deg); }
}

@keyframes gradientBorder {
  0%   { --angle: 0deg; }
  100% { --angle: 360deg; }
}

/* ── NAV ─────────────────────────────────────────────────────────────── */
nav {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         0.75rem 1.4rem;
  border-bottom:   1px solid var(--border);
  background:      rgba(3, 7, 17, 0.85);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  position:        sticky;
  top: 0;
  z-index: 200;
  animation: fadeIn 0.8s var(--ease-out) both;
}

/* Subtle shimmer on nav border */
nav::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--cyan-dim) 20%,
    var(--cyan) 50%,
    var(--cyan-dim) 80%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 6s linear infinite;
  opacity: 0.5;
}

.logo {
  display:        flex;
  align-items:    center;
  gap:            12px;
  font-size:      1.3rem;
  font-weight:    700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.logo-ring {
  width:  38px;
  height: 38px;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  display:     flex;
  align-items: center;
  justify-content: center;
  box-shadow:  var(--glow-c);
  position:    relative;
  flex-shrink: 0;
  animation: glowPulse 3s ease-in-out infinite;
}

/* Inner spinning ring */
.logo-ring::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1.5px solid rgba(0, 212, 255, 0.2);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 3s linear infinite;
}

/* Outer orbit dot */
.logo-ring::before {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--cyan);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--cyan);
  animation: orbit 4s linear infinite;
}

.logo em {
  color: var(--cyan);
  font-style: normal;
  text-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.logo-version {
  font-family:   var(--font-mono);
  font-size:     0.55rem;
  color:         var(--txt-dim);
  letter-spacing: 0.12em;
  margin-top:    2px;
}

.nav-r {
  display:         flex;
  align-items:     center;
  gap:             0.7rem;
  flex-wrap:       wrap;
  justify-content: flex-end;
}

.badge {
  display:       flex;
  align-items:   center;
  gap:           7px;
  font-family:   var(--font-mono);
  font-size:     0.62rem;
  padding:       5px 12px;
  border:        1px solid var(--border);
  border-radius: 24px;
  background:    rgba(0, 212, 255, 0.03);
  backdrop-filter: blur(10px);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space:   nowrap;
  transition:    all 0.3s var(--ease-smooth);
}

.badge:hover {
  border-color: var(--border-hover);
  background:   rgba(0, 212, 255, 0.06);
}

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--txt-dim);
  flex-shrink: 0;
  transition: all 0.4s var(--ease-smooth);
}

.dot.live {
  background: var(--green);
  box-shadow: var(--glow-g);
  animation: blink 1.4s ease-in-out infinite;
}
.dot.alarm {
  background: var(--alert);
  box-shadow: var(--glow-a);
  animation: blink 0.4s ease-in-out infinite;
}

/* ── Layout wrapper ──────────────────────────────────────────────────── */
.wrap {
  display:               grid;
  grid-template-columns: 1fr 280px;
  gap:                   1rem;
  padding:               1.2rem;
  max-width:             1200px;
  margin:                0 auto;
  position:              relative;
  z-index:               1;
}

@media (max-width: 820px) {
  .wrap { grid-template-columns: 1fr; padding: 0.75rem; gap: 0.75rem; }
}

/* ── Camera box ──────────────────────────────────────────────────────── */
.cam-box {
  position:      relative;
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow:      hidden;
  background:    #000;
  aspect-ratio:  4 / 3;
  animation: fadeInUp 0.8s var(--ease-out) 0.1s both;
  box-shadow:
    0 0 0 1px rgba(0, 212, 255, 0.05),
    0 4px 30px rgba(0, 0, 0, 0.4),
    0 0 60px rgba(0, 212, 255, 0.03);
}

.cam-box::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: var(--radius-lg);
  padding: 1px;
  background: linear-gradient(135deg,
    rgba(0, 212, 255, 0.2),
    transparent 40%,
    transparent 60%,
    rgba(57, 255, 20, 0.1)
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 5;
}

.cam-box.alarming { animation: shakeCam 0.12s ease-in-out 4; }

video {
  width:        100%;
  height:       100%;
  object-fit:   cover;
  transform:    scaleX(-1);
  display:      block;
}

#ov {
  position:       absolute;
  inset:          0;
  width:          100%;
  height:         100%;
  transform:      scaleX(-1);
  pointer-events: none;
}

/* Corner brackets */
.cr { position: absolute; width: 32px; height: 32px; z-index: 10; }
.cr::before, .cr::after {
  content: '';
  position: absolute;
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.5);
  transition: all 0.3s;
}
.cr::before { width: 2px;  height: 100%; }
.cr::after  { width: 100%; height: 2px;  }

.cr-tl { top: 12px; left: 12px; }
.cr-tl::before, .cr-tl::after { top: 0; left: 0; }

.cr-tr { top: 12px; right: 12px; transform: scaleX(-1); }
.cr-tr::before, .cr-tr::after { top: 0; left: 0; }

.cr-bl { bottom: 12px; left: 12px; transform: scaleY(-1); }
.cr-bl::before, .cr-bl::after { top: 0; left: 0; }

.cr-br { bottom: 12px; right: 12px; transform: scale(-1); }
.cr-br::before, .cr-br::after { top: 0; left: 0; }

/* Animated scan line */
.scan {
  position: absolute;
  inset-inline: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent,
    rgba(0, 212, 255, 0.3),
    var(--cyan),
    rgba(0, 212, 255, 0.3),
    transparent
  );
  box-shadow: 0 0 15px var(--cyan), 0 0 40px rgba(0, 212, 255, 0.2);
  animation: scanLine 3.2s linear infinite;
  z-index: 10;
  opacity: 0;
}

/* HUD bottom bar */
.hud-bar {
  position:        absolute;
  bottom: 12px; left: 12px; right: 12px;
  display:         flex;
  justify-content: space-between;
  align-items:     flex-end;
  z-index:         10;
  pointer-events:  none;
}

.hud-chip {
  font-family:    var(--font-mono);
  font-size:      0.58rem;
  padding:        4px 10px;
  border:         1px solid var(--border-b);
  border-radius:  6px;
  background:     rgba(3, 7, 17, 0.75);
  backdrop-filter: blur(8px);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--cyan);
  transition:     all 0.3s;
}

#stateChip { color: var(--txt-dim); }

/* ── Start overlay — Cinematic Boot Sequence ─────────────────────────── */
.start-ov {
  position:        absolute;
  inset:           0;
  display:         flex;
  flex-direction:  column;
  align-items:     center;
  justify-content: center;
  background:      rgba(3, 7, 17, 0.92);
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  z-index:         30;
  gap:             1.4rem;
  transition:      opacity 0.6s var(--ease-out);
}

/* Hexagonal grid pattern overlay */
.start-ov::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(30deg, rgba(0, 212, 255, 0.02) 12%, transparent 12.5%),
    linear-gradient(150deg, rgba(0, 212, 255, 0.02) 12%, transparent 12.5%),
    linear-gradient(210deg, rgba(0, 212, 255, 0.02) 12%, transparent 12.5%),
    linear-gradient(330deg, rgba(0, 212, 255, 0.02) 12%, transparent 12.5%);
  background-size: 80px 140px;
  animation: fadeIn 1.5s ease both;
  pointer-events: none;
}

.eye-icon {
  width: 86px; height: 86px;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glow-c);
  position: relative;
  animation: breathe 3s ease-in-out infinite, fadeInUp 0.8s var(--ease-out) 0.1s both;
}

/* Scanning dashed ring */
.eye-icon::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1.5px dashed rgba(0, 212, 255, 0.25);
  border-radius: 50%;
  animation: spin 4s linear infinite;
}

/* Counter-rotating outer ring */
.eye-icon::after {
  content: '';
  position: absolute;
  inset: -8px;
  border: 1px solid rgba(0, 212, 255, 0.08);
  border-top-color: rgba(0, 212, 255, 0.3);
  border-radius: 50%;
  animation: spinReverse 6s linear infinite;
}

.so-title {
  font-size:      1.6rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  text-align:     center;
  line-height:    1.3;
  animation: fadeInUp 0.8s var(--ease-out) 0.3s both;
}
.so-title span {
  color: var(--cyan);
  text-shadow: 0 0 25px rgba(0, 212, 255, 0.3);
}

.so-sub {
  font-size:   0.82rem;
  color:       var(--txt-dim);
  text-align:  center;
  max-width:   320px;
  line-height: 1.7;
  animation: fadeInUp 0.8s var(--ease-out) 0.5s both;
}

#loadMsg {
  font-family:   var(--font-mono);
  font-size:     0.62rem;
  color:         var(--cyan);
  letter-spacing: 0.14em;
  display:       none;
  text-transform: uppercase;
  text-shadow:   0 0 10px rgba(0, 212, 255, 0.3);
}

.load-bar-wrap {
  width: 220px;
  height: 3px;
  background: rgba(0, 212, 255, 0.08);
  border-radius: 2px;
  display: none;
  overflow: hidden;
  position: relative;
}

/* Shimmer overlay on load bar */
.load-bar-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
}

#loadBar {
  height:     100%;
  background: linear-gradient(90deg, var(--cyan), #00ff88, var(--cyan));
  background-size: 300% 100%;
  animation: dataFlow 2s linear infinite;
  box-shadow: 0 0 12px var(--cyan);
  width:      0%;
  transition: width 0.3s var(--ease-out);
  position: relative;
  z-index: 1;
}

.btn-activate {
  padding:        13px 42px;
  background:     transparent;
  border:         2px solid var(--cyan);
  color:          var(--cyan);
  font-family:    var(--font-display);
  font-size:      1rem;
  font-weight:    700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  cursor:         pointer;
  border-radius:  8px;
  transition:     all 0.35s var(--ease-smooth);
  box-shadow:     var(--glow-c);
  position:       relative;
  overflow:       hidden;
  animation: fadeInUp 0.8s var(--ease-out) 0.7s both;
}

/* Sweep fill on hover */
.btn-activate::before {
  content:    '';
  position:   absolute;
  inset:      0;
  background: linear-gradient(135deg, var(--cyan), #00ff88);
  transform:  translateX(-100%);
  transition: transform 0.4s var(--ease-out);
}

.btn-activate:hover {
  color: var(--bg);
  box-shadow: 0 0 40px rgba(0, 212, 255, 0.4), 0 0 80px rgba(0, 212, 255, 0.15);
  transform: translateY(-2px);
}
.btn-activate:hover::before { transform: translateX(0); }
.btn-activate:active { transform: translateY(0) scale(0.98); }

.btn-activate span { position: relative; z-index: 1; }

/* ── Stats panel ─────────────────────────────────────────────────────── */
.stats {
  display:        flex;
  flex-direction: column;
  gap:            0.75rem;
}

@media (max-width: 820px) {
  .stats { display: grid; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
}

/* ── Card — Glassmorphism ────────────────────────────────────────────── */
.card {
  border:         1px solid var(--border);
  border-radius:  var(--radius-md);
  padding:        0.95rem;
  background:     var(--bg-card);
  backdrop-filter: blur(16px) saturate(130%);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  position:       relative;
  overflow:       hidden;
  transition:     all 0.4s var(--ease-smooth);
  animation: fadeInUp 0.6s var(--ease-out) both;
}

/* Staggered entrance for each card */
.stats .card:nth-child(1) { animation-delay: 0.15s; }
.stats .card:nth-child(2) { animation-delay: 0.25s; }
.stats .card:nth-child(3) { animation-delay: 0.35s; }
.stats .card:nth-child(4) { animation-delay: 0.45s; }
.stats .card:nth-child(5) { animation-delay: 0.55s; }

/* Top border gradient shine */
.card::before {
  content:  '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height:   1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(0, 212, 255, 0.3) 30%,
    var(--cyan) 50%,
    rgba(0, 212, 255, 0.3) 70%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 4s linear infinite;
  opacity: 0.5;
}

/* Subtle inner glow */
.card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  background: radial-gradient(
    ellipse at 50% 0%,
    rgba(0, 212, 255, 0.03),
    transparent 70%
  );
  pointer-events: none;
}

.card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(0, 212, 255, 0.06);
}

.clabel {
  font-family:    var(--font-mono);
  font-size:      0.57rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color:          var(--txt-dim);
  margin-bottom:  0.5rem;
  position:       relative;
  z-index: 1;
}

.big-val {
  font-family:  var(--font-mono);
  font-size:    2.2rem;
  font-weight:  700;
  color:        var(--cyan);
  line-height:  1;
  text-shadow:  0 0 20px rgba(0, 212, 255, 0.2);
  position:     relative;
  z-index: 1;
  transition:   color 0.3s, text-shadow 0.3s;
}

.unit {
  font-size: 0.68rem;
  color: var(--txt-dim);
  margin-left: 4px;
  position: relative;
  z-index: 1;
}

/* ── Metric bars — Animated gradients ────────────────────────────────── */
.mbar {
  height:        4px;
  background:    rgba(255, 255, 255, 0.04);
  border-radius: 4px;
  overflow:      hidden;
  margin-top:    8px;
  position:      relative;
  z-index: 1;
}

.mfill {
  height:        100%;
  border-radius: 4px;
  background:    linear-gradient(90deg, var(--cyan), #00ff88, var(--cyan));
  background-size: 300% 100%;
  animation:     dataFlow 3s linear infinite;
  transition:    width 0.2s var(--ease-smooth);
  box-shadow:    0 0 8px rgba(0, 212, 255, 0.3);
  position:      relative;
}

.mfill.warn {
  background: linear-gradient(90deg, var(--warn), #ff8c00, var(--warn));
  background-size: 300% 100%;
  animation: dataFlow 3s linear infinite;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

.mfill.danger {
  background: linear-gradient(90deg, var(--alert), #ff6040, var(--alert));
  background-size: 300% 100%;
  animation: dataFlow 2s linear infinite;
  box-shadow: 0 0 12px rgba(255, 32, 85, 0.4);
}

.two-label {
  display:         flex;
  justify-content: space-between;
  margin-top:      5px;
  position: relative;
  z-index: 1;
}

.two-label span {
  font-family:   var(--font-mono);
  font-size:     0.54rem;
  color:         var(--txt-dim);
  letter-spacing: 0.05em;
}

/* ── Stat grid ───────────────────────────────────────────────────────── */
.sgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  position: relative;
  z-index: 1;
}

.sitem {
  border:         1px solid var(--border);
  border-radius:  var(--radius-sm);
  padding:        0.55rem 0.65rem;
  background:     var(--bg3);
  backdrop-filter: blur(8px);
  transition:     all 0.3s var(--ease-smooth);
  position:       relative;
  overflow:       hidden;
}

.sitem:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

/* Corner accent on stat items */
.sitem::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 1px;
  background: var(--cyan);
  opacity: 0.3;
}

.snum {
  font-family:  var(--font-mono);
  font-size:    1.5rem;
  font-weight:  700;
  color:        var(--green);
  line-height:  1;
  transition:   color 0.3s, text-shadow 0.3s;
}

.slabel {
  font-size:      0.58rem;
  color:          var(--txt-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top:     3px;
}

/* ── Sliders — Premium Style ─────────────────────────────────────────── */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  position: relative;
  z-index: 1;
}

.sld-row {
  position: relative;
}

.sld-lbl {
  font-family:    var(--font-mono);
  font-size:      0.56rem;
  color:          var(--txt-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom:  4px;
  display: block;
}

input[type=range] {
  width:              100%;
  -webkit-appearance: none;
  appearance:         none;
  height:             4px;
  background:         linear-gradient(90deg, rgba(0, 212, 255, 0.1), rgba(0, 212, 255, 0.2));
  border-radius:      4px;
  outline:            none;
  transition:         background 0.3s;
  cursor: pointer;
}

input[type=range]:hover {
  background: linear-gradient(90deg, rgba(0, 212, 255, 0.15), rgba(0, 212, 255, 0.3));
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), #00ff88);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.5), 0 0 4px rgba(0, 212, 255, 0.8);
  transition: all 0.2s;
  border: 2px solid rgba(0, 0, 0, 0.3);
}

input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.7), 0 0 6px rgba(0, 212, 255, 1);
}

input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), #00ff88);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.5);
  border: 2px solid rgba(0, 0, 0, 0.3);
}

.sld-val {
  font-family:   var(--font-mono);
  font-size:     0.62rem;
  color:         var(--cyan);
  text-align:    right;
  margin-top:    3px;
  text-shadow:   0 0 8px rgba(0, 212, 255, 0.2);
}

/* ── Log panel — Terminal Style ──────────────────────────────────────── */
.log-wrap {
  grid-column:    1 / -1;
  border:         1px solid var(--border);
  border-radius:  var(--radius-md);
  background:     var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow:       hidden;
  animation: fadeInUp 0.6s var(--ease-out) 0.6s both;
  position: relative;
}

/* CRT scanline overlay on log */
.log-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 2;
}

@media (max-width: 820px) { .log-wrap { grid-column: 1; } }

.log-hdr {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         0.55rem 1rem;
  border-bottom:   1px solid var(--border);
  font-family:     var(--font-mono);
  font-size:       0.62rem;
  text-transform:  uppercase;
  letter-spacing:  0.12em;
  color:           var(--txt-dim);
  position: relative;
  z-index: 3;
}

.log-body {
  height:      100px;
  overflow-y:  auto;
  padding:     0.5rem 0.7rem;
  font-family: var(--font-mono);
  font-size:   0.62rem;
  position: relative;
  z-index: 1;
}

.lg {
  display: flex;
  gap: 10px;
  padding: 3px 6px;
  border-radius: 4px;
  transition: background 0.2s;
  animation: fadeIn 0.3s var(--ease-out) both;
}

.lg:hover {
  background: rgba(0, 212, 255, 0.03);
}

.lg.info  { color: var(--txt-dim); }
.lg.yawn  { color: var(--warn); }
.lg.alert { color: var(--alert); }
.lg.ok    { color: var(--green); }

.lt {
  opacity: 0.45;
  min-width: 48px;
  flex-shrink: 0;
}

/* ── Alert overlay — Cinematic ───────────────────────────────────────── */
#alertOv {
  position:        fixed;
  inset:           0;
  z-index:         999;
  display:         none;
  flex-direction:  column;
  align-items:     center;
  justify-content: center;
  background:      rgba(255, 32, 85, 0.05);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
}

#alertOv.on {
  display:   flex;
  animation: alertFlash 0.5s ease-in-out infinite alternate;
}

/* Red border frame with pulsing glow */
#alertOv.on::before {
  content:  '';
  position: fixed;
  inset:    0;
  border:   3px solid var(--alert);
  pointer-events: none;
  z-index:  1000;
  box-shadow: inset 0 0 60px rgba(255, 32, 85, 0.2),
              0 0 60px rgba(255, 32, 85, 0.1);
  animation: glowPulse 1.5s ease-in-out infinite;
}

/* Animated warning stripes at top */
#alertOv.on::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: repeating-linear-gradient(
    -45deg,
    var(--alert),
    var(--alert) 10px,
    transparent 10px,
    transparent 20px
  );
  background-size: 40px 4px;
  animation: warningStripe 0.5s linear infinite;
  z-index: 1001;
}

.alert-inner {
  text-align: center;
  padding:    2.5rem;
  animation:  popIn 0.3s var(--ease-spring) both;
  position:   relative;
  z-index: 1002;
}

.alert-big {
  font-size:      clamp(3rem, 10vw, 6rem);
  font-weight:    700;
  color:          var(--alert);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  text-shadow:    0 0 40px rgba(255, 32, 85, 0.5),
                  0 0 80px rgba(255, 32, 85, 0.2);
  line-height:    1;
  position:       relative;
}

/* Glitch layer */
.alert-big::before {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  color: var(--alert);
  opacity: 0.5;
  animation: glitch 0.3s linear infinite alternate;
  z-index: -1;
}

.alert-sub {
  font-size:      1.15rem;
  color:          rgba(255, 100, 120, 0.8);
  letter-spacing: 0.14em;
  margin-top:     0.6rem;
  text-transform: uppercase;
  font-weight:    600;
}

.btn-dismiss {
  margin-top:      2rem;
  padding:         12px 36px;
  background:      transparent;
  border:          2px solid var(--alert);
  color:           var(--alert);
  font-family:     var(--font-display);
  font-size:       0.95rem;
  font-weight:     700;
  letter-spacing:  0.2em;
  text-transform:  uppercase;
  cursor:          pointer;
  border-radius:   8px;
  transition:      all 0.3s var(--ease-smooth);
  position:        relative;
  overflow:        hidden;
}

.btn-dismiss::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--alert);
  transform: translateX(-100%);
  transition: transform 0.3s var(--ease-out);
}

.btn-dismiss:hover {
  color: #fff;
  box-shadow: 0 0 30px rgba(255, 32, 85, 0.3);
  transform: translateY(-2px);
}
.btn-dismiss:hover::before { transform: translateX(0); }
.btn-dismiss span { position: relative; z-index: 1; }

/* ── Footer ──────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.2rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--txt-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
  animation: fadeIn 0.8s var(--ease-out) 1s both;
}

.site-footer::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan-dim), transparent);
}

.footer-brand {
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 212, 255, 0.2);
}

.footer-dot {
  display: inline-block;
  width: 3px;
  height: 3px;
  background: var(--cyan);
  border-radius: 50%;
  margin: 0 8px;
  vertical-align: middle;
  box-shadow: 0 0 6px var(--cyan);
}

/* ── Responsive Refinements ──────────────────────────────────────────── */
@media (max-width: 480px) {
  .logo { font-size: 1.1rem; gap: 8px; }
  .logo-ring { width: 32px; height: 32px; }
  .badge { font-size: 0.56rem; padding: 3px 8px; }
  .so-title { font-size: 1.3rem; }
  .big-val { font-size: 1.8rem; }
  .snum { font-size: 1.3rem; }
  .btn-activate { padding: 10px 28px; font-size: 0.9rem; }
  .cam-box { border-radius: var(--radius-md); }
}

/* ── Selection highlight ─────────────────────────────────────────────── */
::selection {
  background: rgba(0, 212, 255, 0.25);
  color: #fff;
}

/* ── Focus visible ───────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
