/**
 * TeleLive — Apple iOS / iPadOS 27 theme overlay
 * Maps Apple DS tokens onto existing TeleLive CSS variables & components.
 * Loaded last. Skips [data-theme="lite"] (performance theme stays flat).
 * No markup / JS changes required.
 */

/* ========== Map Apple tokens → TeleLive variables ========== */
html:not([data-theme="lite"]),
html:not([data-theme="lite"])[data-theme="dark"],
html:not([data-theme="lite"])[data-theme="auto"] {
  --bg: var(--ios-bg-primary);
  --bg-elev-1: var(--ios-bg-secondary);
  --bg-elev-2: var(--ios-bg-tertiary);
  --bg-elev-3: var(--ios-bg-elevated-tertiary);
  --text: var(--ios-label-primary);
  --text-muted: var(--ios-label-secondary);
  --line: var(--ios-separator);
  --brand: var(--ios-blue);
  --brand-strong: #0077e6;
  --brand-soft: #5cb8ff;
  --danger: var(--ios-red);
  --success: var(--ios-green);
  --warning: var(--ios-orange);
  --radius: var(--ios-radius-lg);
  --radius-sm: var(--ios-radius-md);
  --radius-xs: var(--ios-radius-sm);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --tl-bg-dot: rgba(255, 255, 255, 0.014);
  --tl-bg-glow-1: rgba(0, 145, 255, 0.07);
  --tl-bg-glow-2: rgba(109, 124, 255, 0.05);
  --tl-bg-glow-3: rgba(0, 0, 0, 0.35);
  --tl-bg-base-end: #000000;
  --tl-glass-bg: var(--ios-glass-bg-medium);
  --tl-glass-border: var(--ios-glass-border);
  --tl-surface-blur: var(--ios-glass-blur-chrome);
}

html[data-theme="light"]:not([data-theme="lite"]) {
  --bg: var(--ios-bg-secondary);
  --bg-elev-1: var(--ios-bg-primary);
  --bg-elev-2: var(--ios-bg-secondary);
  --bg-elev-3: var(--ios-gray-5);
  --text: var(--ios-label-primary);
  --text-muted: var(--ios-label-secondary);
  --line: var(--ios-separator);
  --brand: var(--ios-blue);
  --brand-strong: #0066cc;
  --brand-soft: #4da3ff;
  --danger: var(--ios-red);
  --success: var(--ios-green);
  --warning: var(--ios-orange);
  --radius: var(--ios-radius-lg);
  --radius-sm: var(--ios-radius-md);
  --radius-xs: var(--ios-radius-sm);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  --tl-bg-dot: rgba(0, 136, 255, 0.035);
  --tl-bg-glow-1: rgba(0, 136, 255, 0.06);
  --tl-bg-glow-2: rgba(97, 85, 245, 0.04);
  --tl-bg-glow-3: rgba(242, 242, 247, 0.8);
  --tl-bg-base-end: #f2f2f7;
  --tl-glass-bg: var(--ios-glass-bg-medium);
  --tl-glass-border: var(--ios-glass-border);
}

@media (prefers-color-scheme: light) {
  html[data-theme="auto"]:not([data-theme="lite"]) {
    --bg: var(--ios-bg-secondary);
    --bg-elev-1: var(--ios-bg-primary);
    --bg-elev-2: var(--ios-bg-secondary);
    --bg-elev-3: var(--ios-gray-5);
    --text: var(--ios-label-primary);
    --text-muted: var(--ios-label-secondary);
    --line: var(--ios-separator);
    --brand: var(--ios-blue);
    --brand-strong: #0066cc;
    --brand-soft: #4da3ff;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    --tl-bg-base-end: #f2f2f7;
  }
}

