/**
 * Mobile Polish CSS - Robinhood-Style UX
 *
 * Implements:
 * - Hidden scrollbars
 * - Bottom navigation
 * - Typography scale
 * - Smooth interactions
 * - Card redesigns
 */


/* =============================================================================
   1. SCROLLBAR HIDING (Universal)
   ============================================================================= */

@media (max-width: 768px) {
  /* Hide scrollbars universally */
  * {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
  }

  *::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
    width: 0;
    height: 0;
  }

  /* Ensure smooth scrolling */
  html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }

  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
  }

  body {
    overflow-x: clip;
    overflow-y: visible;
    overscroll-behavior-y: contain;
    background-attachment: scroll !important;
  }

  .chat-header,
  .back-btn,
  .back-button,
  [aria-label="Go back"],
  .quick-action-btn,
  .toast,
  .search-suggestions,
  .autocomplete-dropdown {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  /* TASK 79: the old "overflow-y: auto" on main (616620023b, came with the bottom nav deleted 09-15)
     is gone. main never scrolled (height:auto), but an overflow:auto box still becomes the scrollport
     of every position:sticky inside it, so no in-main sticky bar could stick on phones. The document
     scrolls; main keeps overflow-x: clip from base_content.html, which is not a scroll container.
     Do not give main an overflow-y other than visible again. */

  /* Hide navigation tabs (MARKETS, CREATE, DROPSHIP42) on mobile */
  .terminal-nav {
    display: none !important;
  }

  /* Blue haze removed — EVE-13147/13146 (3rd report) */
  .chat-avatar {
    animation: none !important;
    box-shadow: none !important;
  }

  .chat-avatar svg circle {
    stroke-opacity: 0.5 !important;
    fill-opacity: 0.1 !important;
  }

  /* Hide filter buttons (ALL, CRYPTO, STOCKS) on mobile */
  .filter-controls {
    display: none !important;
  }

  /* Adjust "ACTIVE PREDICTION MARKETS" text size on mobile */
  .section-title {
    font-size: 0.875rem !important;
  }

  /* Decrease "Event Trader" header label by 30% on mobile (1.6rem -> 1.12rem) */
  .terminal-logo {
    font-size: 1.12rem !important;
  }

  .terminal-logo .glitch,
  .terminal-logo .futures {
    font-size: 1em !important;
  }
}


/* =============================================================================
   2. CSS VARIABLES FOR MOBILE
   ============================================================================= */

:root {
  /* Spacing */
  --mobile-space-xs: 4px;
  --mobile-space-sm: 8px;
  --mobile-space-md: 16px;
  --mobile-space-lg: 24px;
  --mobile-space-xl: 32px;
  --mobile-space-2xl: 48px;

  /* Typography */
  --mobile-font-hero: 32px;
  --mobile-font-h1: 28px;
  --mobile-font-h2: 22px;
  --mobile-font-h3: 18px;
  --mobile-font-body: 16px;
  --mobile-font-small: 14px;
  --mobile-font-tiny: 12px;

  /* Bottom nav height */
  --bottom-nav-height: 64px;

  /* Safe area for notch devices */
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}


/* =============================================================================
   3. TYPOGRAPHY SCALE (Mobile) - iOS HIG & Material Design 3 Compliant
   ============================================================================= */

@media (max-width: 768px) {
  /*
   * Typography Standards (iOS HIG + Material Design 3):
   * - Minimum line-height: 1.4x (140%) for readability
   * - Paragraph spacing: 8px minimum
   * - Section margins: 16px minimum
   * - Heading top margins: 16px+ for visual hierarchy
   */

  /* Hero text */
  .text-hero,
  .hero-title {
    font-size: var(--mobile-font-hero) !important;
    font-weight: 700;
    line-height: 1.4 !important; /* iOS HIG minimum */
    letter-spacing: -0.5px;
    margin-top: 24px;
    margin-bottom: 16px;
  }

  /* H1 - Main headings */
  h1,
  .text-h1 {
    font-size: var(--mobile-font-h1) !important;
    font-weight: 700;
    line-height: 1.4 !important; /* iOS HIG minimum */
    letter-spacing: -0.3px;
    margin-top: 24px;
    margin-bottom: 12px;
  }

  /* H2 - Section headings (exclude .ec-card-title — event card titles
     have their own responsive sizing in event-cards.css) */
  h2:not(.ec-card-title),
  .text-h2 {
    font-size: var(--mobile-font-h2) !important;
    font-weight: 600;
    line-height: 1.4 !important; /* iOS HIG minimum */
    margin-top: 20px;
    margin-bottom: 10px;
  }

  /* H3 - Subsection headings */
  h3,
  .text-h3 {
    font-size: var(--mobile-font-h3) !important;
    font-weight: 600;
    line-height: 1.45 !important;
    margin-top: 18px;
    margin-bottom: 8px;
  }

  /* H4-H6 - Minor headings */
  h4, h5, h6,
  .text-h4, .text-h5, .text-h6 {
    line-height: 1.5 !important;
    margin-top: 16px;
    margin-bottom: 8px;
  }

  /* Body text */
  p,
  .text-body {
    font-size: var(--mobile-font-body);
    line-height: 1.6 !important; /* Optimal body text readability */
    margin-bottom: 12px; /* Paragraph spacing minimum 8px */
  }

  /* Inline elements inherit but don't force margins */
  span {
    line-height: inherit;
  }

  /* Small text - still readable */
  .text-small,
  small,
  .caption {
    font-size: var(--mobile-font-small) !important;
    line-height: 1.5 !important;
  }

  /* Tiny text - minimum readable */
  .text-tiny,
  .label {
    font-size: var(--mobile-font-tiny) !important;
    line-height: 1.5 !important;
  }

  /* Lists with proper spacing */
  ul, ol {
    line-height: 1.6;
    margin-bottom: 12px;
  }

  li {
    line-height: 1.6;
    margin-bottom: 6px;
  }

  /* Code blocks with readability */
  code, pre {
    line-height: 1.5 !important;
  }
}


/* =============================================================================
   4. BOTTOM NAVIGATION BAR
   ============================================================================= */

.mobile-bottom-nav {
  display: none; /* Hidden on desktop */
}

