/* ============================================
   Zaylo - Premium Design System v3.0
   Professional-Grade UI Framework
   ============================================ */

/* CSS Custom Properties */
:root {
  /* Colors - Dark Mode (Premium Zinc) - OLED Optimized */
  --bg-primary: #050507;
  --bg-secondary: #0c0c10;
  --bg-tertiary: #161619;
  --bg-elevated: #1c1c22;
  --bg-glass: rgba(18, 18, 28, 0.68);
  --bg-glass-strong: rgba(24, 24, 36, 0.80);
  --bg-glass-hover: rgba(32, 32, 44, 0.88);
  --bg-card-gradient: linear-gradient(145deg, rgba(22, 22, 32, 0.85) 0%, rgba(14, 14, 22, 0.90) 100%);

  /* Borders - 'Light Catch' System */
  --border-glass: rgba(255, 255, 255, 0.07);
  --border-glass-strong: rgba(255, 255, 255, 0.12);
  --border-glass-active: rgba(255, 255, 255, 0.22);
  --border-top-highlight: rgba(255, 255, 255, 0.10);

  /* Premium Accent Colors - Richer Gradients */
  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-dark: #5b21b6;
  --accent-vibrant: #8b5cf6;
  --accent-glow: rgba(124, 58, 237, 0.45);
  --accent-glow-strong: rgba(124, 58, 237, 0.65);
  --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #c084fc 100%);
  --accent-gradient-vibrant: linear-gradient(135deg, #8b5cf6 0%, #c084fc 50%, #e879f9 100%);
  --accent-gradient-subtle: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(168, 85, 247, 0.1));

  /* Secondary Accent — Warm Amber (for highlights & contrast) */
  --accent-warm: #f59e0b;
  --accent-warm-light: #fbbf24;
  --accent-warm-glow: rgba(245, 158, 11, 0.35);
  --accent-warm-gradient: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);

  /* Status Colors - Enhanced */
  --success: #10b981;
  --success-light: #34d399;
  --success-glow: rgba(16, 185, 129, 0.4);
  --warning: #f59e0b;
  --warning-light: #fbbf24;
  --warning-glow: rgba(245, 158, 11, 0.4);
  --danger: #ef4444;
  --danger-light: #f87171;
  --danger-glow: rgba(239, 68, 68, 0.4);
  --info: #3b82f6;
  --info-glow: rgba(59, 130, 246, 0.4);

  /* Text Colors - Refined Hierarchy */
  --text-primary: #f0f0f5;
  --text-secondary: rgba(240, 240, 245, 0.62);
  --text-tertiary: rgba(240, 240, 245, 0.38);
  --text-muted: rgba(240, 240, 245, 0.22);

  /* Premium Animation Curves */
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --spring-bouncy: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --smooth-out: cubic-bezier(0, 0, 0.2, 1);
  --smooth-in: cubic-bezier(0.4, 0, 1, 1);
  --snap: cubic-bezier(0.68, -0.6, 0.32, 1.6);
  --bounce: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --elastic: cubic-bezier(0.68, -0.3, 0.32, 1.35);
  --smooth-overshoot: cubic-bezier(0.22, 1.2, 0.36, 1);
  --premium-ease: cubic-bezier(0.19, 1, 0.22, 1);
  --apple-ease: cubic-bezier(0.25, 0.1, 0.25, 1);

  /* Duration Scale */
  --duration-instant: 100ms;
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
  --duration-slower: 700ms;
  --duration-slowest: 1000ms;

  /* Spacing Scale */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;
  --spacing-3xl: 64px;

  /* Border Radius */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-2xl: 32px;
  --radius-full: 9999px;

  /* Premium Shadows - Layered */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35), 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.45), 0 4px 8px rgba(0, 0, 0, 0.25);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.5), 0 8px 16px rgba(0, 0, 0, 0.3);
  --shadow-2xl: 0 24px 64px rgba(0, 0, 0, 0.55), 0 12px 24px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 40px var(--accent-glow);
  --shadow-glow-strong: 0 0 60px var(--accent-glow-strong), 0 0 100px var(--accent-glow);
  --shadow-glow-success: 0 0 30px var(--success-glow), 0 0 60px var(--success-glow);
  --shadow-colored: 0 8px 32px rgba(124, 58, 237, 0.15), 0 4px 8px rgba(0, 0, 0, 0.2);

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-2xs: 10px;
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-md: 15px;
  --font-size-lg: 18px;
  --font-size-xl: 24px;
  --font-size-2xl: 32px;
  --font-size-3xl: 48px;
  --font-size-4xl: 64px;

  /* Line Heights */
  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.7;
}

/* Light Mode - Premium Edition */
[data-theme="light"] {
  --bg-primary: #f5f5fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eef0f6;
  --bg-elevated: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.72);
  --bg-glass-strong: rgba(255, 255, 255, 0.88);
  --bg-glass-hover: rgba(255, 255, 255, 0.95);
  --bg-card-gradient: linear-gradient(145deg, rgba(255, 255, 255, 0.92) 0%, rgba(248, 248, 255, 0.95) 100%);
  --border-glass: rgba(0, 0, 0, 0.06);
  --border-glass-strong: rgba(0, 0, 0, 0.10);
  --border-glass-active: rgba(0, 0, 0, 0.15);

  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-dark: #5b21b6;
  --accent-vibrant: #8b5cf6;
  --accent-glow: rgba(124, 58, 237, 0.2);
  --accent-glow-strong: rgba(124, 58, 237, 0.35);

  --success: #059669;
  --success-light: #10b981;
  --success-glow: rgba(5, 150, 105, 0.2);
  --warning: #d97706;
  --warning-light: #f59e0b;
  --warning-glow: rgba(217, 119, 6, 0.2);
  --danger: #dc2626;
  --danger-light: #ef4444;
  --danger-glow: rgba(220, 38, 38, 0.2);

  --text-primary: #0f172a;
  --text-secondary: rgba(15, 23, 42, 0.68);
  --text-tertiary: rgba(15, 23, 42, 0.45);
  --text-muted: rgba(15, 23, 42, 0.30);

  --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.07), 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.10), 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-2xl: 0 24px 64px rgba(0, 0, 0, 0.12), 0 12px 32px rgba(0, 0, 0, 0.07);
  --shadow-colored: 0 8px 32px rgba(124, 58, 237, 0.08), 0 4px 8px rgba(0, 0, 0, 0.04);
}

/* Light mode specific element overrides */
[data-theme="light"] .brand-icon img {
  filter: invert(1);
}

/* OLED True Black Mode - Pure #000 for OLED pixel-off battery savings */
[data-theme="oled"] {
  --bg-primary: #000000;
  --bg-secondary: #000000;
  --bg-tertiary: #0a0a0a;
  --bg-elevated: #111111;
  --bg-glass: rgba(8, 8, 8, 0.75);
  --bg-glass-strong: rgba(14, 14, 14, 0.85);
  --bg-glass-hover: rgba(22, 22, 22, 0.90);

  --border-glass: rgba(255, 255, 255, 0.06);
  --border-glass-strong: rgba(255, 255, 255, 0.10);
  --border-glass-active: rgba(255, 255, 255, 0.20);
  --border-top-highlight: rgba(255, 255, 255, 0.08);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.55), 0 2px 4px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.65), 0 4px 8px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.7), 0 8px 16px rgba(0, 0, 0, 0.45);
}

/* ============================================
   Keyframe Animations
   ============================================ */

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(100%);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(100%);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

@keyframes glow {

  0%,
  100% {
    box-shadow: 0 0 20px var(--accent-glow);
  }

  50% {
    box-shadow: 0 0 40px var(--accent-glow), 0 0 60px var(--accent-glow);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-5px);
  }

  20%,
  40%,
  60%,
  80% {
    transform: translateX(5px);
  }
}

@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 0.5;
  }

  100% {
    transform: scale(4);
    opacity: 0;
  }
}

@keyframes gradientMove {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }

  50% {
    transform: scale(1.05);
  }

  70% {
    transform: scale(0.9);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Premium Animations - Professional Grade */

@keyframes elasticBounce {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  40% {
    transform: scale(1.15);
    opacity: 1;
  }

  60% {
    transform: scale(0.95);
  }

  80% {
    transform: scale(1.03);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes magneticHover {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-4px) scale(1.02);
  }
}

@keyframes subtlePulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.85;
    transform: scale(0.98);
  }
}

@keyframes premiumGlow {

  0%,
  100% {
    box-shadow:
      0 0 15px var(--accent-glow-strong),
      0 0 30px var(--accent-glow),
      inset 0 0 10px rgba(255, 255, 255, 0.1);
    filter: brightness(1);
    border-color: var(--accent);
  }

  50% {
    box-shadow:
      0 0 20px var(--accent-glow-strong),
      0 0 45px var(--accent-glow),
      inset 0 0 15px rgba(255, 255, 255, 0.2);
    filter: brightness(1.15);
    border-color: var(--accent-light);
  }
}

