/**
 * Vēlora · iOS Liquid Glass Design System v3.0
 * Full translucent surfaces, squircle corners, spring animations,
 * iOS-style toggles, segmented controls, and system typography.
 * Dark/Light mode support via prefers-color-scheme + data-theme.
 */

/* ===================================================================
   DESIGN TOKENS — Light & Dark Mode
   =================================================================== */
:root {
  /* Typography — SF Pro / System stack */
  --font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-scale: 100%;

  /* Accent colors */
  --accent-color: #ff3b30;
  --accent-color-2: #ff6243;
  --accent-pill: linear-gradient(135deg, #ff3b30 0%, #ff6243 100%);
  --accent-vertical: linear-gradient(180deg, #ff6243 0%, #ff3b30 100%);
  --accent-glow: 0 4px 24px rgba(255, 59, 48, 0.45);

  /* Global button color (overridable via JS) */
  --btn-global: #ff3b30;
  --b1: #ff3b30;
  --b2: #ff3b30;
  --b3: #ff3b30;
  --b4: #ff3b30;
}

/* DARK MODE (default) */
:root,
[data-theme="dark"] {
  color-scheme: dark;

  /* Backgrounds — Liquid Glass layers */
  --bg-app:        rgba(11, 12, 18, 1);
  --bg-base:       rgba(14, 15, 22, 0.98);
  --bg-surface:    rgba(255, 255, 255, 0.055);
  --bg-surface-2:  rgba(255, 255, 255, 0.035);
  --bg-surface-3:  rgba(255, 255, 255, 0.08);
  --bg-elevated:   rgba(255, 255, 255, 0.10);
  --bg-sidebar:    rgba(10, 11, 17, 0.97);
  --bg-topbar:     rgba(12, 13, 20, 0.95);
  --bg-input:      rgba(255, 255, 255, 0.07);
  --bg-input-2:    rgba(255, 255, 255, 0.10);
  --bg-card:       rgba(20, 21, 30, 0.90);

  /* Borders — subtle glass edges */
  --border-color:   rgba(255, 255, 255, 0.08);
  --border-color-2: rgba(255, 255, 255, 0.12);
  --border-bright:  rgba(255, 255, 255, 0.18);
  --border-input:   rgba(255, 255, 255, 0.10);

  /* Text */
  --text-primary:   rgba(255, 255, 255, 1);
  --text-secondary: rgba(255, 255, 255, 0.60);
  --text-tertiary:  rgba(255, 255, 255, 0.38);
  --text-placeholder: rgba(255, 255, 255, 0.30);

  /* Shadows — soft diffuse, no hard edges */
  --shadow-card:    0 2px 20px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255,255,255,0.06) inset;
  --shadow-modal:   0 32px 80px rgba(0, 0, 0, 0.65), 0 2px 0 rgba(255,255,255,0.08) inset;
  --shadow-panel:   0 8px 40px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255,255,255,0.07) inset;
  --shadow-btn:     0 2px 12px rgba(0, 0, 0, 0.30);
  --shadow-primary: 0 4px 24px rgba(255, 59, 48, 0.45);

  /* Track BG */
  --track-bg: rgba(255, 255, 255, 0.10);

  /* Radius — Squircle */
  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius-md: 18px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-pill: 9999px;
}