/* ========== Typography ========== */
html:not([data-theme="lite"])[dir="ltr"]:not([lang="fa"]) body,
html:not([data-theme="lite"]):not([lang="fa"]) body {
  font-family: var(--ios-font-en);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html:not([data-theme="lite"])[lang="fa"] body,
html:not([data-theme="lite"])[dir="rtl"] body {
  font-family: var(--ios-font-fa);
  -webkit-font-smoothing: antialiased;
}

html:not([data-theme="lite"]) body {
  letter-spacing: -0.01em;
  line-height: 1.47;
}

/* ========== Liquid Glass helpers ========== */
html:not([data-theme="lite"]) .tl-apple-glass,
html:not([data-theme="lite"]) .tl-glass-surface,
html:not([data-theme="lite"]) .tl-glass-panel,
html:not([data-theme="lite"]) .tl-glass-chip {
  border-color: var(--ios-glass-border) !important;
  border-top-color: var(--ios-glass-border-highlight) !important;
  box-shadow:
    inset 0 1px 0 var(--ios-glass-border-highlight),
    0 8px 28px rgba(0, 0, 0, 0.28);
  transition:
    background var(--ios-duration-normal) var(--ios-ease),
    border-color var(--ios-duration-fast) var(--ios-ease),
    transform var(--ios-duration-fast) var(--ios-ease);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  html:not([data-theme="lite"]) .tl-glass-surface {
    background: linear-gradient(
      165deg,
      var(--ios-glass-tint),
      var(--ios-glass-bg-medium)
    ) !important;
    backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
    -webkit-backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
  }

  html:not([data-theme="lite"]) .tl-glass-panel {
    background: linear-gradient(
      165deg,
      var(--ios-glass-tint),
      var(--ios-glass-bg-large)
    ) !important;
    backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
    -webkit-backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
    border-radius: var(--ios-radius-xl);
  }

  html:not([data-theme="lite"]) .tl-glass-chip {
    background: var(--ios-glass-bg-small) !important;
    backdrop-filter: blur(var(--ios-glass-blur-md)) saturate(var(--ios-glass-saturate));
    -webkit-backdrop-filter: blur(var(--ios-glass-blur-md)) saturate(var(--ios-glass-saturate));
    border-radius: var(--ios-radius-pill);
  }
}

/* ========== Buttons (Apple control style) ========== */
html:not([data-theme="lite"]) .btn {
  border-radius: var(--ios-radius-md);
  font-weight: 600;
  letter-spacing: -0.02em;
  min-height: 44px;
  padding: 10px 18px;
  transition:
    transform var(--ios-duration-fast) var(--ios-ease),
    opacity var(--ios-duration-fast) var(--ios-ease),
    background var(--ios-duration-fast) var(--ios-ease),
    box-shadow var(--ios-duration-fast) var(--ios-ease);
}

html:not([data-theme="lite"]) .btn:active {
  transform: scale(0.97);
}

html:not([data-theme="lite"]) .btn-primary {
  background: var(--ios-blue);
  color: #fff;
  border: none;
  box-shadow: 0 4px 16px rgba(0, 145, 255, 0.35);
}

html:not([data-theme="lite"]) .btn-primary:hover {
  background: color-mix(in srgb, var(--ios-blue) 88%, #fff);
  filter: none;
}

html:not([data-theme="lite"]) .btn-outline {
  background: var(--ios-fill-tertiary);
  border: 1px solid var(--ios-glass-border);
  color: var(--ios-label-primary);
  backdrop-filter: blur(var(--ios-glass-blur-sm));
  -webkit-backdrop-filter: blur(var(--ios-glass-blur-sm));
}

html:not([data-theme="lite"]) .btn-outline:hover {
  background: var(--ios-fill-secondary);
  border-color: var(--ios-blue);
  color: var(--ios-blue);
}

html:not([data-theme="lite"]) .btn-danger {
  background: var(--ios-red);
  box-shadow: 0 4px 16px rgba(255, 66, 69, 0.3);
}

html:not([data-theme="lite"]) .btn-sm {
  min-height: 36px;
  border-radius: var(--ios-radius-sm);
  padding: 6px 12px;
}

html:not([data-theme="lite"]) .btn-lg {
  min-height: 50px;
  border-radius: var(--ios-radius-lg);
  padding: 14px 24px;
  font-size: 17px;
}

/* ========== Navbar / chrome — floating capsule like left sidebar ========== */
html:not([data-theme="lite"]) .nav-link {
  border-radius: var(--ios-radius-pill);
  transition: background var(--ios-duration-fast) var(--ios-ease), color var(--ios-duration-fast) var(--ios-ease);
}

html:not([data-theme="lite"]) .nav-link:hover,
html:not([data-theme="lite"]) .nav-link.active {
  color: var(--ios-blue);
  background: var(--ios-fill-quaternary);
}

html:not([data-theme="lite"]) .search-input {
  border-radius: var(--ios-radius-md);
  background: var(--ios-fill-tertiary);
  border-color: transparent;
  min-height: 36px;
}

html:not([data-theme="lite"]) .search-input:focus {
  background: var(--ios-fill-secondary);
  border-color: var(--ios-blue);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ios-blue) 28%, transparent);
}

