:root {
  color-scheme: light;
  --bg: #f9f9ff;
  --panel: #ffffff;
  --panel-soft: #f1f3ff;
  --panel-high: #e1e8fd;
  --ink: #141b2b;
  --muted: #43474e;
  --line: #c4c6cf;
  --accent: #006398;
  --accent-dark: #001f3f;
  --root: #001f3f;
  --depends: #753900;
  --imports: #0072b2;
  --linkingto: #e69f00;
  --warning: #ba1a1a;
  --level-0: #001f3f;
  --level-1: #d81b60;
  --level-2: #1e88e5;
  --level-3: #43a047;
  --level-4: #fb8c00;
  --level-5: #8e24aa;
  --level-6: #00acc1;
  --level-7: #fdd835;
  --level-8: #3949ab;
  --level-9: #e53935;
  --level-10: #7cb342;
  --level-11: #6d4c41;
  --level-12: #00897b;
  --level-13: #c0ca33;
  --level-14: #5e35b1;
  --level-15: #f4511e;
  --level-16: #039be5;
  --level-17: #c2185b;
  --level-18: #546e7a;
  --level-19: #2e7d32;
  --level-20: #ef6c00;
  --level-deep: #263238;
  --shadow: 0 16px 36px rgba(20, 27, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.material-symbols-outlined {
  display: inline-block;
  font-family: "Material Symbols Outlined";
  font-size: 21px;
  font-style: normal;
  font-weight: 500;
  line-height: 1;
}

.app-shell {
  min-height: 100vh;
}

.top-hub,
.panel-toggles,
.metric-stack,
.filter-panel,
.dev-panel,
.level-panel,
.legend,
.status,
.hint {
  border: 1px solid rgba(0, 31, 63, 0.12);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.top-hub {
  position: fixed;
  top: 24px;
  left: 50%;
  z-index: 12;
  display: grid;
  grid-template-columns: auto minmax(260px, 360px) minmax(220px, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: min(1180px, calc(100vw - 48px));
  min-height: 64px;
  padding: 9px 12px 9px 20px;
  border-radius: 999px;
  transform: translateX(-50%);
}

.panel-toggles {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 11;
  display: flex;
  gap: 12px;
  padding: 8px 16px;
  border-radius: 999px;
}

.toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-btn:hover {
  background: var(--panel-soft);
  color: var(--accent);
}

.toggle-btn.active {
  background: var(--panel-high);
  color: var(--accent-dark);
  box-shadow: 0 2px 4px rgba(0, 31, 63, 0.1);
}

.hidden-panel {
  display: none !important;
}

.brand {
  padding-right: 18px;
  border-right: 1px solid var(--line);
  color: var(--accent-dark);
  font-size: 1.14rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.nav-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid rgba(0, 31, 63, 0.18);
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--panel-soft);
  font-size: 0.78rem;
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link:focus {
  border-color: var(--accent-dark);
  outline: none;
  background: var(--panel-high);
}

.field {
  display: grid;
  gap: 8px;
}

label,
.panel-title h2,
.level-panel h2 {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.package-field {
  gap: 0;
}

.package-field label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 11px;
  color: var(--ink);
  background: var(--panel);
}

input:focus,
select:focus {
  outline: 1px solid var(--accent-dark);
  border-color: var(--accent-dark);
}

.package-picker {
  position: relative;
}

.package-picker input {
  min-height: 42px;
  padding: 9px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--panel-soft);
}

.package-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: none;
  max-height: 320px;
  overflow: auto;
  padding: 6px;
  border: 1px solid rgba(0, 31, 63, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  z-index: 30;
}

.package-suggestions.open {
  display: grid;
  gap: 4px;
}

.package-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "name repo"
    "title repo";
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 7px 8px;
  border: 0;
  border-radius: 5px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.package-option:hover,
.package-option:focus {
  outline: none;
  background: var(--panel-soft);
}

.package-option strong {
  grid-area: name;
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.package-option-title {
  grid-area: title;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.package-option-repo,
.chip {
  padding: 3px 6px;
  border-radius: 4px;
  color: var(--accent-dark);
  background: var(--panel-high);
  font-size: 0.68rem;
  font-weight: 800;
  white-space: nowrap;
}

.package-option-repo {
  grid-area: repo;
}

.selected-title {
  min-width: 0;
}

.selected-title strong {
  display: block;
  overflow: hidden;
  color: var(--accent-dark);
  font-size: 0.98rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-title span {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-stage {
  position: fixed;
  inset: 0;
  z-index: 1;
}

.graph-wrap {
  position: absolute;
  inset: 0;
  min-height: 0;
  overflow: auto;
}

svg {
  width: 100%;
  height: 100%;
  min-width: 1800px;
  min-height: 1040px;
  display: block;
  background-image: radial-gradient(#c8d5f4 1px, transparent 1px);
  background-size: 32px 32px;
}

.empty {
  position: absolute;
  inset: 24px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.legend-metrics-wrapper {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 10;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
  transform: translateX(-50%);
  width: auto;
}

.metric-stack {
  position: relative;
  display: flex;
  gap: 16px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(249, 249, 255, 0.72);
  box-shadow: none;
}

/* ...existing code... */
.chip {
  display: inline-flex;
  align-items: center;
  background: #f3f6fa;
  border-radius: 16px;
  padding: 0 10px;
  margin: 2px 4px 2px 0;
  font-size: 0.95em;
  height: 28px;
  border: 1px solid #dbe4ee;
  color: #1a2330;
  transition: background 0.2s, border 0.2s;
}

/* Added indicator for direct packages */
.chip-added {
  box-shadow: 0 0 0 2px #4caf50, 0 2px 6px rgba(76, 175, 80, 0.15);
  border-color: #4caf50;
}
  width: 1px;
  background: var(--line);
}

.stat b {
  display: block;
  color: var(--accent-dark);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.left-panel {
  position: fixed;
  left: 28px;
  top: 112px;
  bottom: auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 390px;
  max-height: calc(100vh - 140px);
  pointer-events: none;
}

.left-panel > * {
  pointer-events: auto;
}

.right-panel {
  position: fixed;
  right: 28px;
  top: 112px;
  bottom: auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 390px;
  max-height: calc(100vh - 140px);
  pointer-events: none;
}

.right-panel > * {
  pointer-events: auto;
}

.filter-panel {
  position: relative;
  display: grid;
  gap: 16px;
  flex: 0 0 auto;
  min-height: 0;
  max-height: calc(100vh - 170px);
  overflow: auto;
  padding: 20px;
  border-radius: 8px;
}


.dev-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 0 0 auto;
  min-height: 0;
  max-height: calc(100vh - 170px);
  overflow: auto;
  padding: 20px;
  border-radius: 8px;
}

.dev-panel > * {
  flex: 0 0 auto;
}

.dev-panel .field {
  gap: 4px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.inline-field {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.range-control {
  display: grid;
  gap: 12px;
}

.range-values {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.84rem;
}

.range-values b {
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  min-height: 18px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  accent-color: var(--accent-dark);
  background: transparent;
  cursor: pointer;
}

.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}

.toggle-switch input {
  appearance: none;
  position: relative;
  width: 38px;
  min-height: 22px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--line);
  cursor: pointer;
}

.toggle-switch input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(20, 27, 43, 0.25);
  transition: transform 140ms ease;
}

.toggle-switch input:checked {
  background: var(--accent-dark);
}

.toggle-switch input:checked::after {
  transform: translateX(16px);
}

.checks {
  display: grid;
  gap: 8px;
}

.inline-checks,
.dependency-buttons {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dependency-buttons {
  display: grid;
  gap: 8px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.check input {
  width: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: var(--accent-dark);
}

.dependency-button {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--accent-dark);
  background: var(--panel);
  font-size: 0.76rem;
  font-weight: 850;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dependency-button input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.dependency-button:has(input:checked) {
  border-color: var(--accent-dark);
  color: #ffffff;
  background: var(--accent-dark);
}

.prune-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.dev-add-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 3px;
}

.dev-add-grid button {
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid var(--accent-dark);
  border-radius: 4px;
  color: #ffffff;
  background: var(--accent-dark);
  font-weight: 800;
  cursor: pointer;
}

.dev-mode {
  width: max-content;
}

.dev-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.dev-summary div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(249, 249, 255, 0.72);
}

.dev-summary b {
  display: block;
  overflow: hidden;
  color: var(--accent-dark);
  font-size: 1.02rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dev-summary span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.dev-panel details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.dev-panel summary {
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.dev-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.dev-list-item {
  display: grid;
  gap: 4px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(249, 249, 255, 0.72);
}

.dev-list-item strong {
  color: var(--ink);
  font-size: 0.86rem;
}

.dev-list-item span,
.dev-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.prune-picker button,
.chip button,
.level-item {
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}

.prune-picker button {
  min-height: 40px;
  padding: 8px 13px;
  color: #ffffff;
  background: var(--accent-dark);
  font-weight: 800;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 28px;
  overflow: visible;
  padding-bottom: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.chip button {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  color: var(--muted);
  background: #ffffff;
  line-height: 1;
}

.level-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 0 0 auto;
  min-height: 0;
  max-height: calc(100vh - 170px);
  overflow: hidden;
  padding: 20px;
  border-radius: 8px;
}

.level-panel h2 {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-bottom: 8px;
  background: inherit;
}

.level-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.level-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 36px;
  padding: 7px 9px;
  color: var(--ink);
  background: rgba(249, 249, 255, 0.72);
  text-align: left;
}

.level-item:hover,
.level-item.active {
  border-color: var(--accent-dark);
  background: var(--panel-soft);
}

.level-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

.level-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.level-count {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.legend {
  position: static;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  align-items: center;
  padding: 12px 20px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(255,255,255,0.88);
  box-shadow: var(--shadow);
}

.levels-block {
  display: grid;
  gap: 8px;
}

.subsection-title {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.filter-panel .level-list {
  max-height: 260px;
}

.legend span {
  display: flex;
  gap: 8px;
  align-items: center;
}
  gap: 6px;
}

.dot {
  justify-self: center;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.dot.root {
  background: var(--root);
}

.line-swatch {
  display: inline-block;
  justify-self: center;
  width: 24px;
  height: 0;
  border-top: 4px solid #9ba8b6;
}

.line-swatch.imports {
  border-color: var(--imports);
}

.line-swatch.depends {
  border-color: var(--depends);
}

.line-swatch.linkingto {
  border-color: var(--linkingto);
  border-top-style: dashed;
}

.loading-preview {
  pointer-events: none;
}

.loading-preview-title {
  fill: var(--accent-dark);
  font-size: 1rem;
  font-weight: 900;
}

.loading-preview-subtitle {
  fill: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.loading-preview-link {
  opacity: 0.42;
  stroke-dasharray: 7 8;
  animation: loading-preview-dash 1.4s linear infinite;
}

.loading-preview-node {
  opacity: 0.78;
}

@keyframes loading-preview-dash {
  to {
    stroke-dashoffset: -30;
  }
}

.status {
  position: fixed;
  left: 50%;
  bottom: 78px;
  z-index: 11;
  display: none;
  gap: 7px;
  overflow: hidden;
  max-width: min(560px, calc(100vw - 56px));
  min-height: 34px;
  padding: 8px 14px;
  border-radius: 999px;
  color: #ffffff;
  background: rgba(0, 31, 63, 0.94);
  font-size: 0.78rem;
  line-height: 1.35;
  transform: translateX(-50%);
}

.status.loading {
  display: grid;
}

.status-text {
  position: relative;
  z-index: 1;
}

.status-progress {
  position: relative;
  display: block;
  width: 100%;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.status-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, #5bb8fe 18%, #ffffff 50%, #5bb8fe 82%, transparent);
  animation: status-progress-indeterminate 1.15s ease-in-out infinite;
}

.status.error {
  background: rgba(186, 26, 26, 0.95);
}

@keyframes status-progress-indeterminate {
  from {
    transform: translateX(-115%);
  }

  to {
    transform: translateX(255%);
  }
}

.hint {
  position: fixed;
  bottom: 28px;
  left: 50%;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 999px;
  color: #ffffff;
  background: rgba(0, 31, 63, 0.94);
  font-size: 0.76rem;
  transform: translateX(-50%);
}

.node circle {
  stroke: #ffffff;
  stroke-width: 2px;
}

.node {
  cursor: pointer;
}

.node.dimmed {
  opacity: 0.18;
}

.node.pruned circle {
  stroke: #5c6670;
  stroke-width: 3px;
}

.node.pruned text {
  fill: #1f2933;
  stroke: rgba(255, 255, 255, 0.95);
}

.node.path-node circle {
  stroke: var(--accent-dark);
  stroke-width: 3px;
}

.node.target-node circle {
  stroke: #7ffc97;
  stroke-width: 5px;
}

.node.level-node circle {
  stroke: var(--accent-dark);
  stroke-width: 4px;
}

.node.level-node text {
  font-weight: 850;
}

.node .root-halo {
  fill: rgba(0, 31, 63, 0.12);
  stroke: rgba(0, 31, 63, 0.30);
  stroke-width: 2px;
}

.node .root-ring {
  fill: none;
  stroke: #ffffff;
  stroke-width: 4px;
}

.node .added-ring {
  fill: none;
  stroke: #4caf50;
  stroke-width: 3px;
}

.node text {
  pointer-events: none;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 4px;
  stroke-linejoin: round;
  fill: var(--ink);
  font-size: 12px;
  font-weight: 650;
}

.node .level-label {
  dominant-baseline: central;
  text-anchor: middle;
}

.node.root text {
  fill: var(--accent-dark);
  font-size: 18px;
  font-weight: 850;
  stroke-width: 6px;
}


}

.link {
  fill: none;
  stroke: #7a8da6;
  stroke-opacity: 0.76;
  stroke-width: 1.35px;
}

svg .link {
  fill: none !important;
}

.link.dimmed {
  stroke-opacity: 0.08;
}

.link.path-link {
  stroke: var(--accent-dark);
  stroke-opacity: 1;
  stroke-width: 4px;
}

.link.imports {
  stroke: var(--imports);
}

.link.depends {
  stroke: var(--depends);
}

.link.linkingto {
  stroke: var(--linkingto);
  stroke-dasharray: 4 3;
}

.direction-cues {
  pointer-events: none;
}

.direction-cue {
  fill: #7a8da6;
  opacity: 0.88;
  stroke: #ffffff;
  stroke-linejoin: round;
  stroke-width: 1.2px;
  transform-box: fill-box;
  transform-origin: center;
}

.direction-cue.imports {
  fill: var(--imports);
}

.direction-cue.depends {
  fill: var(--depends);
}

.direction-cue.linkingto {
  fill: var(--linkingto);
}

.direction-cue.dimmed {
  opacity: 0.08;
}

.direction-cue.path-link {
  fill: var(--accent-dark);
  opacity: 1;
  stroke-width: 1.8px;
}

.tooltip {
  position: fixed;
  z-index: 30;
  max-width: min(340px, calc(100vw - 24px));
  padding: 10px 12px;
  border: 1px solid rgba(0, 31, 63, 0.14);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translate(10px, 10px);
  transition: opacity 120ms ease;
}

.tooltip b {
  display: block;
  margin-bottom: 4px;
}

.tooltip span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.node-context-menu {
  position: fixed;
  z-index: 40;
  display: none;
  min-width: 300px;
  max-width: min(360px, calc(100vw - 24px));
  padding: 8px;
  border: 1px solid rgba(0, 31, 63, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
}

.node-context-menu.open {
  display: grid;
  gap: 6px;
}

.node-context-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.node-context-node {
  margin: 0 0 2px;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.node-context-menu button {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink);
  background: var(--panel);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.node-context-menu button[hidden] {
  display: none;
}

.node-context-menu button:hover {
  border-color: var(--accent-dark);
  background: var(--panel-soft);
}

@media (max-width: 1080px) {
  body {
    overflow: auto;
    height: auto;
    min-height: 100vh;
  }

  .app-shell {
    display: flex;
    flex-direction: column;
  }

  .top-hub {
    position: sticky;
    top: 12px;
    left: auto;
    z-index: 20;
    grid-template-columns: 1fr auto;
    gap: 10px;
    width: calc(100% - 24px);
    margin: 12px;
    padding: 12px;
    border-radius: 12px;
    transform: none;
    order: 0;
  }

  .hint {
    display: none;
  }

  .brand {
    display: block;
    padding-right: 0;
    border-right: 0;
    font-size: 1rem;
  }

  .package-field {
    grid-column: 1 / -1;
    order: 3;
  }

  .selected-title {
    grid-column: 1 / -1;
    order: 4;
  }

  .nav-actions {
    justify-content: flex-end;
  }

  .nav-link {
    min-height: 34px;
    padding: 7px 11px;
    font-size: 0.74rem;
  }

  .panel-toggles {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 50;
    gap: 6px;
    padding: 6px;
    border-radius: 999px;
  }

  .toggle-btn {
    width: 36px;
    height: 36px;
  }

  .graph-stage,
  .left-panel,
  .metric-stack,
  .right-panel,
  .filter-panel,
  .dev-panel,
  .level-panel,
  .legend-metrics-wrapper,
  .status {
    position: relative;
    inset: auto;
    left: auto;
    right: auto;
    bottom: auto;
    top: auto;
    width: calc(100% - 24px);
    max-width: none;
    max-height: none;
    margin: 12px;
    transform: none;
    pointer-events: auto;
  }

  .graph-stage {
    order: 1;
    height: 62vh;
    min-height: 440px;
    margin-top: 0;
    overflow: hidden;
    border: 1px solid rgba(0, 31, 63, 0.12);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow);
  }

  .right-panel {
    order: 2;
  }

  .left-panel {
    order: 3;
    display: contents;
  }

  .dev-panel {
    order: 3;
  }

  .legend-metrics-wrapper {
    order: 4;
    display: flex;
    justify-content: center;
    margin-bottom: 76px;
  }

  svg {
    min-width: 920px;
    min-height: 680px;
  }

  .filter-panel,
  .dev-panel {
    padding: 16px;
  }

  .panel-title h2,
  .subsection-title,
  label {
    font-size: 0.64rem;
  }

  .inline-checks {
    grid-template-columns: 1fr;
  }

  .dev-add-grid,
  .prune-picker {
    grid-template-columns: 1fr;
  }

  .dev-add-grid button,
  .prune-picker button {
    width: 100%;
  }

  .dev-summary,
  .metric-stack {
    grid-template-columns: 1fr;
  }

  .metric-stack {
    display: grid;
    gap: 8px;
  }

  .legend {
    border-radius: 12px;
  }

  .node-context-menu {
    position: fixed;
    left: 12px !important;
    right: 12px;
    top: auto !important;
    bottom: 64px;
    width: auto;
    min-width: 0;
    max-width: none;
  }
}

@media (max-width: 520px) {
  .top-hub,
  .graph-stage,
  .right-panel,
  .filter-panel,
  .dev-panel,
  .legend-metrics-wrapper,
  .status {
    width: calc(100% - 16px);
    margin: 8px;
  }

  .graph-stage {
    height: 58vh;
    min-height: 380px;
  }

  svg {
    min-width: 820px;
    min-height: 620px;
  }

  .package-suggestions {
    max-height: 260px;
  }

  .dependency-button {
    min-height: 36px;
  }

  .level-item {
    min-height: 38px;
    height: auto;
  }
}