/* LIGHT MODE */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;

    --bg-app:        rgba(242, 242, 247, 1);
    --bg-base:       rgba(255, 255, 255, 0.85);
    --bg-surface:    rgba(255, 255, 255, 0.72);
    --bg-surface-2:  rgba(255, 255, 255, 0.55);
    --bg-surface-3:  rgba(255, 255, 255, 0.90);
    --bg-elevated:   rgba(255, 255, 255, 0.95);
    --bg-sidebar:    rgba(248, 248, 255, 0.96);
    --bg-topbar:     rgba(252, 252, 255, 0.92);
    --bg-input:      rgba(255, 255, 255, 0.70);
    --bg-input-2:    rgba(255, 255, 255, 0.90);
    --bg-card:       rgba(255, 255, 255, 0.78);

    --border-color:   rgba(0, 0, 0, 0.07);
    --border-color-2: rgba(0, 0, 0, 0.10);
    --border-bright:  rgba(255, 255, 255, 0.90);
    --border-input:   rgba(0, 0, 0, 0.10);

    --text-primary:   rgba(0, 0, 0, 0.90);
    --text-secondary: rgba(0, 0, 0, 0.55);
    --text-tertiary:  rgba(0, 0, 0, 0.38);
    --text-placeholder: rgba(0, 0, 0, 0.28);

    --shadow-card:    0 2px 16px rgba(0, 0, 0, 0.10), 0 1px 0 rgba(255,255,255,0.9) inset;
    --shadow-modal:   0 24px 60px rgba(0, 0, 0, 0.20), 0 1px 0 rgba(255,255,255,0.9) inset;
    --shadow-panel:   0 8px 32px rgba(0, 0, 0, 0.12), 0 1px 0 rgba(255,255,255,0.9) inset;
    --shadow-btn:     0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-primary: 0 4px 20px rgba(255, 59, 48, 0.40);

    --track-bg: rgba(0, 0, 0, 0.08);
  }
}

[data-theme="light"] {
  color-scheme: light;
  --bg-app: rgba(242, 242, 247, 1);
  --bg-base: rgba(255, 255, 255, 0.85);
  --bg-surface: rgba(255, 255, 255, 0.72);
  --bg-surface-2: rgba(255, 255, 255, 0.55);
  --bg-surface-3: rgba(255, 255, 255, 0.90);
  --bg-elevated: rgba(255, 255, 255, 0.95);
  --bg-sidebar: rgba(248, 248, 255, 0.96);
  --bg-topbar: rgba(252, 252, 255, 0.92);
  --bg-input: rgba(255, 255, 255, 0.70);
  --bg-input-2: rgba(255, 255, 255, 0.90);
  --bg-card: rgba(255, 255, 255, 0.78);
  --border-color: rgba(0, 0, 0, 0.07);
  --border-color-2: rgba(0, 0, 0, 0.10);
  --border-bright: rgba(255, 255, 255, 0.90);
  --border-input: rgba(0, 0, 0, 0.10);
  --text-primary: rgba(0, 0, 0, 0.90);
  --text-secondary: rgba(0, 0, 0, 0.55);
  --text-tertiary: rgba(0, 0, 0, 0.38);
  --text-placeholder: rgba(0, 0, 0, 0.28);
  --shadow-card: 0 2px 16px rgba(0, 0, 0, 0.10), 0 1px 0 rgba(255,255,255,0.9) inset;
  --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.20), 0 1px 0 rgba(255,255,255,0.9) inset;
  --shadow-panel: 0 8px 32px rgba(0, 0, 0, 0.12), 0 1px 0 rgba(255,255,255,0.9) inset;
  --shadow-btn: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-primary: 0 4px 20px rgba(255, 59, 48, 0.40);
  --track-bg: rgba(0, 0, 0, 0.08);
}

/* ===================================================================
   BASE RESET
   =================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-scale);
  background-color: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===================================================================
   ICON SYSTEM — White line strokes, consistent weight
   =================================================================== */