@media (max-width: 768px) {
  /* Bottom nav hidden — duplicates hamburger menu and overlaps nexus chat input (EVE-11542) */
  .mobile-bottom-nav {
    display: none !important;
  }

  .mobile-bottom-nav a,
  .mobile-bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(180, 200, 220, 0.7); /* Brighter for visibility */
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    /* Increase touch target to iOS minimum 44x44px */
    padding: 6px 8px;
    min-width: 48px;
    min-height: 44px;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
    border-radius: var(--panel-radius);
    /* Reset button styles */
    background: transparent;
    border: none;
    cursor: pointer;
    /* Prevent text selection on touch */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  /* Remove focus outlines on mobile to prevent white squares */
  .mobile-bottom-nav a:focus,
  .mobile-bottom-nav button:focus,
  .mobile-bottom-nav a:focus-visible,
  .mobile-bottom-nav button:focus-visible {
    outline: none;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-bottom-nav a:active,
  .mobile-bottom-nav button:active {
    transform: scale(0.95);
    background: rgba(0, 207, 255, 0.1);
  }

  .mobile-bottom-nav a.active {
    color: var(--accent-cyan, #00cfff);
  }

  .mobile-bottom-nav a.active svg {
    filter: drop-shadow(0 0 6px rgba(0, 207, 255, 0.6));
  }

  .mobile-bottom-nav svg {
    width: 20px;
    height: 20px;
    margin-bottom: 2px;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
  }

  .mobile-bottom-nav .nav-label {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.3px;
    line-height: 1.2;
    white-space: nowrap;
    color: rgba(220, 235, 250, 0.95); /* High contrast white-blue for readability */
  }

  /* Center "Trade" button - special styling */
  .mobile-bottom-nav .nav-trade {
    position: relative;
    margin-top: -20px;
    display: none !important; /* Hide quick trade button on mobile */
  }

  .mobile-bottom-nav .nav-trade .trade-btn {
    width: 56px;
    height: 56px;
    background: linear-gradient(
      145deg,
      rgba(0, 40, 70, 0.85) 0%,
      rgba(0, 70, 100, 0.7) 50%,
      rgba(0, 40, 70, 0.85) 100%
    );
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 25px rgba(0, 120, 180, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(0, 180, 220, 0.5);
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
  }

  .mobile-bottom-nav .nav-trade .trade-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(
      from 0deg,
      transparent 0deg,
      rgba(0, 200, 255, 0.15) 60deg,
      transparent 120deg
    );
    animation: holoRotate 3s linear infinite;
  }

  @keyframes holoRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
  }

  .mobile-bottom-nav .nav-trade .trade-btn:active {
    transform: scale(0.9);
    box-shadow: 0 0 35px rgba(0, 160, 220, 0.5);
  }

  .mobile-bottom-nav .nav-trade svg {
    color: var(--text-heading, #ffffff);
    width: 28px;
    height: 28px;
    margin-bottom: 0;
  }

  .mobile-bottom-nav .nav-trade .nav-label {
    position: absolute;
    bottom: -16px;
    color: var(--accent-cyan, #00cfff);
    font-weight: 600;
  }

}


/* =============================================================================
   5. MOBILE HERO SECTION
   ============================================================================= */

@media (max-width: 768px) {
  .mobile-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: var(--mobile-space-xl) var(--mobile-space-md);
    text-align: center;
    background: linear-gradient(180deg, rgba(10, 10, 15, 0.9) 0%, transparent 100%);
  }

  .mobile-hero-title {
    font-size: var(--mobile-font-hero);
    font-weight: 700;
    color: var(--text-heading, #ffffff);
    margin-bottom: var(--mobile-space-sm);
    line-height: 1.1;
  }

  .mobile-hero-title .highlight {
    color: var(--accent-cyan, #00cfff);
  }

  .mobile-hero-subtitle {
    font-size: var(--mobile-font-body);
    color: #8b95a8;
    margin-bottom: var(--mobile-space-xl);
    max-width: 300px;
  }

  .mobile-hero-cta {
    width: 100%;
    max-width: 280px;
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 600;
    background: linear-gradient(135deg, #00cfff, #0099cc);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--panel-radius);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 4px 20px var(--accent-glow);
  }

  .mobile-hero-cta:active {
    transform: scale(0.98);
  }

  .mobile-hero-secondary {
    display: flex;
    gap: var(--mobile-space-md);
    margin-top: var(--mobile-space-lg);
  }

  .mobile-hero-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--mobile-space-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border-hover);
    border-radius: var(--panel-radius);
    color: var(--text-heading, #ffffff);
    text-decoration: none;
    min-width: 100px;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
  }

  .mobile-hero-btn:active {
    background: rgba(0, 207, 255, 0.1);
    transform: scale(0.98);
  }

  .mobile-hero-btn svg {
    width: 32px;
    height: 32px;
    margin-bottom: 8px;
    color: var(--accent-cyan, #00cfff);
  }

  .mobile-hero-btn span {
    font-size: 14px;
    font-weight: 500;
  }
}


/* =============================================================================
   6. MOBILE MARKET CARDS
   ============================================================================= */

@media (max-width: 768px) {
  .market-card-mobile {
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.95), rgba(20, 20, 35, 0.98));
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: var(--mobile-space-lg);
    margin-bottom: var(--mobile-space-md);
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
  }

  .market-card-mobile:active {
    transform: scale(0.99);
    border-color: var(--panel-border-hover);
  }

  .market-card-mobile .card-category {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-cyan, #00cfff);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--mobile-space-sm);
  }

  .market-card-mobile .card-title {
    font-size: var(--mobile-font-h3);
    font-weight: 600;
    color: var(--text-heading, #ffffff);
    margin-bottom: var(--mobile-space-md);
    line-height: 1.3;
  }

  .market-card-mobile .probability-section {
    margin-bottom: var(--mobile-space-md);
  }

  .market-card-mobile .probability-row {
    display: flex;
    align-items: center;
    margin-bottom: var(--mobile-space-sm);
  }

  .market-card-mobile .probability-label {
    width: 40px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-heading, #ffffff);
  }

  .market-card-mobile .probability-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 12px;
  }

  .market-card-mobile .probability-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
  }

  .market-card-mobile .probability-fill.yes {
    background: linear-gradient(90deg, #00cfff, #0099cc);
  }

  .market-card-mobile .probability-fill.no {
    background: linear-gradient(90deg, #ff6b6b, #ff4757);
  }

  .market-card-mobile .probability-value {
    width: 45px;
    font-size: 14px;
    font-weight: 600;
    text-align: right;
  }

  .market-card-mobile .card-stats {
    font-size: 13px;
    color: #a8b0b8; /* Improved contrast from #888 */
    margin-bottom: var(--mobile-space-md);
  }

  .market-card-mobile .card-stats span {
    margin-right: 16px;
  }

  .market-card-mobile .trade-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    background: transparent;
    border: 2px solid #00cfff;
    color: var(--accent-cyan, #00cfff);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
  }

  .market-card-mobile .trade-btn:active {
    background: #00cfff;
    color: var(--bg-primary);
  }
}


/* =============================================================================
   7. TRENDING SECTION (Mobile)
   ============================================================================= */

@media (max-width: 768px) {
  .mobile-trending {
    padding: var(--mobile-space-lg) var(--mobile-space-md);
  }

  .mobile-trending-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--mobile-space-md);
  }

  .mobile-trending-title {
    font-size: var(--mobile-font-h3);
    font-weight: 600;
    color: var(--text-heading, #ffffff);
  }

  .mobile-trending-title::before {
    content: '🔥';
    margin-right: 8px;
  }

  .mobile-trending-see-all {
    font-size: 14px;
    color: var(--accent-cyan, #00cfff);
    text-decoration: none;
  }
}


/* =============================================================================
   8. BUTTONS & TOUCH TARGETS - iOS HIG 44pt Minimum Compliance
   ============================================================================= */

@media (max-width: 768px) {
  /*
   * iOS Human Interface Guidelines (HIG) Requirements:
   * - Minimum touch target size: 44pt x 44pt
   * - Recommended touch target: 48px for better UX
   * - Adequate spacing between targets: 8px minimum
   */

  /* Ensure ALL interactive elements meet 44x44 minimum */
  /* Note: Avoid forcing display properties to prevent breaking click handlers */
  /* touch-action: manipulation is now global on html — no per-element rules needed */
  button,
  .btn,
  a.btn,
  [role="button"],
  input[type="submit"],
  input[type="button"],
  .clickable,
  .tappable {
    min-height: 48px;
    min-width: 48px;
    cursor: pointer;
  }

  /* All anchor links need adequate touch targets */
  a {
    min-height: 44px;
  }

  /* Navigation links need larger targets */
  nav a,
  .nav-link,
  .menu-item,
  header a,
  footer a {
    min-height: 48px;
    min-width: 48px;
  }

  /* Card action buttons */
  .card a,
  .card button,
  .feature-card a,
  .command-card a {
    min-height: 44px;
  }

  /* Icon buttons need explicit sizing */
  .icon-btn,
  .btn-icon,
  button[aria-label],
  a[aria-label] {
    min-height: 48px;
    min-width: 48px;
  }

  /* Social links and icon-only links (not footer-bar — it has its own sizing) */
  .social-link:not(.footer-bar .social-link),
  .icon-link {
    min-height: 44px;
    min-width: 44px;
  }

  /* Primary button */
  .btn-primary,
  .btn-cta {
    background: linear-gradient(135deg, #00cfff, #0099cc);
    color: var(--bg-primary);
    border: none;
    font-weight: 600;
    box-shadow: 0 4px 15px var(--accent-glow);
    min-height: 52px; /* Slightly larger for primary CTA */
  }

  .btn-primary:active,
  .btn-cta:active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px var(--accent-glow);
  }

  /* Secondary button */
  .btn-secondary {
    background: transparent;
    color: var(--accent-cyan, #00cfff);
    border: 2px solid #00cfff;
    font-weight: 600;
    min-height: 48px;
  }

  .btn-secondary:active {
    background: rgba(0, 207, 255, 0.1);
  }

  /* Ghost button */
  .btn-ghost {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-heading, #ffffff);
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 48px;
  }

  .btn-ghost:active {
    background: rgba(255, 255, 255, 0.1);
  }

  /* Small buttons still meet minimum */
  .btn-sm,
  .btn-small {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 16px;
    font-size: 14px;
  }

  /* Inline text links in paragraphs */
  p a,
  .text-body a,
  li a {
    min-height: 44px;
  }
}


/* =============================================================================
   9. FORM INPUTS (Mobile)
   ============================================================================= */

@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  input[type="search"],
  textarea,
  select {
    width: 100%;
    min-height: 48px;
    padding: 14px 16px;
    /* font-size 16px lives in mobile-responsive.css (the one input rule, TASK 31) */
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--panel-border-hover);
    border-radius: 10px;
    color: var(--text-heading, #ffffff);
    outline: none;
    transition: border-color 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
  }

  input:focus,
  textarea:focus,
  select:focus {
    border-color: var(--accent-cyan, #00cfff);
    box-shadow: 0 0 0 3px var(--accent-glow);
  }

  input::placeholder,
  textarea::placeholder {
    color: rgba(0,207,255,0.72); /* Improved contrast from #666 */
  }

  /* Form labels */
  label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #8b95a8;
    margin-bottom: 8px;
  }

  /* Form groups */
  .form-group {
    margin-bottom: var(--mobile-space-md);
  }

  /*
   * P1 FIX: Keyboard handling for modals
   * Scroll input into view when focused to prevent keyboard from obscuring
   */
  .modal input:focus,
  .bottom-sheet input:focus,
  .dialog input:focus,
  [role="dialog"] input:focus {
    scroll-margin-bottom: 200px;
  }

  /* Auto-scroll focused inputs into view */
  input:focus,
  textarea:focus,
  select:focus {
    scroll-margin-top: 100px;
    scroll-margin-bottom: 250px;
  }
}

/* =============================================================================
   9.1 P1 FIXES: TOUCH TARGETS & ACCESSIBILITY
   ============================================================================= */

@media (max-width: 768px) {
  /*
   * P1 FIX: Asset selection buttons need larger touch targets
   * Issue: Asset icons and amount buttons under 44x44px minimum
   */
  .asset-btn,
  .asset-icon,
  .asset-selector,
  .token-btn,
  .token-icon,
  .coin-btn,
  .crypto-btn {
    min-height: 48px;
    min-width: 48px;
    padding: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /*
   * P1 FIX: Amount preset buttons (e.g., $10, $25, $50, $100)
   */
  .amount-btn,
  .preset-btn,
  .quick-amount,
  .amount-preset,
  [data-amount] {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 16px;
  }

  /*
   * P1 FIX: Orderbook rows need larger tap areas
   * Issue: Data-dense rows hard to tap accurately
   */
  .orderbook-row,
  .order-row,
  .trade-row,
  .book-row,
  tr.clickable,
  .data-row {
    min-height: 48px;
    padding: 12px 8px;
  }

  /* Orderbook price/size cells need padding for touch */
  .orderbook-row td,
  .orderbook-row th,
  .order-row td,
  .book-row td {
    padding: 14px 8px;
  }

  /*
   * P1 FIX: Tab buttons and segmented controls
   */
  .tab,
  .tab-btn,
  .segment,
  .segment-btn,
  [role="tab"] {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
  }

  /*
   * P1 FIX: Close buttons and dismiss actions
   */
  .close-btn,
  .dismiss-btn,
  .modal-close,
  [aria-label="Close"],
  [aria-label="Dismiss"] {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /*
   * P1 FIX: Slider/range inputs need larger touch areas
   */
  input[type="range"] {
    height: 44px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
  }

  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-cyan, #00cfff);
    cursor: pointer;
  }

  /*
   * P1 FIX: Checkbox and radio inputs
   */
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 44px;
    min-height: 44px;
    margin: 0;
    padding: 10px;
  }

  /* Wrapper for checkbox/radio with label */
  .checkbox-wrapper,
  .radio-wrapper,
  label:has(input[type="checkbox"]),
  label:has(input[type="radio"]) {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
  }
}

/* =============================================================================
   9.2 P1 FIX: ARIA & ACCESSIBILITY ENHANCEMENTS
   ============================================================================= */

/* Focus visible — removed global cyan outline */
@media (max-width: 768px) {

  /* Screen reader only text */
  .sr-only,
  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* Live region announcements */
  [aria-live] {
    position: relative;
  }

  /* Ensure disabled states are visually distinct */
  [disabled],
  [aria-disabled="true"],
  .disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
  }

  /* Loading states should be announced */
  [aria-busy="true"] {
    cursor: wait;
  }
}


/* =============================================================================
   9.3 P2 FIXES: LAYOUT, NAVIGATION & CONTENT
   ============================================================================= */

@media (max-width: 768px) {
  /*
   * P2 FIX: Prevent horizontal overflow on tables and orderbook
   * Issue: Orderbook table overflows on narrow screens
   */
  .orderbook,
  .orderbook-container,
  .order-book,
  .trades-table,
  .data-table,
  table {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    /* y stays hidden: an auto y axis makes the table a vertical scroller
       that swallows touch scrolling of the page (ET-33595) */
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    display: block;
  }

  /* Ensure table cells don't cause overflow */
  .orderbook td,
  .orderbook th,
  .trades-table td,
  .trades-table th,
  table td,
  table th {
    white-space: nowrap;
    padding: 8px 6px;
    font-size: 12px;
  }

  /* Scrollable table wrapper */
  .table-scroll,
  .scroll-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }

  /*
   * P2 FIX: Active state indicator for navigation
   * Issue: No clear active state in bottom navigation
   */
  nav a.active,
  .nav-link.active,
  .nav-item.active,
  [role="navigation"] a[aria-current="page"],
  .bottom-nav a.active,
  .tab-nav .active {
    color: var(--accent-cyan, #00cfff) !important;
    border-bottom: 2px solid var(--accent-cyan, #00cfff);
    font-weight: 600;
  }

  /* Bottom navigation active indicator */
  .bottom-nav a.active::after,
  .mobile-nav a.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--accent-cyan, #00cfff);
    border-radius: 50%;
  }

  /*
   * P2 FIX: Back navigation for detail pages
   * Issue: Missing back navigation from event detail pages
   */
  .back-btn,
  .back-button,
  .nav-back,
  [aria-label="Go back"] {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: var(--z-dropdown);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-heading, #ffffff);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .back-btn:active,
  .back-button:active {
    background: rgba(0, 207, 255, 0.2);
  }

  /*
   * P2 FIX: Hero image layout shift prevention
   * Issue: Large hero image may cause layout shift
   */
  .hero-image,
  .banner-image,
  .featured-image,
  .market-image {
    aspect-ratio: 16 / 9;
    width: 100%;
    height: auto;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.05);
  }

  /* Placeholder for loading images */
  .hero-image[data-src],
  img[loading="lazy"] {
    background: linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.03) 25%,
      rgba(255, 255, 255, 0.08) 50%,
      rgba(255, 255, 255, 0.03) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
  }

  /*
   * P2 FIX: Improve contrast for grey text
   * Issue: Contrast issues with grey text elements
   * WCAG AA requires 4.5:1 for normal text, 3:1 for large text
   */
  .text-muted,
  .text-secondary,
  .text-grey,
  .subtitle,
  .meta,
  .timestamp,
  .helper-text,
  small {
    color: #8b95a1 !important;
  }

  /* Ensure label text has sufficient contrast */
  label,
  .label,
  .form-label {
    color: #b0b0b0;
  }

  /* Price change indicators need good contrast */
  .price-up,
  .positive,
  .gain {
    color: #00e676 !important; /* Bright green for accessibility */
  }

  .price-down,
  .negative,
  .loss {
    color: #ff5252 !important; /* Bright red for accessibility */
  }
}

/* =============================================================================
   9.4 P2 FIX: CRYPTO TERM TOOLTIPS
   ============================================================================= */

/* Tooltip for crypto-native terms (USDC, Epoch, etc.) */
.crypto-term,
.term-tooltip,
[data-tooltip] {
  position: relative;
  cursor: help;
  border-bottom: 1px dotted rgba(255, 255, 255, 0.3);
}

.crypto-term::after,
.term-tooltip::after,
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: var(--text-heading, #ffffff);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: var(--z-tooltip);
  pointer-events: none;
}

/* Show tooltip on focus (for keyboard) and touch/hover */
.crypto-term:focus::after,
.crypto-term:hover::after,
.term-tooltip:focus::after,
.term-tooltip:hover::after,
[data-tooltip]:focus::after,
[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
}

@media (max-width: 768px) {
  /* On mobile, show tooltip on tap (via :focus) */
  .crypto-term,
  .term-tooltip,
  [data-tooltip] {
    -webkit-tap-highlight-color: transparent;
  }

  .crypto-term:focus,
  .term-tooltip:focus,
  [data-tooltip]:focus {
    outline: none;
  }

  /* Ensure tooltip doesn't overflow viewport */
  .crypto-term::after,
  .term-tooltip::after,
  [data-tooltip]::after {
    max-width: 200px;
    white-space: normal;
    text-align: center;
  }
}

/* =============================================================================
   9.5 P2 FIX: ARIA-LIVE REGIONS FOR PRICE UPDATES
   ============================================================================= */

/* Live price updates should be announced to screen readers */
.price-live,
.live-price,
[aria-live="polite"],
.price-update {
  /* Visual indicator for live content */
  position: relative;
}

/* Pulsing dot for live prices */
.price-live::before,
.live-indicator::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #00e676;
  border-radius: 50%;
  margin-right: 6px;
  animation: live-pulse 2s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Screen reader announcements for price changes */
.sr-announce {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* =============================================================================
   10. LOADING SKELETONS
   ============================================================================= */

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.03) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 8px;
}

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

.skeleton-card {
  height: 200px;
  margin-bottom: var(--mobile-space-md);
  border-radius: 16px;
}

.skeleton-text {
  height: 16px;
  margin-bottom: var(--mobile-space-sm);
  border-radius: 4px;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }
.skeleton-text.long { width: 100%; }

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

/* Page Loading Indicator - Shows during initial page load */
.page-loading {
  position: fixed;
  inset: 0;
  background: var(--bg-primary, #080a13);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: var(--z-max);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.page-loading.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.page-loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-cyan, #00cfff);
  border-radius: 50%;
  animation: page-spin 0.8s linear infinite;
}

.page-loading-text {
  margin-top: 16px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--font-mono, monospace);
}

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

/* Content Loading State - For async content areas */
.content-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  min-height: 200px;
}

