/* ==========================================================================
   QazHoster Telegram Mini App (TMA) - High-Performance Design System
   Continuous Responsive Continuum: 320px -> Foldables -> Tablets -> Desktop -> Ultrawide
   Zero CDN Dependencies · WCAG AAA / AA · 44px Touch Targets · 60/120fps GPU Animations
   ========================================================================== */

:root {
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Brand Colors & Accents */
  --color-primary: #0088cc;
  --color-primary-hover: #0077b5;
  --color-primary-subtle: rgba(0, 136, 204, 0.12);
  --color-primary-glow: rgba(0, 136, 204, 0.35);

  --color-gold: #d99b14;
  --color-gold-hover: #b8830f;
  --color-gold-subtle: rgba(217, 155, 20, 0.14);

  --color-success: #22c55e;
  --color-success-subtle: rgba(34, 197, 94, 0.12);
  --color-warning: #f59e0b;
  --color-warning-subtle: rgba(245, 158, 11, 0.14);
  --color-danger: #ef4444;
  --color-danger-subtle: rgba(239, 68, 68, 0.14);

  /* Signature Kazakhstan Flag Gradient */
  --rule-kazakh: linear-gradient(90deg, #0088cc 0%, #00a8f0 70%, #d99b14 70%, #d99b14 100%);

  /* Default Dark Mode (Optimized for OLED & Midnight) */
  --bg-app: #0e1621;
  --bg-surface: #17212b;
  --bg-surface-raised: #202b36;
  --bg-surface-sunken: #090e17;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.18);

  --text-main: #ffffff;
  --text-secondary: #c5d1e0;
  --text-muted: #8292a4;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-sheet: 0 -8px 32px rgba(0, 0, 0, 0.55);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Safe Area Insets for Mobile Notches, Home Indicators & Foldables */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* Light Mode Overrides */
[data-theme="light"] {
  --bg-app: #f4f6fa;
  --bg-surface: #ffffff;
  --bg-surface-raised: #edf2f7;
  --bg-surface-sunken: #e2e8f0;
  --border-subtle: rgba(13, 19, 28, 0.08);
  --border-strong: rgba(13, 19, 28, 0.18);

  --text-main: #0d131c;
  --text-secondary: #2b394e;
  --text-muted: #5e6f87;

  --shadow-sm: 0 2px 8px rgba(13, 19, 28, 0.06);
  --shadow-md: 0 8px 24px rgba(13, 19, 28, 0.09);
  --shadow-sheet: 0 -8px 32px rgba(13, 19, 28, 0.12);
}

/* Telegram theme variable passthrough when inside Telegram */
body.telegram-synced {
  --bg-app: var(--tg-theme-bg-color, var(--bg-app));
  --bg-surface: var(--tg-theme-secondary-bg-color, var(--bg-surface));
  --text-main: var(--tg-theme-text-color, var(--text-main));
  --text-muted: var(--tg-theme-hint-color, var(--text-muted));
  --color-primary: var(--tg-theme-button-color, var(--color-primary));
}

/* ==========================================================================
   Base Reset & Fluid Architecture
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100dvh;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

button, input, select {
  font: inherit;
  border: none;
  background: none;
  color: inherit;
}

button, a, .chip-btn, .nav-tab-btn, .btn-star, .promo-code-box {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: transform 0.1s ease, background-color 0.15s ease, opacity 0.15s ease;
}

button:active, a:active {
  transform: scale(0.97);
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ==========================================================================
   Header Bar (Sticky Top)
   ========================================================================== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: max(var(--safe-top), 10px) 16px 12px 16px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  width: 100%;
}

.header-inner {
  max-width: 1140px;
  margin: 0 auto;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--rule-kazakh);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 2px 8px var(--color-primary-glow);
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: clamp(15px, 3.5vw, 18px);
  font-weight: 800;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  background-color: var(--color-primary-subtle);
  color: var(--color-primary);
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-icon {
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 700;
}

@media (hover: hover) and (pointer: fine) {
  .btn-icon:hover {
    background-color: var(--border-subtle);
    color: var(--text-main);
  }
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  background-color: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 38px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background-color: var(--color-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Search Row */
.header-search {
  margin-top: 10px;
  position: relative;
}

.search-input {
  width: 100%;
  height: 44px;
  background-color: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 42px 0 40px;
  font-size: 14px;
  color: var(--text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 16px;
}

.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 36px;
  min-height: 36px;
  color: var(--text-muted);
  font-size: 18px;
  display: none;
}

.search-clear.visible {
  display: flex;
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */

.app-main {
  flex: 1;
  padding: 16px 16px calc(var(--safe-bottom) + 84px) 16px;
  max-width: 1140px;
  margin: 0 auto;
  width: 100%;
}

.tab-pane {
  display: none;
  contain: content;
}

.tab-pane.active {
  display: block;
  animation: paneFadeIn 0.18s ease-out;
}

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

/* ==========================================================================
   Home Screen Components
   ========================================================================== */

/* Live Stats Strip */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  text-align: center;
  min-width: 0;
}

.stat-value {
  font-size: clamp(18px, 4.5vw, 24px);
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1.1;
  font-family: var(--font-mono);
}

.stat-label {
  font-size: clamp(10px, 2.5vw, 12px);
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 600;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Quick Filter Chips (Horizontal Scrollable with Momentum) */
.filter-chips-container {
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px 16px -16px;
  padding: 0 16px;
}

.filter-chips-container::-webkit-scrollbar {
  display: none;
}

.filter-chips {
  display: flex;
  gap: 8px;
  width: max-content;
}

.chip-btn {
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  gap: 6px;
}

.chip-btn.active {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--color-primary-glow);
}

@media (hover: hover) and (pointer: fine) {
  .chip-btn:not(.active):hover {
    border-color: var(--border-strong);
    color: var(--text-main);
  }
}

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Banner Card */
.promo-banner {
  background: linear-gradient(135deg, rgba(0, 136, 204, 0.16) 0%, rgba(217, 155, 20, 0.16) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.promo-banner-text h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}

.promo-banner-text p {
  font-size: 12px;
  color: var(--text-secondary);
}

.promo-banner-btn {
  height: 44px;
  padding: 0 16px;
  background-color: var(--color-primary);
  color: #ffffff;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ==========================================================================
   Continuous Responsive Grid for Plans
   ========================================================================== */

.plans-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

/* Foldables unfolded / Tablets portrait (>= 580px) */
@media (min-width: 580px) {
  .plans-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Laptops / Desktops / Ultrawide (>= 980px) */
@media (min-width: 980px) {
  .plans-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.plan-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  contain: content;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
  .plan-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
  }
}

.plan-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.plan-title-wrap {
  flex: 1;
  min-width: 0;
}

.plan-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-provider {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 1px;
}

.btn-star {
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 20px;
  flex-shrink: 0;
  transition: color 0.15s ease, transform 0.15s ease;
}

.btn-star svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-muted);
  fill: none;
  transition: stroke 0.15s ease, fill 0.15s ease, transform 0.15s ease;
}

.btn-star.active {
  color: var(--color-gold);
}

.btn-star.active svg {
  stroke: var(--color-gold);
  fill: var(--color-gold);
}

.plan-specs-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.spec-pill {
  font-size: 12px;
  font-weight: 600;
  background-color: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.spec-pill.highlight {
  background-color: var(--color-primary-subtle);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.spec-pill.success {
  background-color: var(--color-success-subtle);
  color: var(--color-success);
}

.spec-pill.warning {
  background-color: var(--color-warning-subtle);
  color: var(--color-warning);
}

.plan-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
  margin-top: 8px;
  gap: 8px;
}

.plan-price-wrap {
  display: flex;
  flex-direction: column;
}

.plan-price-amount {
  font-size: 18px;
  font-weight: 800;
  color: var(--color-primary);
  font-family: var(--font-mono);
}

.plan-price-period {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.plan-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-plan-details {
  height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
}

.btn-plan-order {
  height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  background-color: var(--color-primary);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
  box-shadow: 0 2px 8px var(--color-primary-glow);
  white-space: nowrap;
}

/* ==========================================================================
   Promotions Screen (Promos)
   ========================================================================== */

.promos-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) {
  .promos-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.promo-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.promo-provider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.promo-prov-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.promo-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--text-main);
}

.promo-benefit {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.promo-code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-surface-raised);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-bottom: 12px;
  min-height: 48px;
}

.promo-code-text {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--color-primary);
}

