/* Custom Scrollbar - Soft Pastel */
    ::-webkit-scrollbar {
      width: 5px;
      height: 5px;
    }
    ::-webkit-scrollbar-track {
      background: transparent;
    }
    ::-webkit-scrollbar-thumb {
      background: rgba(142, 197, 252, 0.4);
      border-radius: 9999px;
    }
    ::-webkit-scrollbar-thumb:hover {
      background: rgba(142, 197, 252, 0.7);
    }

    :root {
      --sat: env(safe-area-inset-top, 0px);
      --sab: env(safe-area-inset-bottom, 0px);
      --sal: env(safe-area-inset-left, 0px);
      --sar: env(safe-area-inset-right, 0px);
    }

    html {
      width: 100%;
      max-width: 100vw;
      overflow-x: hidden !important;
      -webkit-text-size-adjust: 100%;
    }

    body {
      background-color: #f1f6fb;
      color: #2d3748;
      min-height: 100vh;
      width: 100%;
      max-width: 100vw;
      overflow-x: hidden !important;
      touch-action: pan-y;
      padding-top: var(--sat);
      padding-left: var(--sal);
      padding-right: var(--sar);
    }

    /* Guaranteed Display None for Modals & Drawers when inactive (without breaking responsive sm:/md:/lg: classes) */
    .hidden:not([class*=":flex"]):not([class*=":block"]):not([class*=":inline"]):not([class*=":inline-flex"]):not([class*=":grid"]) {
      display: none !important;
    }

    /* Smooth horizontal scrolling without ugly scrollbars for Top Nav */
    .no-scrollbar::-webkit-scrollbar {
      display: none !important;
    }
    .no-scrollbar {
      -ms-overflow-style: none !important;
      scrollbar-width: none !important;
    }

    /* Glassmorphic Top Nav Bar */
    .top-nav-glass {
      background: rgba(255, 255, 255, 0.85);
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
      border-bottom: 1px solid rgba(226, 232, 240, 0.85);
    }
    html.dark .top-nav-glass {
      background: rgba(15, 23, 42, 0.88);
      border-bottom-color: rgba(51, 65, 85, 0.7);
    }

    /* Soft Pastel Sky Wallpaper */
    .pastel-bg-layer {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      z-index: -2;
      background: url('/assets/pastel_bg.jpg') center center / cover no-repeat;
      opacity: 0.95;
    }

    /* Ethereal Morning Mist Veil */
    .mist-veil {
      position: fixed;
      inset: 0;
      background: radial-gradient(circle at 15% 20%, rgba(254, 247, 238, 0.45) 0%, rgba(232, 243, 251, 0.35) 45%, rgba(246, 249, 252, 0.65) 100%);
      pointer-events: none;
      z-index: -1;
    }

    /* Three.js Canvas Layer */
    #threeCanvas {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      z-index: 0;
      pointer-events: none;
    }

    /* Soft Frosted Pastel Glass Cards (Minimal & Clean) */
    .soft-card {
      background: rgba(255, 255, 255, 0.78);
      backdrop-filter: blur(24px) saturate(140%);
      -webkit-backdrop-filter: blur(24px) saturate(140%);
      border: 1px solid rgba(255, 255, 255, 0.92);
      border-radius: 1.25rem;
      box-shadow: 0 10px 30px -5px rgba(91, 155, 213, 0.08), 0 0 0 1px rgba(255, 255, 255, 0.6);
      transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1), box-shadow 0.25s ease, border-color 0.25s ease;
      position: relative;
      overflow: hidden;
    }

    .soft-card:hover {
      box-shadow: 0 16px 36px -6px rgba(91, 155, 213, 0.15), 0 0 0 1px rgba(186, 222, 255, 0.8);
      border-color: rgba(186, 222, 255, 0.95);
    }

    /* Soft Inner Sub-Panels */
    .soft-panel {
      background: rgba(255, 255, 255, 0.62);
      border: 1px solid rgba(235, 242, 250, 0.9);
      border-radius: 0.875rem;
    }

    .soft-panel:hover {
      background: rgba(255, 255, 255, 0.88);
    }

    /* ======================================================== */
    /* AETHER NIGHT (DARK MODE) — LUXURIOUS OLED / MIDNIGHT SLATE */
    /* ======================================================== */
    html.dark body {
      background-color: #070b14 !important;
      color: #e2e8f0 !important;
    }

    html.dark ::-webkit-scrollbar-thumb {
      background: rgba(148, 163, 184, 0.3);
    }
    html.dark ::-webkit-scrollbar-thumb:hover {
      background: rgba(148, 163, 184, 0.5);
    }

    html.dark .pastel-bg-layer {
      background: radial-gradient(circle at 50% 0%, #0d1a3a 0%, #060913 55%, #020409 100%) !important;
      opacity: 0.98 !important;
    }

    html.dark .mist-veil {
      background: radial-gradient(circle at 15% 20%, rgba(29, 78, 216, 0.16) 0%, rgba(15, 23, 42, 0.6) 45%, rgba(3, 7, 18, 0.92) 100%) !important;
    }

    html.dark .soft-card {
      background: rgba(15, 23, 42, 0.78) !important;
      backdrop-filter: blur(28px) saturate(160%) !important;
      -webkit-backdrop-filter: blur(28px) saturate(160%) !important;
      border: 1px solid rgba(255, 255, 255, 0.08) !important;
      box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.03) !important;
      color: #f1f5f9 !important;
    }

    html.dark .soft-card:hover {
      box-shadow: 0 16px 40px -6px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(56, 189, 248, 0.35) !important;
      border-color: rgba(56, 189, 248, 0.35) !important;
    }

    html.dark .soft-panel {
      background: rgba(30, 41, 59, 0.6) !important;
      border: 1px solid rgba(255, 255, 255, 0.07) !important;
      color: #cbd5e1 !important;
    }

    html.dark .soft-panel:hover {
      background: rgba(30, 41, 59, 0.85) !important;
    }

    html.dark .header-icon-box {
      background: rgba(30, 41, 59, 0.8) !important;
      border-color: rgba(255, 255, 255, 0.1) !important;
    }

    html.dark .card-title,
    html.dark .text-slate-800,
    html.dark .text-slate-900 {
      color: #f8fafc !important;
    }

    html.dark .text-slate-700 {
      color: #e2e8f0 !important;
    }

    html.dark .text-slate-600 {
      color: #cbd5e1 !important;
    }

    html.dark .text-slate-500 {
      color: #94a3b8 !important;
    }

    html.dark .text-slate-400 {
      color: #64748b !important;
    }

    html.dark .border-slate-100,
    html.dark .border-slate-200 {
      border-color: rgba(255, 255, 255, 0.08) !important;
    }

    html.dark .border-b-slate-100,
    html.dark .border-t-slate-100 {
      border-color: rgba(255, 255, 255, 0.07) !important;
    }

    html.dark .bg-white {
      background-color: #1e293b !important;
    }

    html.dark .bg-white\/80,
    html.dark .bg-white\/90,
    html.dark .bg-white\/95 {
      background-color: rgba(30, 41, 59, 0.9) !important;
    }

    html.dark .bg-slate-50 {
      background-color: #0f172a !important;
    }

    html.dark .bg-slate-100 {
      background-color: #1e293b !important;
    }

    html.dark .cat-pill {
      background: rgba(30, 41, 59, 0.65) !important;
      color: #94a3b8 !important;
      border: 1px solid rgba(255, 255, 255, 0.06) !important;
    }

    html.dark .cat-pill:hover {
      background: rgba(30, 41, 59, 0.95) !important;
      color: #f1f5f9 !important;
    }

    html.dark .cat-pill.active {
      background: rgba(14, 165, 233, 0.22) !important;
      color: #38bdf8 !important;
      border: 1px solid rgba(56, 189, 248, 0.5) !important;
    }

    html.dark .col-pill {
      color: #94a3b8 !important;
    }

    html.dark .col-pill:hover {
      background: #334155 !important;
      color: #ffffff !important;
    }

    html.dark .col-pill.active {
      background: #0284c7 !important;
      color: #ffffff !important;
    }

    html.dark input, 
    html.dark select {
      background-color: #0f172a !important;
      color: #f8fafc !important;
      border-color: rgba(255, 255, 255, 0.15) !important;
    }

    html.dark input::placeholder {
      color: #64748b !important;
    }

    html.dark #detailModalCard,
    html.dark #agentDrawer {
      background: rgba(15, 23, 42, 0.97) !important;
      border-color: rgba(255, 255, 255, 0.12) !important;
      color: #f1f5f9 !important;
    }

    html.dark #detailModalOverlay {
      background-color: rgba(3, 7, 18, 0.8) !important;
    }

    html.dark .card-badge-pill {
      background: rgba(30, 41, 59, 0.8) !important;
      border-color: rgba(255, 255, 255, 0.1) !important;
    }

    /* Smooth Transition between Light & Dark */
    body, .soft-card, .soft-panel, .cat-pill, header, input, select {
      transition: background-color 0.28s ease, border-color 0.28s ease, color 0.28s ease, box-shadow 0.28s ease;
    }

    /* Soft Marquee Animation */
    @keyframes softMarquee {
      0% { transform: translateX(0%); }
      100% { transform: translateX(-50%); }
    }
    .animate-soft-marquee {
      display: inline-flex;
      animation: softMarquee 42s linear infinite;
    }
    .animate-soft-marquee:hover {
      animation-play-state: paused;
    }

    /* Soft Soundwave Voice Equalizer */
    @keyframes softEq {
      0%, 100% { height: 4px; }
      50% { height: 16px; }
    }
    .soft-eq-bar {
      width: 2.5px;
      background: #718096;
      border-radius: 2px;
      animation: softEq 0.9s ease-in-out infinite;
    }

    /* Drawer Transition */
    .drawer-slide {
      transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
    }

    /* ======================================================== */
    /* DYNAMIC INTELLIGENT GRID & RESPONSIVE SCALING (1-6 COLS) */
    /* ======================================================== */

    /* Ultra-wide & Desktop Displays (>= 1180px): Full 1 to 6 Column Freedom */
    @media (min-width: 1180px) {
      #mainGrid.cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)) !important; }
      #mainGrid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
      #mainGrid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
      #mainGrid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
      #mainGrid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
      #mainGrid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; }
    }

    /* Medium Displays & Small Desktops (900px to 1179px): Respect chosen column density */
    @media (min-width: 900px) and (max-width: 1179px) {
      #mainGrid.cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)) !important; }
      #mainGrid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
      #mainGrid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
      #mainGrid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
      #mainGrid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
      #mainGrid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; }
    }

    /* Tablets (640px to 899px): Clean readable layout (1-3 cols; cap ultra-dense 4-6 cols to 3 cols on tablets) */
    @media (min-width: 640px) and (max-width: 899px) {
      #mainGrid.cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)) !important; }
      #mainGrid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
      #mainGrid.cols-3,
      #mainGrid.cols-4,
      #mainGrid.cols-5,
      #mainGrid.cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    }

    /* Mobile Phones (< 640px): Clean single-column stack by default (allow explicit 2-col compact view, prevent unreadable 3-6 col squish) */
    @media (max-width: 639px) {
      #mainGrid {
        display: grid !important;
        grid-auto-rows: auto !important;
        gap: 0.875rem !important;
        padding-bottom: calc(5.5rem + var(--sab, 0px)) !important;
      }
      #mainGrid.cols-1,
      #mainGrid.cols-3,
      #mainGrid.cols-4,
      #mainGrid.cols-5,
      #mainGrid.cols-6 { grid-template-columns: repeat(1, minmax(0, 1fr)) !important; }
      #mainGrid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 0.5rem !important; }
      #mainGrid.cols-2 > section.soft-card {
        padding: 0.75rem 0.65rem !important;
      }
      #mainGrid > section.soft-card {
        min-height: auto !important;
        height: auto !important;
        max-height: none !important;
        padding: 1rem 0.875rem !important;
        border-radius: 1.15rem !important;
        box-shadow: 0 4px 16px -2px rgba(91, 155, 213, 0.08) !important;
      }
      #mainGrid #weatherGridInner {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
      }
      #mainGrid #weatherMiniMapContainer {
        height: 160px !important;
        width: 100% !important;
      }
    }

    /* Standardized 560px Uniform Height System across all 12 cards on desktop */
    @media (min-width: 640px) {
      #mainGrid {
        display: grid !important;
        grid-auto-rows: 560px !important;
      }
      #mainGrid > section.soft-card {
        height: 560px !important;
        min-height: 560px !important;
        max-height: 560px !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
      }
      #mainGrid.cols-1 {
        grid-auto-rows: auto !important;
      }
      #mainGrid.cols-1 > section.soft-card {
        height: auto !important;
        min-height: 520px !important;
        max-height: none !important;
      }
    }

    /* Strict Card Hidden & Toggling Rules - guarantees show/hide works without breaking Tailwind responsive md:flex / sm:inline */
    .hidden:not([class*=":flex"]):not([class*=":block"]):not([class*=":inline"]):not([class*=":inline-flex"]):not([class*=":grid"]),
    #mainGrid .soft-card.hidden,
    #mainGrid > section.hidden,
    #noCardsSelectedBanner.hidden {
      display: none !important;
    }

    /* Common Card Smooth Transition & Equal Grid Height Balancing */
    #mainGrid .soft-card {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }

    /* Standard Card Header & Footer Height Alignment */
    #mainGrid .soft-card > div:first-of-type {
      min-height: 46px !important;
      margin-bottom: 0.25rem !important;
    }
    #mainGrid .soft-card > div:last-of-type {
      margin-top: auto !important;
      min-height: 32px !important;
    }

    /* ================================================= */
    /* DENSITY LEVEL 1: 1 COLUMN (Cinematic Roomy Mode)  */
    /* ================================================= */
    @media (min-width: 640px) {
      #mainGrid.cols-1 .soft-card { padding: 1.75rem !important; }
      #mainGrid.cols-1 h2, #mainGrid.cols-1 .card-title { font-size: 1.35rem !important; }
      #mainGrid.cols-1 .card-subtitle { font-size: 0.85rem !important; }
      #mainGrid.cols-1 .card-badge-pill { font-size: 0.8rem !important; padding: 0.3rem 0.75rem !important; }
      #mainGrid.cols-1 .card-metric-primary { font-size: 3.2rem !important; }
      #mainGrid.cols-1 .card-metric-secondary { font-size: 1.65rem !important; }
      #mainGrid.cols-1 .header-icon-box { width: 3rem !important; height: 3rem !important; font-size: 1.25rem !important; border-radius: 1rem !important; }
      #mainGrid.cols-1 .text-xs { font-size: 1rem !important; line-height: 1.5 !important; }
      #mainGrid.cols-1 .text-sm { font-size: 1.125rem !important; line-height: 1.5 !important; }
      #mainGrid.cols-1 .text-[10px], #mainGrid.cols-1 .text-[11px], #mainGrid.cols-1 .text-[9px], #mainGrid.cols-1 .text-[8px] { font-size: 0.85rem !important; line-height: 1.35 !important; }
      #mainGrid.cols-1 .soft-panel { padding: 0.75rem 1rem !important; border-radius: 1rem !important; }
      #mainGrid.cols-1 .stat-row { padding: 0.65rem 1rem !important; }
      #mainGrid.cols-1 #globeContainer { height: 160px !important; width: 160px !important; margin: 0 auto; }
      #mainGrid.cols-1 #popBarContainer { height: 64px !important; }
    }

    /* ================================================= */
    /* DENSITY LEVEL 2: 2 COLUMNS (Comfortable & Generous) */
    /* ================================================= */
    @media (min-width: 640px) {
      #mainGrid.cols-2 .soft-card { padding: 1.35rem !important; }
      #mainGrid.cols-2 h2, #mainGrid.cols-2 .card-title { font-size: 1.125rem !important; }
      #mainGrid.cols-2 .card-subtitle { font-size: 0.78rem !important; }
      #mainGrid.cols-2 .card-badge-pill { font-size: 0.72rem !important; padding: 0.25rem 0.6rem !important; }
      #mainGrid.cols-2 .card-metric-primary { font-size: 2.4rem !important; }
      #mainGrid.cols-2 .card-metric-secondary { font-size: 1.35rem !important; }
      #mainGrid.cols-2 .header-icon-box { width: 2.6rem !important; height: 2.6rem !important; font-size: 1.05rem !important; }
      #mainGrid.cols-2 .text-xs { font-size: 0.875rem !important; line-height: 1.4 !important; }
      #mainGrid.cols-2 .text-sm { font-size: 0.975rem !important; line-height: 1.4 !important; }
      #mainGrid.cols-2 .text-[10px], #mainGrid.cols-2 .text-[11px], #mainGrid.cols-2 .text-[9px] { font-size: 0.76rem !important; line-height: 1.3 !important; }
      #mainGrid.cols-2 .soft-panel { padding: 0.6rem 0.85rem !important; }
      #mainGrid.cols-2 .stat-row { padding: 0.55rem 0.8rem !important; }
      #mainGrid.cols-2 #globeContainer { height: 140px !important; width: 140px !important; margin: 0 auto; }
      #mainGrid.cols-2 #popBarContainer { height: 64px !important; }
    }

    /* ================================================= */
    /* DENSITY LEVEL 3: 3 COLUMNS (Standard Classic View) */
    /* ================================================= */
    @media (min-width: 640px) {
      #mainGrid.cols-3 .soft-card { padding: 1rem !important; }
      #mainGrid.cols-3 h2, #mainGrid.cols-3 .card-title { font-size: 0.875rem !important; }
      #mainGrid.cols-3 .card-subtitle { font-size: 0.6875rem !important; }
      #mainGrid.cols-3 .card-badge-pill { font-size: 0.625rem !important; padding: 0.2rem 0.5rem !important; }
      #mainGrid.cols-3 .card-metric-primary { font-size: 1.85rem !important; }
      #mainGrid.cols-3 .card-metric-secondary { font-size: 1.15rem !important; }
      #mainGrid.cols-3 .header-icon-box { width: 2.25rem !important; height: 2.25rem !important; font-size: 0.875rem !important; }
      #mainGrid.cols-3 #globeContainer { height: 125px !important; }
      #mainGrid.cols-3 #popBarContainer { height: 64px !important; }
    }

    /* ================================================= */
    /* DENSITY LEVEL 4: 4 COLUMNS (Compact Cockpit)      */
    /* ================================================= */
    @media (min-width: 640px) {
      #mainGrid.cols-4 .soft-card { padding: 0.8rem !important; }
      #mainGrid.cols-4 h2, #mainGrid.cols-4 .card-title { font-size: 0.8rem !important; }
      #mainGrid.cols-4 .card-subtitle { font-size: 0.625rem !important; }
      #mainGrid.cols-4 .card-badge-pill { font-size: 0.58rem !important; padding: 0.15rem 0.4rem !important; }
      #mainGrid.cols-4 .card-metric-primary { font-size: 1.45rem !important; }
      #mainGrid.cols-4 .card-metric-secondary { font-size: 0.95rem !important; }
      #mainGrid.cols-4 .header-icon-box { width: 2rem !important; height: 2rem !important; font-size: 0.8rem !important; }
      #mainGrid.cols-4 .text-xs { font-size: 0.7rem !important; line-height: 1.25 !important; }
      #mainGrid.cols-4 .text-sm { font-size: 0.78rem !important; line-height: 1.25 !important; }
      #mainGrid.cols-4 .text-[10px], #mainGrid.cols-4 .text-[11px], #mainGrid.cols-4 .text-[9px] { font-size: 0.62rem !important; line-height: 1.18 !important; }
      #mainGrid.cols-4 .soft-panel { padding: 0.4rem 0.55rem !important; }
      #mainGrid.cols-4 .stat-row { padding: 0.35rem 0.5rem !important; }
      #mainGrid.cols-4 #globeContainer { height: 105px !important; }
      #mainGrid.cols-4 #popBarContainer { height: 56px !important; }
    }

    /* ================================================= */
    /* DENSITY LEVEL 5: 5 COLUMNS (Dense Wall Layout)    */
    /* ================================================= */
    @media (min-width: 640px) {
      #mainGrid.cols-5 .soft-card { padding: 0.65rem !important; }
      #mainGrid.cols-5 h2, #mainGrid.cols-5 .card-title { font-size: 0.74rem !important; }
      #mainGrid.cols-5 .card-subtitle { font-size: 0.58rem !important; }
      #mainGrid.cols-5 .card-badge-pill { font-size: 0.52rem !important; padding: 0.12rem 0.35rem !important; }
      #mainGrid.cols-5 .card-metric-primary { font-size: 1.25rem !important; }
      #mainGrid.cols-5 .card-metric-secondary { font-size: 0.82rem !important; }
      #mainGrid.cols-5 .header-icon-box { width: 1.75rem !important; height: 1.75rem !important; font-size: 0.72rem !important; }
      #mainGrid.cols-5 .text-xs { font-size: 0.64rem !important; line-height: 1.2 !important; }
      #mainGrid.cols-5 .text-sm { font-size: 0.7rem !important; line-height: 1.2 !important; }
      #mainGrid.cols-5 .text-[10px], #mainGrid.cols-5 .text-[11px], #mainGrid.cols-5 .text-[9px] { font-size: 0.56rem !important; line-height: 1.15 !important; }
      #mainGrid.cols-5 .soft-panel { padding: 0.32rem 0.45rem !important; }
      #mainGrid.cols-5 .stat-row { padding: 0.28rem 0.42rem !important; }
      #mainGrid.cols-5 #weatherGridInner { display: flex !important; flex-direction: column !important; align-items: center !important; text-align: center !important; gap: 0.5rem !important; }
      #mainGrid.cols-5 #weatherGridInner > div:first-child { display: flex; flex-direction: column; align-items: center; }
      #mainGrid.cols-5 #globeContainer { height: 90px !important; width: 90px !important; }
      #mainGrid.cols-5 #popBarContainer { height: 38px !important; }
      #mainGrid.cols-5 .card-subtitle-hide { display: none !important; }
    }

    /* ================================================= */
    /* DENSITY LEVEL 6: 6 COLUMNS (Single-Row Panorama)  */
    /* ================================================= */
    @media (min-width: 640px) {
      #mainGrid.cols-6 .soft-card { padding: 0.5rem !important; }
      #mainGrid.cols-6 h2, #mainGrid.cols-6 .card-title { font-size: 0.68rem !important; }
      #mainGrid.cols-6 .card-subtitle { font-size: 0.52rem !important; }
      #mainGrid.cols-6 .card-badge-pill { font-size: 0.48rem !important; padding: 0.08rem 0.28rem !important; }
      #mainGrid.cols-6 .card-metric-primary { font-size: 1.1rem !important; }
      #mainGrid.cols-6 .card-metric-secondary { font-size: 0.74rem !important; }
      #mainGrid.cols-6 .header-icon-box { width: 1.55rem !important; height: 1.55rem !important; font-size: 0.68rem !important; border-radius: 0.5rem !important; }
      #mainGrid.cols-6 .text-xs { font-size: 0.58rem !important; line-height: 1.15 !important; }
      #mainGrid.cols-6 .text-sm { font-size: 0.64rem !important; line-height: 1.15 !important; }
      #mainGrid.cols-6 .text-[10px], #mainGrid.cols-6 .text-[11px], #mainGrid.cols-6 .text-[9px] { font-size: 0.52rem !important; line-height: 1.1 !important; }
      #mainGrid.cols-6 .soft-panel { padding: 0.25rem 0.35rem !important; }
      #mainGrid.cols-6 .stat-row { padding: 0.22rem 0.32rem !important; }
      #mainGrid.cols-6 #weatherGridInner { display: flex !important; flex-direction: column !important; align-items: center !important; text-align: center !important; gap: 0.35rem !important; }
      #mainGrid.cols-6 #weatherGridInner > div:first-child { display: flex; flex-direction: column; align-items: center; }
      #mainGrid.cols-6 #globeContainer { height: 75px !important; width: 75px !important; }
      #mainGrid.cols-6 #popBarContainer { height: 32px !important; }
      #mainGrid.cols-6 .card-subtitle-hide { display: none !important; }
      #mainGrid.cols-6 .card-footer-extra { display: none !important; }
    }

    /* ======================================================== */
    /* CARD REORDER MODE (รูปมือ & DRAG-AND-DROP)               */
    /* ======================================================== */
    #mainGrid.reorder-mode-active {
      position: relative;
    }
    #mainGrid.reorder-mode-active .soft-card {
      position: relative !important;
      cursor: grab !important;
      user-select: none !important;
      outline: 2px dashed rgba(245, 158, 11, 0.75) !important;
      outline-offset: -2px !important;
      transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.2s ease, opacity 0.2s ease !important;
    }
    #mainGrid.reorder-mode-active .soft-card:hover {
      transform: translateY(-4px) scale(1.01) !important;
      box-shadow: 0 16px 30px -6px rgba(245, 158, 11, 0.25), 0 0 0 1px rgba(245, 158, 11, 0.5) !important;
    }
    #mainGrid.reorder-mode-active .soft-card:active {
      cursor: grabbing !important;
    }
    #mainGrid.reorder-mode-active .soft-card.is-dragging {
      opacity: 0.35 !important;
      transform: scale(0.96) !important;
      outline: 2px dashed #0284c7 !important;
      box-shadow: none !important;
    }
    /* Floating Hand Badge (รูปมือ) on each card in reorder mode */
    .card-reorder-hand-badge {
      display: none;
      position: absolute;
      top: 0.6rem;
      right: 0.6rem;
      z-index: 45;
      background: linear-gradient(135deg, #f59e0b, #d97706);
      color: #ffffff;
      padding: 0.25rem 0.55rem;
      border-radius: 0.85rem;
      font-size: 0.72rem;
      font-weight: 700;
      box-shadow: 0 4px 12px rgba(217, 119, 6, 0.38);
      border: 1px solid rgba(255, 255, 255, 0.85);
      align-items: center;
      gap: 0.35rem;
      user-select: none;
      cursor: grab;
      animation: gentle-hand-bounce 1.6s ease-in-out infinite;
    }
    .card-reorder-hand-badge:hover {
      background: linear-gradient(135deg, #d97706, #b45309);
      box-shadow: 0 6px 14px rgba(217, 119, 6, 0.5);
    }
    .card-reorder-hand-badge:active {
      cursor: grabbing;
      transform: scale(0.95);
    }
    #mainGrid.reorder-mode-active .card-reorder-hand-badge {
      display: inline-flex !important;
    }
    @keyframes gentle-hand-bounce {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(-3px); }
    }

    /* WeatherNext 3 Neural Radar & Leaflet Map Styling */
    .weathernext-pulse-marker {
      position: relative;
      width: 24px;
      height: 24px;
    }
    .weathernext-pulse-ring, .pulse-ring {
      position: absolute;
      width: 36px;
      height: 36px;
      top: -6px;
      left: -6px;
      border-radius: 50%;
      background: rgba(14, 165, 233, 0.45);
      animation: weathernext-ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
    }
    .weathernext-pulse-dot, .pulse-core {
      position: absolute;
      width: 14px;
      height: 14px;
      top: 5px;
      left: 5px;
      border-radius: 50%;
      background: #0284c7;
      border: 2px solid #ffffff;
      box-shadow: 0 0 12px rgba(14, 165, 233, 0.9);
    }
    @keyframes weathernext-ping {
      75%, 100% {
        transform: scale(2.4);
        opacity: 0;
      }
    }
    @keyframes pulse-ring {
      75%, 100% {
        transform: scale(2.4);
        opacity: 0;
      }
    }
    .dark .leaflet-container {
      background: #0b1120 !important;
    }
    .leaflet-container {
      font-family: 'Plus Jakarta Sans', 'Sarabun', sans-serif !important;
    }
    .leaflet-tile {
      filter: saturate(1.1);
    }
    .dark .leaflet-tile {
      filter: brightness(0.85) contrast(1.15) saturate(1.2);
    }

    /* ======================================================== */
    /* 1. LOADING SKELETON ANIMATION (H-01)                      */
    /* ======================================================== */
    @keyframes aether-shimmer {
      0% { transform: translateX(-100%); }
      100% { transform: translateX(100%); }
    }
    .skeleton-box {
      position: relative;
      overflow: hidden;
      background-color: rgba(226, 232, 240, 0.75);
      border-radius: 0.5rem;
    }
    html.dark .skeleton-box {
      background-color: rgba(30, 41, 59, 0.75);
    }
    .skeleton-box::after {
      content: '';
      position: absolute;
      top: 0; right: 0; bottom: 0; left: 0;
      transform: translateX(-100%);
      background-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0, rgba(255, 255, 255, 0.4) 20%, rgba(255, 255, 255, 0.8) 60%, rgba(255, 255, 255, 0));
      animation: aether-shimmer 1.8s infinite;
    }
    html.dark .skeleton-box::after {
      background-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0, rgba(255, 255, 255, 0.06) 20%, rgba(255, 255, 255, 0.15) 60%, rgba(255, 255, 255, 0));
    }

    /* ======================================================== */
    /* 6. DARK MODE POLISH & CONTRAST (H-06)                     */
    /* ======================================================== */
    body, .soft-card, .soft-panel, header, nav {
      transition: background-color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                  border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                  color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                  box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }
    html.dark .border-slate-100 {
      border-color: rgba(255, 255, 255, 0.08) !important;
    }
    html.dark .border-slate-200 {
      border-color: rgba(255, 255, 255, 0.12) !important;
    }
    html.dark input, html.dark select, html.dark textarea {
      background-color: rgba(15, 23, 42, 0.85);
      border-color: rgba(255, 255, 255, 0.12);
      color: #f8fafc;
    }
    html.dark input:focus, html.dark select:focus {
      border-color: #38bdf8;
      box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
    }

    /* ======================================================== */
    /* 5. MODERN TOAST NOTIFICATIONS (H-05)                      */
    /* ======================================================== */
    #toastStackContainer {
      position: fixed;
      bottom: 1.5rem;
      right: 1.5rem;
      z-index: 9999;
      display: flex;
      flex-direction: column-reverse;
      gap: 0.5rem;
      pointer-events: none;
      max-width: 90vw;
    }
    .aether-toast-item {
      pointer-events: auto;
      transform: translateY(1rem) scale(0.95);
      opacity: 0;
      transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    .aether-toast-item.toast-show {
      transform: translateY(0) scale(1);
      opacity: 1;
    }
    .toast-progress-bar {
      position: absolute;
      bottom: 0;
      left: 0;
      height: 2.5px;
      width: 100%;
      border-radius: 0 0 1rem 1rem;
      transform-origin: left;
    }

    /* ======================================================== */
    /* MOBILE APP-LIKE BOTTOM DOCK & TOUCH HARDENING (H-MOBILE) */
    /* ======================================================== */
    .mobile-bottom-dock {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      z-index: 45;
      align-items: center;
      justify-content: space-around;
      background: rgba(255, 255, 255, 0.94);
      backdrop-filter: blur(24px) saturate(180%);
      -webkit-backdrop-filter: blur(24px) saturate(180%);
      border-top: 1px solid rgba(226, 232, 240, 0.85);
      padding: 0.35rem 0.25rem calc(0.35rem + var(--sab, 0px));
      box-shadow: 0 -4px 20px -2px rgba(15, 23, 42, 0.08);
      transition: transform 0.25s ease, background-color 0.25s ease;
    }

    html.dark .mobile-bottom-dock {
      background: rgba(15, 23, 42, 0.94) !important;
      border-top-color: rgba(51, 65, 85, 0.8) !important;
      box-shadow: 0 -4px 24px -2px rgba(0, 0, 0, 0.45) !important;
    }

    .bottom-dock-btn {
      flex: 1 1 0%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 0.15rem;
      padding: 0.25rem 0.125rem;
      font-size: 0.65rem;
      font-weight: 500;
      color: #64748b;
      border-radius: 0.75rem;
      touch-action: manipulation;
      -webkit-tap-highlight-color: transparent;
    }
    html.dark .bottom-dock-btn {
      color: #94a3b8;
    }
    .bottom-dock-btn.active {
      color: #0284c7 !important;
    }
    html.dark .bottom-dock-btn.active {
      color: #38bdf8 !important;
    }

    /* Mobile Sheet / Drawer Transitions */
    .mobile-sheet-overlay {
      position: fixed;
      inset: 0;
      z-index: 1050;
      background: rgba(15, 23, 42, 0.5);
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.25s ease;
    }
    .mobile-sheet-overlay.active {
      opacity: 1;
      pointer-events: auto;
    }

    .mobile-sheet-card {
      position: fixed;
      bottom: 0;
      left: 0;
      right: 0;
      z-index: 1060;
      max-height: 85vh;
      border-radius: 1.5rem 1.5rem 0 0;
      padding-bottom: calc(1.5rem + var(--sab, 0px));
      background: rgba(255, 255, 255, 0.98);
      backdrop-filter: blur(24px);
      -webkit-backdrop-filter: blur(24px);
      border-top: 1px solid rgba(226, 232, 240, 0.9);
      box-shadow: 0 -10px 40px -10px rgba(0, 0, 0, 0.2);
      transform: translateY(100%);
      transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    html.dark .mobile-sheet-card {
      background: rgba(15, 23, 42, 0.98) !important;
      border-top-color: rgba(51, 65, 85, 0.8) !important;
      box-shadow: 0 -10px 40px -10px rgba(0, 0, 0, 0.6) !important;
    }
    .mobile-sheet-card.sheet-open {
      transform: translateY(0);
    }

    /* Zero Horizontal Jitter on Modals & Cards */
    @media (max-width: 639px) {
      .soft-card, .soft-panel, #aiAssistantDrawer, #detailModalCard, #cityPickerModalCard, #pwaModalCard {
        max-width: calc(100vw - 1rem) !important;
      }
      header.soft-card {
        padding: 0.875rem !important;
        border-radius: 1.15rem !important;
      }
      /* Ensure category chips don't cause parent horizontal scroll */
      #categoryPillsContainer {
        padding-left: 0.25rem;
        padding-right: 0.25rem;
        -webkit-overflow-scrolling: touch;
      }
    }