/* Desktop: rounded glass capsule header (same 24px as .tl-left-sidebar) */
@media (min-width: 769px) {
  html:not([data-theme="lite"]) .navbar {
    background: transparent !important;
    border-bottom: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 10px 12px 0 !important;
  }

  html:not([data-theme="lite"]) .navbar-container {
    border-radius: 24px !important;
    border: 1px solid var(--ios-glass-border) !important;
    border-top-color: var(--ios-glass-border-highlight) !important;
    min-height: 56px !important;
    padding: 0 16px !important;
    box-shadow:
      0 12px 36px rgba(0, 0, 0, 0.28),
      inset 0 1px 0 var(--ios-glass-border-highlight);
  }

  @supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    html:not([data-theme="lite"]) .navbar-container {
      background: linear-gradient(
        165deg,
        var(--ios-glass-tint),
        var(--ios-glass-bg-medium)
      ) !important;
      backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
      -webkit-backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
    }
  }

  html:not([data-theme="lite"]) .tl-left-sidebar {
    border-radius: 24px !important;
    border-color: var(--ios-glass-border) !important;
    border-top-color: var(--ios-glass-border-highlight) !important;
    margin-inline-end: 14px !important;
  }

  /* Expanded drawer: more air from content (don't stick to the right) */
  html:not([data-theme="lite"]) .tl-left-sidebar.is-expanded,
  html:not([data-theme="lite"]) .tl-left-sidebar--drawer.is-expanded {
    margin-inline-end: 18px !important;
  }

  @supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    html:not([data-theme="lite"]) .tl-left-sidebar {
      background: linear-gradient(
        165deg,
        var(--ios-glass-tint),
        var(--ios-glass-bg-medium)
      ) !important;
      backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
      -webkit-backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
    }
  }
}

/* ========== Cards ========== */
html:not([data-theme="lite"]) .stream-card,
html:not([data-theme="lite"]) .card,
html:not([data-theme="lite"]) .settings-card,
html:not([data-theme="lite"]) .dash-card,
html:not([data-theme="lite"]) .analytics-ov-card,
html:not([data-theme="lite"]) .analytics-stat-box,
html:not([data-theme="lite"]) .tl-chat-admin-card,
html:not([data-theme="lite"]) .emoji-tier-board {
  border-radius: var(--ios-radius-xl) !important;
  border-color: var(--ios-glass-border) !important;
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  html:not([data-theme="lite"]) .stream-card {
    background: linear-gradient(
      165deg,
      var(--ios-glass-tint),
      var(--ios-glass-bg-medium)
    ) !important;
    backdrop-filter: blur(var(--ios-glass-blur-lg)) saturate(var(--ios-glass-saturate));
    -webkit-backdrop-filter: blur(var(--ios-glass-blur-lg)) saturate(var(--ios-glass-saturate));
    box-shadow:
      inset 0 1px 0 var(--ios-glass-border-highlight),
      0 8px 24px rgba(0, 0, 0, 0.22);
  }

  html:not([data-theme="lite"]) .stream-card:hover {
    transform: translateY(-2px) scale(1.01);
    border-color: color-mix(in srgb, var(--ios-blue) 40%, var(--ios-glass-border)) !important;
    box-shadow:
      inset 0 1px 0 var(--ios-glass-border-highlight),
      0 14px 36px rgba(0, 0, 0, 0.32);
  }
}