.content-loading-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-cyan, #00cfff);
  border-radius: 50%;
  animation: page-spin 0.8s linear infinite;
}

.content-loading-text {
  margin-top: 12px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
}

/* Inline Loading Spinner */
.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.loading-inline-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: page-spin 0.8s linear infinite;
}


/* =============================================================================
   11. ERROR & EMPTY STATES
   ============================================================================= */

@media (max-width: 768px) {
  .empty-state,
  .error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--mobile-space-2xl) var(--mobile-space-md);
    text-align: center;
  }

  .empty-state-icon,
  .error-state-icon {
    font-size: 48px;
    margin-bottom: var(--mobile-space-md);
  }

  .empty-state-title,
  .error-state-title {
    font-size: var(--mobile-font-h3);
    font-weight: 600;
    color: var(--text-heading, #ffffff);
    margin-bottom: var(--mobile-space-sm);
  }

  .empty-state-message,
  .error-state-message {
    font-size: var(--mobile-font-body);
    color: #a8b0b8; /* Improved contrast from #888 */
    margin-bottom: var(--mobile-space-lg);
    max-width: 280px;
  }

  .error-state {
    background: rgba(255, 77, 77, 0.1);
    border: 1px solid rgba(255, 77, 77, 0.2);
    border-radius: 16px;
    margin: var(--mobile-space-md);
  }

  .error-state-title {
    color: #ff6b6b;
  }
}


/* =============================================================================
   12. FLOATING ACTION BUTTONS (Cleanup)
   ============================================================================= */

@media (max-width: 768px) {
  /* Move FABs above bottom nav */
  .floating-btn,
  .fab,
  .support-chat-btn,
  #supportChatBtn {
    bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 16px) !important;
  }

  /* Hide phone/calculator FAB on mobile if not needed */
  .fab-secondary {
    display: none;
  }
}


/* =============================================================================
   13. MOBILE MENU IMPROVEMENTS
   ============================================================================= */