.promo-copy-hint {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-promo-go {
  width: 100%;
  height: 44px;
  border-radius: var(--radius-md);
  background-color: var(--color-success);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  gap: 6px;
}

/* ==========================================================================
   Providers Screen
   ========================================================================== */

.providers-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) {
  .providers-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.provider-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.prov-info h3 {
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.prov-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.prov-rating {
  font-weight: 700;
  color: var(--color-gold);
}

/* ==========================================================================
   Favorites & Responsive Comparison Matrix
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: 48px 16px;
  background-color: var(--bg-surface);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
}

.empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 14px auto;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-raised);
  color: var(--text-muted);
}

.empty-icon svg {
  width: 28px;
  height: 28px;
}

.empty-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 320px;
  margin: 0 auto 16px auto;
}

/* Dense Comparison Table with Sticky Left Key Column */
.compare-matrix-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  margin-bottom: 16px;
  position: relative;
}

.compare-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.compare-table th, .compare-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  white-space: nowrap;
}

.compare-table th {
  background-color: var(--bg-surface-raised);
  font-weight: 700;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
}

/* 2D Sticky Headers: First Column Sticks Horizontally */
.compare-table th:first-child,
.compare-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background-color: var(--bg-surface-raised);
  border-right: 1px solid var(--border-strong);
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.12);
  font-weight: 700;
}

