:root {
  color-scheme: light;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --primary: #1a3d8f;
  --accent: #f7b733;
  --border: #d7dce6;
  --text-muted: #59627a;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: #182033;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem clamp(1rem, 4vw, 3rem);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header h1 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  max-width: 700px;
}

.hero-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.5rem;
  order: -1;
  flex: 0 0 210px;
}

.hero-copy {
  flex: 1 1 360px;
  min-width: 260px;
}

.hero-portrait {
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 24px -18px rgba(15, 26, 55, 0.4);
  align-self: center;
}

.header-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
  max-width: 210px;
  align-self: stretch;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--primary);
}

.btn-outline:hover {
  border-color: var(--primary);
  background: rgba(26, 61, 143, 0.08);
  color: var(--primary);
}

.btn:disabled,
.btn-outline:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn:hover {
  background: #102a63;
  text-decoration: none;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  padding: 1.5rem clamp(1rem, 4vw, 3rem);
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: 0 6px 16px -12px rgba(19, 31, 64, 0.2);
}

.summary-card h2 {
  margin: 0;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.summary-card p {
  margin: 0.35rem 0 0;
  font-size: 1.8rem;
  font-weight: 700;
}

.layout {
  display: grid;
  gap: 1.75rem;
  grid-template-columns: minmax(320px, 360px) 1fr;
  align-items: start;
  padding: 0 clamp(1rem, 4vw, 3rem) 2.5rem;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: 0 10px 24px -18px rgba(15, 26, 55, 0.3);
}

.panel h2 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.panel-hint {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.field {
  display: flex;
  flex-direction: column;
  margin: 0.75rem 0;
  font-weight: 600;
  gap: 0.45rem;
  color: var(--text-muted);
}

.field input,
.field select {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 1rem;
  background: #fff;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(26, 61, 143, 0.2);
  border-color: var(--primary);
}

.roster-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 480px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.roster-list li {
  background: #f8f9ff;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.roster-list li:hover {
  border-color: rgba(26, 61, 143, 0.4);
  transform: translateY(-1px);
}

.roster-list li.active {
  border-color: var(--primary);
  background: rgba(26, 61, 143, 0.08);
}

.roster-list .name {
  font-weight: 600;
}

.roster-list .meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}


.graph-area {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

#network {
  width: 100%;
  min-height: 580px;
  height: clamp(620px, 70vh, 800px);
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px rgba(26, 61, 143, 0.03),
    0 14px 36px -24px rgba(15, 26, 55, 0.5);
  position: relative;
  overflow: hidden;
}

.graph-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.graph-viewport {
  cursor: grab;
}

.graph-viewport:active {
  cursor: grabbing;
}

.graph-link {
  stroke: #9bb7db;
  stroke-opacity: 0.32;
}

.graph-link.selected {
  stroke-opacity: 0.75;
  stroke: #4b6fb6;
}

.graph-link.lineage-active {
  stroke: #1a3d8f;
  stroke-width: 1.8px;
  stroke-opacity: 0.9;
}

.graph-link.lineage-muted {
  stroke-opacity: 0.08;
}

.graph-link.hovered {
  stroke: #f7b733;
  stroke-opacity: 0.9;
  stroke-width: 2px;
}

.graph-link.hover-muted {
  stroke-opacity: 0.1;
}

.graph-node {
  cursor: pointer;
}

.graph-node-circle {
  transition: stroke 0.2s ease, stroke-width 0.2s ease, fill 0.2s ease;
}

.graph-node.selected .graph-node-circle {
  stroke: #1a3d8f;
  stroke-width: 3px;
}

.graph-node.lineage-active .graph-node-circle {
  stroke: #1a3d8f;
  stroke-width: 3px;
}

.graph-node.lineage-active .node-label {
  fill: #0c1e4f;
}

.graph-node.lineage-muted .graph-node-circle {
  opacity: 0.28;
}

.graph-node.lineage-muted .node-label {
  opacity: 0.45;
}

.graph-node.hovered .graph-node-circle {
  stroke: #f7b733;
  stroke-width: 3px;
}

.graph-node.hovered .node-label {
  fill: #f7b733;
}

.graph-node.hover-muted .graph-node-circle {
  opacity: 0.35;
}

.graph-node.hover-muted .node-label {
  opacity: 0.55;
}

.graph-node.is-root .graph-node-circle {
  stroke: #143166;
  stroke-width: 3px;
}

.graph-node .node-label {
  font-size: 0.7rem;
  font-weight: 600;
  fill: #1c233a;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.95);
  stroke-width: 4px;
  pointer-events: none;
}

.graph-node.is-root .node-label {
  font-size: 0.78rem;
}

.graph-node.selected .node-label {
  fill: #102a63;
}

.hover-badge {
  font-size: 0.68rem;
  font-weight: 600;
  fill: #143166;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 6px;
  paint-order: stroke;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.graph-node.hovered .hover-badge {
  opacity: 1;
  transform: translateY(-2px);
}

.graph-node:focus-visible .graph-node-circle {
  outline: 3px solid rgba(26, 61, 143, 0.45);
  outline-offset: 4px;
}

.graph-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem;
  text-align: center;
  color: #102a63;
  background: rgba(255, 255, 255, 0.92);
}

.graph-error h3 {
  margin: 0;
  font-size: 1.25rem;
}

.graph-error p {
  margin: 0;
  max-width: 420px;
  color: #47506a;
}

.details-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
}

.profile-card,
.preview-card {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 12px 30px -24px rgba(15, 26, 55, 0.6);
}

.profile-card.hidden {
  display: none;
}

.profile-card header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.profile-card h2 {
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  background: rgba(26, 61, 143, 0.1);
  color: var(--primary);
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 12px 30px -24px rgba(15, 26, 55, 0.6);
}

.preview-card.hidden {
  display: none;
}

.preview-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.preview-card h2 {
  margin: 0;
}

.preview-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.preview-frame-wrapper {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  height: 400px;
  background: #f3f4f9;
}

#profile-preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

.preview-status {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.profile-card dl {
  display: grid;
  grid-template-columns: minmax(140px, 200px) 1fr;
  gap: 0.4rem 1rem;
  margin: 0;
}

.profile-card dt {
  font-weight: 700;
  color: var(--text-muted);
}

.profile-card dd {
  margin: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  background: rgba(247, 183, 51, 0.2);
  color: #8b5a00;
  border-radius: 999px;
  font-size: 0.8rem;
  margin: 0.15rem;
}

.site-footer {
  padding: 1.5rem clamp(1rem, 4vw, 3rem);
  text-align: center;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .hero-meta {
    width: 100%;
    align-items: flex-start;
    flex: 1 1 auto;
  }

  .header-actions {
    flex-direction: row;
    width: auto;
  }
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }

  #network {
    min-height: 520px;
    height: 520px;
  }

  .profile-card dl {
    grid-template-columns: 1fr;
  }

  .preview-frame-wrapper {
    height: 320px;
  }
}