@keyframes premiumGlowStrong {

  0%,
  100% {
    box-shadow:
      0 0 25px var(--accent-glow-strong),
      0 0 50px var(--accent-glow);
  }

  50% {
    box-shadow:
      0 0 35px var(--accent-glow-strong),
      0 0 70px var(--accent-glow);
  }
}

@keyframes shimmerLoading {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

@keyframes smoothReveal {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
    filter: blur(10px);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes slideInFromBottom {
  0% {
    opacity: 0;
    transform: translateY(100%);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideOutToBottom {
  0% {
    opacity: 1;
    transform: translateY(0);
  }

  100% {
    opacity: 0;
    transform: translateY(100%);
  }
}

@keyframes breathe {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.02);
    opacity: 0.9;
  }
}

@keyframes successPulse {
  0% {
    box-shadow: 0 0 0 0 var(--success-glow);
  }

  50% {
    box-shadow: 0 0 0 15px transparent;
  }

  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

@keyframes borderGlow {

  0%,
  100% {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
  }

  50% {
    border-color: var(--accent-light);
    box-shadow: 0 0 25px var(--accent-glow-strong);
  }
}

@keyframes gentleFloat {

  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  25% {
    transform: translateY(-8px) rotate(1deg);
  }

  75% {
    transform: translateY(-4px) rotate(-1deg);
  }
}

@keyframes rippleExpand {
  0% {
    transform: scale(0);
    opacity: 0.6;
  }

  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

@keyframes iconPop {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.25);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes countdownTick {
  0% {
    transform: scale(1);
  }

  25% {
    transform: scale(1.08);
  }

  50% {
    transform: scale(0.95);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes staggeredFadeIn {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardLift {
  0% {
    transform: translateY(0) scale(1);
    box-shadow: var(--shadow-md);
  }

  100% {
    transform: translateY(-8px) scale(1.01);
    box-shadow: var(--shadow-xl);
  }
}

@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

@keyframes borderRotate {
  0% {
    --border-angle: 0deg;
  }

  100% {
    --border-angle: 360deg;
  }
}

/* ============================================
   Drag & Drop - Premium Interactions
   ============================================ */

/* The card being dragged (Ghost) */
.drag-ghost {
  position: fixed !important;
  z-index: 9999 !important;
  pointer-events: none !important;
  transform-origin: center center !important;
  will-change: top, left, transform !important;
  background: var(--bg-glass-strong) !important;
  backdrop-filter: blur(24px) !important;
  -webkit-backdrop-filter: blur(24px) !important;
  border-radius: clamp(20px, 4.5vw, 28px) !important;
  /* Pop animation — shadow + opacity ramp, NOT transform (JS owns transform) */
  animation: ghostPop 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* The placeholder in the list — styles now in index.html */

/* Animation for the ghost lifting up — shadow/opacity ramp, no transform */
@keyframes ghostPop {
  0% {
    opacity: 0.6;
    box-shadow:
      0 2px 8px rgba(0, 0, 0, 0.1),
      0 0 0 0 transparent;
  }

  40% {
    opacity: 0.85;
    box-shadow:
      0 10px 24px rgba(0, 0, 0, 0.25),
      0 4px 12px rgba(0, 0, 0, 0.12),
      0 0 0 1px var(--accent);
  }

  100% {
    opacity: 0.98;
    box-shadow:
      0 24px 48px rgba(0, 0, 0, 0.4),
      0 12px 24px rgba(0, 0, 0, 0.18),
      0 0 0 2px var(--accent),
      0 0 40px rgba(124, 58, 237, 0.12);
  }
}

/* Animation for dropping back down - Handled by JS transition but kept for reference */
@keyframes ghostDrop {
  0% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

/* Class for cards moving out of the way (FLIP) */
.device-card.is-moving {
  transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.1, 1) !important;
  z-index: 10;
}

/* When a card is long-pressed but not yet dragged */
.device-card.hold-active {
  transform: scale(0.96);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
  transition: all 0.2s ease-out;
}

/* ============================================
   Base Styles
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Allow text selection in inputs and textareas */
input,
textarea {
  -webkit-user-select: auto;
  -moz-user-select: auto;
  -ms-user-select: auto;
  user-select: auto;
}

/* Global Accessible Focus Ring - Premium */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
  /* Adaptive radius would be better but simple default is safe */
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  height: 100%;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  overflow: hidden;
  overscroll-behavior: none;
}

@media (max-width: 768px) {
  html {
    scrollbar-width: none;
  }
}

/* Hide scrollbar for Chrome, Safari and Opera */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}



/* Hide scrollbar for IE, Edge and Firefox */
.no-scrollbar {
  -ms-overflow-style: none;
  /* IE and Edge */
  scrollbar-width: none;
  /* Firefox */
}


body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  overflow: hidden;
  overscroll-behavior: none;
  transition: background-color 0.3s ease,
    color 0.3s ease;
}

/* Typography overrides for premium headers and displays */
h1, h2, h3, h4, h5, h6, 
.device-title, .section-title, .mode-label, .btn, .btn-primary, .btn-secondary,
.power-label, .sleep-hours, .score-value, .analytics-value, .timer-countdown,
.card-title, .stat-value, .tab-item, .nav-item, .badge, .title, .logo, .brand,
.device-status, .control-label, .percentage-display, .metric-label, .metric-value,
.automation-item-title, .routine-name, .time-picker-value {
  font-family: var(--font-display) !important;
}

/* Subtle noise texture overlay for premium depth */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px 200px;
  mix-blend-mode: overlay;
}

[data-theme="light"] body::before {
  opacity: 0.025;
  mix-blend-mode: multiply;
}

/* Premium Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.16);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.15);
}

/* ============================================
   Glass Card Component - Premium Edition v3
   ============================================ */

.glass-card {
  background: var(--bg-card-gradient);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);

  /* 3D Lighting Effect - Top Border Highlight */
  border: 1px solid var(--border-glass);
  border-top: 1px solid var(--border-top-highlight);
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);

  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md), 0 0 0 0.5px rgba(255, 255, 255, 0.04) inset;
  position: relative;
  overflow: hidden;
  transition:
    transform var(--duration-normal) var(--smooth-overshoot),
    box-shadow var(--duration-normal) var(--smooth),
    border-color var(--duration-normal) var(--smooth);
}

/* Subtle inner glow effect */
.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 5%, rgba(255, 255, 255, 0.12) 30%, rgba(255, 255, 255, 0.18) 50%, rgba(255, 255, 255, 0.12) 70%, transparent 95%);
  opacity: 0.9;
}

/* Shimmer effect on hover */
.glass-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
      transparent,
      rgba(255, 255, 255, 0.02),
      rgba(255, 255, 255, 0.05),
      rgba(255, 255, 255, 0.02),
      transparent);
  transition: left 0.7s var(--smooth);
  pointer-events: none;
}

.glass-card:hover::after {
  left: 100%;
}

.glass-card:hover {
  box-shadow: var(--shadow-xl),
    inset 0 0 0 1px var(--border-glass-strong),
    0 0 40px rgba(124, 58, 237, 0.08);
  transform: translateY(-2px);
  border-color: var(--border-glass-strong);
}

.glass-card.interactive {
  cursor: pointer;
}

.glass-card.interactive:hover {
  transform: translateY(-4px) scale(1.005);
}

.glass-card.interactive:active {
  transform: scale(0.98) translateY(0);
  transition-duration: var(--duration-fast);
}

/* Elevated variant for modals/overlays */
.glass-card.elevated {
  background: var(--bg-glass-strong);
  box-shadow: var(--shadow-xl);
}

/* Light mode glass card overrides */
[data-theme="light"] .glass-card {
  border-bottom-color: rgba(0, 0, 0, 0.04);
  border-top-color: rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .glass-card::before {
  background: linear-gradient(90deg, transparent 5%, rgba(255, 255, 255, 0.8) 30%, rgba(255, 255, 255, 0.95) 50%, rgba(255, 255, 255, 0.8) 70%, transparent 95%);
  opacity: 0.5;
}

[data-theme="light"] .glass-card::after {
  background: linear-gradient(90deg,
      transparent,
      rgba(0, 0, 0, 0.01),
      rgba(0, 0, 0, 0.02),
      rgba(0, 0, 0, 0.01),
      transparent);
}

/* ============================================
   Button Components - Premium Edition
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-lg);
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  font-weight: 600;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition:
    transform var(--duration-normal) var(--smooth-overshoot),
    box-shadow var(--duration-normal) var(--smooth),
    background var(--duration-fast) var(--smooth);
}

/* Subtle highlight on top edge */
.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.1), transparent);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--smooth);
}

.btn:hover::before {
  opacity: 1;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--accent-gradient);
  background-size: 200% 200%;
  color: white;
  box-shadow:
    var(--shadow-md),
    0 0 20px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  animation: gradientShift 6s ease-in-out infinite;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.02);
  box-shadow:
    var(--shadow-lg),
    0 0 40px var(--accent-glow),
    0 0 60px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  filter: brightness(1.05);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.97) translateY(0);
  transition-duration: var(--duration-fast);
  box-shadow:
    var(--shadow-sm),
    0 0 15px var(--accent-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  filter: brightness(0.95);
}