@media (max-width: 768px) {
  .mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #0a0f19;
    z-index: var(--z-overlay);
    padding: var(--mobile-space-xl) var(--mobile-space-md);
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .mobile-menu.open {
    transform: translateX(0);
  }

  .mobile-menu-item {
    display: flex;
    align-items: center;
    padding: var(--mobile-space-md);
    color: var(--text-heading, #ffffff);
    text-decoration: none;
    font-size: var(--mobile-font-body);
    border-radius: var(--panel-radius);
    margin-bottom: var(--mobile-space-xs);
    transition: background 0.2s ease;
  }

  .mobile-menu-item:active {
    background: rgba(0, 207, 255, 0.1);
  }

  .mobile-menu-item svg,
  .mobile-menu-item .icon {
    width: 24px;
    height: 24px;
    margin-right: var(--mobile-space-md);
    color: var(--accent-cyan, #00cfff);
  }

  .mobile-menu-section {
    margin-top: var(--mobile-space-lg);
    margin-bottom: var(--mobile-space-sm);
    padding-left: var(--mobile-space-md);
    font-size: 12px;
    font-weight: 600;
    color: rgba(0,207,255,0.72); /* Improved contrast from #666 */
    text-transform: uppercase;
    letter-spacing: 1px;
  }
}


/* =============================================================================
   14. PULL TO REFRESH INDICATOR
   ============================================================================= */

.pull-indicator {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  background: rgba(0, 207, 255, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: top 0.2s ease;
  z-index: var(--z-sticky);
}

.pull-indicator.visible {
  top: 20px;
}

.pull-indicator.loading {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: translateX(-50%) rotate(0deg); }
  to { transform: translateX(-50%) rotate(360deg); }
}


/* =============================================================================
   15. SAFE AREA HANDLING (Notch devices)
   ============================================================================= */

@supports (padding: env(safe-area-inset-bottom)) {
  @media (max-width: 768px) {
    body {
      padding-left: env(safe-area-inset-left);
      padding-right: env(safe-area-inset-right);
    }

    .mobile-bottom-nav {
      padding-bottom: env(safe-area-inset-bottom);
      height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    }

    .mobile-hero {
      padding-top: calc(var(--mobile-space-xl) + env(safe-area-inset-top));
    }
  }
}


/* =============================================================================
   16. EDGE PADDING & HORIZONTAL SPACING - Material Design 3 Compliant
   ============================================================================= */

@media (max-width: 768px) {
  /*
   * Horizontal Spacing Standards:
   * - Minimum edge padding: 16px from screen edges
   * - Content containers: 16-24px horizontal padding
   * - No content should touch viewport edges
   */

  /* Global container edge padding */
  body > *,
  main,
  .main-content,
  .page-content,
  .container,
  .content-wrapper {
    padding-left: max(16px, env(safe-area-inset-left, 16px));
    padding-right: max(16px, env(safe-area-inset-right, 16px));
  }

  /* Section containers */
  section,
  .section,
  .content-section,
  .page-section {
    padding-left: 16px;
    padding-right: 16px;
    margin-left: 0;
    margin-right: 0;
  }

  /* Card containers maintain internal padding */
  .card,
  .feature-card,
  .command-card,
  .market-card,
  .reward-tier,
  .info-card {
    margin-left: 16px;
    margin-right: 16px;
    padding: 16px;
  }

  /* Full-bleed elements with internal padding */
  .full-bleed,
  .hero-section,
  .banner {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Text content should never touch edges */
  p, h1, h2, h3, h4, h5, h6,
  .text-content,
  .prose {
    max-width: calc(100% - 32px);
    margin-left: auto;
    margin-right: auto;
  }

  /* Code blocks with horizontal scroll */
  pre, code {
    margin-left: 16px;
    margin-right: 16px;
    padding: 16px;
    overflow-x: auto;
    max-width: calc(100vw - 32px);
  }

  /* Lists need padding */
  ul, ol {
    padding-left: 32px;
    margin-left: 16px;
    margin-right: 16px;
  }

  /* Tables need horizontal scroll container */
  table {
    margin-left: 16px;
    margin-right: 16px;
    max-width: calc(100% - 32px);
  }

  /* Images constrained to viewport with padding */
  img {
    max-width: calc(100vw - 32px);
    margin-left: auto;
    margin-right: auto;
  }

  /* Grid containers */
  .grid,
  .feature-grid,
  .card-grid,
  .tier-grid {
    padding-left: 16px;
    padding-right: 16px;
    gap: 16px;
  }

  /* Flex containers */
  .flex-container,
  .button-group,
  .action-buttons {
    padding-left: 16px;
    padding-right: 16px;
    gap: 12px;
  }

  /* Equal-width button pairs (Deposit/Withdraw, Yes/No, etc.) */
  .wallet-action-buttons,
  .balance-actions,
  .action-btn-pair {
    display: flex;
    width: 100%;
    gap: 0.5rem;
  }

  .wallet-action-buttons > button,
  .wallet-action-buttons > a,
  .balance-actions > button,
  .balance-actions > a,
  .action-btn-pair > button,
  .action-btn-pair > a {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    box-sizing: border-box;
  }

  /* Footer content */
  footer,
  .footer-content {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Header content */
  header,
  .header-content,
  nav {
    padding-left: 16px;
    padding-right: 16px;
  }
}


/* =============================================================================
   17. HEADING HIERARCHY - Consistent Visual Weight
   ============================================================================= */

@media (max-width: 768px) {
  /*
   * Heading Hierarchy Standards:
   * - H1 > H2 > H3 > H4 > H5 > H6 (always descending)
   * - Clear visual distinction between levels
   * - Consistent spacing above and below
   */

  /* Ensure heading sizes are always hierarchical */
  h1 { font-size: 28px !important; font-weight: 700 !important; }
  h2:not(.ec-card-title) { font-size: 24px !important; font-weight: 600 !important; }
  h3 { font-size: 20px !important; font-weight: 600 !important; }
  h4 { font-size: 18px !important; font-weight: 600 !important; }
  h5 { font-size: 16px !important; font-weight: 600 !important; }
  h6 { font-size: 14px !important; font-weight: 600 !important; }

  /* Consistent heading spacing */
  h1, h2, h3, h4, h5, h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: 1.4;
  }

  /* First heading after section start */
  section > h1:first-child,
  section > h2:first-child,
  section > h3:first-child,
  .content > h1:first-child,
  .content > h2:first-child,
  .content > h3:first-child {
    margin-top: 0;
  }

  /* Consecutive headings */
  h1 + h2,
  h2 + h3,
  h3 + h4,
  h4 + h5,
  h5 + h6 {
    margin-top: 0.5em;
  }
}


/* =============================================================================
   18. REWARDS PAGE SPECIFIC FIXES
   ============================================================================= */

@media (max-width: 768px) {
  /* Rewards tier cards need proper spacing */
  .reward-tier,
  .tier-card,
  .reward-card {
    margin: 8px 16px;
    padding: 16px;
  }

  /* Rewards grid spacing */
  .rewards-grid,
  .tier-grid {
    padding: 0 16px;
    gap: 12px;
  }

  /* Rewards section headings */
  .rewards-section h2,
  .rewards-section h3 {
    padding: 0 16px;
  }
}


/* =============================================================================
   19. CRITICAL OVERRIDES - High Specificity Rules for Typography QA
   ============================================================================= */

/*
 * These rules use maximum specificity to override inline styles
 * Required for iOS HIG and Material Design 3 compliance
 * All rules target computed styles for QA test validation
 */

@media (max-width: 768px) {
  /* Override inline html/body styles */
  html body {
    line-height: 1.6 !important;
  }

  /* Force line-height on ALL text elements */
  html body *:not(script):not(style):not(br):not(hr) {
    line-height: 1.4 !important;
  }

  /* Specific overrides for common text containers */
  html body p,
  html body span,
  html body div,
  html body li,
  html body td,
  html body th,
  html body label,
  html body a {
    line-height: 1.5 !important;
  }

  /* Heading line-heights with proper hierarchy */
  html body h1,
  html body .h1 {
    font-size: 28px !important;
    line-height: 1.4 !important;
    margin-top: 24px !important;
    margin-bottom: 12px !important;
  }

  html body h2:not(.ec-card-title),
  html body .h2 {
    font-size: 24px !important;
    line-height: 1.4 !important;
    margin-top: 20px !important;
    margin-bottom: 10px !important;
  }

  html body h3,
  html body .h3 {
    font-size: 20px !important;
    line-height: 1.45 !important;
    margin-top: 18px !important;
    margin-bottom: 8px !important;
  }

  html body h4,
  html body .h4 {
    font-size: 18px !important;
    line-height: 1.5 !important;
    margin-top: 16px !important;
    margin-bottom: 8px !important;
  }

  html body h5,
  html body .h5 {
    font-size: 16px !important;
    line-height: 1.5 !important;
    margin-top: 14px !important;
    margin-bottom: 6px !important;
  }

  html body h6,
  html body .h6 {
    font-size: 14px !important;
    line-height: 1.5 !important;
    margin-top: 12px !important;
    margin-bottom: 6px !important;
  }

  /* Paragraph spacing - minimum 8px bottom margin */
  html body p {
    margin-bottom: 12px !important;
    line-height: 1.6 !important;
  }

  /* Touch targets - ALL interactive elements */
  /* Note: Removed display: inline-flex !important to avoid breaking button functionality */
  html body a,
  html body button,
  html body [role="button"],
  html body input[type="button"],
  html body input[type="submit"],
  html body .btn,
  html body .wallet-btn,
  html body .nav-link {
    min-height: 44px;
    min-width: 44px;
    cursor: pointer;
  }

  /* Edge padding - containers */
  html body main,
  html body .main-content,
  html body section,
  html body .section,
  html body .container,
  html body .content,
  html body article {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  /* Cards and panels */
  html body .card,
  html body .panel,
  html body .feature-card,
  html body .command-card,
  html body .stat-block {
    margin-left: 8px !important;
    margin-right: 8px !important;
    padding: 16px !important;
  }

  /* Grid and flex containers */
  html body .grid,
  html body .flex,
  html body .row,
  html body .col {
    padding-left: 8px !important;
    padding-right: 8px !important;
    gap: 12px !important;
  }

  /* Footer links spacing (scoped to page footer, not footer-bar nav) */
  html body .footer-links a {
    min-height: 44px !important;
    padding: 10px 8px !important;
    margin: 4px !important;
  }

  /* Header wallet buttons */
  html body .wallet-section a,
  html body .wallet-section button,
  html body header a,
  html body header button {
    min-height: 44px !important;
    min-width: 44px !important;
    padding: 10px 14px !important;
  }

  /* Code blocks readability */
  html body pre,
  html body code,
  html body .code-block {
    line-height: 1.5 !important;
    padding: 12px !important;
    margin: 8px 16px !important;
    font-size: 13px !important;
  }

  /* List items */
  html body ul,
  html body ol {
    margin-left: 16px !important;
    padding-left: 20px !important;
    margin-bottom: 12px !important;
  }

  html body li {
    line-height: 1.6 !important;
    margin-bottom: 6px !important;
  }
}


/* =============================================================================
   20. ANTI-TRUNCATION - Prevent Text Cutoff
   ============================================================================= */

@media (max-width: 768px) {
  /* Prevent text overflow — scoped to text containers (not * wildcard) */
  body p,
  body span,
  body div,
  body li,
  body td,
  body th,
  body label,
  body h1, body h2, body h3, body h4, body h5, body h6 {
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
  }

  /* Prevent truncation on block-level text — matches original scope (NOT td/th/li) */
  body p,
  body span,
  body div,
  body h1, body h2, body h3, body h4, body h5, body h6 {
    text-overflow: clip !important;
    white-space: normal !important;
  }

  /* Allow horizontal scroll only for code */
  html body pre,
  html body code {
    overflow-x: auto !important;
    white-space: pre-wrap !important;
    word-break: break-word !important;
  }

  /* Ensure headers never truncate */
  html body .terminal-header,
  html body header,
  html body nav {
    overflow: visible !important;
  }

  /* Hero text should wrap properly */
  html body .hero-title,
  html body .page-title,
  html body .section-title {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  /* Exchange-crypto swap card: financial amounts MUST NOT break mid-number */
  html body #swapCard .pair-usd,
  html body #swapCard .pair-name,
  html body #swapCard .swap-toggle-display,
  html body #swapCard .pair-usd *,
  html body #swapCard .pair-name *,
  html body #swapCard .swap-toggle-display * {
    white-space: nowrap !important;
    overflow-wrap: normal !important;
    word-wrap: normal !important;
    word-break: normal !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  /* pair-right container + pair-sub label: allow wrapping for descriptive text */
  html body #swapCard .pair-right {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }
  html body #swapCard .pair-sub {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }
}


/* =============================================================================
   21. HORIZONTAL SCROLL FIX - Global Override
   ============================================================================= */

@media (max-width: 480px) {
  /* Prevent horizontal scroll without blocking vertical scroll */
  html {
    overflow-x: clip;
  }

  body {
    overflow-x: clip;
    max-width: 100%;
  }

  /* Keep avatar visible on small screens — title is hidden, avatar is the logo */
  .chat-avatar {
    display: flex !important;
    width: 32px !important;
    height: 32px !important;
  }

  /* SDK Docs Page */
  .docs-layout {
    grid-template-columns: 1fr !important;
    padding: 0.5rem !important;
    gap: 0.5rem !important;
    max-width: 100vw !important;
  }

  .sdk-hero {
    padding: 1rem !important;
  }

  .sdk-hero h1 {
    font-size: 1.5rem !important;
  }

  .sdk-section {
    padding: 0.75rem !important;
    margin: 0.5rem 0 !important;
  }

  /* Contact Page */
  .contact-options {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
  }

  .contact-container,
  .contact-content,
  .contact-form {
    max-width: 100% !important;
    padding: 0.5rem !important;
    box-sizing: border-box !important;
  }

  /* Getting Started Page */
  .guide-container,
  .guide-content,
  .guide-section {
    max-width: 100% !important;
    padding: 0.5rem !important;
    box-sizing: border-box !important;
  }

  .guide-hero {
    padding: 1rem !important;
  }

  /* Swagger UI */
  .swagger-ui {
    max-width: 100vw !important;
    overflow-x: clip !important;
  }

  .swagger-ui .wrapper {
    padding: 0 0.5rem !important;
    max-width: 100% !important;
  }

  .swagger-ui .opblock {
    max-width: 100% !important;
    overflow-x: auto !important;
  }

  /* All code blocks */
  pre, code {
    max-width: calc(100vw - 1rem) !important;
    overflow-x: auto !important;
    font-size: 0.75rem !important;
    word-break: break-all !important;
  }

  /* All content containers */
  .container,
  .wrapper,
  .content,
  .page-content,
  main,
  section {
    max-width: 100vw !important;
    box-sizing: border-box !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }
}


/* =============================================================================
   22. QUICK TRADE BOTTOM SHEET - Reduce Taps to Trade
   ============================================================================= */

/*
 * Quick Trade Bottom Sheet
 * - Slides up from bottom when user taps a market card
 * - Pre-fills with market data and smart defaults
 * - Enables 2-tap trading (tap card → confirm)
 * - Inline confirmation, no screen navigation
 */

.quick-trade-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, var(--bg-tertiary) 0%, var(--bg-primary) 100%);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: var(--z-modal);
  max-height: 85vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

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

.quick-trade-sheet-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: var(--z-modal-backdrop);
}

.quick-trade-sheet-backdrop.open {
  opacity: 1;
  visibility: visible;
}

/* Drag handle */
.quick-trade-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  margin: 12px auto 16px;
}

/* Header */
.quick-trade-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.quick-trade-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-heading, #ffffff);
}

.quick-trade-close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: var(--text-heading, #ffffff);
  font-size: 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.quick-trade-close:active {
  background: rgba(255, 255, 255, 0.2);
}

/* Market Info */
.quick-trade-market {
  padding: 16px 20px;
  background: rgba(0, 207, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.quick-trade-market-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-heading, #ffffff);
  margin-bottom: 8px;
}

.quick-trade-market-odds {
  display: flex;
  gap: 12px;
}

.quick-trade-odd {
  flex: 1;
  padding: 12px;
  border-radius: var(--panel-radius);
  text-align: center;
  font-weight: 600;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

.quick-trade-odd.yes {
  background: rgba(0, 207, 255, 0.1);
  border: 2px solid transparent;
  color: var(--accent-cyan, #00cfff);
}

.quick-trade-odd.no {
  background: rgba(255, 77, 77, 0.15);
  border: 2px solid transparent;
  color: #ff4d4d;
}

.quick-trade-odd.selected.yes {
  border-color: var(--accent-cyan, #00cfff);
  background: rgba(0, 207, 255, 0.15);
}

.quick-trade-odd.selected.no {
  border-color: #ff4d4d;
  background: rgba(255, 77, 77, 0.25);
}

.quick-trade-odd-label {
  font-size: 12px;
  opacity: 0.8;
  margin-bottom: 4px;
}

.quick-trade-odd-value {
  font-size: 24px;
}

/* Amount Input */
.quick-trade-amount {
  padding: 20px;
}

.quick-trade-amount-label {
  font-size: 14px;
  color: #a8b0b8; /* Improved contrast from #888 */
  margin-bottom: 12px;
}

.quick-trade-amount-input {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border-hover);
  border-radius: var(--panel-radius);
  padding: 4px;
}

.quick-trade-amount-input input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-heading, #ffffff);
  font-size: 24px;
  font-weight: 600;
  padding: 12px 16px;
  outline: none;
  min-width: 0;
}

.quick-trade-amount-input input::placeholder {
  color: #8b95a1; /* Improved contrast from #555 */
}

.quick-trade-max-btn {
  padding: 8px 16px;
  background: rgba(0, 207, 255, 0.15);
  border: none;
  border-radius: 8px;
  color: var(--accent-cyan, #00cfff);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 8px;
  min-height: 44px;
  min-width: 44px;
}

.quick-trade-max-btn:active {
  background: rgba(0, 207, 255, 0.2);
}

/* Quick Amount Buttons */
.quick-trade-presets {
  display: flex;
  gap: 8px;
  padding: 0 20px 16px;
}

.quick-trade-preset {
  flex: 1;
  padding: 12px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: var(--text-heading, #ffffff);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  min-height: 48px;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

.quick-trade-preset:active {
  background: rgba(0, 207, 255, 0.1);
  border-color: var(--accent-cyan, #00cfff);
}

/* Payout Preview */
.quick-trade-payout {
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.quick-trade-payout-label {
  font-size: 14px;
  color: #a8b0b8; /* Improved contrast from #888 */
}

.quick-trade-payout-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-cyan, #00cfff);
}

/* Submit Button */
.quick-trade-submit {
  margin: 20px;
  padding: 18px;
  background: linear-gradient(135deg, #00cfff, #0099cc);
  border: none;
  border-radius: 14px;
  color: var(--bg-primary);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  width: calc(100% - 40px);
  min-height: 56px;
  box-shadow: 0 4px 20px var(--accent-glow);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

.quick-trade-submit:active {
  transform: scale(0.98);
  box-shadow: 0 2px 10px var(--accent-glow);
}

.quick-trade-submit:disabled {
  background: #1a2332;
  color: rgba(0,207,255,0.72);
  box-shadow: none;
}

/* Confirmation State */
.quick-trade-success {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.quick-trade-success.show {
  display: flex;
}

.quick-trade-success-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #00cfff, #0099cc);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  margin-bottom: 20px;
  animation: successPop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes successPop {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.quick-trade-success-text {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-heading, #ffffff);
  margin-bottom: 8px;
}

.quick-trade-success-details {
  font-size: 14px;
  color: #a8b0b8; /* Improved contrast from #888 */
}

/* Swipe to Trade Gesture Support */
@media (max-width: 768px) {
  .market-card,
  .featured-market-panel,
  .prediction-card {
    /* Enable swipe gestures */
    touch-action: pan-y pinch-zoom;
    user-select: none;
    -webkit-user-select: none;
  }

  /* Swipe indicator */
  .swipe-trade-indicator {
    position: absolute;
    right: -60px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #00cfff, #0099cc);
    padding: 12px 16px;
    border-radius: var(--panel-radius) 0 0 var(--panel-radius);
    color: var(--bg-primary);
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
  }

  .market-card.swiping .swipe-trade-indicator {
    opacity: 1;
    right: 0;
  }
}


/* =============================================================================
   23. MOBILE BOTTOM NAVIGATION WITH QUICK TRADE
   ============================================================================= */

@media (max-width: 768px) {
  /* Enhance existing bottom nav with quick trade button */
  .mobile-bottom-nav .nav-trade .trade-btn {
    /* Pulse animation to draw attention */
    animation: tradePulse 2s ease-in-out infinite;
  }

  @keyframes tradePulse {
    0%, 100% { box-shadow: 0 4px 15px var(--accent-glow); }
    50% { box-shadow: 0 4px 25px var(--accent-glow), 0 0 40px var(--accent-glow); }
  }

  /* Quick action buttons on market cards */
  .market-card-quick-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
  }

  .quick-action-btn {
    flex: 1;
    padding: 14px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    min-height: 48px;
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
  }

  .quick-action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s ease;
    pointer-events: none;
  }

  .quick-action-btn:active::before {
    left: 100%;
  }

  .quick-action-btn.yes {
    background: linear-gradient(
      145deg,
      rgba(0, 40, 70, 0.6) 0%,
      rgba(0, 70, 100, 0.45) 50%,
      rgba(0, 40, 70, 0.6) 100%
    );
    border: 2px solid rgba(0, 180, 220, 0.5);
    color: var(--accent-cyan, #00cfff);
    box-shadow: 0 4px 20px rgba(0, 100, 150, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.05);
  }

  .quick-action-btn.no {
    background: linear-gradient(
      145deg,
      rgba(70, 30, 30, 0.6) 0%,
      rgba(100, 40, 40, 0.45) 50%,
      rgba(70, 30, 30, 0.6) 100%
    );
    border: 2px solid rgba(255, 77, 77, 0.5);
    color: #ff4d4d;
    box-shadow: 0 4px 20px rgba(150, 50, 50, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.05);
  }

  .quick-action-btn:active {
    transform: scale(0.98);
  }

  .quick-action-btn.yes:active {
    background: linear-gradient(
      145deg,
      rgba(0, 55, 90, 0.7) 0%,
      rgba(0, 90, 130, 0.55) 50%,
      rgba(0, 55, 90, 0.7) 100%
    );
    box-shadow: 0 0 35px rgba(0, 160, 220, 0.35);
  }

  .quick-action-btn.no:active {
    background: linear-gradient(
      145deg,
      rgba(90, 40, 40, 0.7) 0%,
      rgba(130, 50, 50, 0.55) 50%,
      rgba(90, 40, 40, 0.7) 100%
    );
    box-shadow: 0 0 35px rgba(220, 80, 80, 0.35);
  }
}


/* =============================================================================
   MOBILE QA FIXES - Extended States (P0/P1)
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Disabled Button States (P0 - Critical)
   ----------------------------------------------------------------------------- */

@media (max-width: 768px) {
  /* Generic disabled state */
  button:disabled,
  button[aria-disabled="true"],
  .btn:disabled,
  .btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    background: #1a2332 !important;
    border-color: #253345 !important;
    color: #6b7a8d !important;
  }

  /* Trade buttons - clear disabled indication */
  .trade-btn:disabled,
  .quick-trade-submit:disabled,
  .buy-btn:disabled,
  .sell-btn:disabled {
    opacity: 0.4;
    background: linear-gradient(135deg, #1a2332 0%, #253345 100%) !important;
    box-shadow: none !important;
    transform: none !important;
  }

  /* Disabled button with tooltip */
  .btn-disabled-tooltip {
    position: relative;
  }

  .btn-disabled-tooltip::after {
    content: attr(data-disabled-reason);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: rgba(30, 30, 35, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 12px;
    color: #4a5568;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: var(--z-tooltip);
  }

  .btn-disabled-tooltip:focus::after,
  .btn-disabled-tooltip:hover::after {
    opacity: 1;
    visibility: visible;
  }
}


/* -----------------------------------------------------------------------------
   Loading States (P0 - Critical)
   ----------------------------------------------------------------------------- */

@media (max-width: 768px) {
  /* Element loading state */
  .is-loading {
    position: relative;
    pointer-events: none;
  }

  .is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(18, 18, 22, 0.7);
    border-radius: inherit;
    z-index: 10;
  }

  /* Loading overlay with spinner */
  .loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(18, 18, 22, 0.8);
    border-radius: inherit;
    z-index: 20;
  }

  /* Inline loading indicator */
  .loading-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #a8b0b8; /* Improved contrast from #888 */
    font-size: 14px;
  }

  .loading-inline::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: var(--accent-cyan, #00cfff);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }

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

  /* Price loading state - pulse instead of $-- */
  .price-loading,
  .price--loading {
    color: #8b95a1; /* Improved contrast from #555 */
    animation: pricePulse 1.5s ease-in-out infinite;
  }

  @keyframes pricePulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
  }
}


/* -----------------------------------------------------------------------------
   Epoch Timer States (P0 - Critical)
   ----------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .epoch-timer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--panel-radius);
    transition: background 0.3s;
  }

  .epoch-timer-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #a8b0b8; /* Improved contrast from #888 */
  }

  .epoch-timer-value {
    font-size: 24px;
    font-weight: 700;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    color: var(--text-heading, #ffffff);
  }

  /* Loading state */
  .epoch-timer--loading {
    background: rgba(255, 255, 255, 0.03);
  }

  .epoch-timer--loading .epoch-timer-value {
    animation: pricePulse 1.5s ease-in-out infinite;
    color: #8b95a1; /* Improved contrast from #555 */
  }

  /* Active countdown */
  .epoch-timer--active {
    background: rgba(0, 207, 255, 0.1);
    border: 1px solid rgba(0, 207, 255, 0.2);
  }

  .epoch-timer--active .epoch-timer-value {
    color: var(--accent-cyan, #00cfff);
  }

  /* Ending soon (< 60 seconds) */
  .epoch-timer--urgent {
    background: rgba(0, 207, 255, 0.15);
    border: 1px solid rgba(0, 207, 255, 0.3);
    animation: urgentPulse 1s ease-in-out infinite;
  }

  .epoch-timer--urgent .epoch-timer-value {
    color: var(--negative-color, #ff4444);
  }

  @keyframes urgentPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 207, 255, 0); }
    50% { box-shadow: 0 0 20px rgba(0, 207, 255, 0.3); }
  }

  /* Ended state - pulsating red like /perpetual page */
  .epoch-timer--ended {
    background: rgba(255, 68, 68, 0.1);
    border: 1px solid rgba(255, 68, 68, 0.3);
    animation: endedPulse 1s infinite;
  }

  .epoch-timer--ended .epoch-timer-value {
    color: var(--negative-color, #ff4444);
    animation: endedTextPulse 1s infinite;
  }

  @keyframes endedPulse {
    0%, 100% {
      background: rgba(255, 68, 68, 0.1);
      border-color: rgba(255, 68, 68, 0.3);
    }
    50% {
      background: rgba(255, 68, 68, 0.05);
      border-color: rgba(255, 68, 68, 0.15);
    }
  }

  @keyframes endedTextPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
  }

  /* No epoch */
  .epoch-timer--no-epoch {
    background: rgba(255, 255, 255, 0.03);
  }

  .epoch-timer--no-epoch .epoch-timer-label {
    color: rgba(0,207,255,0.72); /* Improved contrast from #666 */
  }

  .epoch-timer--no-epoch .epoch-timer-value {
    color: #8b95a1; /* Improved contrast from #555 */
  }
}


/* -----------------------------------------------------------------------------
   Focus Visible States (P1 - Accessibility)
   ----------------------------------------------------------------------------- */

@media (max-width: 768px) {
  /* Hide outlines for mouse clicks, preserve for keyboard (WCAG 2.4.7) */
  a:focus:not(:focus-visible),
  a:active {
    outline: none;
    box-shadow: none;
  }
  a:focus-visible {
    outline: 2px solid var(--accent-cyan, #00cfff);
    outline-offset: 2px;
  }
}


/* -----------------------------------------------------------------------------
   Bottom Nav Active State Indicator (P2)
   ----------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .mobile-bottom-nav .nav-item.active {
    color: var(--accent-cyan, #00cfff);
  }

  .mobile-bottom-nav .nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: #00cfff;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(0, 207, 255, 0.5);
  }

  .mobile-bottom-nav .nav-item {
    position: relative;
  }
}


/* -----------------------------------------------------------------------------
   Toast/Snackbar Notifications (P2)
   ----------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .toast-container {
    position: fixed;
    bottom: calc(var(--bottom-nav-height, 64px) + var(--safe-area-bottom, 0px) + 16px);
    left: 16px;
    right: 16px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
  }

  .toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(30, 30, 35, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--panel-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease-out;
  }

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

  .toast--success {
    border-color: rgba(0, 200, 100, 0.3);
  }

  .toast--success .toast-icon {
    color: #00c864;
  }

  .toast--error {
    border-color: rgba(255, 77, 77, 0.3);
  }

  .toast--error .toast-icon {
    color: #ff4d4d;
  }

  .toast--info {
    border-color: rgba(0, 207, 255, 0.3);
  }

  .toast--info .toast-icon {
    color: var(--accent-cyan, #00cfff);
  }

  .toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
  }

  .toast-message {
    flex: 1;
    font-size: 14px;
    color: var(--text-heading, #ffffff);
    line-height: 1.4;
  }

  .toast-close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #a8b0b8; /* Improved contrast from #888 */
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
  }

  .toast-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-heading, #ffffff);
  }

  /* Toast exit animation */
  .toast.exiting {
    animation: toastSlideOut 0.2s ease-in forwards;
  }

  @keyframes toastSlideOut {
    to {
      opacity: 0;
      transform: translateY(-10px);
    }
  }
}


/* -----------------------------------------------------------------------------
   Hero Image Layout Shift Prevention (P2)
   ----------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .hero-image,
  .market-hero-image,
  .featured-image {
    aspect-ratio: 16 / 9;
    background: rgba(255, 255, 255, 0.05);
    overflow: hidden;
  }

  .hero-image img,
  .market-hero-image img,
  .featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}


/* -----------------------------------------------------------------------------
   Orderbook Mobile Optimization (P1)
   ----------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .orderbook-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .orderbook-row {
    min-height: 48px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    -webkit-tap-highlight-color: rgba(0, 207, 255, 0.2);
  }

  .orderbook-row:active {
    background: rgba(255, 255, 255, 0.05);
  }

  /* Simplified orderbook for very narrow screens */
  .orderbook--simplified .orderbook-timestamp,
  .orderbook--simplified .orderbook-count {
    display: none;
  }
}


/* =============================================================================
   24. KEYBOARD-AWARE AUTO-SUGGEST (Gemini QA P0)
   ============================================================================= */

/*
 * Fixes: Keyboard covers auto-suggest results on iOS/Android
 * Solution: Use visualViewport API to detect keyboard and reposition
 */

:root {
  --keyboard-height: 0px;
}

body.keyboard-open .mobile-bottom-nav,
body.keyboard-open #nexus-chat-widget {
  transform: translateY(100%);
  transition: transform var(--duration-fast, 150ms) var(--ease-out-expo, ease);
}

body.keyboard-open .bottom-sheet {
  max-height: calc(100dvh - var(--keyboard-height, 0px));
}

@media (max-width: 768px) {
  /* Search suggestions container */
  .search-suggestions,
  .autocomplete-dropdown,
  .search-results-dropdown {
    position: fixed;
    left: 16px;
    right: 16px;
    max-height: 40vh;
    overflow-y: auto;
    background: rgba(25, 25, 30, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--panel-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: var(--z-dropdown);
    transform: translateY(-100%);
    margin-top: -8px;
  }

  /* When keyboard is open, position above it */
  .keyboard-open .search-suggestions,
  .keyboard-open .autocomplete-dropdown {
    bottom: calc(var(--keyboard-height) + 60px);
    top: auto;
    transform: none;
  }

  /* Suggestion item */
  .search-suggestion-item,
  .autocomplete-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    min-height: 52px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.15s;
  }

  .search-suggestion-item:last-child {
    border-bottom: none;
  }

  .search-suggestion-item:active {
    background: rgba(0, 207, 255, 0.1);
  }

  .suggestion-ticker {
    font-weight: 600;
    color: var(--accent-cyan, #00cfff);
    min-width: 60px;
  }

  .suggestion-name {
    flex: 1;
    color: #4a5568;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Search input with keyboard awareness */
  .search-input-container {
    position: relative;
  }

  .search-input-container input {
    padding-right: 48px;
  }

  .search-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #a8b0b8; /* Improved contrast from #888 */
    font-size: 16px;
    cursor: pointer;
  }
}


/* =============================================================================
   25. SHIMMER LOADING FOR GRAPHS (Gemini QA P0)
   ============================================================================= */

/*
 * Fixes: Complex relationship maps take 3.5s+ to render on 4G
 * Solution: Shimmer skeleton for graph containers
 */

@media (max-width: 768px) {
  /* Graph skeleton container */
  .graph-skeleton,
  .visualization-skeleton,
  .chart-skeleton {
    position: relative;
    min-height: 300px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
    overflow: hidden;
  }

  /* Animated shimmer overlay */
  .graph-skeleton::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
      90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.03) 20%,
      rgba(255, 255, 255, 0.06) 50%,
      rgba(255, 255, 255, 0.03) 80%,
      transparent 100%
    );
    background-size: 200% 100%;
    animation: graphShimmer 2s ease-in-out infinite;
  }

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

  /* Skeleton nodes */
  .skeleton-node {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    animation: nodePulse 1.5s ease-in-out infinite;
  }

  .skeleton-node--primary {
    width: 64px;
    height: 64px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  .skeleton-node--secondary {
    width: 40px;
    height: 40px;
  }

  .skeleton-node:nth-child(2) { top: 20%; left: 25%; animation-delay: 0.2s; }
  .skeleton-node:nth-child(3) { top: 20%; right: 25%; animation-delay: 0.4s; }
  .skeleton-node:nth-child(4) { bottom: 20%; left: 30%; animation-delay: 0.6s; }
  .skeleton-node:nth-child(5) { bottom: 25%; right: 20%; animation-delay: 0.8s; }

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

  /* Skeleton edges/connections */
  .skeleton-edge {
    position: absolute;
    height: 2px;
    background: rgba(255, 255, 255, 0.05);
    transform-origin: left center;
  }

  /* Graph loading message */
  .graph-loading-message {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 20px;
    font-size: 13px;
    color: #a8b0b8; /* Improved contrast from #888 */
  }

  .graph-loading-message::before {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: var(--accent-cyan, #00cfff);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
}


/* =============================================================================
   26. SLIM MOBILE HEADER (Gemini QA P1)
   ============================================================================= */

/*
 * Fixes: Navigation bar takes ~15% of vertical screen real estate
 * Solution: Collapsible header that shrinks on scroll
 */

@media (max-width: 768px) {
  /* Site header classes only (partials/header.html .terminal-header, partials/mobile-header.html
     .mobile-header). A bare `header` selector also caught page heroes (/guide .guide-header,
     /marketplace .page-header) and would pin them over the content once main stopped being
     the sticky scrollport (TASK 79). */
  .main-header,
  .terminal-header,
  .mobile-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    transition: height 0.3s ease, padding 0.3s ease, box-shadow 0.3s ease;
  }

  /* Scrolled/slim state */
  .header--scrolled,
  .main-header.scrolled,
  .terminal-header.scrolled {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
  }

  .header--scrolled .header-logo,
  .main-header.scrolled .terminal-logo {
    font-size: 0.9rem !important;
  }

  .header--scrolled .header-tagline,
  .main-header.scrolled .header-subtitle,
  .header--scrolled .header-description {
    display: none !important;
  }

  /* Add shadow when scrolled */
  .header--scrolled,
  .main-header.scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  }

  /* Compact header by default on mobile */
  .header-compact {
    height: 52px;
    padding: 8px 16px;
  }

  .header-compact .header-logo {
    font-size: 1rem;
  }
}


/* =============================================================================
   27. CLEAR ALL FILTERS BUTTON (Gemini QA P1)
   ============================================================================= */

/*
 * Fixes: No "Clear All" button visible on mobile UI for active filters
 * Solution: Add prominent Clear All button to filter bar
 */

@media (max-width: 768px) {
  .filter-bar,
  .active-filters-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .filter-bar::-webkit-scrollbar {
    display: none;
  }

  /* Active filter chips */
  .filter-chip,
  .active-filter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(0, 207, 255, 0.1);
    border: 1px solid rgba(0, 207, 255, 0.2);
    border-radius: 20px;
    font-size: 13px;
    color: var(--accent-cyan, #00cfff);
    white-space: nowrap;
    flex-shrink: 0;
  }

  .filter-chip-remove,
  .chip-remove {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: var(--text-heading, #ffffff);
    font-size: 14px;
    cursor: pointer;
    margin-left: 4px;
  }

  .filter-chip-remove:active {
    background: rgba(255, 255, 255, 0.2);
  }

  /* Clear All button */
  .btn-clear-all,
  .clear-all-filters {
    padding: 10px 16px;
    min-height: 44px;
    font-size: 13px;
    font-weight: 600;
    color: #ff6b6b;
    background: transparent;
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
  }

  .btn-clear-all:active {
    background: rgba(255, 107, 107, 0.1);
    border-color: rgba(255, 107, 107, 0.5);
  }

  /* Hide when no filters active */
  .btn-clear-all.hidden,
  .clear-all-filters:empty {
    display: none;
  }

  /* Filter count badge */
  .filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #00cfff;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--bg-primary);
  }
}


/* =============================================================================
   28. FRIENDLY EMPTY STATES (Gemini QA P1)
   ============================================================================= */

/*
 * Fixes: Generic "404" or "Data Not Found" when search returns no results
 * Solution: Friendly empty states with suggestions
 */

@media (max-width: 768px) {
  /* Search empty state */
  .empty-state--search {
    padding: 48px 24px;
    text-align: center;
  }

  .empty-state-query {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-family: monospace;
    color: var(--text-heading, #ffffff);
    margin-bottom: 8px;
  }

  /* Suggestions section */
  .empty-state-suggestions,
  .empty-state-sectors {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
  }

  .suggestions-label {
    font-size: 12px;
    color: rgba(0,207,255,0.72); /* Improved contrast from #666 */
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
  }

  /* Suggestion chips */
  .suggestion-chips,
  .sector-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .suggestion-chip,
  .sector-chip {
    display: inline-block;
    padding: 12px 18px;
    min-height: 44px;
    background: rgba(0, 207, 255, 0.08);
    border: 1px solid rgba(0, 207, 255, 0.15);
    border-radius: 22px;
    color: var(--accent-cyan, #00cfff);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
  }

  .suggestion-chip:active,
  .sector-chip:active {
    background: rgba(0, 207, 255, 0.15);
    border-color: rgba(0, 207, 255, 0.3);
    transform: scale(0.98);
  }

  /* Ticker suggestion with price */
  .suggestion-chip--ticker {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .suggestion-ticker-symbol {
    font-weight: 600;
  }

  .suggestion-ticker-change {
    font-size: 12px;
    opacity: 0.8;
  }

  .suggestion-ticker-change.positive { color: #00c853; }
  .suggestion-ticker-change.negative { color: #ff5252; }

  /* Related searches */
  .related-searches {
    margin-top: 24px;
  }

  .related-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--panel-radius);
    margin-bottom: 8px;
    text-decoration: none;
    color: #4a5568;
    font-size: 14px;
    transition: background 0.15s;
  }

  .related-search-item:active {
    background: rgba(255, 255, 255, 0.06);
  }

  .related-search-item svg {
    width: 18px;
    height: 18px;
    color: rgba(0,207,255,0.72); /* Improved contrast from #666 */
  }
}


/* =============================================================================
   29. BOTTOM SHEET FOR STOCK DETAILS (Gemini QA P2)
   ============================================================================= */

/*
 * Fixes: Hover tooltips don't work on touchscreens
 * Solution: Bottom sheet panel for detailed information
 */

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(25, 25, 30, 0.98);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: var(--z-modal);
  max-height: 75vh;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

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

/* Backdrop */
.bottom-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: var(--z-modal-backdrop);
}

.bottom-sheet-backdrop.open {
  opacity: 1;
  visibility: visible;
}

/* Drag handle */
.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  margin: 12px auto 0;
}

/* Header */
.bottom-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.bottom-sheet-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-heading, #ffffff);
}

.bottom-sheet-close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 50%;
  color: #a8b0b8; /* Improved contrast from #888 */
  font-size: 20px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s, opacity 0.2s, transform 0.2s;
}

.bottom-sheet-close:active {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-heading, #ffffff);
}

/* Content */
.bottom-sheet-content {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(75vh - 80px);
  -webkit-overflow-scrolling: touch;
}

/* Stock detail specific */
.stock-detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.stock-detail-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--panel-radius);
  background: rgba(255, 255, 255, 0.05);
  object-fit: contain;
}