/* ========== Modals / sheets / menus ========== */
html:not([data-theme="lite"]) .modal-content,
html:not([data-theme="lite"]) .user-dropdown,
html:not([data-theme="lite"]) .notification-dropdown,
html:not([data-theme="lite"]) .tl-lang-menu,
html:not([data-theme="lite"]) .tl-lang-menu--menu,
html:not([data-theme="lite"]) .tl-lang-menu--guest,
html:not([data-theme="lite"]) .dropdown-menu {
  border-radius: var(--ios-radius-xl) !important;
  border: 1px solid var(--ios-glass-border) !important;
  overflow: hidden;
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  html:not([data-theme="lite"]) .modal-content,
  html:not([data-theme="lite"]) .user-dropdown,
  html:not([data-theme="lite"]) .notification-dropdown,
  html:not([data-theme="lite"]) .tl-lang-menu,
  html:not([data-theme="lite"]) .tl-lang-menu--menu,
  html:not([data-theme="lite"]) .tl-lang-menu--guest {
    background: var(--ios-glass-bg-large) !important;
    backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
    -webkit-backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
    box-shadow:
      inset 0 1px 0 var(--ios-glass-border-highlight),
      0 24px 64px rgba(0, 0, 0, 0.45);
  }
}

/* Sheet-like modal top radius (iPhone sheet) */
@media (max-width: 768px) {
  html:not([data-theme="lite"]) .modal-content {
    border-radius: var(--ios-radius-sheet) var(--ios-radius-sheet) 0 0 !important;
  }
}

/* ========== Mobile chrome (Liquid Glass floating bars) ========== */
@media (max-width: 768px) {
  /* Keep capsule rounded corners (match sidebar / footer language) */
  html:not([data-theme="lite"]) body:not(.page-stream) .navbar,
  html:not([data-theme="lite"]) body.page-stream .navbar {
    border-radius: 26px !important;
    overflow: hidden;
  }

  /* Drawer must sit ABOVE floating header (navbar z-index is 10050) */
  html:not([data-theme="lite"]) .mob-drawer-overlay {
    z-index: 10100 !important;
  }
  html:not([data-theme="lite"]) .mob-drawer {
    z-index: 10110 !important;
  }
  /* also fix when lite/dark — always above header on phone */
  .mob-drawer-overlay {
    z-index: 10100 !important;
  }
  .mob-drawer {
    z-index: 10110 !important;
  }

  html:not([data-theme="lite"]) .mob-bottom-nav {
    border-radius: 30px !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    justify-content: space-between !important;
    width: auto !important;
    left: 12px !important;
    right: 12px !important;
    gap: 0 !important;
  }

  html:not([data-theme="lite"]) .mob-bottom-nav .mob-nav-item {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: none !important;
    width: auto !important;
    margin: 2px !important;
    justify-content: center !important;
    align-items: center !important;
  }

  html:not([data-theme="lite"]) body:not(.page-stream) .navbar::before,
  html:not([data-theme="lite"]) .mob-bottom-nav::before {
    border-radius: inherit !important;
  }

  @supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    html:not([data-theme="lite"]) body:not(.page-stream) .navbar,
    html:not([data-theme="lite"]) body.page-stream .navbar,
    html:not([data-theme="lite"]) .mob-bottom-nav {
      background: var(--ios-glass-bg-medium) !important;
      backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
      -webkit-backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
      border: 1px solid var(--ios-glass-border) !important;
      border-top-color: var(--ios-glass-border-highlight) !important;
      box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 var(--ios-glass-border-highlight);
    }

    html:not([data-theme="lite"]) .mob-drawer {
      background: var(--ios-glass-bg-large) !important;
      backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
      -webkit-backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
    }
  }

  /* RTL drawer opens from left → round the inner (right) edge */
  html[dir="rtl"]:not([data-theme="lite"]) .mob-drawer {
    border-radius: 0 24px 24px 0 !important;
  }
  html[dir="ltr"]:not([data-theme="lite"]) .mob-drawer {
    border-radius: 24px 0 0 24px !important;
  }

  /* Active tab: soft inset highlight, not a separate floating pill */
  html:not([data-theme="lite"]) .mob-nav-item.active {
    color: var(--ios-label-primary);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 22px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
  html:not([data-theme="lite"]) .mob-nav-item.active i {
    color: var(--ios-blue);
  }

  html:not([data-theme="lite"]) .mob-drawer-item {
    border-radius: var(--ios-radius-md);
    min-height: 44px;
  }

  html:not([data-theme="lite"]) .mob-drawer-item:hover,
  html:not([data-theme="lite"]) .mob-drawer-item.active {
    background: var(--ios-fill-secondary);
  }
}