.compare-table thead th:first-child {
  z-index: 3;
}

/* ==========================================================================
   Bottom Navigation Bar (Fixed / Fluid)
   ========================================================================== */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 6px 12px max(var(--safe-bottom), 8px) 12px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

/* Hide navigation smoothly when mobile virtual keyboard is open */
body.keyboard-open .bottom-nav {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

.nav-tabs {
  display: flex;
  align-items: center;
  justify-content: space-around;
  max-width: 680px;
  margin: 0 auto;
}

.nav-tab-btn {
  flex: 1;
  min-height: 48px;
  min-width: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  position: relative;
  border-radius: var(--radius-md);
}

.nav-tab-btn .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  transition: transform 0.15s ease;
}

.nav-tab-btn .nav-icon svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-muted);
  transition: stroke 0.15s ease;
}

.nav-tab-btn.active {
  color: var(--color-primary);
}

.nav-tab-btn.active .nav-icon {
  transform: translateY(-2px);
}

.nav-tab-btn.active .nav-icon svg {
  stroke: var(--color-primary);
}

.svg-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.btn-lang-badge {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 0 10px;
}

.nav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 16px);
  background-color: var(--color-danger);
  color: #ffffff;
  font-size: 9px;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ==========================================================================
   Bottom Sheet Modal (Plan Details) - GPU Accelerated
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease;
  will-change: opacity;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 210;
  background-color: var(--bg-surface);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  border-top: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sheet);
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
  contain: layout style paint;
  padding-bottom: max(var(--safe-bottom), 16px);
}

/* Centered modal presentation on large desktop */
@media (min-width: 800px) {
  .bottom-sheet {
    max-width: 600px;
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(100%);
    border-radius: 20px;
    bottom: 24px;
    border: 1px solid var(--border-strong);
  }
  .bottom-sheet.open {
    transform: translateX(-50%) translateY(0);
  }
}

.bottom-sheet.open {
  transform: translateY(0);
}

.sheet-handle-wrap {
  padding: 12px 0 6px 0;
  display: flex;
  justify-content: center;
  cursor: grab;
  touch-action: none;
}

.sheet-handle {
  width: 44px;
  height: 5px;
  border-radius: var(--radius-full);
  background-color: var(--border-strong);
}

.sheet-header {
  padding: 10px 18px 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-header h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-close-btn {
  min-width: 44px;
  min-height: 44px;
  font-size: 20px;
  color: var(--text-muted);
}

.sheet-content {
  padding: 16px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.spec-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.spec-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background-color: var(--bg-surface-raised);
  border-radius: var(--radius-md);
  font-size: 14px;
}

.spec-item-label {
  color: var(--text-muted);
  font-weight: 500;
}

.spec-item-val {
  font-weight: 700;
  color: var(--text-main);
}

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.sheet-actions .btn-primary {
  flex: 1;
  height: 48px;
  border-radius: var(--radius-md);
  background-color: var(--color-primary);
  color: #ffffff;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 4px 12px var(--color-primary-glow);
}

/* ==========================================================================
   Skeleton Shimmer Placeholders (Zero-CLS Instant Shell)
   ========================================================================== */

.skeleton-shimmer {
  background: linear-gradient(
    90deg,
    var(--bg-surface-raised) 25%,
    var(--border-strong) 50%,
    var(--bg-surface-raised) 75%
  );
  background-size: 200% 100%;
  animation: skeletonWave 1.4s infinite linear;
  border-radius: var(--radius-sm);
}

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

/* ==========================================================================
   Toast Notification
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 80px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 300;
  background-color: var(--text-main);
  color: var(--bg-app);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 90%;
  white-space: nowrap;
}

.toast-container.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   Landscape Compact Mode & Reduced Motion Accessibility
   ========================================================================== */

@media (orientation: landscape) and (max-height: 520px) {
  .app-header {
    padding: max(var(--safe-top), 4px) 14px 6px 14px;
  }
  .header-search {
    margin-top: 6px;
  }
  .search-input {
    height: 38px;
  }
  .app-main {
    padding-bottom: calc(var(--safe-bottom) + 64px);
  }
  .nav-tab-btn {
    min-height: 40px;
  }
  .bottom-sheet {
    max-height: 94dvh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .bottom-sheet {
    transition: none !important;
  }
}
