/* =========================================================
       THEME SYSTEM — System / Light / Dark
    ========================================================= */

    html{
      color-scheme:light;
    }

    html.theme-dark{
      color-scheme:dark;

      --bg:#101722;
      --surface:#182230;
      --surface-2:#202c3a;
      --text:#e8eef5;
      --muted:#aab8c7;
      --line:#2d3a49;
      --primary:#74b6ff;
      --primary-2:#8bc4ff;
      --accent:#4d9cff;
      --success:#5bd18d;
      --warning:#f5b14c;
      --danger:#ff8181;
      --shadow:0 12px 34px rgba(0,0,0,.24);
    }

    .theme-control{
      position:relative;
      flex:0 0 auto;
    }

    .theme-btn{
      width:42px;
      height:42px;
      display:grid;
      place-items:center;
      border:1px solid var(--line);
      border-radius:11px;
      background:var(--surface);
      color:var(--primary);
    }

    .theme-btn:hover{
      background:var(--surface-2);
    }

    .theme-btn .icon{
      width:20px;
      height:20px;
      margin:auto;
    }

    .theme-menu{
      position:absolute;
      top:calc(100% + 10px);
      right:0;
      width:250px;
      display:none;
      padding:9px;
      background:var(--surface);
      border:1px solid var(--line);
      border-radius:15px;
      box-shadow:0 18px 45px rgba(23,74,126,.18);
      z-index:1100;
    }

    html.theme-dark .theme-menu{
      box-shadow:0 18px 45px rgba(0,0,0,.38);
    }

    .theme-menu.active{
      display:block;
    }

    .theme-menu-title{
      padding:7px 9px 9px;
      color:var(--muted);
      font-size:12px;
      font-weight:800;
      text-transform:uppercase;
      letter-spacing:.45px;
    }

    .theme-option{
      width:100%;
      display:grid;
      grid-template-columns:36px 1fr 20px;
      align-items:center;
      gap:10px;
      padding:10px;
      border:0;
      border-radius:11px;
      background:transparent;
      color:var(--text);
      text-align:left;
    }

    .theme-option:hover{
      background:var(--surface-2);
    }

    .theme-option-icon{
      width:34px;
      height:34px;
      display:grid;
      place-items:center;
      border-radius:10px;
      border:1px solid var(--line);
      background:var(--bg);
      color:var(--primary);
    }

    .theme-option-icon .icon{
      width:17px;
      height:17px;
    }

    .theme-option strong{
      display:block;
      color:var(--text);
      font-size:13.5px;
    }

    .theme-option small{
      display:block;
      margin-top:1px;
      color:var(--muted);
      font-size:11.5px;
      line-height:1.35;
    }

    .theme-check{
      opacity:0;
      color:var(--primary);
      font-weight:900;
      text-align:center;
    }

    .theme-option.active .theme-check{
      opacity:1;
    }

    .theme-option.active{
      background:var(--surface-2);
    }

    /* Dark-mode overrides for components that previously used fixed light colors */
    html.theme-dark .brand-logo{filter:drop-shadow(0 6px 14px rgba(0,0,0,.32));}

    html.theme-dark .brand:hover .brand-logo{filter:drop-shadow(0 8px 18px rgba(0,0,0,.42));}

    html.theme-dark body{
      background:var(--bg);
      color:var(--text);
    }

    html.theme-dark .site-header{
      background:rgba(16,23,34,.94);
      border-color:var(--line);
    }

    html.theme-dark .nav-links a,
    html.theme-dark .mobile-panel a{
      color:#d8e2ed;
    }

    html.theme-dark .nav-links a:hover{
      background:var(--surface-2);
      color:var(--primary);
    }

    html.theme-dark .nav-search-btn,
    html.theme-dark .menu-btn,
    html.theme-dark .search-clear,
    html.theme-dark .chip,
    html.theme-dark .open-btn,
    html.theme-dark .support-close-btn{
      background:var(--surface);
      border-color:var(--line);
      color:var(--primary);
    }

    html.theme-dark .hero{
      background:
        radial-gradient(circle at 50% 0%,rgba(77,156,255,.15),transparent 46%),
        linear-gradient(180deg,#111b28 0%,var(--bg) 100%);
      border-color:var(--line);
    }

    html.theme-dark .hero h1,
    html.theme-dark .section-title,
    html.theme-dark .category-card h3,
    html.theme-dark .tool-card h4,
    html.theme-dark .workflow-card strong,
    html.theme-dark .recent-card h4,
    html.theme-dark .guide-card h4,
    html.theme-dark .update-dialog h3,
    html.theme-dark .support-dialog h3{
      color:var(--text);
    }

    html.theme-dark .eyebrow,
    html.theme-dark .hero-search,
    html.theme-dark .search-suggestions,
    html.theme-dark .category-card,
    html.theme-dark .tool-card,
    html.theme-dark .workflow-card,
    html.theme-dark .standard-card,
    html.theme-dark .recent-card,
    html.theme-dark .guide-card,
    html.theme-dark .update-dialog,
    html.theme-dark .support-dialog{
      background:var(--surface);
      border-color:var(--line);
    }

    html.theme-dark .hero-search input{
      color:var(--text);
    }

    html.theme-dark .hero-search input::placeholder{
      color:#8797a8;
    }

    html.theme-dark .suggestion{
      border-color:var(--line);
    }

    html.theme-dark .suggestion:hover,
    html.theme-dark .suggestion.is-active{
      background:#223142;
    }

    html.theme-dark .chip:hover,
    html.theme-dark .workflow-card:hover,
    html.theme-dark .support-close-btn:hover{
      background:var(--surface-2);
      border-color:#42556b;
    }

    html.theme-dark .popular{
      background:#131c28;
      border-color:var(--line);
    }

    html.theme-dark .category-icon,
    html.theme-dark .tool-icon,
    html.theme-dark .workflow-symbol,
    html.theme-dark .recent-icon{
      background:linear-gradient(145deg,#223247,#1b2a3b);
      border-color:#33475d;
      color:#8bc4ff;
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,.04),
        0 8px 20px rgba(0,0,0,.16);
    }

    html.theme-dark .category-card:hover .category-icon{
      background:linear-gradient(145deg,#26394f,#1e3042);
      box-shadow:
        inset 0 1px 0 rgba(255,255,255,.05),
        0 10px 24px rgba(0,0,0,.2);
    }

    html.theme-dark .standard-card .name{
      color:#d5dee8;
    }

    html.theme-dark .standard-card .tag{
      color:#70dfa0;
      background:#183426;
      border-color:#28543a;
    }

    html.theme-dark .coming-soon-badge{
      background:#352a16;
      border-color:#67512b;
      color:#f6c76c;
    }

    html.theme-dark .coming-soon:hover .coming-soon-badge{
      background:#3d3018;
      border-color:#7a6030;
    }

    html.theme-dark .update-dialog-icon,
    html.theme-dark .support-dialog-icon{
      background:linear-gradient(145deg,#382d1c,#2d2518);
      border-color:#614e2e;
      color:#f1bd62;
    }

    html.theme-dark .support-note{
      background:#111b27;
      border-color:var(--line);
      color:var(--muted);
    }

    html.theme-dark .support-note strong{
      color:var(--text);
    }

    html.theme-dark .mobile-panel{
      background:var(--surface);
      border-color:var(--line);
      box-shadow:0 12px 24px rgba(0,0,0,.18);
    }

    html.theme-dark .mobile-panel a{
      border-color:var(--line);
    }

    html.theme-dark footer{
      background:#0b1520;
      color:#d5e0ea;
    }

    @media (max-width:980px){
      html.theme-dark .site-header{
        background:var(--surface);
      }
    }

    @media (max-width:680px){
      .theme-menu{
        position:fixed;
        top:72px;
        right:11px;
        left:11px;
        width:auto;
        max-width:none;
      }
    }