/* ========== Forms ========== */
html:not([data-theme="lite"]) input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
html:not([data-theme="lite"]) textarea,
html:not([data-theme="lite"]) select {
  border-radius: var(--ios-radius-md);
  border-color: var(--ios-separator-transparent);
  background: var(--ios-fill-quaternary);
  transition: border-color var(--ios-duration-fast) var(--ios-ease), box-shadow var(--ios-duration-fast) var(--ios-ease);
}

html:not([data-theme="lite"]) input:focus,
html:not([data-theme="lite"]) textarea:focus,
html:not([data-theme="lite"]) select:focus {
  border-color: var(--ios-blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ios-blue) 25%, transparent);
  outline: none;
}

/* ========== Chat / stream chrome ========== */
html:not([data-theme="lite"]) .chat-panel,
html:not([data-theme="lite"]) .stream-info-bar,
html:not([data-theme="lite"]) .mobile-tab-bar,
html:not([data-theme="lite"]) .mob-info-bar {
  border-color: var(--ios-separator-transparent);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  html:not([data-theme="lite"]) .chat-panel,
  html:not([data-theme="lite"]) .stream-info-bar {
    background: var(--ios-material-regular);
    backdrop-filter: blur(var(--ios-glass-blur-md)) saturate(var(--ios-glass-saturate));
    -webkit-backdrop-filter: blur(var(--ios-glass-blur-md)) saturate(var(--ios-glass-saturate));
  }
}

html:not([data-theme="lite"]) .chat-input-area input,
html:not([data-theme="lite"]) .chat-input-area textarea {
  border-radius: var(--ios-radius-pill);
}

/* ========== Footer / search / tele / tabs — Apple fill-ins ========== */
html:not([data-theme="lite"]) .site-footer-glass {
  border-radius: 26px !important;
  border-color: var(--ios-glass-border) !important;
  border-top-color: var(--ios-glass-border-highlight) !important;
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  html:not([data-theme="lite"]) .site-footer-glass {
    background: linear-gradient(
      165deg,
      var(--ios-glass-tint),
      var(--ios-glass-bg-medium)
    ) !important;
    backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
    -webkit-backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
  }

  html:not([data-theme="lite"]) .search-results,
  html:not([data-theme="lite"]) .tele-dropdown,
  html:not([data-theme="lite"]) .tele-modal-box,
  html:not([data-theme="lite"]) .tl-live-toast {
    background: var(--ios-glass-bg-large) !important;
    backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
    -webkit-backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
    border-color: var(--ios-glass-border) !important;
    border-radius: var(--ios-radius-xl) !important;
  }
}

html:not([data-theme="lite"]) .tab-btn,
html:not([data-theme="lite"]) .category-chip,
html:not([data-theme="lite"]) .tl-spotlight__pill {
  border-radius: var(--ios-radius-pill) !important;
}

/* Categories row: keep modest radius (not full pill) */
html:not([data-theme="lite"]) .category-card-scroll,
html:not([data-theme="lite"]) .categories-scroll-row a.category-card-scroll,
html:not([data-theme="lite"]) .category-card,
html:not([data-theme="lite"]) .category-card-lg {
  border-radius: 10px !important;
}

html:not([data-theme="lite"]) .tab-btn.active {
  background: color-mix(in srgb, var(--ios-blue) 22%, transparent);
  border-color: color-mix(in srgb, var(--ios-blue) 45%, transparent);
  color: var(--ios-blue);
}

html:not([data-theme="lite"]) .sidebar-item,
html:not([data-theme="lite"]) .tl-sidebar-item {
  border-radius: var(--ios-radius-md);
}