.btn-secondary {
  background: var(--bg-glass-strong);
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-glass-hover);
  border-color: var(--border-glass-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary:active:not(:disabled) {
  transform: scale(0.98);
  background: var(--bg-tertiary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-glass);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.btn-ghost:active:not(:disabled) {
  transform: scale(0.98);
  background: var(--bg-glass-strong);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, var(--danger-light) 100%);
  background-size: 200% 200%;
  color: white;
  box-shadow: var(--shadow-md), 0 0 25px var(--danger-glow);
}

.btn-danger:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg), 0 0 40px var(--danger-glow);
}

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, var(--success-light) 100%);
  color: white;
  box-shadow: var(--shadow-md), 0 0 25px var(--success-glow);
}

.btn-success:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg), 0 0 40px var(--success-glow);
}

.btn-icon {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: var(--radius-full);
}

.btn-lg {
  padding: var(--spacing-lg) var(--spacing-xl);
  font-size: var(--font-size-lg);
  border-radius: var(--radius-xl);
}

.btn-sm {
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: var(--font-size-sm);
  border-radius: var(--radius-md);
}

.btn-xs {
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: var(--font-size-xs);
  border-radius: var(--radius-sm);
}

/* Premium Ripple Effect */
.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.1) 100%);
  animation: rippleExpand 0.6s var(--smooth-out);
  pointer-events: none;
  z-index: 1;
}

/* Premium Loading State with Shimmer */
.btn.loading {
  color: transparent;
  pointer-events: none;
  position: relative;
}

.btn.loading>* {
  opacity: 0;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(255, 255, 255, 0.25);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Shimmer loading effect for buttons */
.btn.loading.shimmer::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.15) 50%,
      transparent 100%);
  background-size: 200% 100%;
  animation: shimmerLoading 1.5s infinite;
}


/* ============================================
   Input Components
   ============================================ */

.input-group {
  position: relative;
  margin-bottom: var(--spacing-lg);
}

.input-group label {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--spacing-sm);
  font-weight: 500;
}

.input {
  width: 100%;
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  color: var(--text-primary);
  transition: all var(--duration-normal) var(--smooth);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input::placeholder {
  color: var(--text-tertiary);
}

.input-icon {
  position: relative;
}

.input-icon .input {
  padding-left: 48px;
}

.input-icon .icon {
  position: absolute;
  left: var(--spacing-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 20px;
}

.input-icon .icon-right {
  left: auto;
  right: var(--spacing-md);
  cursor: pointer;
  transition: color var(--duration-fast) var(--smooth);
}

.input-icon .icon-right:hover {
  color: var(--text-primary);
}

/* ============================================
   Power Button Component
   ============================================ */

.device-page .power-btn {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: none;
  background: var(--bg-glass-strong);
  color: var(--text-secondary);
  font-size: 0;
  line-height: 0;
  cursor: pointer;
  position: relative;
  transition: all var(--duration-normal) var(--spring);
  box-shadow: var(--shadow-lg),
    inset 0 2px 4px rgba(255, 255, 255, 0.1),
    inset 0 -2px 4px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.power-btn::before {
  content: '';
  position: absolute;
  top: -4px;
  right: -4px;
  bottom: -4px;
  left: -4px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--border-glass);
  transition: all var(--duration-normal) var(--smooth);
}

.power-btn:hover {
  background: var(--bg-glass-hover);
}

.power-btn:active {
  opacity: 0.8;
}

.power-btn.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: var(--shadow-lg),
    0 0 25px var(--accent-glow),
    0 0 50px var(--accent-glow);
  animation: premiumGlow 3s ease-in-out infinite;
}

.power-btn.active::before {
  border-color: var(--accent-light);
}

/* Power button SVG icon styles - Centered Properly */
.power-btn svg,
.main-power-btn svg {
  display: block;
  stroke: currentColor;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
}

/* ============================================
   Mode Buttons
   ============================================ */

.mode-buttons {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-xs);
  background: var(--bg-glass);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-glass);
}

.mode-btn {
  flex: 1;
  padding: var(--spacing-sm) var(--spacing-md);
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-normal) var(--spring);
  position: relative;
  z-index: 2;
}

.mode-btn:hover {
  color: var(--text-primary);
  background: var(--bg-glass-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm), 0 0 10px rgba(124, 58, 237, 0.1);
}

.mode-btn:active {
  opacity: 0.8;
  transition: opacity 0.1s;
}

.mode-btn.active {
  background: var(--accent-gradient-vibrant);
  color: white;
  box-shadow: var(--shadow-sm), 0 0 25px var(--accent-glow-strong);
  border-color: transparent;
}

/* ============================================
   Toggle Switch
   ============================================ */

.toggle {
  position: relative;
  width: 52px;
  height: 32px;
  cursor: pointer;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  transition: background var(--duration-normal) var(--smooth);
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 28px;
  height: 28px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform 0.4s var(--spring-bouncy), background-color 0.3s var(--smooth);
}

.toggle:hover .toggle-thumb {
  transform: scale(1.05);
  box-shadow: var(--shadow-md), 0 0 10px rgba(255, 255, 255, 0.2);
}

.toggle input:checked+.toggle-track {
  background: var(--accent);
}

.toggle input:checked+.toggle-track .toggle-thumb {
  transform: translateX(20px);
}

/* ============================================
   Mini Toggle (Card Action)
   ============================================ */
.toggle-mini {
  position: relative;
  width: 42px;
  height: 26px;
  cursor: pointer;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  transition: background var(--duration-normal) var(--smooth);
}

.toggle-mini .thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-normal) var(--spring);
}

.toggle-mini.active {
  background: var(--accent);
}

.toggle-mini.active .thumb {
  transform: translateX(16px);
}

/* ============================================
   Quick Info Row (Alarm)
   ============================================ */
.quick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-sm) var(--spacing-md);
  margin-top: var(--spacing-xs);
  background: var(--bg-glass-hover);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-glass);
}

.quick-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.quick-icon {
  font-size: 16px;
}

.quick-text {
  display: flex;
  flex-direction: column;
}

.quick-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
  font-weight: 700;
}

.quick-value {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ============================================
   Settings Row
   ============================================ */

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md) 0;
  border-bottom: 1px solid var(--border-glass);
  cursor: pointer;
  transition: background var(--duration-fast) var(--smooth);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-row:hover {
  background: var(--bg-glass);
  border-radius: var(--radius-md);
}

/* Settings List Container */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.settings-card {
  width: 100%;
  padding: var(--spacing-md);
  margin-top: var(--spacing-sm);
}

.settings-row-left {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.settings-row-label {
  font-size: var(--font-size-md);
  color: var(--text-primary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.settings-row-label svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.danger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.danger-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sunrise-time svg,
.sunset-time svg {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
}

.settings-row-sublabel {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.settings-row-value {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  color: var(--text-secondary);
  font-size: var(--font-size-md);
}

.settings-row-value .icon {
  font-size: 20px;
  color: var(--text-tertiary);
}

/* ============================================
   Tab Navigation
   ============================================ */

.tabs {
  display: flex;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs);
  background: var(--bg-glass);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-glass);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Mask image for horizontal scroll fade effect */
  mask-image: linear-gradient(to right,
      transparent,
      black 20px,
      black calc(100% - 20px),
      transparent);
  -webkit-mask-image: linear-gradient(to right,
      transparent,
      black 20px,
      black calc(100% - 20px),
      transparent);
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 1;
  min-width: max-content;
  padding: var(--spacing-sm) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s var(--spring);
  white-space: nowrap;
  position: relative;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-glass);
}

.tab:active {
  opacity: 0.8;
}

.tab.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: var(--shadow-sm), 0 0 20px var(--accent-glow);
}

/* ============================================
   Modal / Popup Component - Premium Glow-Up
   ============================================ */

.modal-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0, 0, 0, 0);
  -webkit-backdrop-filter: blur(0px) saturate(100%);
  backdrop-filter: blur(0px) saturate(100%);
  opacity: 0;
  visibility: hidden;
  /* Flexbox ensures .modal is always pinned to the bottom of the viewport */
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  /* Use a snappy ease-out for the fade-in */
  transition:
    opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.4s,
    background-color 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    -webkit-backdrop-filter 0.5s ease-out,
    backdrop-filter 0.5s ease-out;
  z-index: 1000;
}

@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .modal-backdrop {
    background: rgba(0, 0, 0, 0);
  }
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
  background: rgba(0, 0, 0, 0.65);
  -webkit-backdrop-filter: blur(32px) saturate(200%);
  backdrop-filter: blur(32px) saturate(200%);
}

.modal {
  position: relative;
  width: 100%;
  background: linear-gradient(180deg, rgba(20, 20, 25, 0.95) 0%, rgba(10, 10, 15, 0.98) 100%);
  border-radius: 32px 32px 0 0;
  padding: var(--spacing-xl) var(--spacing-lg);
  padding-bottom: calc(var(--spacing-xl) + env(safe-area-inset-bottom));
  transform: translateY(100%);
  /* A bouncy spring-like ease-out for a premium feel */
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1001;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow:
    0 -20px 60px rgba(0, 0, 0, 0.6),
    0 -1px 0 rgba(255, 255, 255, 0.1) inset;
}

