  @import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Crimson+Pro:wght@300;400;600;700&display=swap');

  * { margin: 0; padding: 0; box-sizing: border-box; }

  body {
    background: #0a0a0f;
    color: #e8ddd3;
    font-family: 'Space Mono', monospace;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
  }

  #header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    padding: 14px 24px;
    background: linear-gradient(180deg, rgba(10,10,15,0.95) 0%, rgba(10,10,15,0) 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
  }

  #header > * { pointer-events: auto; }

  #header h1 {
    font-family: 'Crimson Pro', serif;
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: #f4c542;
    text-shadow: 0 0 20px rgba(244,197,66,0.3);
  }

  #header h1 span {
    font-weight: 300;
    color: #e8ddd3;
    font-size: 14px;
    letter-spacing: 2px;
    margin-left: 12px;
  }

  #controls {
    display: flex;
    gap: 8px;
    align-items: center;
  }

  #controls button {
    background: rgba(244,197,66,0.1);
    border: 1px solid rgba(244,197,66,0.3);
    color: #f4c542;
    padding: 6px 14px;
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.2s;
  }

  #controls button:hover {
    background: rgba(244,197,66,0.25);
    border-color: #f4c542;
  }

  #search-box {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(244,197,66,0.2);
    color: #e8ddd3;
    padding: 6px 12px;
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    width: 200px;
    border-radius: 2px;
    outline: none;
  }

  #search-box::placeholder { color: rgba(232,221,211,0.3); }
  #search-box:focus { border-color: #f4c542; }

  svg { width: 100%; height: 100%; }

  .link {
    stroke-opacity: 0.15;
    stroke-linecap: round;
  }

  .node-circle {
    cursor: pointer;
    stroke-width: 1.5;
    transition: r 0.2s;
  }

  .node-label {
    font-family: 'Space Mono', monospace;
    pointer-events: none;
    fill: #e8ddd3;
    text-anchor: middle;
    dominant-baseline: central;
    paint-order: stroke;
    stroke: #0a0a0f;
    stroke-width: 3px;
    stroke-linejoin: round;
  }

  #tooltip {
    position: fixed;
    background: rgba(15,15,22,0.95);
    border: 1px solid rgba(244,197,66,0.4);
    padding: 12px 16px;
    border-radius: 3px;
    font-size: 11px;
    max-width: 320px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 200;
    line-height: 1.6;
    backdrop-filter: blur(8px);
  }

  #tooltip .tt-title {
    font-family: 'Crimson Pro', serif;
    font-size: 16px;
    font-weight: 700;
    color: #f4c542;
    margin-bottom: 4px;
  }

  #tooltip .tt-category {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(232,221,211,0.5);
    margin-bottom: 6px;
  }

  #tooltip .tt-description {
    color: rgba(232,221,211,0.85);
    margin: 8px 0;
    line-height: 1.7;
    font-size: 11px;
  }

  #tooltip .tt-connections {
    color: rgba(232,221,211,0.4);
    font-size: 10px;
    margin-top: 6px;
    border-top: 1px solid rgba(244,197,66,0.2);
    padding-top: 6px;
  }

  #legend {
    position: fixed;
    bottom: 16px;
    left: 16px;
    z-index: 100;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    max-width: 700px;
    font-size: 10px;
    pointer-events: auto;
  }

  .legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
  }

  .legend-item:hover { opacity: 1; }
  .legend-item.active {
    opacity: 1;
    background: rgba(244,197,66,0.1);
    border-radius: 3px;
    padding: 2px 6px;
    margin: -2px -6px;
  }

  .legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  #stats {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 100;
    font-size: 10px;
    color: rgba(232,221,211,0.35);
    text-align: right;
    line-height: 1.8;
  }

  .node-icon {
    dominant-baseline: central;
    pointer-events: none;
  }

  .related-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .glow-ring {
    animation: pulse-glow 3s ease-in-out infinite;
  }

  @keyframes pulse-glow {
    0%, 100% { opacity: 0.15; }
    50% { opacity: 0.4; }
  }

  /* Side Drawer */
  #drawer {
    position: fixed;
    top: 0;
    right: -500px;
    width: 500px;
    height: 100vh;
    background: rgba(15,15,22,0.98);
    border-left: 1px solid rgba(244,197,66,0.3);
    z-index: 300;
    overflow-y: auto;
    transition: right 0.3s ease;
    backdrop-filter: blur(12px);
  }

  #drawer.open {
    right: 0;
  }

  #drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 250;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  #drawer-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }

  #drawer-header {
    padding: 24px;
    border-bottom: 1px solid rgba(244,197,66,0.2);
    position: sticky;
    top: 0;
    background: rgba(15,15,22,0.98);
    backdrop-filter: blur(12px);
    z-index: 10;
  }

  #drawer-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: #f4c542;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    transition: opacity 0.2s;
  }

  #drawer-close:hover {
    opacity: 0.7;
  }

  #drawer-title {
    font-family: 'Crimson Pro', serif;
    font-size: 28px;
    font-weight: 700;
    color: #f4c542;
    margin-bottom: 8px;
    padding-right: 40px;
    line-height: 1.2;
  }

  #drawer-category {
    display: inline-block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 4px 10px;
    border-radius: 2px;
    background: rgba(244,197,66,0.1);
    border: 1px solid rgba(244,197,66,0.3);
    color: #f4c542;
  }

  #drawer-content {
    padding: 24px;
  }

  .drawer-section {
    margin-bottom: 32px;
  }

  .drawer-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #f4c542;
    margin-bottom: 12px;
    font-weight: 700;
  }

  #drawer-description {
    color: rgba(232,221,211,0.9);
    line-height: 1.8;
    font-size: 13px;
    margin-bottom: 8px;
  }

  #drawer-connections-count {
    color: rgba(232,221,211,0.5);
    font-size: 11px;
    margin-top: 16px;
  }

  .resource-link {
    display: block;
    padding: 12px;
    margin-bottom: 8px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(244,197,66,0.15);
    border-radius: 3px;
    text-decoration: none;
    color: #e8ddd3;
    transition: all 0.2s;
  }

  .resource-link:hover {
    background: rgba(244,197,66,0.1);
    border-color: rgba(244,197,66,0.4);
  }

  .resource-icon {
    font-size: 16px;
    margin-right: 8px;
  }

  .resource-title {
    font-weight: 700;
    color: #f4c542;
    font-size: 13px;
    margin-bottom: 4px;
  }

  .resource-desc {
    font-size: 11px;
    color: rgba(232,221,211,0.7);
    line-height: 1.5;
  }

  .related-chip {
    display: inline-block;
    padding: 6px 12px;
    margin: 4px 4px 4px 0;
    background: rgba(244,197,66,0.1);
    border: 1px solid rgba(244,197,66,0.25);
    border-radius: 16px;
    font-size: 11px;
    color: #e8ddd3;
    cursor: pointer;
    transition: all 0.2s;
  }

  .related-chip:hover {
    background: rgba(244,197,66,0.2);
    border-color: #f4c542;
  }

  #drawer::-webkit-scrollbar {
    width: 8px;
  }

  #drawer::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
  }

  #drawer::-webkit-scrollbar-thumb {
    background: rgba(244,197,66,0.3);
    border-radius: 4px;
  }

  #drawer::-webkit-scrollbar-thumb:hover {
    background: rgba(244,197,66,0.5);
  }

  /* ========================================
     MOBILE RESPONSIVENESS
     ======================================== */

  /* Tablet and Below (768px) */
  @media (max-width: 768px) {
    /* Drawer - Full width on mobile */
    #drawer {
      width: 100%;
      right: -100%;
    }

    /* Header - Stack vertically */
    #header {
      flex-direction: column;
      align-items: flex-start;
      gap: 12px;
      padding: 12px 16px;
    }

    #header h1 {
      font-size: 18px;
      letter-spacing: 2px;
    }

    #header h1 span {
      font-size: 12px;
      display: block;
      margin-left: 0;
      margin-top: 4px;
    }

    /* Controls - Full width */
    #controls {
      width: 100%;
      flex-wrap: wrap;
    }

    /* Search box - Expand to fill */
    #search-box {
      flex: 1;
      min-width: 0;
      font-size: 14px;
      padding: 10px 14px;
    }

    /* Buttons - Larger touch targets */
    #controls button {
      min-height: 44px;
      font-size: 14px;
      padding: 10px 16px;
      flex: 1;
      -webkit-tap-highlight-color: rgba(244,197,66,0.2);
    }

    #controls button:active {
      transform: scale(0.97);
    }

    /* Legend - Better mobile layout */
    #legend {
      max-width: calc(100vw - 24px);
      font-size: 11px;
      gap: 8px 12px;
      bottom: 12px;
      left: 12px;
    }

    .legend-item {
      padding: 8px 4px;
      -webkit-tap-highlight-color: rgba(244,197,66,0.1);
    }

    .legend-item:active {
      background: rgba(244,197,66,0.1);
    }

    /* Stats - Smaller */
    #stats {
      font-size: 9px;
      bottom: 12px;
      right: 12px;
    }

    /* Tooltip - Fit mobile screen */
    #tooltip {
      max-width: calc(100vw - 32px);
      font-size: 12px;
    }

    /* Drawer - Mobile optimizations */
    #drawer-close {
      font-size: 32px;
      padding: 8px 12px;
      -webkit-tap-highlight-color: rgba(244,197,66,0.2);
    }

    #drawer-close:active {
      transform: scale(0.95);
    }

    #drawer-title {
      font-size: 24px;
    }

    #drawer-content {
      padding: 20px;
    }

    /* Related chips - Better touch targets */
    .related-chip {
      padding: 8px 14px;
      font-size: 12px;
      -webkit-tap-highlight-color: rgba(244,197,66,0.1);
    }

    .related-chip:active {
      transform: scale(0.98);
    }

    /* Resource links - Better touch targets */
    .resource-link {
      padding: 14px;
      -webkit-tap-highlight-color: rgba(244,197,66,0.05);
    }

    .resource-link:active {
      transform: scale(0.99);
    }

    /* Touch-friendly scrolling */
    #drawer {
      -webkit-overflow-scrolling: touch;
      overscroll-behavior: none;
    }

    body {
      overscroll-behavior: none;
    }
  }

  /* Small Mobile (480px) */
  @media (max-width: 480px) {
    /* Header - Even more compact */
    #header h1 {
      font-size: 16px;
      letter-spacing: 1px;
    }

    #header h1 span {
      font-size: 11px;
    }

    /* Search box - Full width with margin */
    #search-box {
      width: 100%;
      margin-bottom: 8px;
    }

    /* Buttons - Share row space */
    #controls button {
      font-size: 13px;
      padding: 10px 12px;
    }

    /* Legend - Further compact */
    #legend {
      font-size: 10px;
      max-width: calc(100vw - 16px);
      gap: 6px 8px;
    }

    /* Stats - Hide on small mobile */
    #stats {
      display: none;
    }

    /* Drawer - Smaller text */
    #drawer-title {
      font-size: 20px;
    }

    #drawer-content {
      padding: 16px;
    }

    .drawer-section-title {
      font-size: 10px;
    }
  }

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

    .glow-ring {
      animation: none;
    }
  }
