.phylo-viewer {
  --phylo-border: #d9dee7;
  --phylo-surface: #ffffff;
  --phylo-muted: #667085;
  --phylo-text: #1f2937;
  --phylo-accent: #2563eb;
  --phylo-accent-soft: #eff6ff;
  --phylo-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);

  width: 100%;
  min-width: 0;
  border: 1px solid var(--phylo-border);
  border-radius: 8px;
  background: var(--phylo-surface);
  box-shadow: var(--phylo-shadow);
  overflow: hidden;
  color: var(--phylo-text);
}

.phylo-viewer__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--phylo-border);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.phylo-viewer__title {
  min-width: 0;
  font: 600 14px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phylo-viewer__controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.phylo-viewer__button {
  appearance: none;
  border: 1px solid #cfd7e6;
  border-radius: 6px;
  background: #fff;
  color: var(--phylo-text);
  padding: 5px 10px;
  font: 500 13px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
}

.phylo-viewer__button:hover {
  border-color: #adc0db;
  background: var(--phylo-accent-soft);
  color: var(--phylo-accent);
}

.phylo-viewer__button:active {
  transform: translateY(1px);
}

.phylo-viewer__stage {
  position: relative;
  width: 100%;
  min-height: 360px;
  height: clamp(360px, 62vh, 720px);
  background:
    linear-gradient(#eef2f7 1px, transparent 1px),
    linear-gradient(90deg, #eef2f7 1px, transparent 1px),
    #ffffff;
  background-size: 24px 24px;
  overflow: hidden;
}

.phylo-viewer__stage svg {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.phylo-viewer__stage svg:active {
  cursor: grabbing;
}

.phylo-viewer__stage .brush {
  display: none;
  pointer-events: none;
}

.phylo-viewer__empty,
.phylo-viewer__error {
  position: absolute;
  inset: 0;
  /* display: flex; */
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  font: 14px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--phylo-muted);
  pointer-events: none;
}

.phylo-viewer__error {
  color: #b42318;
  background: rgba(255, 255, 255, 0.82);
}

.phylo-viewer .branch,
.phylo-viewer .link {
  stroke: #374151;
  stroke-width: 1.35px;
  fill: none;
}

.phylo-viewer .node circle {
  fill: #ffffff;
  stroke: #64748b;
  stroke-width: 1.2px;
}

.phylo-viewer .node text {
  fill: #111827;
  font: 12px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.phylo-viewer .tree-scale-bar text {
  fill: var(--phylo-muted);
  font: 11px/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (max-width: 640px) {
  .phylo-viewer__toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .phylo-viewer__controls {
    justify-content: flex-end;
  }

  .phylo-viewer__stage {
    height: 420px;
  }
}