[data-theme="oled"] .modal {
  background: #000000;
}

/* Light Mode Modal — must override dark gradient backgrounds */
[data-theme="light"] .modal {
  background: linear-gradient(180deg, #ffffff 0%, #f8f8fc 100%);
  box-shadow:
    0 -20px 60px rgba(0, 0, 0, 0.15),
    0 -1px 0 rgba(0, 0, 0, 0.05) inset;
}

[data-theme="light"] .modal::before {
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.06), transparent);
}

[data-theme="light"] .modal-title {
  background: linear-gradient(135deg, #0f172a 0%, rgba(15, 23, 42, 0.8) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="light"] .modal-handle {
  background-color: rgba(0, 0, 0, 0.12);
  background-clip: content-box;
  box-shadow: none;
}

[data-theme="light"] .modal-close {
  border-color: rgba(0, 0, 0, 0.08);
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .modal-close:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.12);
  color: var(--text-primary);
}

[data-theme="light"] .modal-backdrop.active {
  background: rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .modal-actions .btn-secondary {
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
}

[data-theme="light"] .modal-actions .btn-secondary:hover {
  background: rgba(0, 0, 0, 0.07);
  border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .modal-actions::before {
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.06), transparent);
}

[data-theme="light"] .modal-input,
[data-theme="light"] .modal-select {
  background-color: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .modal-input:focus,
[data-theme="light"] .modal-select:focus {
  background-color: rgba(0, 0, 0, 0.02);
  border-color: var(--accent);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04), 0 0 0 3px var(--accent-glow);
}

/* Inner Glow Border */
.modal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  border-radius: 32px 32px 0 0;
  pointer-events: none;
  opacity: 0.8;
}

/* Accent Glow Aura */
.modal::after {
  content: '';
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 40px;
  background: radial-gradient(ellipse at center, var(--accent-glow-strong), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
  z-index: -1;
}

.modal-backdrop.active .modal::after {
  opacity: 0.6;
}

/* Modal content fades in and slides up slightly for a staggered effect */
.modal .modal-content {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.4s ease-out 0.2s, transform 0.4s ease-out 0.2s;
}

.modal-backdrop.active .modal {
  transform: translateY(0);
}

.modal-backdrop.active .modal .modal-content {
  opacity: 1;
  transform: translateY(0);
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-full);
  margin: 0 auto var(--spacing-lg);
  cursor: grab;
  padding: 8px 16px;
  background-clip: content-box;
  transition: all 0.3s var(--smooth);
  touch-action: none;
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.2);
}

.modal-handle:hover {
  background-color: rgba(255, 255, 255, 0.4);
  transform: translateX(-50%) scale(1.1);
}

.modal-handle:active {
  cursor: grabbing;
  background-color: var(--accent);
  transform: translateX(-50%) scale(0.95);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  margin-bottom: var(--spacing-xl);
  position: relative;
}

.modal-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, rgba(255, 255, 255, 0.7) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(10px);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: white;
  transform: scale(1.1) rotate(90deg);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.modal-close:active {
  transform: scale(0.9) rotate(90deg);
  background: rgba(255, 255, 255, 0.15);
}

.modal-actions {
  display: flex;
  gap: var(--spacing-md);
  margin-top: var(--spacing-2xl);
  position: relative;
}

.modal-actions::before {
  content: '';
  position: absolute;
  top: -24px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
}

.modal-actions .btn {
  flex: 1;
  padding: 16px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Enhancing primary action buttons inside modals to glow more */
.modal-actions .btn-primary {
  background: var(--accent-gradient);
  border: none;
  box-shadow: 0 8px 25px var(--accent-glow-strong), inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.modal-actions .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px var(--accent-glow-strong), inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

.modal-actions .btn-primary:active {
  transform: scale(0.96);
  box-shadow: 0 4px 15px var(--accent-glow-strong);
}

.modal-actions .btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.modal-actions .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Premium Inputs inside Modals */
.modal-input, .modal-select {
  width: 100%;
  padding: 16px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 500;
  transition: all 0.3s var(--smooth);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.modal-input:focus, .modal-select:focus {
  outline: none;
  background-color: rgba(255, 255, 255, 0.06);
  border-color: var(--accent);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2), 0 0 0 3px var(--accent-glow);
}

.modal-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px;
}

.modal-select option {
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* ============================================
   Modal Option Buttons — Reusable Card Buttons
   Used in Add Device flow, type selection, etc.
   ============================================ */

.modal-option-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-option-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-glass);
  border: 2px solid var(--border-glass);
  border-radius: 16px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.modal-option-btn:hover {
  border-color: var(--border-glass-active);
  background: var(--bg-glass-hover);
  transform: translateY(-1px);
}

.modal-option-btn:active {
  transform: scale(0.98);
  transition-duration: 0.1s;
}

.modal-option-btn.accent {
  background: rgba(124, 58, 237, 0.1);
  border-color: var(--accent);
}

.modal-option-btn.accent:hover {
  background: rgba(124, 58, 237, 0.18);
  border-color: var(--accent-light);
  box-shadow: 0 4px 20px var(--accent-glow);
}

.modal-option-btn.teal {
  background: rgba(20, 184, 166, 0.08);
  border-color: rgba(20, 184, 166, 0.4);
}

.modal-option-btn.teal:hover {
  background: rgba(20, 184, 166, 0.15);
  border-color: rgba(20, 184, 166, 0.6);
  box-shadow: 0 4px 20px rgba(20, 184, 166, 0.2);
}

.modal-option-btn .option-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  flex-shrink: 0;
  color: var(--accent);
}

.modal-option-btn.teal .option-icon {
  color: #14b8a6;
}

.modal-option-btn .option-title {
  font-weight: 700;
  font-size: 15px;
}

.modal-option-btn .option-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Light mode option button overrides */
[data-theme="light"] .modal-option-btn {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .modal-option-btn:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .modal-option-btn.accent {
  background: rgba(124, 58, 237, 0.06);
  border-color: var(--accent);
}

[data-theme="light"] .modal-option-btn.teal {
  background: rgba(20, 184, 166, 0.06);
  border-color: rgba(20, 184, 166, 0.35);
}

/* ============================================
   Settings Section Components
   ============================================ */

.settings-section {
  margin-bottom: 24px;
}

.settings-section-title {
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  transition: border-color 0.2s ease;
}

.settings-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 6px;
  line-height: 1.4;
}

.modal-value-display {
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  margin-top: 16px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--blind-accent) 0%, #ffffff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

/* ============================================
   Light Mode Overrides for Modals
   ============================================ */
[data-theme="light"] .modal {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(245, 245, 250, 0.98) 100%);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.15), 0 -1px 0 rgba(0, 0, 0, 0.05) inset;
}

[data-theme="light"] .modal::before {
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.05), transparent);
}

[data-theme="light"] .modal::after {
  background: radial-gradient(ellipse at center, var(--accent-glow-strong), transparent 60%);
  opacity: 0.15;
}

[data-theme="light"] .modal-backdrop.active .modal::after {
  opacity: 0.4;
}

[data-theme="light"] .modal-handle {
  background: rgba(0, 0, 0, 0.15);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.5);
}

[data-theme="light"] .modal-handle:hover {
  background-color: rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .modal-title {
  background: none;
  -webkit-text-fill-color: initial;
  color: var(--text-primary);
}

[data-theme="light"] .modal-close {
  border-color: rgba(0, 0, 0, 0.1);
  background: rgba(0, 0, 0, 0.03);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .modal-close:hover {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
}

[data-theme="light"] .modal-actions::before {
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.08), transparent);
}

[data-theme="light"] .modal-input,
[data-theme="light"] .modal-select {
  background-color: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

[data-theme="light"] .modal-input:focus,
[data-theme="light"] .modal-select:focus {
  background-color: rgba(0, 0, 0, 0.04);
  border-color: var(--accent);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05), 0 0 0 3px var(--accent-glow);
}

[data-theme="light"] .modal-select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(0,0,0,0.5)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}

[data-theme="light"] .modal-value-display {
  background: linear-gradient(135deg, var(--blind-accent) 0%, rgba(0,0,0,0.8) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

/* ============================================
   Network Status Banner — Premium Glassmorphic
   ============================================ */

.network-banner {
  position: fixed;
  top: max(16px, env(safe-area-inset-top, 16px));
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  padding: 10px 22px;
  background: var(--bg-glass-strong);
  border: 1px solid var(--border-glass);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-radius: 28px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9000;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  white-space: nowrap;
}

.network-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.network-banner.dismissing {
  opacity: 0;
  transform: translateX(-50%) translateY(-20px);
  transition: all 0.4s cubic-bezier(0.4, 0, 1, 1);
}

/* Online state — green glow */
.network-banner.online {
  border-color: rgba(16, 185, 129, 0.3);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), var(--bg-glass-strong) 60%);
  box-shadow: var(--shadow-lg), 0 0 24px rgba(16, 185, 129, 0.2);
}

.network-banner.online .network-banner-icon {
  color: var(--success);
}

