/* =============================================
   CSS VARIABLES / DESIGN TOKENS
   ============================================= */
   :root {
    --bg: #0b0c0f;
    --panel: #12141a;
    --line: #21232b;
    --text: #e7eaf0;
    --muted: #9aa1ad;
    --accent: #5b9dff;
    --radius: 12px;
    --gap: 16px;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  }
  
  /* =============================================
     BASE STYLES / RESET
     ============================================= */
  * {
    box-sizing: border-box;
  }
  
  html, body {
    height: 100%;
  }
  
  body {
    margin: 0;
    background: linear-gradient(180deg, #0b0c0f, #0e1116);
    color: var(--text);
    font: 14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Inter, sans-serif;
  }
  
  /* =============================================
   UTILITY CLASSES
   ============================================= */
  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }

  #js-warning {
    display: none;
  }
  
  /* =============================================
   TOPBAR / HEADER
   ============================================= */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(12px) saturate(1.8);
    background: rgba(10, 12, 16, 0.7);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    position: relative;
    background-size: 200% 200%;
    animation: glassShimmer 20s ease infinite;
  }

  .topbar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 50%, rgba(255, 255, 255, 0) 100%);
    z-index: -1;
  }

  .topbar::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(91, 157, 255, 0.15) 0%, rgba(91, 157, 255, 0.05) 20%, transparent 50%);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .topbar:hover::after {
    opacity: 1;
  }

  .topbar h1 {
    font-size: 16px;
    letter-spacing: 0.4px;
    margin: 0;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 2;
    flex-shrink: 0;
    order: 1;
  }

  .controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 1;
    max-width: 560px;
    margin: 0 auto;
    z-index: 2;
    min-width: 0;
    position: relative;
    order: 2;
  }

  #search {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(14, 17, 22, 0.6);
    color: var(--text);
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
    position: relative;
    z-index: 3;
  }

  #search:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(14, 17, 22, 0.8);
    box-shadow: 0 0 0 2px rgba(91, 157, 255, 0.2);
  }

  .tagbar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
    justify-content: flex-start;
    z-index: 2;
    position: relative;
    max-width: 100%;
    overflow: hidden;
    order: 3;
    width: 100%;
  }
  
  .tag-group {
    display: inline-flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 8px 10px;
    transition: all 0.2s ease;
  }
  
  .tag-group:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
  }
  
  .tag-group-header {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(154, 161, 173, 0.6);
    margin-bottom: 2px;
    user-select: none;
  }
  
  .tag-group-items {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
  }

  .tag {
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--muted);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    z-index: 2;
  }

  .tag::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  .tag:hover::before {
    opacity: 1;
  }

  .tag.active {
    border-color: var(--accent);
    color: #fff;
    background: rgba(91, 157, 255, 0.2);
    box-shadow: 0 2px 8px rgba(91, 157, 255, 0.2);
  }
  
  /* =============================================
     WELCOME BANNER
     ============================================= */
  .welcome-banner {
    max-width: 1200px;
    margin: 24px auto 32px;
    padding: 0 16px;
  }
  
  .welcome-content {
    padding: 24px;
    background: rgba(18, 20, 26, 0.7);
    backdrop-filter: blur(8px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    text-align: center;
  }
  
  .welcome-content h2 {
    margin: 0 0 12px 0;
    font-size: 24px;
    color: #fff;
  }
  
  .welcome-content p {
    margin: 0 0 16px 0;
    color: var(--muted);
    font-size: 15px;
  }
  
  .welcome-content kbd {
    display: inline-block;
    padding: 4px 8px;
    background: rgba(91, 157, 255, 0.15);
    border: 1px solid rgba(91, 157, 255, 0.3);
    border-radius: 6px;
    font-family: monospace;
    font-size: 13px;
    color: #5b9dff;
  }
  
  body.light-theme .welcome-content {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
  }
  
  body.light-theme .welcome-content h2 {
    color: #1c2938;
  }
  
  body.light-theme .welcome-content kbd {
    background: rgba(37, 99, 235, 0.1);
    border-color: rgba(37, 99, 235, 0.2);
    color: #2563eb;
  }
  
  /* =============================================
     GRID LAYOUT
     ============================================= */
  .grid {
    max-width: 1200px;
    margin: 32px auto;
    padding: 0 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
  }
  
  /* =============================================
     CARDS
     ============================================= */
  .card {
    background: rgba(18, 20, 26, 0.7);
    backdrop-filter: blur(8px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    min-height: 180px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
  }
  
  .card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
  }
  
  .card:hover::before {
    opacity: 1;
  }
  
  .card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    border-color: rgba(91, 157, 255, 0.2);
  }
  
  .card .thumb {
    height: 120px;
    background: conic-gradient(from 90deg at 50% 50%, #1a1f2e, #0f1725, #1a1f2e);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
  }
  
  .card .thumb::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
      80% 140% at var(--thumb-mx, 50%) var(--thumb-my, 50%), 
      rgba(91, 157, 255, 0.25), 
      rgba(91, 157, 255, 0) 60%
    );
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: 2;
  }
  
  .card .thumb::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(91, 157, 255, 0.1) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
  }
  
  .card:hover .thumb::before {
    opacity: 1;
  }
  
  .card:hover .thumb::after {
    opacity: 1;
  }
  
  .card:hover .thumb {
    transform: translate3d(var(--thumb-dx, 0), var(--thumb-dy, 0), 0);
    box-shadow: 0 10px 30px rgba(91, 157, 255, 0.25);
  }
  
  .card .body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    z-index: 2;
  }
  
  .card h3 {
    margin: 0;
    font-size: 15px;
    color: var(--text);
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  }
  
  .card .actions {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 2;
  }
  
  /* =============================================
   MODAL
   ============================================= */
  dialog {
    width: min(1100px, 95vw);
    border: none;
    border-radius: 16px;
    padding: 0;
    overflow: hidden;
    background: rgba(18, 20, 26, 0.85);
    backdrop-filter: blur(12px) saturate(1.8);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    color: var(--text); /* Add this to ensure default text color is light */
  }

  dialog::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 1;
  }

  dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
  }

  .modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(10, 12, 16, 0.5);
    backdrop-filter: blur(8px);
    position: relative;
    z-index: 2;
  }

  .modal-head h2 {
    margin: 0;
    color: #fff; /* Explicitly set the modal title color to white */
    font-size: 18px;
    font-weight: 600;
  }

  .modal-body {
    display: grid;
    grid-template-columns: 1fr min(320px, 35%);
    gap: 12px;
    padding: 12px 16px;
    position: relative;
    z-index: 2;
  }

  .sandbox {
    height: min(60vh, 70svh);
    background: rgba(11, 13, 18, 0.9);
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
  }

  .sandbox::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 1;
  }

  .explain {
    height: min(60vh, 70svh);
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    background: rgba(15, 17, 23, 0.9);
    color: var(--muted);
    backdrop-filter: blur(4px);
    position: relative;
  }

  .explain::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 1;
  }

  .explain h3 {
    margin: 0 0 8px 0;
    color: #fff;
    font-size: 14px;
    position: relative;
    z-index: 2;
  }

  .explain p, .explain li {
    font-size: 13px;
    line-height: 1.5;
    position: relative;
    z-index: 2;
  }

  .meta {
    padding: 10px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--muted);
    font-size: 12px;
    background: rgba(10, 12, 16, 0.5);
    backdrop-filter: blur(4px);
    position: relative;
    z-index: 2;
  }
  
  /* =============================================
     BUTTONS
     ============================================= */
  .btn {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 19, 27, 0.7);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    z-index: 3;
  }
  
  .btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  .btn:hover::before {
    opacity: 1;
  }
  
  .btn:hover {
    background: rgba(15, 19, 27, 0.9);
    border-color: rgba(91, 157, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }
  
  .btn.ghost {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(4px);
  }
  
  .btn.ghost:hover {
    background: rgba(255, 255, 255, 0.1);
  }
  
  /* =============================================
     BADGES
     ============================================= */
  .badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  
  .badge {
    font-size: 11px;
    color: var(--muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(2px);
  }
  
  /* =============================================
     SPECIAL EFFECTS
     ============================================= */
  /* Glass reflection effect */
  .glass-reflection {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 50%, transparent 100%);
    pointer-events: none;
    z-index: 1;
  }
  
  /* CSS-only magnetic button effect */
  .magnetic-btn {
    display: inline-block;
    padding: 14px 18px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: radial-gradient(80% 140% at var(--mx, 50%) var(--my, 50%), rgba(91, 157, 255, 0.25), rgba(91, 157, 255, 0) 60%), rgba(15, 19, 27, 0.7);
    backdrop-filter: blur(4px);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.12s linear;
    will-change: transform, background;
    color: #fff;
    position: relative;
    overflow: hidden;
  }
  
  .magnetic-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  
  .magnetic-btn:hover::before {
    opacity: 1;
  }
  
  .magnetic-btn:hover {
    transform: translate3d(var(--dx, 0), var(--dy, 0), 0);
    box-shadow: 0 10px 30px rgba(91, 157, 255, 0.25);
  }
  
  /* Interactive card glow effect */
  .card.glow {
    border-color: rgba(91, 157, 255, 0.3);
    box-shadow: 0 0 20px rgba(91, 157, 255, 0.2);
  }
  
  /* =============================================
     ANIMATIONS
     ============================================= */
  /* Glass shimmer animation */
  @keyframes glassShimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
  }
  
  /* Thumb pulse animation */
  @keyframes thumbPulse {
    0% { box-shadow: 0 0 0 0 rgba(91, 157, 255, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(91, 157, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(91, 157, 255, 0); }
  }
  
  .card:hover .thumb {
    animation: thumbPulse 2s infinite;
  }
  
  /* =============================================
   CODE PANEL
   ============================================= */
  .code-panel {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 17, 23, 0.9);
    backdrop-filter: blur(4px);
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-rows: auto 1fr;
    max-height: 30vh;
    overflow: hidden;
  }
  
  .code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
  }
  
  .code-content {
    margin: 0;
    padding: 12px;
    background: #0b0d12;
    border-radius: 8px;
    overflow: auto;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
    color: #a6accd;
    border: 1px solid rgba(255, 255, 255, 0.05);
  }
  
  .copy-code {
    padding: 4px 8px;
    font-size: 11px;
  }
  
  /* =============================================
   LIGHT THEME
   ============================================= */
  body.light-theme {
    --bg: #f5f7fa;
    --panel: #ffffff;
    --line: #e1e8ed;
    --text: #1c2938;
    --muted: #6b7280;
    --accent: #2563eb;
    background: linear-gradient(180deg, #f5f7fa, #ffffff);
  }
  
  body.light-theme .topbar {
    background: rgba(255, 255, 255, 0.8);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  }
  
  body.light-theme .topbar h1 {
    color: #1c2938;
  }
  
  body.light-theme #search {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--text);
  }
  
  body.light-theme #search:focus {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
  }
  
  body.light-theme .card {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
  }
  
  body.light-theme .tag {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--muted);
  }
  
  body.light-theme .tag:hover {
    background: rgba(0, 0, 0, 0.06);
  }
  
  body.light-theme .tag.active {
    border-color: var(--accent);
    color: #2563eb;
    background: rgba(37, 99, 235, 0.1);
  }
  
  body.light-theme .tag-group {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
  }
  
  body.light-theme .tag-group:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
  }
  
  body.light-theme .tag-group-header {
    color: rgba(107, 114, 128, 0.6);
  }
  
  body.light-theme dialog {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.08);
    color: var(--text);
  }
  
  body.light-theme .modal-head,
  body.light-theme .meta {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.05);
  }
  
  body.light-theme .sandbox {
    background: rgba(245, 247, 250, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
  }
  
  body.light-theme .explain {
    background: rgba(248, 250, 252, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
  }
  
  body.light-theme .code-panel {
    background: rgba(248, 250, 252, 0.9);
    border-top-color: rgba(0, 0, 0, 0.08);
  }
  
  body.light-theme .code-content {
    background: #0b0d12;
    border-color: rgba(0, 0, 0, 0.1);
  }
  
  /* =============================================
   MOBILE RESPONSIVE
   ============================================= */
  @media (max-width: 768px) {
    .topbar {
      flex-direction: column;
      align-items: stretch;
      padding: 8px 12px;
      gap: 12px;
    }
    
    .topbar h1 {
      font-size: 14px;
      order: 1;
    }
    
    .controls {
      order: 2;
      width: 100%;
      max-width: 100%;
    }
    
    .tagbar {
      order: 3;
      justify-content: flex-start;
      gap: 8px;
    }
    
    .tag-group {
      padding: 6px 8px;
    }
    
    .tag-group-header {
      font-size: 9px;
    }
    
    .tag {
      padding: 5px 8px;
      font-size: 11px;
    }
    
    .tag-group-items {
      gap: 4px;
    }
    
    .grid {
      grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
      gap: 12px;
      padding: 0 12px;
    }
    
    .card {
      min-height: 160px;
    }
    
    .card .thumb {
      height: 100px;
    }
    
    .modal-body {
      grid-template-columns: 1fr;
      gap: 8px;
      padding: 8px 12px;
    }
    
    .sandbox,
    .explain {
      height: min(40vh, 50svh);
    }
  }