.ref-icon, .velora-icon {
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ===================================================================
   GLASS PANELS — Translucent surfaces with backdrop blur
   =================================================================== */
.glass-panel {
  background: var(--bg-surface);
  backdrop-filter: blur(32px) saturate(1.6);
  -webkit-backdrop-filter: blur(32px) saturate(1.6);
  border: 1px solid var(--border-color);
  border-top: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  box-shadow: var(--shadow-panel);
}

.glass-card {
  background: var(--bg-surface);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid var(--border-color);
  border-top: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.glass-card-interactive {
  cursor: pointer;
}
.glass-card:hover,
.glass-card-interactive:hover {
  border-color: var(--border-color-2);
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(255,255,255,0.06);
  transform: translateY(-1px);
}

/* ===================================================================
   iOS PILL / CHIP ELEMENTS
   =================================================================== */
.glass-pill {
  border-radius: var(--radius-pill);
  background: var(--bg-surface-2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  transition: all 0.18s ease;
}
.glass-pill:hover {
  color: var(--text-primary);
  background: var(--bg-surface-3);
  border-color: var(--border-color-2);
}
.glass-pill.active {
  background: var(--accent-pill);
  color: #ffffff !important;
  border-color: transparent;
  box-shadow: var(--accent-glow);
}

/* ===================================================================
   GLASS INPUTS — Translucent text fields, rounded corners
   =================================================================== */
.glass-input {
  background: var(--bg-input);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.65rem 0.95rem;
  font-size: 0.875rem;
  font-family: var(--font-family);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  width: 100%;
}
.glass-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.20);
  background: var(--bg-input-2);
}
.glass-input::placeholder {
  color: var(--text-placeholder);
}
.glass-input option {
  background: #1a1b26;
  color: #fff;
}
textarea.glass-input {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}
select.glass-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='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 12px center;
  padding-right: 2.25rem;
}

/* ===================================================================
   GLASS BUTTONS — iOS primary / secondary style
   =================================================================== */
.glass-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.845rem;
  font-weight: 500;
  font-family: var(--font-family);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface-3);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.glass-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border-color-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-btn);
}
.glass-btn:active {
  transform: scale(0.97);
  box-shadow: none;
}
.glass-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Primary Button — filled, accent color */
.glass-btn-primary {
  background: var(--accent-pill);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-primary);
  position: relative;
  overflow: hidden;
}
.glass-btn-primary::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, transparent 100%);
  border-radius: inherit;
  pointer-events: none;
}
.glass-btn-primary:hover {
  filter: brightness(1.10);
  box-shadow: 0 6px 28px rgba(255, 59, 48, 0.55);
  transform: translateY(-2px) scale(1.01);
}
.glass-btn-primary:active {
  transform: scale(0.97);
  filter: brightness(0.95);
}

/* Destructive (red) button */
.glass-btn-danger {
  background: rgba(255, 59, 48, 0.12);
  border-color: rgba(255, 59, 48, 0.25);
  color: #ff6b6b;
}
.glass-btn-danger:hover {
  background: rgba(255, 59, 48, 0.22);
  border-color: rgba(255, 59, 48, 0.45);
  color: #ff3b30;
}

/* ===================================================================
   iOS TOGGLE SWITCH (replaces checkbox)
   =================================================================== */
.ios-toggle-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
}
.ios-toggle {
  position: relative;
  width: 50px;
  height: 30px;
  flex-shrink: 0;
}
.ios-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.ios-toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 15px;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.10);
  transition: background 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
              border-color 0.28s ease;
  backdrop-filter: blur(8px);
}
.ios-toggle input:checked ~ .ios-toggle-track {
  background: #34c759;
  border-color: #34c759;
}
.ios-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.30), 0 1px 3px rgba(0,0,0,0.20);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
              width 0.12s ease;
}
.ios-toggle input:checked ~ .ios-toggle-thumb {
  transform: translateX(20px);
}
.ios-toggle:active .ios-toggle-thumb {
  width: 27px;
}

/* Small toggle variant */
.ios-toggle-sm {
  width: 38px;
  height: 22px;
}
.ios-toggle-sm .ios-toggle-track { border-radius: 11px; }
.ios-toggle-sm .ios-toggle-thumb {
  top: 2px; left: 2px;
  width: 16px; height: 16px;
}
.ios-toggle-sm input:checked ~ .ios-toggle-thumb {
  transform: translateX(16px);
}
.ios-toggle-sm:active .ios-toggle-thumb {
  width: 20px;
}

/* ===================================================================
   iOS SEGMENTED CONTROL (replaces text tabs)
   =================================================================== */