/* Offline state — red glow */
.network-banner.offline {
  border-color: rgba(239, 68, 68, 0.3);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12), var(--bg-glass-strong) 60%);
  box-shadow: var(--shadow-lg), 0 0 24px rgba(239, 68, 68, 0.15);
}

.network-banner.offline .network-banner-icon {
  color: var(--danger);
}

.network-banner-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  animation: iconPop 0.4s var(--spring) 0.1s both;
}

.network-banner-text {
  font-family: var(--font-family);
  letter-spacing: 0.01em;
}

/* Light mode overrides */
[data-theme="light"] .network-banner.online {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.08), rgba(255, 255, 255, 0.9) 60%);
  border-color: rgba(5, 150, 105, 0.25);
}

[data-theme="light"] .network-banner.offline {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.08), rgba(255, 255, 255, 0.9) 60%);
  border-color: rgba(220, 38, 38, 0.25);
}

/* ============================================
   iOS-Style Picker
   ============================================ */

.picker {
  height: 200px;
  overflow: hidden;
  position: relative;
}

.picker::before,
.picker::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 80px;
  pointer-events: none;
  z-index: 1;
}

.picker::before {
  top: 0;
  background: linear-gradient(to bottom, var(--bg-secondary), transparent);
}

.picker::after {
  bottom: 0;
  background: linear-gradient(to top, var(--bg-secondary), transparent);
}

.picker-highlight {
  position: absolute;
  top: 50%;
  left: var(--spacing-md);
  right: var(--spacing-md);
  height: 44px;
  transform: translateY(-50%);
  background: var(--bg-glass);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  pointer-events: none;
}

.picker-scroll {
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
}

.picker-scroll::-webkit-scrollbar {
  display: none;
}

.picker-item {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-secondary);
  scroll-snap-align: center;
  transition: all var(--duration-fast) var(--smooth);
}

.picker-item.selected {
  color: var(--text-primary);
  font-size: var(--font-size-xl);
}

.picker-spacer {
  height: 78px;
}

/* ============================================
   Toast Notifications - Enhanced
   ============================================ */

.toast-container {
  position: fixed;
  top: var(--spacing-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  pointer-events: none;
  width: calc(100% - var(--spacing-lg) * 2);
  max-width: 400px;
}

.toast {
  background: var(--bg-glass-strong);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md) var(--spacing-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.15s var(--smooth), box-shadow 0.15s var(--smooth), opacity 0.3s ease;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-12px) scale(0.96);
}

.toast.toast-enter {
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.25s ease-out;
}

.toast:hover {
  transform: scale(1.01);
  box-shadow: var(--shadow-xl);
}

.toast:active {
  transform: scale(0.98);
}

/* Toast progress bar */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 100%;
  background: currentColor;
  opacity: 0.3;
  transform-origin: left;
}

@keyframes toastProgress {
  from {
    transform: scaleX(1);
  }

  to {
    transform: scaleX(0);
  }
}

/* Toast exit animation */
.toast.toast-exit {
  opacity: 0;
  transform: translateY(-16px) scale(0.92);
  transition: transform 0.3s cubic-bezier(0.4, 0, 1, 1),
              opacity 0.25s ease-in;
  pointer-events: none;
}

.toast.success {
  border-color: var(--success);
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.12), var(--bg-glass-strong));
  box-shadow: var(--shadow-lg), 0 0 20px var(--success-glow);
}

.toast.error {
  border-color: var(--danger);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12), var(--bg-glass-strong));
  box-shadow: var(--shadow-lg), 0 0 20px var(--danger-glow);
}

.toast.warning {
  border-color: var(--warning);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), var(--bg-glass-strong));
  box-shadow: var(--shadow-lg), 0 0 15px var(--warning-glow);
}

.toast.info {
  border-color: var(--info);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), var(--bg-glass-strong));
  box-shadow: var(--shadow-lg), 0 0 15px var(--info-glow);
}

.toast-icon {
  font-size: 20px;
  animation: iconPop 0.4s var(--spring) 0.1s both;
}

.toast.success .toast-icon {
  color: var(--success);
}

.toast.error .toast-icon {
  color: var(--danger);
}

.toast.warning .toast-icon {
  color: var(--warning);
}

.toast.info .toast-icon {
  color: var(--info);
}

.toast-message {
  flex: 1;
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.toast-dismiss {
  animation: fadeIn var(--duration-slow) var(--smooth) 2s both;
}

/* ============================================
   Timer Display
   ============================================ */

.timer-display {
  text-align: center;
  padding: var(--spacing-xl);
}

.timer-value {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  transition: transform var(--duration-fast) var(--spring);
}

.timer-value.tick {
  animation: bounceIn 0.3s var(--spring);
}

.timer-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: var(--spacing-sm);
}

.timer-progress {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  margin-top: var(--spacing-lg);
  overflow: hidden;
}

.timer-progress-bar {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
  transition: width 1s linear;
  box-shadow: 0 0 10px var(--accent-glow);
}

/* ============================================
   Status Indicators - Premium
   ============================================ */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
  transition: all 0.3s var(--smooth);
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  /* Solid core glow */
  animation: statusPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 6px var(--danger-glow);
}

.status-dot.sleeping {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: sleepBreath 3s ease-in-out infinite;
}

@keyframes statusPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 var(--success-glow);
  }

  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    /* Fade out ring */
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

@keyframes sleepBreath {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.6;
    transform: scale(0.9);
  }
}

/* ============================================
   Header Component
   ============================================ */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glass);
}

.header-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.header-back {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  transition: opacity var(--duration-fast) var(--smooth);
}

.header-back:hover {
  opacity: 0.8;
}

/* ============================================
   Floating Dock - Enhanced
   ============================================ */

.dock {
  position: fixed;
  bottom: var(--spacing-lg);
  bottom: calc(var(--spacing-lg) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
  background: var(--bg-glass-strong);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255, 255, 255, 0.05);
  z-index: 100;
  animation: dockSlideUp 0.5s var(--spring) 0.2s both;
}

@keyframes dockSlideUp {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }

  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.dock-item {
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
  transition: all var(--duration-normal) var(--spring);
  position: relative;
}

.dock-item:hover {
  color: var(--text-primary);
  background: var(--bg-glass);
  transform: translateY(-2px);
}

.dock-item:active {
  opacity: 0.7;
}

.dock-item.active {
  color: var(--accent);
  background: var(--accent-gradient-subtle);
}

.dock-item.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ============================================
   Device Card
   ============================================ */

.device-card {
  padding: var(--spacing-lg);
  /* Animation removed - handled by .card-enter */
}

/* Only animate entry when explicitly requested (e.g. first load) */
.device-card.card-enter {
  animation: fadeInUp var(--duration-slow) var(--spring) both;
}

.device-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-lg);
}

.device-card-status {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.device-card-name {
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.device-card-settings {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--bg-glass);
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--smooth);
}

.device-card-settings:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.device-card-power {
  display: flex;
  justify-content: center;
  margin-bottom: var(--spacing-lg);
}

.device-card-modes {
  margin-bottom: var(--spacing-lg);
}

.device-card-alarm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  background: var(--bg-glass);
  border-radius: var(--radius-lg);
}

.device-card-alarm-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

/* ============================================
   Progress Ring
   ============================================ */

.progress-ring {
  position: relative;
  width: 160px;
  height: 160px;
}

.progress-ring svg {
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 12;
}

.progress-ring-fill {
  fill: none;
  stroke: url(#accent-gradient);
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s var(--smooth);
}

.progress-ring-content {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.progress-ring-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
}

.progress-ring-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* ============================================
   Empty State
   ============================================ */

.empty-state {
  text-align: center;
  padding: var(--spacing-2xl);
  animation: fadeIn var(--duration-slow) var(--smooth);
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: var(--spacing-lg);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
}

.empty-state-text {
  color: var(--text-secondary);
  font-size: var(--font-size-md);
  margin-bottom: var(--spacing-xl);
}

/* ============================================
   Utility Classes
   ============================================ */

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--spacing-lg);
  padding-bottom: calc(100px + env(safe-area-inset-bottom));
}

.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.mt-sm {
  margin-top: var(--spacing-sm);
}

.mt-md {
  margin-top: var(--spacing-md);
}

.mt-lg {
  margin-top: var(--spacing-lg);
}

.mt-xl {
  margin-top: var(--spacing-xl);
}

.mb-sm {
  margin-bottom: var(--spacing-sm);
}

.mb-md {
  margin-bottom: var(--spacing-md);
}

.mb-lg {
  margin-bottom: var(--spacing-lg);
}

.mb-xl {
  margin-bottom: var(--spacing-xl);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-sm {
  gap: var(--spacing-sm);
}

.gap-md {
  gap: var(--spacing-md);
}

.gap-lg {
  gap: var(--spacing-lg);
}

.hidden {
  display: none !important;
}

.visible {
  visibility: visible !important;
}

.invisible {
  visibility: hidden !important;
}

/* ============================================
   Animated Background (Auth Page)
   ============================================ */

.animated-bg {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(-45deg, #1a1a2e, #16213e, #0f3460, #1a1a2e);
  background-size: 400% 400%;
  animation: gradientMove 15s ease infinite;
  z-index: -1;
}

.animated-bg::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: radial-gradient(circle at 30% 50%, var(--accent-glow, rgba(124, 58, 237, 0.45)), transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(139, 92, 246, 0.2), transparent 50%);
  pointer-events: none;
}

/* Floating particles */
.particles {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  animation: float 6s ease-in-out infinite;
}

/* ============================================
   Logo Component
   ============================================ */

.logo {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--spacing-lg);
  animation: float 3s ease-in-out infinite;
}

