:root {
      --bg: #0c0c0e;
      --surface: #141416;
      --surface-2: #1a1a1d;
      --surface-3: #202024;
      --border: rgba(255, 255, 255, 0.07);
      --border-hover: rgba(255, 255, 255, 0.14);
      --text: #e8e8ea;
      --text-muted: #888890;
      --text-faint: #444450;
      --accent: #1fb8cd;
      --accent-dim: rgba(31, 184, 205, 0.12);
      --radius-sm: 6px;
      --radius-md: 10px;
      --radius-lg: 14px;
      --radius-xl: 18px;
      --font-body: 'Inter', sans-serif;
      --font-mono: 'JetBrains Mono', monospace;
      --trans: 160ms cubic-bezier(0.16, 1, 0.3, 1);
      /* Node type colors */
      --c-provider: #f59e0b;
      --c-model: #22d3ee;
      --c-hub: #a78bfa;
      --c-application: #34d399;
      --c-connector: #fb7185;
      --c-agent: #fbbf24;
      --c-mcp: #60a5fa;
    }

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

    html {
      -webkit-font-smoothing: antialiased;
      scroll-behavior: smooth;
    }

    body {
      font-family: var(--font-body);
      background: var(--bg);
      color: var(--text);
      font-size: 14px;
      line-height: 1.6;
      height: 100dvh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    button {
      cursor: pointer;
      background: none;
      border: none;
      font: inherit;
      color: inherit;
    }

    a {
      color: inherit;
      text-decoration: none;
    }

    /* ── HEADER ── */
    header {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 0 20px;
      height: 56px;
      flex-shrink: 0;
      border-bottom: 1px solid var(--border);
      background: var(--surface);
    }

    .logo {
      display: flex;
      align-items: center;
      gap: 8px;
      font-weight: 600;
      font-size: 15px;
      white-space: nowrap;
    }

    .logo svg {
      color: var(--accent);
    }

    .logo span {
      color: var(--text-muted);
      font-weight: 400;
      font-size: 13px;
      margin-left: 2px;
    }

    .search-wrap {
      flex: 1;
      max-width: 340px;
      position: relative;
      margin-left: 8px;
    }

    .search-wrap input {
      width: 100%;
      background: var(--surface-2);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: 7px 12px 7px 34px;
      color: var(--text);
      font-size: 13px;
      outline: none;
      transition: border-color var(--trans), box-shadow var(--trans);
    }

    .search-wrap input:focus {
      border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(31, 184, 205, 0.12);
    }

    .search-wrap input::placeholder {
      color: var(--text-faint);
    }

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

    .view-tabs {
      display: flex;
      gap: 4px;
      margin-left: auto;
    }

    .view-tab {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 6px 14px;
      border-radius: var(--radius-md);
      font-size: 13px;
      font-weight: 500;
      color: var(--text-muted);
      border: 1px solid transparent;
      transition: all var(--trans);
    }

    .view-tab:hover {
      background: var(--surface-2);
      color: var(--text);
    }

    .view-tab.active {
      background: var(--accent-dim);
      color: var(--accent);
      border-color: rgba(31, 184, 205, 0.2);
    }

    .stats-chip {
      font-size: 11px;
      background: var(--surface-3);
      color: var(--text-faint);
      padding: 2px 7px;
      border-radius: 99px;
      margin-left: auto;
    }

    /* ── LAYOUT ── */
    .app-body {
      flex: 1;
      display: flex;
      overflow: hidden;
      position: relative;
    }

    .main-area {
      flex: 1;
      overflow: hidden;
      position: relative;
    }

    .view {
      position: absolute;
      inset: 0;
      display: none;
    }

    .view.active {
      display: flex;
      flex-direction: column;
    }

    /* ── GRAPH VIEW ── */
    #graph-view {
      background: var(--bg);
    }

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

    #graph-svg:active {
      cursor: grabbing;
    }

    .graph-controls {
      position: absolute;
      bottom: 20px;
      left: 20px;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .graph-controls button {
      width: 36px;
      height: 36px;
      border-radius: var(--radius-md);
      background: var(--surface);
      border: 1px solid var(--border);
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-muted);
      transition: all var(--trans);
    }

    .graph-controls button:hover {
      background: var(--surface-2);
      color: var(--text);
      border-color: var(--border-hover);
    }

    .graph-legend {
      position: absolute;
      top: 16px;
      left: 16px;
      background: rgba(20, 20, 22, 0.88);
      backdrop-filter: blur(12px);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      padding: 12px 14px;
      display: flex;
      flex-direction: column;
      gap: 6px;
    }

    .legend-item {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 12px;
      color: var(--text-muted);
      cursor: pointer;
      transition: color var(--trans);
      user-select: none;
    }

    .legend-item:hover {
      color: var(--text);
    }

    .legend-item.hidden {
      opacity: 0.35;
    }

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

    .legend-count {
      font-size: 11px;
      color: var(--text-faint);
      margin-left: auto;
      padding-left: 12px;
      font-variant-numeric: tabular-nums;
    }

    .graph-filters {
      position: absolute;
      top: 16px;
      right: 16px;
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      justify-content: flex-end;
      max-width: 320px;
    }

    /* Node tooltips */
    .tooltip {
      position: fixed;
      pointer-events: none;
      z-index: 1000;
      background: var(--surface-2);
      border: 1px solid var(--border-hover);
      border-radius: var(--radius-md);
      padding: 10px 14px;
      font-size: 12px;
      max-width: 220px;
      display: none;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    }

    .tooltip strong {
      display: block;
      font-size: 13px;
      margin-bottom: 2px;
      color: var(--text);
    }

    .tooltip .tip-type {
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.06em;
      opacity: 0.6;
      margin-bottom: 6px;
    }

    .tooltip .tip-meta {
      color: var(--text-muted);
      line-height: 1.5;
    }

    /* ── EXPLORER VIEW ── */
    #explorer-view {
      overflow: hidden;
    }

    .explorer-toolbar {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 14px 20px 0;
      flex-shrink: 0;
      flex-wrap: wrap;
    }

    .cat-tabs {
      display: flex;
      gap: 4px;
      flex-wrap: wrap;
    }

    .cat-tab {
      padding: 5px 12px;
      border-radius: var(--radius-md);
      font-size: 12px;
      font-weight: 500;
      color: var(--text-muted);
      border: 1px solid transparent;
      cursor: pointer;
      transition: all var(--trans);
      display: flex;
      align-items: center;
      gap: 5px;
    }

    .cat-tab:hover {
      background: color-mix(in srgb, var(--cc, var(--accent)), transparent 92%);
      color: var(--cc, var(--accent));
    }

    .cat-tab.active {
      background: color-mix(in srgb, var(--cc, var(--accent)), transparent 88%);
      color: var(--cc, var(--accent));
      border-color: color-mix(in srgb, var(--cc, var(--accent)), transparent 80%);
    }

    .cat-tab .ct-count {
      font-size: 10px;
      background: rgba(255, 255, 255, 0.07);
      padding: 1px 5px;
      border-radius: 99px;
    }

    .card-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
      gap: 12px;
      padding: 14px 20px 20px;
      overflow-y: auto;
    }

    .grid-section-header {
      grid-column: 1 / -1;
      font-size: 13px;
      font-weight: 600;
      color: var(--text-muted);
      padding: 20px 0 8px;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      border-bottom: 1px solid var(--border);
      margin-bottom: 4px;
    }

    .card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      padding: 16px;
      cursor: pointer;
      transition: all var(--trans);
      position: relative;
      /* overflow: hidden; */
      min-height: 100px;
    }

    .card::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      height: 2px;
      background: var(--card-accent, var(--accent));
      opacity: 0.6;
      transition: opacity var(--trans);
    }

    .card:hover {
      border-color: var(--border-hover);
      background: var(--surface-2);
      transform: translateY(-1px);
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    }

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

    .card-header {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 10px;
    }

    .card-icon {
      width: 36px;
      height: 36px;
      border-radius: var(--radius-md);
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
      font-size: 16px;
    }

    .card-title {
      font-weight: 600;
      font-size: 14px;
      line-height: 1.3;
    }

    .card-subtitle {
      font-size: 11px;
      color: var(--text-muted);
      margin-top: 1px;
    }

    .card-type-badge {
      font-size: 10px;
      text-transform: uppercase;
      letter-spacing: 0.07em;
      font-weight: 600;
      padding: 2px 7px;
      border-radius: 99px;
      width: fit-content;
      margin-bottom: 8px;
    }

    .card-url {
      font-size: 11px;
      color: var(--text-faint);
      font-family: var(--font-mono);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .card-tiers {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      margin-top: 10px;
    }

    .tier-badge {
      font-size: 10px;
      padding: 2px 8px;
      border-radius: 99px;
      border: 1px solid;
    }

    .tier-free {
      background: rgba(52, 211, 153, 0.1);
      color: #34d399;
      border-color: rgba(52, 211, 153, 0.25);
    }

    .tier-freemium {
      background: rgba(251, 191, 36, 0.1);
      color: #fbbf24;
      border-color: rgba(251, 191, 36, 0.25);
    }

    .tier-premium {
      background: rgba(167, 139, 250, 0.1);
      color: #a78bfa;
      border-color: rgba(167, 139, 250, 0.25);
    }

    .cap-chips {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      margin-top: 8px;
    }

    .cap-chip {
      font-size: 10px;
      background: var(--surface-3);
      color: var(--text-muted);
      padding: 2px 7px;
      border-radius: 99px;
    }

    .open-badge {
      background: rgba(34, 211, 238, 0.1);
      color: #22d3ee;
      border: 1px solid rgba(34, 211, 238, 0.25);
      font-size: 10px;
      padding: 2px 7px;
      border-radius: 99px;
    }

    .prop-badge {
      background: rgba(251, 113, 133, 0.1);
      color: #fb7185;
      border: 1px solid rgba(251, 113, 133, 0.25);
      font-size: 10px;
      padding: 2px 7px;
      border-radius: 99px;
    }

    /* ── MATRIX VIEW ── */
    #matrix-view {
      overflow: hidden;
    }

    .matrix-toolbar {
      padding: 14px 20px 0;
      display: flex;
      align-items: center;
      gap: 10px;
      flex-shrink: 0;
    }

    .matrix-toolbar h2 {
      font-size: 15px;
      font-weight: 600;
    }

    .matrix-toolbar p {
      font-size: 12px;
      color: var(--text-muted);
    }

    .matrix-wrap {
      overflow: auto;
      flex: 1;
      padding: 14px 20px 20px;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      font-size: 12px;
    }

    thead th {
      position: sticky;
      top: 0;
      background: var(--surface);
      z-index: 5;
      padding: 10px 14px;
      text-align: left;
      font-weight: 600;
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.07em;
      color: var(--text-muted);
      border-bottom: 1px solid var(--border);
      white-space: nowrap;
    }

    tbody tr {
      transition: background var(--trans);
    }

    tbody tr:hover td {
      background: var(--surface-2);
    }

    td {
      padding: 10px 14px;
      border-bottom: 1px solid var(--border);
      vertical-align: middle;
    }

    .model-cell {
      display: flex;
      align-items: center;
      gap: 10px;
    }

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

    .model-name {
      font-weight: 600;
    }

    .model-provider {
      font-size: 11px;
      color: var(--text-muted);
    }

    .tiers-cell {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
    }

    .matrix-tier {
      font-size: 10px;
      padding: 3px 9px;
      border-radius: 99px;
      border: 1px solid rgba(255, 255, 255, 0.08);
      background: var(--surface-3);
      color: var(--text-muted);
      display: flex;
      align-items: center;
      gap: 4px;
    }

    .matrix-tier.has-reasoning::after {
      content: '🧠';
      font-size: 9px;
    }

    .modal-badge {
      padding: 1px 6px;
      border-radius: 99px;
      font-size: 10px;
    }

    .mod-text {
      background: rgba(34, 211, 238, 0.1);
      color: #22d3ee;
    }

    .mod-image {
      background: rgba(167, 139, 250, 0.1);
      color: #a78bfa;
    }

    .mod-audio {
      background: rgba(251, 191, 36, 0.1);
      color: #fbbf24;
    }

    .mod-video {
      background: rgba(251, 113, 133, 0.1);
      color: #fb7185;
    }

    /* ── DETAIL PANEL ── */
    .detail-panel {
      width: 0;
      overflow: hidden;
      border-left: 1px solid transparent;
      transition: width 280ms cubic-bezier(0.16, 1, 0.3, 1), border-color 280ms;
      background: var(--surface);
      flex-shrink: 0;
    }

    .detail-panel.open {
      width: 320px;
      border-color: var(--border);
    }

    .detail-inner {
      width: 320px;
      height: 100%;
      overflow-y: auto;
      padding: 20px;
    }

    .detail-close {
      position: absolute;
      top: 14px;
      right: 14px;
      width: 28px;
      height: 28px;
      border-radius: var(--radius-md);
      display: flex;
      align-items: center;
      justify-content: center;
      color: var(--text-muted);
      transition: all var(--trans);
    }

    .detail-close:hover {
      background: var(--surface-3);
      color: var(--text);
    }

    .detail-header {
      margin-bottom: 16px;
      padding-bottom: 16px;
      border-bottom: 1px solid var(--border);
    }

    .detail-icon {
      width: 48px;
      height: 48px;
      border-radius: var(--radius-lg);
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 12px;
      font-size: 22px;
    }

    .detail-title {
      font-size: 17px;
      font-weight: 700;
    }

    .detail-type {
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.07em;
      margin-top: 2px;
    }

    .detail-section {
      margin-top: 16px;
    }

    .detail-section h4 {
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.08em;
      color: var(--text-faint);
      margin-bottom: 8px;
    }

    .detail-prop {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 6px 0;
      border-bottom: 1px solid var(--border);
      font-size: 12px;
    }

    .detail-prop:last-child {
      border: none;
    }

    .detail-prop span:first-child {
      color: var(--text-muted);
    }

    .detail-prop span:last-child {
      color: var(--text);
      text-align: right;
      font-family: var(--font-mono);
      font-size: 11px;
    }

    .detail-tiers {
      display: flex;
      flex-direction: column;
      gap: 8px;
      margin-top: 4px;
    }

    .detail-tier-card {
      background: var(--surface-2);
      border: 1px solid var(--border);
      border-radius: var(--radius-md);
      padding: 10px 12px;
    }

    .detail-tier-card h5 {
      font-size: 12px;
      font-weight: 600;
      margin-bottom: 6px;
    }

    .detail-caps {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
    }

    .detail-link {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 12px;
      color: var(--accent);
      margin-top: 10px;
      padding: 8px 12px;
      background: var(--accent-dim);
      border-radius: var(--radius-md);
      text-decoration: none;
      transition: all var(--trans);
    }

    .detail-link:hover {
      background: rgba(31, 184, 205, 0.2);
    }

    /* Node SVG styles */
    .node circle {
      transition: r 0.2s, filter 0.2s;
      cursor: pointer;
    }

    .node circle:hover {
      filter: brightness(1.3);
    }

    .node text {
      font-family: var(--font-body);
      pointer-events: none;
      fill: var(--text);
      font-size: 11px;
    }

    .link {
      stroke: rgba(255, 255, 255, 0.06);
      stroke-width: 1;
    }

    .link.highlighted {
      stroke: rgba(31, 184, 205, 0.35);
      stroke-width: 2;
    }

    .node.dimmed {
      opacity: 0.15;
    }

    .node.selected circle {
      filter: drop-shadow(0 0 8px var(--node-color, var(--accent)));
    }

    /* Scrollbars */
    ::-webkit-scrollbar {
      width: 6px;
      height: 6px;
    }

    ::-webkit-scrollbar-track {
      background: transparent;
    }

    ::-webkit-scrollbar-thumb {
      background: var(--surface-3);
      border-radius: 3px;
    }

    ::-webkit-scrollbar-thumb:hover {
      background: var(--border-hover);
    }

    /* Mobile */
    @media(max-width:680px) {
      .view-tab span {
        display: none;
      }

      .stats-chip,
      .graph-filters {
        display: none;
      }

      .detail-panel.open {
        width: 280px;
      }

      .detail-inner {
        width: 280px;
      }
    }