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

  :root {
    --bg: #08080f;
    --surface: #0f0f1a;
    --surface2: #161625;
    --border: rgba(255,255,255,0.07);
    --text: #e8e8f0;
    --text-muted: #6b6b8a;
    --accent: #7c6aff;
    --accent-glow: rgba(124, 106, 255, 0.3);
    --accent2: #ff6a9b;
    --glass: rgba(15, 15, 26, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);

    /* Categoria cores */
    --c-rock:       #ff4d6d;
    --c-electronic: #00d4ff;
    --c-jazz:       #ffd166;
    --c-classical:  #c8b8ff;
    --c-hiphop:     #ff9f1c;
    --c-pop:        #ff79c6;
    --c-folk:       #a8d8a8;
    --c-blues:      #4ecdc4;
    --c-rnb:        #f7b2bd;
    --c-latin:      #ff6b35;
    --c-reggae:     #06d6a0;
    --c-metal:      #e63946;
    --c-punk:       #ff595e;
    --c-world:      #8ecae6;
    --c-experimental: #bd93f9;
    --c-fusion:     #ffb700;
    --c-country:    #c77dff;
    --c-gospel:     #f4a261;
    --c-other:      #888888;
  }

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

  body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  /* HEADER */
  #header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    z-index: 100;
    flex-shrink: 0;
  }

  #header h1 {
    font-family: 'Space Mono', monospace;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--text);
  }

  #header h1 span { color: var(--accent); }

  #stats {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'Space Mono', monospace;
  }

  /* CONTROLS */
  #controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
    flex-wrap: wrap;
  }

  #search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 320px;
  }

  #search {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    padding: 7px 12px 7px 32px;
    outline: none;
    transition: border-color .2s;
  }
  #search:focus { border-color: var(--accent); }
  #search::placeholder { color: var(--text-muted); }

  .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
    pointer-events: none;
  }

  select {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    padding: 7px 10px;
    outline: none;
    cursor: pointer;
    transition: border-color .2s;
  }
  select:focus { border-color: var(--accent); }
  select option { background: var(--surface2); }

  .btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-size: 12px;
    padding: 7px 12px;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
  }
  .btn:hover { border-color: var(--accent); color: var(--text); }
  .btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

  /* MAIN */
  #main {
    display: flex;
    flex: 1;
    overflow: hidden;
    transition: opacity 0.4s ease, transform 0.4s ease;
  }

  /* LEGEND */
  #legend {
    width: 200px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 12px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  #legend h3 {
    font-size: 10px;
    font-family: 'Space Mono', monospace;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
    margin-top: 4px;
  }

  .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background .15s;
    font-size: 12px;
    color: var(--text-muted);
  }
  .legend-item:hover, .legend-item.active { background: var(--surface2); color: var(--text); }

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

  .legend-count {
    margin-left: auto;
    font-size: 10px;
    font-family: 'Space Mono', monospace;
    color: var(--text-muted);
    opacity: .6;
  }

  /* CANVAS */
  #canvas-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
  }

  #graph-svg {
    width: 100%;
    height: 100%;
    cursor: grab;
  }
  #graph-svg:active { cursor: grabbing; }

  /* LOADING */
  #loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    z-index: 200;
    gap: 16px;
  }

  #loading-title {
    font-family: 'Space Mono', monospace;
    font-size: 13px;
    letter-spacing: .1em;
    color: var(--text-muted);
    text-transform: uppercase;
  }

  #loading-msg {
    font-size: 13px;
    color: var(--text-muted);
    min-height: 20px;
    transition: opacity .3s;
  }

  .spinner {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  #loading-progress {
    width: 240px;
    height: 2px;
    background: var(--surface2);
    border-radius: 2px;
    overflow: hidden;
  }
  #loading-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 2px;
    width: 0%;
    transition: width .4s ease;
  }

  /* TOOLTIP */
  #tooltip {
    position: absolute;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s, transform .2s;
    transform: translateY(10px);
    max-width: 260px;
    z-index: 300;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  }

  #tooltip.visible { opacity: 1; transform: translateY(0); }

  #tooltip .tt-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
  }

  #tooltip .tt-cat {
    font-size: 11px;
    margin-bottom: 6px;
    opacity: .7;
    font-family: 'Space Mono', monospace;
    letter-spacing: .05em;
  }

  #tooltip .tt-info {
    color: var(--text-muted);
    line-height: 1.5;
  }

  #tooltip .tt-fusion {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--accent);
  }

  /* INFO PANEL */
  #info-panel {
    position: absolute;
    right: 16px;
    top: 16px;
    width: 280px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(16px);
    border-radius: 12px;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    z-index: 150;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }

  #info-panel.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  #info-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
  }

  #info-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    padding-right: 20px;
  }

  #info-cat {
    font-size: 11px;
    font-family: 'Space Mono', monospace;
    letter-spacing: .06em;
    margin-bottom: 10px;
    opacity: .7;
  }

  #info-desc {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 10px;
  }

  #info-fusions h4, #info-related h4 {
    font-size: 11px;
    font-family: 'Space Mono', monospace;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin-bottom: 6px;
    margin-top: 10px;
  }

  .tag {
    display: inline-block;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
    padding: 2px 8px;
    margin: 2px;
    cursor: pointer;
    transition: all .15s;
  }
  .tag:hover { border-color: var(--accent); color: var(--accent); }

  /* ZOOM controls */
  #zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 100;
  }

  .zoom-btn {
    width: 32px;
    height: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    line-height: 1;
  }
  .zoom-btn:hover { border-color: var(--accent); color: var(--text); }

  /* VIEW TOGGLE BUTTONS */
  .view-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 5px 7px;
    border-radius: 4px;
    cursor: pointer;
    transition: all .15s;
    display: flex;
    align-items: center;
  }
  .view-toggle:hover { color: var(--text); }
  .view-toggle.active { background: var(--accent); color: #fff; }

  /* TREE VIEW */
  #tree-view {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    background: var(--bg);
    transition: opacity 0.4s ease, transform 0.4s ease;
    opacity: 0;
    transform: translateY(10px);
  }

  #tree-view.active { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 16px; 
    align-content: flex-start;
    opacity: 1;
    transform: translateY(0);
  }

  .tree-category {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    width: calc(50% - 8px);
    min-width: 280px;
    overflow: hidden;
    transition: box-shadow .2s;
  }

  @media (max-width: 700px) { .tree-category { width: 100%; } }

  .tree-cat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid transparent;
    transition: border-color .2s;
  }

  .tree-cat-header:hover { background: var(--surface2); }
  .tree-cat-header.open { border-bottom-color: var(--border); }

  .tree-cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

  .tree-cat-name {
    font-size: 13px;
    font-weight: 500;
    flex: 1;
    color: var(--text);
  }

  .tree-cat-count {
    font-size: 11px;
    font-family: 'Space Mono', monospace;
    color: var(--text-muted);
    background: var(--surface2);
    padding: 2px 7px;
    border-radius: 10px;
  }

  .tree-cat-arrow {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform .2s;
    margin-left: 4px;
  }
  .tree-cat-header.open .tree-cat-arrow { transform: rotate(90deg); }

  .tree-nodes {
    display: none;
    padding: 8px 0;
    max-height: 320px;
    overflow-y: auto;
  }
  .tree-nodes.open { display: block; }

  /* search highlight inside tree */
  .tree-node {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 7px 16px;
    cursor: pointer;
    transition: background .12s;
    border-radius: 0;
  }
  .tree-node:hover { background: var(--surface2); }
  .tree-node.fusion-node .tree-node-name { color: var(--c-fusion, #ffb700); }

  .tree-node-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
  }

  .tree-node-body { flex: 1; min-width: 0; }

  .tree-node-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tree-node-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
  }

  .tree-node-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 3px;
    display: none;
  }
  .tree-node.expanded .tree-node-desc { display: block; }

  .tree-fusion-badge {
    font-size: 10px;
    background: rgba(255,183,0,.15);
    color: #ffb700;
    border-radius: 3px;
    padding: 2px 6px;
    white-space: normal;
    max-width: 260px;
    line-height: 1.4;
    flex-shrink: 0;
  }

  .tree-search-wrap {
    padding: 8px 16px 4px;
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
  }

  .tree-search {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text);
    font-size: 12px;
    padding: 5px 10px;
    outline: none;
    font-family: 'Outfit', sans-serif;
  }
  .tree-search:focus { border-color: var(--accent); }

  .tree-node.hidden { display: none; }
  .tree-cat-stats { font-size: 10px; color: var(--text-muted); padding: 4px 16px 6px; font-family: 'Space Mono', monospace; }


  .link.fusion {
    stroke-dasharray: 4 3;
  }

  /* Highlight & Interaction */
  .node-group {
    transition: opacity .3s ease;
  }

  .node-group.dimmed {
    opacity: 0.05 !important;
    pointer-events: none;
  }

  .node-circle {
    transition: r .3s ease, stroke-width .3s ease, filter .3s ease;
  }

  .node-circle.highlighted {
    stroke-width: 4px !important;
    filter: drop-shadow(0 0 8px var(--accent));
  }

  .node-group.connected .node-circle {
    stroke-width: 2px;
    filter: drop-shadow(0 0 3px rgba(255,255,255,0.3));
  }

  .node-group.connected .node-label,
  .node-circle.highlighted + .node-label {
    fill: #fff !important;
    font-weight: 600;
    opacity: 1 !important;
    display: block !important;
    font-size: 11px !important;
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.8));
  }

  .link {
    transition: opacity .3s ease, stroke-width .3s ease;
  }

  .link.dimmed {
    opacity: 0.02 !important;
  }

  .link.highlighted {
    opacity: 1 !important;
    stroke-width: 2.5px !important;
    filter: drop-shadow(0 0 2px rgba(255,255,255,0.5));
  }

  /* FOOTER */
  #footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 6px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'Space Mono', monospace;
    letter-spacing: .04em;
  }

  #footer strong { color: var(--text); }

  #footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color .15s;
  }
  #footer a:hover { color: var(--accent); }

  .footer-sep { opacity: .4; }

  @media (max-width: 480px) {
    #footer { flex-wrap: wrap; gap: 4px; padding: 6px 12px; }
    .footer-sep:last-of-type { display: none; }
  }

  /* HEADER END */
  #header-end {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  #btn-help {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: 'Space Mono', monospace;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    flex-shrink: 0;
  }
  #btn-help:hover { border-color: var(--accent); color: var(--accent); }

  /* MODAL */
  #help-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
  }

  #help-modal.open {
    opacity: 1;
    pointer-events: auto;
  }

  .modal {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 24px 64px rgba(0,0,0,0.6);
    transform: translateY(12px);
    transition: transform .25s cubic-bezier(0.4,0,0.2,1);
  }

  #help-modal.open .modal { transform: translateY(0); }

  #modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
    z-index: 1;
    transition: color .15s;
  }
  #modal-close:hover { color: var(--text); }

  .modal-tabs {
    display: flex;
    gap: 2px;
    padding: 14px 16px 0;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .modal-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    padding: 6px 12px 10px;
    cursor: pointer;
    transition: color .15s, border-color .15s;
    margin-bottom: -1px;
  }
  .modal-tab:hover { color: var(--text); }
  .modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

  .modal-body {
    overflow-y: auto;
    flex: 1;
    padding: 20px 24px 24px;
  }

  .modal-pane { display: none; }
  .modal-pane.active { display: block; }

  .modal-lead {
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 10px;
  }

  .modal-pane > p:not(.modal-lead):not(.modal-label) {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
  }

  .modal-label {
    font-size: 10px;
    font-family: 'Space Mono', monospace;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
  }

  .modal-divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
  }

  .modal-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 7px;
  }

  .modal-list li {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.5;
  }

  .modal-list li strong { color: var(--text); }

  .modal-key {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
    font-family: 'Space Mono', monospace;
    padding: 2px 7px;
    color: var(--text);
    white-space: nowrap;
    flex-shrink: 0;
  }

  .link-swatch {
    display: inline-block;
    width: 28px;
    height: 3px;
    border-radius: 2px;
    border: 1px solid transparent;
    flex-shrink: 0;
  }

  .modal-stats-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: var(--surface2);
    border-radius: 6px;
    font-size: 13px;
  }

  .stat-row span { color: var(--text-muted); }
  .stat-row strong { color: var(--text); font-family: 'Space Mono', monospace; font-size: 12px; }

  .modal-eras {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .modal-eras span {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-muted);
    padding: 3px 9px;
  }

  .faq-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
  }
  .faq-item:last-child { border-bottom: none; padding-bottom: 0; }

  .faq-q {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
    line-height: 1.5;
  }

  .faq-a {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
  }

  .faq-a code {
    font-family: 'Space Mono', monospace;
    font-size: 11px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    color: var(--text);
  }

  @media (max-width: 600px) {
    #help-modal { padding: 0; align-items: flex-end; }
    .modal { max-height: 85vh; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  }

  /* Error */
  #error-msg {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    color: var(--text-muted);
    font-size: 14px;
    z-index: 201;
  }