.logo svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 20px var(--accent-glow));
}

/* ============================================
   Gradient Text
   ============================================ */

.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================
   WiFi Signal Bars
   ============================================ */

.wifi-signal {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
}

.wifi-bar {
  width: 4px;
  background: var(--text-tertiary);
  border-radius: 1px;
  transition: background var(--duration-fast) var(--smooth);
}

.wifi-bar:nth-child(1) {
  height: 25%;
}

.wifi-bar:nth-child(2) {
  height: 50%;
}

.wifi-bar:nth-child(3) {
  height: 75%;
}

.wifi-bar:nth-child(4) {
  height: 100%;
}

.wifi-signal.excellent .wifi-bar {
  background: var(--success);
}

.wifi-signal.good .wifi-bar:nth-child(-n+3) {
  background: var(--success);
}

.wifi-signal.fair .wifi-bar:nth-child(-n+2) {
  background: var(--warning);
}

.wifi-signal.poor .wifi-bar:nth-child(1) {
  background: var(--danger);
}

/* ============================================
   Servo Visualization
   ============================================ */

.servo-viz {
  width: 200px;
  height: 200px;
  margin: var(--spacing-xl) auto;
  position: relative;
}

.servo-base {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 40px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.servo-arm {
  position: absolute;
  bottom: 50px;
  left: 50%;
  width: 8px;
  height: 100px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(var(--angle, 0deg));
  transition: transform var(--duration-normal) var(--spring);
  box-shadow: 0 0 20px var(--accent-glow);
}

.servo-arm::after {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

/* ============================================
   Sleep Graph
   ============================================ */

.sleep-graph {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 200px;
  padding: var(--spacing-md);
  gap: var(--spacing-sm);
}

.sleep-bar-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  height: 100%;
}

.sleep-bar-wrapper {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
}

.sleep-bar {
  width: 100%;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  min-height: 4px;
  transition: height 0.5s var(--spring);
  box-shadow: 0 0 10px var(--accent-glow);
}

.sleep-bar-label {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 375px) {
  :root {
    --font-size-3xl: 40px;
    --font-size-2xl: 28px;
  }

  .power-btn {
    width: 100px;
    height: 100px;
    font-size: 40px;
  }

  .container {
    padding: var(--spacing-md);
  }
}

/* Safe area for notched devices */
@supports (padding: env(safe-area-inset-top)) {
  .header {
    padding-top: calc(var(--spacing-md) + env(safe-area-inset-top));
  }
}

/* Skeleton Loader */
.skeleton {
  pointer-events: none;
}

.skeleton * {
  animation: skeletonPulse 1.5s ease-in-out infinite;
}

@keyframes skeletonPulse {
  0% {
    opacity: 0.6;
  }

  50% {
    opacity: 0.3;
  }

  100% {
    opacity: 0.6;
  }
}

/* Initial Loader Overlay */
#initialLoader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-lg);
  transition: opacity 0.5s var(--smooth);
}

.loader-logo {
  width: 64px;
  height: 64px;
  color: var(--accent);
  animation: loaderPulse 2s ease-in-out infinite;
}

.loader-text {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 1px;
  text-transform: uppercase;
  animation: fadeIn 1s ease-out;
}

@keyframes loaderPulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
    filter: drop-shadow(0 0 20px var(--accent-glow));
  }

  50% {
    transform: scale(1.1);
    opacity: 0.7;
    filter: drop-shadow(0 0 40px var(--accent-glow));
  }
}

/* ============================================
   Device Page & Tab Content Fixes
   ============================================ */

.device-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: var(--app-height, 100dvh);
  background: var(--bg-primary);
  overflow: hidden;
  /* Prevent body scroll, use inner scroll */
}

/* Fix mobile viewport height issues */
@supports (-webkit-touch-callout: none) {
  .device-page {
    min-height: -webkit-fill-available;
  }
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 120px;
  /* Space for floating dock */
  -webkit-overflow-scrolling: touch;
  /* Smooth iOS scrolling */
  scroll-behavior: smooth;
  position: relative;
  /* Ensure stacking context */
}

/* Ensure settings cards don't get cut off */
.settings-group {
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}

/* Ensure settings values are visible */
.settings-value {
  color: var(--text-primary);
  font-weight: 500;
}

/* Fix floating dock z-index to be above content */
.floating-dock {
  z-index: 1000;
}

/* Make sure modal is above everything */
.modal-backdrop {
  z-index: 9999;
}

/* ============================================
   Setup Page - Mobile First
   ============================================ */

.setup-page {
  min-height: 100vh;
  min-height: 100dvh;
  min-height: var(--app-height, 100dvh);
  /* Dynamic viewport height for mobile */
  display: flex;
  flex-direction: column;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(100px, calc(80px + env(safe-area-inset-bottom)));
  /* Space for sticky nav */
  background: var(--bg-primary);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Header */
.setup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-weight: 600;
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 8px 0;
  font-family: var(--font-family);
}

.theme-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--bg-glass-strong);
  border: 1px solid var(--border-glass);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
}

/* Progress - Premium Edition */
.progress-section {
  text-align: center;
  margin-bottom: 28px;
  flex-shrink: 0;
}

.progress-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  position: relative;
}

/* Connecting line between dots */
.progress-connector {
  width: 30px;
  height: 2px;
  background: var(--bg-tertiary);
  border-radius: 1px;
  transition: background 0.4s ease;
}

.progress-connector.active {
  background: var(--success);
}

.progress-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  transition:
    all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease;
  position: relative;
  flex-shrink: 0;
}

.progress-dot.active {
  background: var(--accent);
  box-shadow:
    0 0 20px var(--accent-glow),
    0 0 40px var(--accent-glow);
  transform: scale(1.3);
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {

  0%,
  100% {
    box-shadow: 0 0 20px var(--accent-glow), 0 0 40px var(--accent-glow);
  }

  50% {
    box-shadow: 0 0 30px var(--accent-glow), 0 0 60px var(--accent-glow);
  }
}

.progress-dot.completed {
  background: var(--success);
  box-shadow: 0 0 15px var(--success-glow);
}

.progress-dot.completed::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 8px;
  font-weight: 700;
}

.progress-label {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* Steps - Enhanced Transitions */
.steps-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Allow shrinking for scroll */
}

.step {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  /* Allow content to scroll */
  animation: stepSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.step.active {
  display: flex;
}

.step.exiting {
  animation: stepSlideOut 0.3s ease forwards;
}

@keyframes stepSlideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
    filter: blur(8px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
    filter: blur(0);
  }
}

@keyframes stepSlideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }

  to {
    opacity: 0;
    transform: translateX(-20px);
  }
}


.step-header {
  text-align: center;
  margin-bottom: 20px;
}

.step-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.step-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

.step-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  /* Critical for flex child scrolling */
  padding-bottom: 16px;
}

/* Connection Cards */
.connection-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.connection-card {
  background: var(--bg-glass);
  border: 2px solid var(--border-glass);
  border-radius: 16px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 16px;
}

.connection-card:active {
  transform: scale(0.98);
}

.connection-card.selected {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.connection-icon {
  font-size: 32px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-glass-strong);
  border-radius: 14px;
  flex-shrink: 0;
}

.connection-info {
  flex: 1;
}

.connection-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.connection-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ============================================
    SERVO CALIBRATION - NEW DESIGN
    ============================================ */
.servo-calibration {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}

/* Servo Dial Visualization */
.servo-dial-container {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  /* ADDED GAP HERE */
}

.servo-dial {
  position: relative;
  width: 220px;
  height: 220px;
  /* Removed margin-bottom: 20px; */
}

/* Outer ring with tick marks */
.servo-dial-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 3px solid var(--border-glass-strong);
}

/* Tick marks around the edge */
.servo-dial-ticks {
  position: absolute;
  inset: 0;
}

.servo-dial-tick {
  position: absolute;
  width: 2px;
  height: 12px;
  background: var(--text-tertiary);
  left: 50%;
  top: 6px;
  transform-origin: center 104px;
  border-radius: 1px;
}

.servo-dial-tick.major {
  height: 16px;
  width: 3px;
  background: var(--text-secondary);
  top: 4px;
}

/* Servo body (center circle) */
.servo-body {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 70px;
  height: 70px;
  background: linear-gradient(145deg, #3a3a4a 0%, #1a1a24 100%);
  border-radius: 50%;
  border: 3px solid #4a4a5a;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.4),
    inset 0 2px 4px rgba(255, 255, 255, 0.1);
  z-index: 10;
}

.servo-body::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  background: linear-gradient(145deg, #5a5a6a 0%, #3a3a4a 100%);
  border-radius: 50%;
  border: 2px solid #6a6a7a;
}

/* Two-arm servo horn */
.servo-arm-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(0deg);
  width: 160px;
  height: 20px;
  transform-origin: center center;
  transition: transform 0.15s ease-out;
  z-index: 5;
}