.ios-segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-surface-2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  gap: 2px;
}
.ios-segmented button,
.ios-segmented [data-seg] {
  flex: 1;
  padding: 0.4rem 0.85rem;
  border-radius: calc(var(--radius-sm) - 4px);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
  font-family: var(--font-family);
}
.ios-segmented button.active,
.ios-segmented [data-seg].active {
  background: var(--bg-elevated);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25), 0 1px 0 rgba(255,255,255,0.12) inset;
  color: var(--text-primary);
  font-weight: 600;
}

/* ===================================================================
   WORKSPACE LAYOUT
   =================================================================== */
.lantools-workspace,
.velora-workspace {
  display: grid;
  grid-template-columns: 234px 1fr;
  min-height: 88vh;
  background: var(--bg-base);
  backdrop-filter: blur(40px) saturate(1.5);
  -webkit-backdrop-filter: blur(40px) saturate(1.5);
  border: 1px solid var(--border-color);
  border-top: 1px solid var(--border-bright);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  position: relative;
}

/* When rendered as a full-page panel (adminDirectMount), fill the entire viewport */
#adminDirectMount > .velora-workspace,
#adminDirectMount > .lantools-workspace {
  min-height: 100vh;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

@media (max-width: 1023px) {
  .lantools-workspace,
  .velora-workspace {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    border-radius: var(--radius-lg);
    min-height: 100vh;
    height: 100vh;
    inset: 0 !important;
    margin: 0 !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
  }
}

/* ===================================================================
   SIDEBAR
   =================================================================== */
.lantools-sidebar,
.velora-sidebar {
  background: var(--bg-sidebar);
  backdrop-filter: blur(40px) saturate(1.5);
  -webkit-backdrop-filter: blur(40px) saturate(1.5);
  border-right: 1px solid var(--border-color);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.25rem;
  width: 234px;
  flex-shrink: 0;
}

@media (max-width: 1023px) {
  .lantools-sidebar,
  .velora-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 272px !important;
    max-width: 86vw !important;
    height: 100% !important;
    z-index: 10000 !important;
    background: var(--bg-sidebar) !important;
    backdrop-filter: blur(48px) !important;
    -webkit-backdrop-filter: blur(48px) !important;
    border-right: 1px solid var(--border-color) !important;
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.60) !important;
    transform: translateX(-100%);
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .lantools-sidebar.open,
  .velora-sidebar.open {
    transform: translateX(0) !important;
  }
}

/* Mobile drawer backdrop */
.lantools-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.lantools-drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile bottom bar */
.lantools-mobile-bar {
  display: none;
}
@media (max-width: 767px) {
  .lantools-mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--bg-sidebar);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    border-top: 1px solid var(--border-color);
    padding: 0.5rem 0.25rem;
    z-index: 800;
    flex-shrink: 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.30);
  }
  .lantools-mobile-bar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-tertiary);
    font-size: 9.5px;
    font-weight: 500;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    touch-action: manipulation;
    font-family: var(--font-family);
  }
  .lantools-mobile-bar-btn:active {
    transform: scale(0.90);
  }
  .lantools-mobile-bar-btn.active {
    color: var(--accent-color);
    font-weight: 700;
  }
  .lantools-mobile-bar-btn.active svg {
    filter: drop-shadow(0 0 6px rgba(255, 59, 48, 0.55));
  }
}

/* ===================================================================
   BRAND LOGO
   =================================================================== */
.lantools-logo,
.velora-logo {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0 0.4rem;
  text-transform: uppercase;
}
.lantools-logo-dot,
.velora-logo-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: var(--accent-pill);
  display: inline-block;
  margin-top: 1px;
  box-shadow: 0 0 12px rgba(255, 59, 48, 0.70);
}

/* ===================================================================
   NAV BUTTONS
   =================================================================== */
.lantools-nav-btn,
.velora-nav-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-pill);
  font-size: 0.845rem;
  font-weight: 500;
  font-family: var(--font-family);
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
@media (max-width: 1024px) {
  .lantools-nav-btn,
  .velora-nav-btn {
    padding: 0.45rem 0.8rem;
    font-size: 0.78rem;
    width: auto;
    flex-shrink: 0;
  }
}
.lantools-nav-btn:hover,
.velora-nav-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-2);
  transform: translateX(2px);
}
.lantools-nav-btn.active,
.velora-nav-btn.active {
  background: var(--accent-pill) !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  box-shadow: var(--accent-glow) !important;
  transform: none !important;
}