.stock-detail-info {
  flex: 1;
}

.stock-detail-ticker {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-cyan, #00cfff);
}

.stock-detail-name {
  font-size: 14px;
  color: #a8b0b8; /* Improved contrast from #888 */
  margin-top: 2px;
}

.stock-detail-price {
  text-align: right;
}

.stock-detail-price-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-heading, #ffffff);
}

.stock-detail-change {
  font-size: 14px;
  font-weight: 500;
  margin-top: 2px;
}

.stock-detail-change.positive { color: #00c853; }
.stock-detail-change.negative { color: #ff5252; }

/* Relationships section */
.stock-relationships {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.relationships-title {
  font-size: 12px;
  color: rgba(0,207,255,0.72); /* Improved contrast from #666 */
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.relationship-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.relationship-item:last-child {
  border-bottom: none;
}

.relationship-ticker {
  font-weight: 600;
  color: var(--text-heading, #ffffff);
}

.relationship-score {
  font-size: 13px;
  color: var(--accent-cyan, #00cfff);
}

/* Action buttons */
.bottom-sheet-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.bottom-sheet-action-btn {
  flex: 1;
  padding: 16px;
  min-height: 52px;
  border-radius: var(--panel-radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s, opacity 0.2s, transform 0.2s;
}

.bottom-sheet-action-btn.primary {
  background: linear-gradient(135deg, #00cfff, #0099cc);
  border: none;
  color: var(--bg-primary);
}

.bottom-sheet-action-btn.secondary {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.2);
  color: var(--text-heading, #ffffff);
}

.bottom-sheet-action-btn:active {
  transform: scale(0.98);
}



/* ============================================ */
/* MOBILE FIXES (Auto-generated)               */
/* ============================================ */


/* Focus indicators handled by main.css — scoped to :focus-visible only (WCAG 2.4.7) */


/* =============================================================================
   LIGHT MODE OVERRIDES
   Converts hardcoded dark-mode colors to CSS variables for [data-theme="light"]
   ============================================================================= */

/* ---------------------------------------------------------------------------
   Backgrounds — panels, sheets, overlays, cards
   --------------------------------------------------------------------------- */

[data-theme="light"] .mobile-hero {
  background: linear-gradient(180deg, rgba(248, 249, 252, 0.9) 0%, transparent 100%) !important;
}

[data-theme="light"] .mobile-hero-cta {
  color: #ffffff !important;
}

[data-theme="light"] .market-card-mobile {
  background: var(--panel-bg) !important;
  border-color: var(--panel-border) !important;
}

[data-theme="light"] .market-card-mobile:active {
  border-color: var(--panel-border-hover) !important;
}

[data-theme="light"] .mobile-menu {
  background: rgba(248, 249, 252, 0.98) !important;
}

[data-theme="light"] .quick-trade-sheet {
  background: linear-gradient(180deg, #ffffff 0%, var(--bg-primary) 100%) !important;
  box-shadow: 0 -10px 40px rgba(0, 50, 120, 0.12) !important;
}

[data-theme="light"] .quick-trade-sheet-backdrop {
  background: rgba(15, 23, 42, 0.3) !important;
}

[data-theme="light"] .quick-trade-market {
  background: rgba(3, 105, 161, 0.05) !important;
  border-bottom-color: var(--divider-color) !important;
}

[data-theme="light"] .quick-trade-amount-input {
  background: var(--input-bg) !important;
  border-color: var(--input-border) !important;
}

[data-theme="light"] .quick-trade-payout {
  background: var(--bg-secondary) !important;
}

[data-theme="light"] .quick-trade-preset {
  background: var(--bg-secondary) !important;
  border-color: var(--panel-border) !important;
}

[data-theme="light"] .quick-trade-preset:active {
  background: rgba(3, 105, 161, 0.08) !important;
  border-color: var(--accent-cyan) !important;
}

[data-theme="light"] .quick-trade-submit {
  color: #ffffff !important;
}

[data-theme="light"] .quick-trade-submit:disabled {
  background: var(--bg-tertiary) !important;
  color: var(--text-dim) !important;
}

[data-theme="light"] .quick-trade-close {
  background: rgba(0, 100, 180, 0.06) !important;
}

[data-theme="light"] .quick-trade-close:active {
  background: rgba(0, 100, 180, 0.12) !important;
}

[data-theme="light"] .quick-trade-odd.yes {
  background: rgba(3, 105, 161, 0.08) !important;
}

[data-theme="light"] .quick-trade-odd.no {
  background: rgba(220, 38, 38, 0.08) !important;
}

[data-theme="light"] .quick-trade-odd.selected.yes {
  border-color: var(--accent-cyan) !important;
  background: rgba(3, 105, 161, 0.15) !important;
}

[data-theme="light"] .quick-trade-odd.selected.no {
  border-color: var(--negative-color) !important;
  background: rgba(220, 38, 38, 0.15) !important;
}

[data-theme="light"] .bottom-sheet {
  background: rgba(255, 255, 255, 0.98) !important;
  box-shadow: 0 -10px 40px rgba(0, 50, 120, 0.12) !important;
}

[data-theme="light"] .bottom-sheet-backdrop {
  background: rgba(15, 23, 42, 0.3) !important;
}

[data-theme="light"] .bottom-sheet-close {
  background: rgba(0, 100, 180, 0.06) !important;
}

[data-theme="light"] .bottom-sheet-close:active {
  background: rgba(0, 100, 180, 0.12) !important;
}

[data-theme="light"] .bottom-sheet-header {
  border-bottom-color: var(--divider-color) !important;
}

[data-theme="light"] .bottom-sheet-action-btn.primary {
  color: #ffffff !important;
}

[data-theme="light"] .bottom-sheet-action-btn.secondary {
  border-color: var(--panel-border) !important;
}

[data-theme="light"] .page-loading {
  background: var(--bg-primary) !important;
}

[data-theme="light"] .page-loading-spinner {
  border-color: var(--panel-border) !important;
  border-top-color: var(--accent-cyan) !important;
}

[data-theme="light"] .content-loading-spinner {
  border-color: var(--panel-border) !important;
  border-top-color: var(--accent-cyan) !important;
}

[data-theme="light"] .loading-inline-spinner {
  border-color: var(--panel-border) !important;
}

[data-theme="light"] .is-loading::after {
  background: rgba(248, 249, 252, 0.7) !important;
}

[data-theme="light"] .loading-overlay {
  background: rgba(248, 249, 252, 0.8) !important;
}

[data-theme="light"] .error-state {
  background: rgba(220, 38, 38, 0.06) !important;
  border-color: rgba(220, 38, 38, 0.15) !important;
}

/* ---------------------------------------------------------------------------
   Text colors — headings, body, muted, labels
   --------------------------------------------------------------------------- */

[data-theme="light"] .mobile-hero-title,
[data-theme="light"] .market-card-mobile .card-title,
[data-theme="light"] .market-card-mobile .probability-label,
[data-theme="light"] .mobile-trending-title,
[data-theme="light"] .mobile-menu-item,
[data-theme="light"] .mobile-hero-btn,
[data-theme="light"] .empty-state-title,
[data-theme="light"] .quick-trade-title,
[data-theme="light"] .quick-trade-market-name,
[data-theme="light"] .quick-trade-success-text,
[data-theme="light"] .bottom-sheet-title,
[data-theme="light"] .stock-detail-price-value,
[data-theme="light"] .relationship-ticker,
[data-theme="light"] .epoch-timer-value,
[data-theme="light"] .toast-message {
  color: var(--text-heading) !important;
}

[data-theme="light"] .mobile-hero-subtitle,
[data-theme="light"] .market-card-mobile .card-stats,
[data-theme="light"] .quick-trade-amount-label,
[data-theme="light"] .quick-trade-payout-label,
[data-theme="light"] .quick-trade-success-details,
[data-theme="light"] .stock-detail-name,
[data-theme="light"] .epoch-timer-label,
[data-theme="light"] .loading-inline,
[data-theme="light"] .empty-state-message,
[data-theme="light"] .graph-loading-message {
  color: var(--text-secondary) !important;
}

[data-theme="light"] .mobile-menu-section,
[data-theme="light"] .relationships-title,
[data-theme="light"] .suggestions-label,
[data-theme="light"] .epoch-timer--no-epoch .epoch-timer-label,
[data-theme="light"] .related-search-item svg {
  color: var(--text-dim) !important;
}

[data-theme="light"] label,
[data-theme="light"] .label,
[data-theme="light"] .form-label {
  color: var(--text-secondary) !important;
}

[data-theme="light"] .suggestion-name,
[data-theme="light"] .related-search-item {
  color: var(--text-secondary) !important;
}

[data-theme="light"] .btn-disabled-tooltip::after {
  background: rgba(255, 255, 255, 0.95) !important;
  border-color: var(--panel-border) !important;
  color: var(--text-secondary) !important;
}

[data-theme="light"] .page-loading-text,
[data-theme="light"] .content-loading-text {
  color: var(--text-dim) !important;
}

[data-theme="light"] .price-loading,
[data-theme="light"] .price--loading,
[data-theme="light"] .epoch-timer--loading .epoch-timer-value,
[data-theme="light"] .epoch-timer--no-epoch .epoch-timer-value {
  color: var(--text-dim) !important;
}

[data-theme="light"] .quick-trade-amount-input input {
  color: var(--text-heading) !important;
}

[data-theme="light"] .quick-trade-amount-input input::placeholder {
  color: var(--text-dim) !important;
}

/* ---------------------------------------------------------------------------
   Borders — panel edges, dividers, separators
   --------------------------------------------------------------------------- */

[data-theme="light"] .quick-trade-header {
  border-bottom-color: var(--divider-color) !important;
}

[data-theme="light"] .quick-trade-market {
  border-bottom-color: var(--divider-color) !important;
}

[data-theme="light"] .orderbook-row {
  border-bottom-color: var(--divider-color) !important;
}

[data-theme="light"] .relationship-item {
  border-bottom-color: var(--divider-color) !important;
}

[data-theme="light"] .stock-relationships {
  border-top-color: var(--divider-color) !important;
}

[data-theme="light"] .empty-state-suggestions,
[data-theme="light"] .empty-state-sectors {
  border-top-color: var(--divider-color) !important;
}

[data-theme="light"] .search-suggestion-item,
[data-theme="light"] .autocomplete-item {
  border-bottom-color: var(--divider-color) !important;
}

[data-theme="light"] .crypto-term,
[data-theme="light"] .term-tooltip,
[data-theme="light"] [data-tooltip] {
  border-bottom-color: rgba(0, 80, 160, 0.2) !important;
}

/* ---------------------------------------------------------------------------
   Form inputs
   --------------------------------------------------------------------------- */

@media (max-width: 768px) {
  [data-theme="light"] input[type="text"],
  [data-theme="light"] input[type="email"],
  [data-theme="light"] input[type="password"],
  [data-theme="light"] input[type="number"],
  [data-theme="light"] input[type="tel"],
  [data-theme="light"] input[type="search"],
  [data-theme="light"] textarea,
  [data-theme="light"] select {
    background: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--text-primary) !important;
  }

  [data-theme="light"] input:focus,
  [data-theme="light"] textarea:focus,
  [data-theme="light"] select:focus {
    border-color: var(--accent-cyan) !important;
    box-shadow: var(--input-focus-glow) !important;
  }

  [data-theme="light"] input::placeholder,
  [data-theme="light"] textarea::placeholder {
    color: var(--text-dim) !important;
  }
}

/* ---------------------------------------------------------------------------
   Financial colors — positive/negative
   --------------------------------------------------------------------------- */

[data-theme="light"] .price-up,
[data-theme="light"] .positive,
[data-theme="light"] .gain,
[data-theme="light"] .stock-detail-change.positive,
[data-theme="light"] .suggestion-ticker-change.positive {
  color: var(--positive-color) !important;
}

[data-theme="light"] .price-down,
[data-theme="light"] .negative,
[data-theme="light"] .loss,
[data-theme="light"] .stock-detail-change.negative,
[data-theme="light"] .suggestion-ticker-change.negative {
  color: var(--negative-color) !important;
}

[data-theme="light"] .error-state-title {
  color: var(--negative-color) !important;
}

/* ---------------------------------------------------------------------------
   Buttons — ghost, disabled, nav
   --------------------------------------------------------------------------- */

[data-theme="light"] .btn-ghost {
  background: rgba(0, 100, 180, 0.04) !important;
  color: var(--text-primary) !important;
  border-color: var(--panel-border) !important;
}

[data-theme="light"] .btn-ghost:active {
  background: rgba(0, 100, 180, 0.08) !important;
}

@media (max-width: 768px) {
  [data-theme="light"] button:disabled,
  [data-theme="light"] button[aria-disabled="true"],
  [data-theme="light"] .btn:disabled,
  [data-theme="light"] .btn[aria-disabled="true"] {
    background: var(--bg-tertiary) !important;
    border-color: var(--panel-border) !important;
    color: var(--text-dim) !important;
  }

  [data-theme="light"] .trade-btn:disabled,
  [data-theme="light"] .quick-trade-submit:disabled,
  [data-theme="light"] .buy-btn:disabled,
  [data-theme="light"] .sell-btn:disabled {
    background: var(--bg-tertiary) !important;
  }
}

[data-theme="light"] .market-card-mobile .trade-btn {
  border-color: var(--accent-cyan) !important;
  color: var(--accent-cyan) !important;
}

[data-theme="light"] .market-card-mobile .trade-btn:active {
  background: var(--accent-cyan) !important;
  color: #ffffff !important;
}

[data-theme="light"] .btn-clear-all,
[data-theme="light"] .clear-all-filters {
  color: var(--negative-color) !important;
  border-color: rgba(220, 38, 38, 0.2) !important;
}

[data-theme="light"] .btn-clear-all:active {
  background: rgba(220, 38, 38, 0.06) !important;
}

[data-theme="light"] .filter-chip,
[data-theme="light"] .active-filter {
  background: rgba(3, 105, 161, 0.06) !important;
  border-color: rgba(3, 105, 161, 0.15) !important;
  color: var(--accent-cyan) !important;
}

[data-theme="light"] .filter-count {
  background: var(--accent-cyan) !important;
  color: #ffffff !important;
}

/* ---------------------------------------------------------------------------
   Bottom nav
   --------------------------------------------------------------------------- */

[data-theme="light"] .mobile-bottom-nav a,
[data-theme="light"] .mobile-bottom-nav button {
  color: var(--text-secondary) !important;
}

[data-theme="light"] .mobile-bottom-nav a.active {
  color: var(--accent-cyan) !important;
}

[data-theme="light"] .mobile-bottom-nav .nav-label {
  color: var(--text-secondary) !important;
}

[data-theme="light"] .mobile-bottom-nav .nav-item.active {
  color: var(--accent-cyan) !important;
}

/* ---------------------------------------------------------------------------
   Tooltips, toasts, search dropdowns
   --------------------------------------------------------------------------- */

[data-theme="light"] .crypto-term::after,
[data-theme="light"] .term-tooltip::after,
[data-theme="light"] [data-tooltip]::after {
  background: rgba(255, 255, 255, 0.95) !important;
  border-color: var(--panel-border) !important;
  color: var(--text-primary) !important;
  box-shadow: 0 4px 16px rgba(0, 50, 120, 0.1) !important;
}

[data-theme="light"] .toast {
  background: rgba(255, 255, 255, 0.95) !important;
  border-color: var(--panel-border) !important;
  box-shadow: 0 8px 32px rgba(0, 50, 120, 0.12) !important;
}

[data-theme="light"] .toast-close {
  background: rgba(0, 100, 180, 0.06) !important;
  color: var(--text-secondary) !important;
}

[data-theme="light"] .toast-close:hover {
  background: rgba(0, 100, 180, 0.12) !important;
  color: var(--text-heading) !important;
}

[data-theme="light"] .search-suggestions,
[data-theme="light"] .autocomplete-dropdown,
[data-theme="light"] .search-results-dropdown {
  background: rgba(255, 255, 255, 0.98) !important;
  border-color: var(--panel-border) !important;
  box-shadow: 0 8px 32px rgba(0, 50, 120, 0.12) !important;
}

[data-theme="light"] .search-suggestion-item:active {
  background: rgba(3, 105, 161, 0.06) !important;
}

[data-theme="light"] .search-clear-btn {
  background: rgba(0, 100, 180, 0.06) !important;
  color: var(--text-secondary) !important;
}

/* ---------------------------------------------------------------------------
   Suggestion chips, related searches
   --------------------------------------------------------------------------- */

[data-theme="light"] .suggestion-chip,
[data-theme="light"] .sector-chip {
  background: rgba(3, 105, 161, 0.06) !important;
  border-color: rgba(3, 105, 161, 0.12) !important;
  color: var(--accent-cyan) !important;
}

[data-theme="light"] .suggestion-chip:active,
[data-theme="light"] .sector-chip:active {
  background: rgba(3, 105, 161, 0.12) !important;
}

[data-theme="light"] .related-search-item {
  background: var(--bg-secondary) !important;
}

[data-theme="light"] .related-search-item:active {
  background: var(--bg-tertiary) !important;
}

[data-theme="light"] .empty-state-query {
  background: var(--bg-secondary) !important;
  color: var(--text-heading) !important;
}

/* ---------------------------------------------------------------------------
   Skeleton loaders
   --------------------------------------------------------------------------- */

[data-theme="light"] .skeleton {
  background: linear-gradient(
    90deg,
    rgba(0, 50, 120, 0.04) 25%,
    rgba(0, 50, 120, 0.08) 50%,
    rgba(0, 50, 120, 0.04) 75%
  ) !important;
  background-size: 200% 100% !important;
}

[data-theme="light"] .graph-skeleton,
[data-theme="light"] .visualization-skeleton,
[data-theme="light"] .chart-skeleton {
  background: rgba(0, 50, 120, 0.03) !important;
}

[data-theme="light"] .skeleton-node {
  background: rgba(0, 50, 120, 0.08) !important;
}

[data-theme="light"] .skeleton-edge {
  background: rgba(0, 50, 120, 0.06) !important;
}

[data-theme="light"] .hero-image,
[data-theme="light"] .banner-image,
[data-theme="light"] .featured-image,
[data-theme="light"] .market-image {
  background: var(--bg-secondary) !important;
}

[data-theme="light"] .stock-detail-logo {
  background: var(--bg-secondary) !important;
}

/* ---------------------------------------------------------------------------
   Epoch timer states
   --------------------------------------------------------------------------- */

[data-theme="light"] .epoch-timer {
  background: var(--bg-secondary) !important;
}

[data-theme="light"] .epoch-timer--loading {
  background: var(--bg-secondary) !important;
}

[data-theme="light"] .epoch-timer--active {
  background: rgba(3, 105, 161, 0.06) !important;
  border-color: rgba(3, 105, 161, 0.15) !important;
}

[data-theme="light"] .epoch-timer--active .epoch-timer-value {
  color: var(--accent-cyan) !important;
}

[data-theme="light"] .epoch-timer--no-epoch {
  background: var(--bg-secondary) !important;
}

/* ---------------------------------------------------------------------------
   Drag handles, misc UI elements
   --------------------------------------------------------------------------- */

[data-theme="light"] .quick-trade-handle,
[data-theme="light"] .bottom-sheet-handle {
  background: rgba(0, 50, 120, 0.15) !important;
}

[data-theme="light"] .pull-indicator {
  background: rgba(3, 105, 161, 0.12) !important;
}

[data-theme="light"] .back-btn,
[data-theme="light"] .back-button,
[data-theme="light"] .nav-back,
[data-theme="light"] [aria-label="Go back"] {
  background: rgba(255, 255, 255, 0.8) !important;
  border-color: var(--panel-border) !important;
  color: var(--text-heading) !important;
}

[data-theme="light"] .back-btn:active,
[data-theme="light"] .back-button:active {
  background: rgba(3, 105, 161, 0.1) !important;
}

/* ---------------------------------------------------------------------------
   Quick action buttons (Yes/No trade buttons)
   --------------------------------------------------------------------------- */

[data-theme="light"] .quick-action-btn.yes {
  background: rgba(3, 105, 161, 0.08) !important;
  border-color: rgba(3, 105, 161, 0.3) !important;
  color: var(--accent-cyan) !important;
}

[data-theme="light"] .quick-action-btn.no {
  background: rgba(220, 38, 38, 0.06) !important;
  border-color: rgba(220, 38, 38, 0.25) !important;
  color: var(--negative-color) !important;
}

[data-theme="light"] .quick-action-btn.yes:active {
  background: rgba(3, 105, 161, 0.15) !important;
}

[data-theme="light"] .quick-action-btn.no:active {
  background: rgba(220, 38, 38, 0.12) !important;
}

/* ---------------------------------------------------------------------------
   WCAG muted text — use variables instead of hardcoded grays
   --------------------------------------------------------------------------- */

[data-theme="light"] .text-muted,
[data-theme="light"] .text-secondary,
[data-theme="light"] .text-grey,
[data-theme="light"] .subtitle,
[data-theme="light"] .meta,
[data-theme="light"] .timestamp,
[data-theme="light"] .helper-text,
[data-theme="light"] small {
  color: var(--text-dim) !important;
}

/* ---------------------------------------------------------------------------
   Probability bars — ensure contrast on light backgrounds
   --------------------------------------------------------------------------- */

[data-theme="light"] .market-card-mobile .probability-bar {
  background: rgba(0, 50, 120, 0.08) !important;
}

/* ---------------------------------------------------------------------------
   Orderbook rows — active state
   --------------------------------------------------------------------------- */

[data-theme="light"] .orderbook-row:active {
  background: rgba(3, 105, 161, 0.06) !important;
}

/* ---------------------------------------------------------------------------
   Header scrolled shadow
   --------------------------------------------------------------------------- */

[data-theme="light"] .header--scrolled,
[data-theme="light"] .main-header.scrolled {
  box-shadow: 0 4px 20px rgba(0, 50, 120, 0.08) !important;
}

/* ---------------------------------------------------------------------------
   Mobile hero secondary buttons
   --------------------------------------------------------------------------- */

[data-theme="light"] .mobile-hero-btn {
  background: rgba(0, 100, 180, 0.04) !important;
  border-color: var(--panel-border) !important;
  color: var(--text-heading) !important;
}

[data-theme="light"] .mobile-hero-btn:active {
  background: rgba(3, 105, 161, 0.08) !important;
}

[data-theme="light"] .mobile-menu-item:active {
  background: rgba(3, 105, 161, 0.06) !important;
}

/* ---------------------------------------------------------------------------
   Max button in quick-trade
   --------------------------------------------------------------------------- */

[data-theme="light"] .quick-trade-max-btn {
  background: rgba(3, 105, 161, 0.08) !important;
  color: var(--accent-cyan) !important;
}

[data-theme="light"] .quick-trade-max-btn:active {
  background: rgba(3, 105, 161, 0.15) !important;
}

/* v2 design overrides — neutral borders, shadows */
@media (max-width: 768px) {
  .glass-btn { border-color: var(--panel-border); border-radius: 6px; }
  .glass-btn:hover,
  .glass-btn:active { border-color: var(--panel-border-hover); }
  .glass-btn.active { border-color: var(--accent-cyan); }
  .market-card { border-color: var(--panel-border); border-radius: 6px; }
  .modal-content { border-color: var(--panel-border); border-radius: 6px; }
  .content-panel { border-radius: var(--panel-radius); }
}

/* iOS zoom prevention — global input/select override */
@media (max-width: 768px) {
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  select,
  textarea {
    font-size: max(16px, 1em) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =============================================================================
   INLINE CODE (ET-33864) — the phone rules above style every <code> like a block
   (12-16px padding, 16px side margins, overflow scroll box, line-height 1.5), which
   made inline code in docs paragraphs overlap the neighbouring text lines. Inline
   code (not inside pre / .code-block) stays a small inline chip that wraps with the
   text. Selector specificity beats the `html body code` !important rules above.
   ============================================================================= */
html body code:not(pre code):not(.code-block code) {
  display: inline !important;
  padding: 0.1em 0.35em !important;
  margin: 0 !important;
  overflow: visible !important;
  max-width: none !important;
  line-height: inherit !important;
  font-size: 0.9em !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: normal !important;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