html:not([data-theme="lite"]) .sidebar-item.active,
html:not([data-theme="lite"]) .tl-sidebar-item.active,
html:not([data-theme="lite"]) .tl-sidebar-item.is-active {
  background: var(--ios-fill-secondary);
  color: var(--ios-blue);
}

html:not([data-theme="lite"]) .tl-hero-live__dock,
html:not([data-theme="lite"]) .tl-hero-live__chat-col,
html:not([data-theme="lite"]) .tl-home-clips-panel,
html:not([data-theme="lite"]) .tl-spotlight {
  border-radius: var(--ios-radius-xxl);
  border-color: var(--ios-glass-border);
}

/* ========== Auth pages ========== */
html:not([data-theme="lite"]) .tl-auth-modern,
html:not([data-theme="lite"]) .auth-card,
html:not([data-theme="lite"]) .login-card,
html:not([data-theme="lite"]) .register-card {
  border-radius: var(--ios-radius-xxl);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  html:not([data-theme="lite"]) .tl-auth-modern .auth-card,
  html:not([data-theme="lite"]) .auth-card,
  html:not([data-theme="lite"]) .login-card,
  html:not([data-theme="lite"]) .register-card {
    background: var(--ios-glass-bg-large);
    backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
    -webkit-backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
    border: 1px solid var(--ios-glass-border);
    box-shadow:
      inset 0 1px 0 var(--ios-glass-border-highlight),
      0 24px 64px rgba(0, 0, 0, 0.4);
  }
}

/* ========== Dashboard ========== */
html:not([data-theme="lite"]) body .tl-dash-page .dashboard.tl-dash-inner {
  background: linear-gradient(180deg, var(--ios-glass-bg-medium), var(--ios-bg-secondary));
  border: 1px solid var(--ios-glass-border);
  border-radius: var(--ios-radius-xxl);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
}

html:not([data-theme="lite"]) body .tl-dash-page .dash-tabs .dash-tab {
  border-radius: var(--ios-radius-pill);
  font-weight: 600;
}

html:not([data-theme="lite"]) body .tl-dash-page .dash-tabs .dash-tab.active {
  background: color-mix(in srgb, var(--ios-blue) 28%, transparent);
  border-color: color-mix(in srgb, var(--ios-blue) 55%, transparent);
  color: var(--ios-blue);
}

/* ========== Profile / settings ========== */
html:not([data-theme="lite"]) .profile-header,
html:not([data-theme="lite"]) .settings-section,
html:not([data-theme="lite"]) .settings-card {
  border-radius: var(--ios-radius-xl);
}

/* ========== Header chips: Tele + mini-profile + wheel + mem — same language ========== */
html:not([data-theme="lite"]) .tele-pill,
html:not([data-theme="lite"]) .user-menu-btn,
html:not([data-theme="lite"]) .notification-bell,
html:not([data-theme="lite"]) .tl-mem-nav-btn,
html:not([data-theme="lite"]) .tl-wheel-nav-btn,
html:not([data-theme="lite"]) .search-wheel-row .search-btn,
html:not([data-theme="lite"]) .mob-hdr-btn {
  box-sizing: border-box;
  height: 36px;
  min-height: 36px;
  border-radius: 999px !important;
  border: 1px solid var(--ios-glass-border) !important;
  background: var(--ios-fill-tertiary) !important;
  box-shadow: none;
  vertical-align: middle;
}

html:not([data-theme="lite"]) .tele-pill {
  padding: 0 12px !important;
  gap: 6px;
  color: var(--ios-label-primary) !important;
  background: color-mix(in srgb, var(--ios-blue) 16%, var(--ios-fill-tertiary)) !important;
  border-color: color-mix(in srgb, var(--ios-blue) 40%, var(--ios-glass-border)) !important;
}
html:not([data-theme="lite"]) .tele-pill i.fa-bolt {
  color: var(--ios-blue) !important;
}
html:not([data-theme="lite"]) .tele-pill-amount {
  color: var(--ios-label-primary) !important;
}

html:not([data-theme="lite"]) .user-menu-btn {
  padding: 3px 10px 3px 4px !important;
  gap: 7px;
  color: var(--ios-label-primary) !important;
  background: var(--ios-fill-tertiary) !important;
}
html:not([data-theme="lite"]) .user-menu-btn .avatar-sm {
  width: 28px;
  height: 28px;
  border: none;
}