/* ===================================================================
   TOPBAR
   =================================================================== */
.lantools-topbar,
.velora-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-topbar);
  backdrop-filter: blur(32px) saturate(1.5);
  -webkit-backdrop-filter: blur(32px) saturate(1.5);
}
@media (max-width: 640px) {
  .lantools-topbar,
  .velora-topbar {
    padding: 0.7rem 0.9rem;
    gap: 0.5rem;
  }
}

/* Search box */
.velora-search {
  position: relative;
  width: 260px;
}
.velora-search input {
  width: 100%;
  padding: 0.45rem 1rem 0.45rem 2.2rem;
  border-radius: var(--radius-pill);
  background: var(--bg-input);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-input);
  font-size: 0.80rem;
  color: var(--text-primary);
  font-family: var(--font-family);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.velora-search input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(255, 59, 48, 0.18);
}
.velora-search svg {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-tertiary);
}

/* ===================================================================
   STAT TAGS
   =================================================================== */
.velora-stat-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 600;
  font-family: var(--font-family);
}
.velora-stat-tag.up {
  background: rgba(52, 199, 89, 0.14);
  color: #34c759;
}
.velora-stat-tag.down {
  background: rgba(255, 59, 48, 0.12);
  color: #ff3b30;
}

/* ===================================================================
   PROGRESS BARS
   =================================================================== */
.velora-bars-container {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 56px;
  padding-top: 0.5rem;
}
.velora-bar-col {
  flex: 1;
  background: var(--track-bg);
  border-radius: 9999px;
  transition: all 0.3s ease;
  animation: barRiseAnim 0.75s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.velora-bar-col.active {
  background: var(--accent-vertical) !important;
  box-shadow: 0 0 14px rgba(255, 59, 48, 0.45) !important;
}

.velora-progress-track {
  width: 100%;
  height: 7px;
  background: var(--track-bg);
  border-radius: 9999px;
  overflow: hidden;
}
.velora-progress-fill {
  height: 100%;
  border-radius: 9999px;
  background: var(--accent-pill);
  box-shadow: 0 0 8px rgba(255, 59, 48, 0.35);
}

/* Segment capsules */
.segment-capsule {
  background: var(--track-bg);
  border-radius: 9999px;
  width: 100%;
  max-width: 32px;
  transition: all 0.3s ease;
}
.segment-capsule.active {
  background: var(--accent-vertical) !important;
  box-shadow: 0 0 24px rgba(255, 59, 48, 0.5) !important;
}

/* ===================================================================
   COLOR CHIPS
   =================================================================== */
.color-chip {
  width: 22px;
  height: 22px;
  border-radius: 9999px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  cursor: pointer;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.18s;
}
.color-chip:hover {
  transform: scale(1.22);
  border-color: rgba(255, 255, 255, 0.85);
}

/* ===================================================================
   OS WINDOW CONTROL BUTTONS
   =================================================================== */
.os-win-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.os-win-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  transform: scale(1.05);
}
.os-win-btn.close:hover {
  background: rgba(255, 59, 48, 0.20);
  color: #ff6b6b;
  border-color: rgba(255, 59, 48, 0.35);
}

/* ===================================================================
   CUSTOM SCROLLBARS
   =================================================================== */
.custom-scroll::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
.custom-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.custom-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.12);
  border-radius: 9999px;
}
.custom-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.22);
}

/* ===================================================================
   SECTION DIVIDERS — glass-card inner groups
   =================================================================== */
.glass-section-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
}
.glass-section-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: var(--accent-pill);
  box-shadow: 0 0 8px rgba(255, 59, 48, 0.55);
  flex-shrink: 0;
}

/* ===================================================================
   SPRING ANIMATIONS — 60fps hardware-accelerated
   =================================================================== */