.servo-arm {
  position: absolute;
  top: 50%;
  height: 12px;
  background: linear-gradient(180deg, #e0e0e0 0%, #a0a0a0 50%, #c0c0c0 100%);
  border-radius: 6px;
  transform: translateY(-50%);
  border: 1px solid #888;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.servo-arm.left {
  left: 0;
  width: 65px;
  border-radius: 6px 3px 3px 6px;
}

.servo-arm.right {
  right: 0;
  width: 65px;
  border-radius: 3px 6px 6px 3px;
}

/* Arm tips */
.servo-arm::before {
  content: '';
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  background: #666;
  border-radius: 50%;
  transform: translateY(-50%);
  border: 1px solid #555;
}

.servo-arm.left::before {
  left: 4px;
}

.servo-arm.right::before {
  right: 4px;
}

/* Screw holes on arms */
.servo-arm::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 4px;
  height: 4px;
  background: #444;
  border-radius: 50%;
  transform: translateY(-50%);
}

.servo-arm.left::after {
  left: 20px;
}

.servo-arm.right::after {
  right: 20px;
}

/* Angle display badge */
.servo-angle-badge {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-gradient);
  color: white;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 4px 15px var(--accent-glow);
  z-index: 15;
}

/* Position markers */
.servo-dial-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.servo-dial-marker {
  position: absolute;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-tertiary);
}

.servo-dial-marker.m0 {
  top: 50%;
  left: -20px;
  transform: translateY(-50%);
}

.servo-dial-marker.m90 {
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
}

.servo-dial-marker.m180 {
  top: 50%;
  right: -28px;
  transform: translateY(-50%);
}

/* Center button */
.center-btn {
  width: 100%;
  padding: 12px;
  background: var(--bg-glass);
  border: 2px solid var(--border-glass);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.center-btn:active {
  transform: scale(0.98);
}

.center-btn:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

/* Position Buttons */
.position-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
}

.position-btn {
  flex: 1;
  padding: 14px;
  border-radius: 14px;
  border: 2px solid var(--border-glass);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.position-btn:active {
  transform: scale(0.96);
}

.position-btn.active {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent);
}

.position-btn .value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
}

.position-btn.off-btn.active {
  border-color: var(--danger);
  color: var(--danger);
}

.position-btn.off-btn.active .value {
  color: var(--danger);
}

.position-btn.on-btn.active {
  border-color: var(--success);
  color: var(--success);
}

.position-btn.on-btn.active .value {
  color: var(--success);
}

/* Slider Control */
.slider-section {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 20px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.slider-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.slider-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
}

.angle-slider {
  width: 100%;
  height: 48px;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(to right, var(--danger), #f59e0b, var(--success));
  border-radius: 24px;
  outline: none;
  padding: 0 4px;
}

.angle-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 44px;
  background: white;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s ease;
}

.angle-slider::-webkit-slider-thumb:active {
  transform: scale(1.1);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Slider with precision buttons container */
.slider-with-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slider-with-buttons .angle-slider {
  flex: 1;
}

.precision-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--bg-glass-strong);
  border: 2px solid var(--border-glass);
  color: var(--text-primary);
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.precision-btn:hover {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.precision-btn:active {
  transform: scale(0.9);
  background: var(--accent);
  color: white;
}

/* Test Button */
.test-servo-btn {
  width: 100%;
  padding: 16px;
  background: var(--accent-gradient);
  border: none;
  border-radius: 14px;
  color: white;
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px var(--accent-glow);
  margin-top: 8px;
}

.test-servo-btn:active {
  transform: scale(0.98);
}

.test-servo-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Position Save Buttons */
.save-positions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Device Info Card */
.device-info-card {
  padding: var(--spacing-lg);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--spacing-md);
  width: 100%;
}

@media (max-width: 600px) {
  .info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--spacing-sm);
  }
}

.info-item {
  text-align: center;
  padding: var(--spacing-md);
  background: var(--bg-glass);
  border-radius: var(--radius-lg);
  min-width: 0;
  /* Critical for grid child truncation/wrapping */
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (max-width: 360px) {
  .info-item {
    padding: 10px 4px;
  }
}

.info-value {
  font-size: var(--font-size-md);
  /* Slightly smaller base size to fit more */
  font-weight: 700;
  margin-bottom: 2px;
  word-wrap: break-word;
  word-break: break-word;
  /* Ensure long values wrap */
  line-height: 1.2;
}

.info-label {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.save-btn {
  padding: 14px;
  border-radius: 14px;
  border: none;
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.save-btn:active {
  transform: scale(0.96);
}

.save-btn.off {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 2px solid var(--danger);
}

.save-btn.on {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
  border: 2px solid var(--success);
}

.save-btn .icon {
  font-size: 20px;
}

.save-btn .angle {
  font-size: 12px;
  opacity: 0.8;
}

/* WiFi Section */
.wifi-section {
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}

.scan-btn {
  width: 100%;
  padding: 14px;
  margin-bottom: 16px;
  background: var(--bg-glass-strong);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.scan-btn:active {
  transform: scale(0.98);
}

.wifi-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wifi-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-glass);
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.wifi-item:active {
  transform: scale(0.98);
}

.wifi-item.selected {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
}

.wifi-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wifi-signal {
  font-size: 18px;
}

.wifi-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 15px;
}

.wifi-lock {
  font-size: 14px;
  opacity: 0.6;
}

.password-input {
  margin-top: 16px;
  display: none;
}

.password-input.show {
  display: block;
  animation: fadeIn 0.3s ease;
}

.password-input label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.password-input input {
  width: 100%;
  padding: 14px;
  background: var(--bg-glass);
  border: 2px solid var(--border-glass);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 16px;
  font-family: var(--font-family);
}

.password-input input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Success Section */
.success-section {
  text-align: center;
  padding: 32px 16px;
}

.success-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.success-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.success-message {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.device-info-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  padding: 16px;
  max-width: 280px;
  margin: 0 auto 24px;
  text-align: left;
}

.device-info-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-glass);
  font-size: 14px;
}

.device-info-row:last-child {
  border-bottom: none;
}

.device-info-label {
  color: var(--text-secondary);
}

.device-info-value {
  font-weight: 600;
  color: var(--text-primary);
}

/* Navigation - Fixed at bottom with slide-in */
.step-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 12px;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg-primary) 0%, var(--bg-primary) 80%, rgba(10, 10, 15, 0.95) 100%);
  border-top: 1px solid var(--border-glass);
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  /* Prevent layout shift with smooth entrance */
  animation: navSlideIn 0.4s ease-out both;
}

@keyframes navSlideIn {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.nav-btn {
  flex: 1;
  padding: 16px;
  border-radius: 14px;
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.nav-btn.secondary {
  background: var(--bg-glass-strong);
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
}

.nav-btn.primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.nav-btn:active {
  transform: scale(0.98);
}

.nav-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.nav-btn.loading {
  position: relative;
  color: transparent;
}

.nav-btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

a.nav-btn {
  text-decoration: none;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Arm Attachment Modal */
.arm-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.arm-modal-backdrop.visible {
  opacity: 1;
  visibility: visible;
}

.arm-modal {
  background: var(--bg-secondary);
  border-radius: 24px;
  padding: 32px 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.arm-modal-backdrop.visible .arm-modal {
  transform: scale(1) translateY(0);
}

.arm-modal-icon {
  font-size: 56px;
  margin-bottom: 16px;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }
}

.arm-modal-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.arm-modal-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.arm-modal-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--success);
  font-weight: 600;
  padding: 10px 16px;
  background: rgba(34, 197, 94, 0.1);
  border-radius: 10px;
  margin-bottom: 24px;
}

.arm-modal-btn {
  width: 100%;
  padding: 16px;
  background: var(--accent-gradient);
  border: none;
  border-radius: 14px;
  color: white;
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px var(--accent-glow);
  transition: all 0.2s ease;
}

.arm-modal-btn:active {
  transform: scale(0.98);
}

/* ============================================
   Status & Loading States - Premium
   ============================================ */

/* Offline State - Grayscale & Dimmed */
.device-card.offline {
  filter: grayscale(100%) opacity(0.7);
  transition: filter 0.3s ease, opacity 0.3s ease;
}

.device-card.offline:hover {
  filter: grayscale(100%) opacity(0.8);
}

/* Skeleton Loading Animation */
.skeleton {
  background: linear-gradient(90deg,
      var(--bg-glass-strong) 25%,
      rgba(255, 255, 255, 0.08) 50%,
      var(--bg-glass-strong) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* Loading Spinner */
.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   Premium Ripple Effect
   ============================================ */
.ripple-container {
  position: relative;
  overflow: hidden;
  transform: translate3d(0, 0, 0);
}

.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.1) 60%, transparent 100%);
  transform: scale(0);
  animation: rippleExpand 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  pointer-events: none;
  z-index: 100;
  will-change: transform, opacity;
}