html:not([data-theme="lite"]) .tl-mem-nav-btn,
html:not([data-theme="lite"]) .tl-wheel-nav-btn,
html:not([data-theme="lite"]) .search-wheel-row .search-btn,
html:not([data-theme="lite"]) .notification-bell,
html:not([data-theme="lite"]) .mob-hdr-btn {
  width: 36px;
  min-width: 36px;
  padding: 0 !important;
  justify-content: center;
}

html:not([data-theme="lite"]) .tl-mem-nav-btn {
  color: #fbbf24 !important;
  background: color-mix(in srgb, #f59e0b 14%, var(--ios-fill-tertiary)) !important;
  border-color: color-mix(in srgb, #f59e0b 40%, var(--ios-glass-border)) !important;
}

/* Kill FOUC: never show mobile-only header controls on desktop */
@media (min-width: 769px) {
  .mob-hdr-btn,
  .tl-wheel-mob-btn {
    display: none !important;
  }
  .search-wheel-row {
    flex-wrap: nowrap !important;
    align-items: center !important;
  }
  .tl-wheel-nav-btn--inline {
    align-self: center !important;
    position: relative !important;
    top: auto !important;
  }
}

/* Mobile header: actions pinned to the trailing edge (not centered) */
@media (max-width: 768px) {
  html:not([data-theme="lite"]) body:not(.page-stream) .navbar-container {
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    align-items: center !important;
  }
  html:not([data-theme="lite"]) body:not(.page-stream) .navbar-container > .navbar-left,
  html:not([data-theme="lite"]) body:not(.page-stream) .navbar-container > .navbar-right {
    flex: 0 0 auto !important;
    width: auto !important;
  }
  /* Brand stays start; action cluster stays end */
  html[dir="rtl"]:not([data-theme="lite"]) body:not(.page-stream) .navbar-container > .navbar-left {
    margin-inline-start: auto !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 6px !important;
  }
  html[dir="ltr"]:not([data-theme="lite"]) body:not(.page-stream) .navbar-container > .navbar-right {
    margin-inline-start: auto !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 6px !important;
  }
  html:not([data-theme="lite"]) .navbar .tele-pill,
  html:not([data-theme="lite"]) .navbar .tl-mem-nav-btn,
  html:not([data-theme="lite"]) .navbar .mob-hdr-btn,
  html:not([data-theme="lite"]) .navbar .notification-bell {
    height: 34px !important;
    min-height: 34px !important;
  }
  html:not([data-theme="lite"]) .navbar .tl-mem-nav-btn,
  html:not([data-theme="lite"]) .navbar .mob-hdr-btn,
  html:not([data-theme="lite"]) .navbar .notification-bell {
    width: 34px !important;
    min-width: 34px !important;
  }
}

/* ========== Profile page (tl-*) ========== */
html:not([data-theme="lite"]) .tl-channel-bar,
html:not([data-theme="lite"]) .tl-bio-card,
html:not([data-theme="lite"]) .tl-vods-panel,
html:not([data-theme="lite"]) .tl-clips-panel,
html:not([data-theme="lite"]) .tl-about-right > div {
  border-radius: 16px !important;
  border-color: var(--ios-glass-border);
}
html:not([data-theme="lite"]) .tl-tab {
  border-radius: 999px !important;
}
html:not([data-theme="lite"]) .tl-tab.active {
  background: color-mix(in srgb, var(--ios-blue) 22%, transparent);
  color: var(--ios-blue);
}
html:not([data-theme="lite"]) .tl-live-hero,
html:not([data-theme="lite"]) .tl-offline-hero {
  border-radius: 18px;
  overflow: hidden;
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  html:not([data-theme="lite"]) .tl-channel-bar,
  html:not([data-theme="lite"]) .tl-bio-card {
    background: var(--ios-glass-bg-medium);
    backdrop-filter: blur(var(--ios-glass-blur-lg)) saturate(var(--ios-glass-saturate));
    -webkit-backdrop-filter: blur(var(--ios-glass-blur-lg)) saturate(var(--ios-glass-saturate));
    border: 1px solid var(--ios-glass-border);
  }
}

/* ========== /links page ========== */
html:not([data-theme="lite"]) .links-card {
  border-radius: 22px !important;
  border-color: var(--ios-glass-border) !important;
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  html:not([data-theme="lite"]) .links-card {
    background: var(--ios-glass-bg-large) !important;
    backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
    -webkit-backdrop-filter: blur(var(--ios-glass-blur-chrome)) saturate(var(--ios-glass-saturate));
  }
}
html:not([data-theme="lite"]) .links-pill,
html:not([data-theme="lite"]) .links-btn,
html:not([data-theme="lite"]) a.links-item,
html:not([data-theme="lite"]) .links-action,
html:not([data-theme="lite"]) .links-row {
  border-radius: 14px !important;
}

/* ========== /live (stream) chrome ========== */
html:not([data-theme="lite"]).page-stream .chat-panel,
html:not([data-theme="lite"]) body.page-stream .chat-panel,
html:not([data-theme="lite"]) body.page-stream .stream-info-bar,
html:not([data-theme="lite"]) body.page-stream .mob-info-bar {
  border-color: var(--ios-glass-border);
}
html:not([data-theme="lite"]) body.page-stream .chat-hdr-btn,
html:not([data-theme="lite"]) body.page-stream .si-mob-info-btn {
  border-radius: 999px !important;
  border: 1px solid var(--ios-glass-border);
  background: var(--ios-fill-tertiary);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  html:not([data-theme="lite"]) body.page-stream .chat-panel {
    background: var(--ios-material-regular);
    backdrop-filter: blur(var(--ios-glass-blur-md)) saturate(var(--ios-glass-saturate));
    -webkit-backdrop-filter: blur(var(--ios-glass-blur-md)) saturate(var(--ios-glass-saturate));
  }
}

/* ========== Pills / chips (legacy shared) ========== */
html:not([data-theme="lite"]) .tl-lang-trigger,
html:not([data-theme="lite"]) .tl-lang-trigger--guest,
html:not([data-theme="lite"]) .tl-lang-trigger--menu {
  border-radius: var(--ios-radius-pill) !important;
  border-color: var(--ios-glass-border) !important;
  background: var(--ios-fill-tertiary);
}

/* ========== Live badge / accent tint on glass ========== */
html:not([data-theme="lite"]) .tl-glass-chip--live,
html:not([data-theme="lite"]) .live-badge,
html:not([data-theme="lite"]) .tl-hero-live__live-badge {
  color: var(--ios-red);
}

html:not([data-theme="lite"]) .tl-glass-chip--blue {
  color: var(--ios-blue);
}

/* ========== Links ========== */
html:not([data-theme="lite"]) a.link,
html:not([data-theme="lite"]) .text-link,
html:not([data-theme="lite"]) .auth-link {
  color: var(--ios-blue);
}

/* ========== Theme-color meta sync helper (visual only) ========== */
html:not([data-theme="lite"]) {
  color-scheme: dark;
}
html[data-theme="light"]:not([data-theme="lite"]) {
  color-scheme: light;
}

/* ========== Reduced motion ========== */
@media (prefers-reduced-motion: reduce) {
  html:not([data-theme="lite"]) .btn,
  html:not([data-theme="lite"]) .stream-card,
  html:not([data-theme="lite"]) .tl-glass-surface,
  html:not([data-theme="lite"]) .tl-glass-panel,
  html:not([data-theme="lite"]) .tl-glass-chip {
    transition: none !important;
  }
  html:not([data-theme="lite"]) .stream-card:hover {
    transform: none;
  }
  html:not([data-theme="lite"]) .btn:active {
    transform: none;
  }
}

/* ========== Mobile perf: keep glass but lower blur cost ========== */
@media (max-width: 900px), (hover: none) and (pointer: coarse) {
  html:not([data-theme="lite"]) {
    --ios-glass-blur-chrome: 24px;
    --ios-glass-blur-lg: 10px;
    --ios-glass-blur-md: 8px;
    --ios-glass-saturate: 140%;
  }
}