@keyframes springIn {
  0% {
    opacity: 0;
    transform: scale(0.88) translateY(16px);
  }
  60% {
    opacity: 1;
    transform: scale(1.02) translateY(-2px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes springFadeUp {
  0% {
    opacity: 0;
    transform: translateY(24px);
  }
  60% {
    opacity: 1;
    transform: translateY(-3px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes springScale {
  0% {
    opacity: 0;
    transform: scale(0.92);
  }
  65% {
    opacity: 1;
    transform: scale(1.02);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(28px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  0% {
    opacity: 0;
    transform: translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleUp {
  0% {
    opacity: 0;
    transform: scale(0.94);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes gentlePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.4);
  }
  50% {
    transform: scale(1.03);
    box-shadow: 0 0 16px 4px rgba(255, 59, 48, 0.22);
  }
}

@keyframes liveDotGlow {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.7);
  }
  50% {
    opacity: 0.55;
    transform: scale(0.85);
    box-shadow: 0 0 10px 4px rgba(255, 98, 67, 0.40);
  }
}

@keyframes buttonSheen {
  0% {
    transform: translateX(-150%) skewX(-20deg);
  }
  25%, 100% {
    transform: translateX(260%) skewX(-20deg);
  }
}

@keyframes floatSlow {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@keyframes barRiseAnim {
  0% {
    transform: scaleY(0);
    transform-origin: bottom;
    opacity: 0.2;
  }
  100% {
    transform: scaleY(1);
    transform-origin: bottom;
    opacity: 1;
  }
}

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

@keyframes modalZoomIn {
  0% {
    opacity: 0;
    transform: scale(0.90) translateY(18px);
  }
  65% {
    transform: scale(1.02) translateY(-2px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Animation utility classes */
.anim-spring-in {
  animation: springIn 0.52s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.anim-fade-up {
  opacity: 0;
  animation: fadeInUp 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.anim-fade-down {
  opacity: 0;
  animation: fadeInDown 0.60s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.anim-scale-in {
  opacity: 0;
  animation: springScale 0.50s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.anim-fade-in {
  opacity: 0;
  animation: scaleUp 0.35s ease forwards;
}
.anim-float {
  animation: floatSlow 4s ease-in-out infinite;
}
.live-dot-pulse {
  animation: liveDotGlow 2s ease-in-out infinite;
}

/* Stagger delays */
.delay-75  { animation-delay: 75ms; }
.delay-100 { animation-delay: 100ms; }
.delay-150 { animation-delay: 150ms; }
.delay-200 { animation-delay: 200ms; }
.delay-250 { animation-delay: 250ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }
.delay-600 { animation-delay: 600ms; }

/* Scroll reveals */
.scroll-reveal {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 0.85s cubic-bezier(0.16, 1, 0.3, 1), transform 0.85s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}
.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}
.scroll-reveal-scale {
  opacity: 0;
  transform: scale(0.94) translateY(20px);
  transition: opacity 0.85s cubic-bezier(0.16, 1, 0.3, 1), transform 0.85s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}
.scroll-reveal-scale.revealed {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* ===================================================================
   BUTTON SHEEN EFFECT
   =================================================================== */
.glass-btn-primary,
.btn-hero, .btn-vsl, .btn-form,
.velora-btn-primary, .save-pill-btn {
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.22s ease,
              filter 0.22s ease;
}

.glass-btn-primary::after,
.btn-hero::after, .btn-vsl::after,
.btn-form::after, .velora-btn-primary::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 55%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.24), transparent);
  transform: translateX(-150%) skewX(-20deg);
  pointer-events: none;
  animation: buttonSheen 6s ease-in-out infinite;
}

/* ===================================================================
   MODAL ENTER ANIMATION
   =================================================================== */
#leadFormModal > div,
#privacyModal > div,
#adminModal > div,
.modal-container > div,
[id$="Modal"] > div {
  animation: modalZoomIn 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Tab switching */
#veloraStage > * {
  animation: tabCrossFade 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Animated bar charts */
.velora-bar-col {
  transition: height 0.4s ease, background 0.2s ease;
}

/* ===================================================================
   TOAST NOTIFICATION — Liquid glass style
   =================================================================== */
#liquidToast {
  background: var(--bg-surface) !important;
  backdrop-filter: blur(32px) saturate(1.6) !important;
  -webkit-backdrop-filter: blur(32px) saturate(1.6) !important;
  border: 1px solid var(--border-color) !important;
  border-top-color: var(--border-bright) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-modal) !important;
  color: var(--text-primary) !important;
  font-family: var(--font-family) !important;
}

/* ===================================================================
   HARDWARE-ACCELERATED VIDEO BACKGROUND
   =================================================================== */
#bgVideo {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  perspective: 1000;
  -webkit-perspective: 1000;
  will-change: transform;
}

/* ===================================================================
   REDUCED MOTION OVERRIDE
   =================================================================== */
@media (prefers-reduced-motion: reduce) {
  .anim-fade-up, .anim-fade-down, .anim-scale-in,
  .anim-spring-in, .anim-fade-in,
  .scroll-reveal, .scroll-reveal-scale {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .velora-bar-col {
    animation: none !important;
  }
}

/* ===================================================================
   DETAIL/SUMMARY COLLAPSIBLE — Glass styled
   =================================================================== */
details.glass-card summary {
  list-style: none;
}
details.glass-card summary::-webkit-details-marker {
  display: none;
}
details.glass-card[open] summary {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
}

/* ===================================================================
   TABLE STYLES — Inside glass cards
   =================================================================== */
.glass-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.glass-table th {
  padding: 0.7rem 0.9rem;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface-2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.glass-table td {
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}
.glass-table tr:hover td {
  background: var(--bg-surface-2);
}

/* ===================================================================
   SECTION HEADING UTILITIES
   =================================================================== */
.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0;
}
.section-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin: 0.3rem 0 0;
  line-height: 1.5;
}

/* ===================================================================
   FORM GROUP — label + input pairing
   =================================================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.form-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-hint {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin-top: 0.25rem;
}

/* ===================================================================
   SEGMENTED NAV — for sub-tabs inside sections
   =================================================================== */
#boardsSubNav,
#recommendTfSelector {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--bg-surface-2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}
#boardsSubNav button,
#recommendTfSelector button {
  flex: 1;
  padding: 0.38rem 0.8rem;
  border-radius: calc(var(--radius-sm) - 4px);
  font-size: 0.77rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
  font-family: var(--font-family);
}
#boardsSubNav button.active,
#recommendTfSelector button.active {
  background: var(--bg-elevated);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25), 0 1px 0 rgba(255,255,255,0.10) inset;
  color: var(--text-primary);
  font-weight: 600;
}

/* ===================================================================
   RESPONSIVE & MOBILE POLISH (iOS, Android, Tablets, Small Screens)
   =================================================================== */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

/* Prevent iOS Safari 16px auto-zoom when tapping inputs */
@media (max-width: 768px) {
  .glass-input,
  input.glass-input,
  select.glass-input,
  textarea.glass-input {
    font-size: 16px !important;
  }
}

/* Touch-optimized horizontal scroll containers */
.custom-scroll,
#catalogModelTabs {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.custom-scroll::-webkit-scrollbar,
#catalogModelTabs::-webkit-scrollbar {
  height: 4px;
  width: 4px;
}
.custom-scroll::-webkit-scrollbar-track,
#catalogModelTabs::-webkit-scrollbar-track {
  background: transparent;
}
.custom-scroll::-webkit-scrollbar-thumb,
#catalogModelTabs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 9999px;
}

/* Safe area support for notch and home bar */
@supports (padding: env(safe-area-inset-bottom)) {
  #btnFloatingAdmin {
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    right: calc(1rem + env(safe-area-inset-right, 0px));
  }
  #cookieBanner {
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }
}

/* Modal responsive constraints for small viewports */
@media (max-width: 640px) {
  #leadFormModal > div,
  #privacyModal > div {
    max-height: calc(100svh - 2rem) !important;
    padding: 1.25rem !important;
  }
}