@keyframes rippleExpand {
  0% {
    transform: scale(0);
    opacity: 0.5;
  }

  100% {
    transform: scale(8);
    /* Increased scale for full coverage */
    opacity: 0;
  }
}

/* ============================================
   Page Transitions
   ============================================ */
.page-transition-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity;
}

.page-transition-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* Smooth Fade In on Load */
body {
  animation: pageFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes pageFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Micro-Interaction Refinements
   ============================================ */

/* Enhanced Active State for Buttons */
.device-card:active,
.header-btn:active,
.mode-btn:active,
.power-btn:active,
.blind-quick-btn:active,
.preset-btn:active {
  transform: scale(0.96) !important;
  /* Force a consistent "press" depth */
  transition: transform 0.1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Power Button Burst Effect */
.power-btn.active {
  animation: powerGlow 3s ease-in-out infinite, powerBurst 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes powerBurst {
  0% {
    transform: scale(0.9);
  }

  50% {
    transform: scale(1.15);
  }

  100% {
    transform: scale(1);
  }
}

/* ============================================
   Mobile Optimizations & Precision Touch
   ============================================ */

/* Remove 300ms delay on touch devices */
a,
button,
input,
textarea,
select,
.btn,
.device-card,
.header-btn,
.mode-btn,
.power-btn,
.blind-quick-btn,
.preset-btn,
.dock-btn {
  touch-action: manipulation;
}

/* Prevent text selection on interactive elements */
.device-card,
.btn,
.header-btn,
.mode-btn {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  /* Disable iOS magnifying glass */
}

/* Status Dot Breathing Animation */
.status-dot.connecting {
  background-color: var(--warning);
  box-shadow: 0 0 10px var(--warning-glow);
  animation: breatheDot 2s ease-in-out infinite;
}

@keyframes breatheDot {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.6;
    transform: scale(0.85);
  }
}

/* Scrollbar refinement for mobile */
@media (max-width: 768px) {
  ::-webkit-scrollbar {
    width: 0px;
    background: transparent;
  }
}

/* ============================================
   WiFi Scanner - Premium UI
   ============================================ */

.wifi-changer-popup {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.wifi-network-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  max-height: 240px;
  overflow-y: auto;
  padding-right: var(--spacing-xs);
  margin-top: var(--spacing-md);
}

/* Custom Scrollbar for WiFi List */
.wifi-network-list::-webkit-scrollbar {
  width: 4px;
}

.wifi-network-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.wifi-network-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.wifi-network-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s var(--premium-ease);
  position: relative;
  overflow: hidden;
}

.wifi-network-item:hover {
  background: var(--bg-glass-strong);
  border-color: var(--accent-glow);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.wifi-network-item:active {
  transform: scale(0.98);
}

.wifi-network-item.current {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(5, 150, 105, 0.08));
  border-color: rgba(16, 185, 129, 0.3);
}

.wifi-network-left {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  flex: 1;
  min-width: 0;
  /* Text truncation fix */
}

.wifi-network-icon {
  font-size: 1.25em;
  opacity: 0.8;
}

.wifi-network-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.wifi-ssid {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wifi-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
}

/* Signal Strength Visualizer */
.wifi-signal-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
  width: 18px;
}

.wifi-bar {
  flex: 1;
  background: var(--text-muted);
  border-radius: 1px;
  transition: all 0.3s ease;
}

.wifi-bar:nth-child(1) {
  height: 25%;
}

.wifi-bar:nth-child(2) {
  height: 50%;
}

.wifi-bar:nth-child(3) {
  height: 75%;
}

.wifi-bar:nth-child(4) {
  height: 100%;
}

.wifi-bar.active {
  background: currentColor;
}

/* Staggered Animation for List Items */
.wifi-network-item {
  animation: slideInRight 0.3s var(--smooth-out) backwards;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Security Lock Icon */
.wifi-lock {
  font-size: 0.8em;
  opacity: 0.6;
}

/* Scan Spinner */
.scan-spinner-container {
  padding: var(--spacing-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-secondary);
  gap: var(--spacing-md);
}

/* ============================================
   Blind specific utilities
   ============================================ */

.stepper-calibration {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}

.stepper-visual-container {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  box-shadow: inset 0 2px 20px rgba(0, 0, 0, 0.2);
}

.stepper-icon {
  font-size: 64px;
  animation: float 4s ease-in-out infinite;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
}

.stepper-status-badge {
  background: var(--accent-gradient-subtle);
  color: var(--accent-light);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid rgba(168, 85, 247, 0.2);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}html.fast-load #appLoader { display: none !important; }

/* ============================================
   Performance: Disable GPU-heavy blur effects
   on devices that prefer reduced motion or
   have low-resolution displays (budget phones).
   Prevents frame drops from stacking blurs.
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .device-card,
  .modal,
  .modal-backdrop,
  .floating-dock,
  .context-menu,
  .glass-card,
  .toast,
  .drag-ghost {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

/* ============================================
   Zaylo Premium Glow-Up Additions
   ============================================ */

/* Presence & Telemetry Cards Glow-Up */
.presence-card {
    margin-bottom: var(--spacing-md);
    background: var(--bg-card-gradient);
    border: 1px solid var(--border-glass);
    border-top: 1px solid var(--border-top-highlight);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    backdrop-filter: blur(28px) saturate(190%);
    -webkit-backdrop-filter: blur(28px) saturate(190%);
    transition: transform 0.4s var(--spring), box-shadow 0.4s var(--spring);
}

.presence-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), 0 0 20px rgba(124, 58, 237, 0.1);
    border-color: var(--border-glass-strong);
}

.presence-row {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: var(--spacing-md);
}

.presence-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex: 1;
    justify-content: center;
}

.presence-icon {
    font-size: var(--font-size-xl);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.presence-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.presence-lbl {
    font-size: var(--font-size-2xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.presence-val {
    font-size: var(--font-size-md);
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-display);
    transition: color 0.3s var(--smooth);
}

.presence-val.active {
    color: var(--success-light);
    text-shadow: var(--shadow-glow-success);
}

.presence-divider {
    width: 1px;
    height: 36px;
    background: linear-gradient(to bottom, transparent, var(--border-glass-strong), transparent);
}

/* Stats Card */
.stats-card {
    margin-bottom: var(--spacing-md);
    background: var(--bg-card-gradient);
    border: 1px solid var(--border-glass);
    border-top: 1px solid var(--border-top-highlight);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    backdrop-filter: blur(28px) saturate(190%);
    -webkit-backdrop-filter: blur(28px) saturate(190%);
    transition: transform 0.4s var(--spring), box-shadow 0.4s var(--spring);
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), 0 0 25px rgba(124, 58, 237, 0.15);
    border-color: var(--border-glass-strong);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: var(--spacing-sm) var(--spacing-xs);
    gap: 6px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) 2px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.3s var(--smooth), border-color 0.3s var(--smooth);
}

.stat-box:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}

.stat-icon-wrapper {
    font-size: var(--font-size-md);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: rgba(124, 58, 237, 0.1);
    color: var(--accent-light);
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.05);
}

.stat-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    width: 100%;
}

.stat-lbl {
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: visible;
}

.stat-num {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-display);
    white-space: nowrap;
    overflow: visible;
}

/* Responsive Overrides to Eliminate Any Cutout/Clipping on Mobile Screens */
@media (max-width: 480px) {
    .tab-content {
        padding-left: var(--spacing-sm) !important;
        padding-right: var(--spacing-sm) !important;
    }
}

@media (max-width: 360px) {
    .stats-grid {
        gap: 4px;
        padding: var(--spacing-xs) 2px;
    }
    .stat-box {
        padding: var(--spacing-xs) 1px;
    }
    .stat-icon-wrapper {
        width: 24px;
        height: 24px;
        font-size: var(--font-size-sm);
    }
    .stat-lbl {
        font-size: 8px;
        letter-spacing: 0.01em;
    }
    .stat-num {
        font-size: 11px;
    }
}

/* Calibration & Motor Warning Card */
.warning-card {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(245, 158, 11, 0.06) 100%);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-top: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.08);
    backdrop-filter: blur(28px) saturate(190%);
    -webkit-backdrop-filter: blur(28px) saturate(190%);
    animation: warningPulse 3s infinite ease-in-out;
}

.warning-icon-wrapper {
    font-size: var(--font-size-xl);
    line-height: 1;
    filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.5));
}

.warning-content {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    align-items: flex-start;
    text-align: left;
}

.warning-title {
    font-size: var(--font-size-md);
    font-weight: 700;
    color: var(--warning-light);
    font-family: var(--font-display);
    letter-spacing: 0.02em;
}

.warning-desc {
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
    color: var(--text-secondary);
}

@keyframes warningPulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(245, 158, 11, 0.08), inset 0 0 0 rgba(245, 158, 11, 0);
        border-color: rgba(245, 158, 11, 0.25);
    }
    50% {
        box-shadow: 0 4px 30px rgba(245, 158, 11, 0.18), inset 0 0 15px rgba(245, 158, 11, 0.05);
        border-color: rgba(245, 158, 11, 0.45);
    }
}
