:root {
  color-scheme: light;
  --canvas: #f6f7f5;
  --surface: #ffffff;
  --surface-muted: #eef2ef;
  --surface-strong: #dfe7e2;
  --text: #24211d;
  --text-muted: #6c645a;
  --line: rgba(36, 33, 29, 0.12);
  --line-strong: rgba(36, 33, 29, 0.22);
  --accent: #9f1239;
  --accent-strong: #7f1d1d;
  --accent-soft: #f8e4e8;
  --focus: #0f766e;
  --shadow: 0 18px 50px rgba(36, 33, 29, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100%;
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

label {
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

select,
input[type="text"] {
  width: 100%;
  min-height: 2.375rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--text);
  padding: 0.5rem 0.625rem;
}

select:focus-visible,
input[type="text"]:focus-visible,
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 20ch;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0;
}

h2 {
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 600;
}

h3 {
  font-size: 1.0625rem;
  font-weight: 600;
}

.app-shell {
  isolation: isolate;
  min-height: 100vh;
  padding: 1rem;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  max-width: 92rem;
  margin: 0 auto;
  padding: 1.25rem 0 1rem;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 600;
}

.lede {
  max-width: 58ch;
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 1rem;
}

.header-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.header-actions {
  align-items: end;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.25rem;
  border: 0;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.secondary-button {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  color: var(--text);
}

.ghost-button {
  background: transparent;
  color: var(--text-muted);
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  cursor: pointer;
  opacity: 0;
}

.workspace {
  display: grid;
  grid-template-columns: 18rem minmax(0, 1fr) 20rem;
  gap: 1rem;
  max-width: 92rem;
  margin: 0 auto;
  align-items: stretch;
}

.controls-panel,
.details-panel,
.graph-stage {
  min-width: 0;
}

.controls-panel,
.details-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.control-section {
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  padding: 0.875rem;
}

.control-section > * + * {
  margin-top: 0.625rem;
}

.edge-form {
  display: grid;
  gap: 0.5rem;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.legend {
  display: grid;
  gap: 0.45rem;
}

.legend-item,
.type-badge,
.count-pill {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
}

.legend-item {
  gap: 0.5rem;
  justify-content: space-between;
  border: 1px solid var(--line);
  padding: 0.375rem 0.5rem;
}

.legend-item[aria-pressed="false"] {
  background: var(--surface-muted);
  color: var(--text-muted);
  opacity: 0.65;
}

.legend-label {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 0.5rem;
}

.legend-dot {
  width: 0.7rem;
  height: 0.7rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--dot-color);
}

.legend-count,
.count-pill {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.type-badge {
  background: var(--badge-color, var(--surface-muted));
  color: #ffffff;
  padding: 0.25rem 0.5rem;
}

.count-pill {
  background: var(--surface-muted);
  padding: 0.25rem 0.5rem;
}

.graph-stage {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(36rem, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.graph-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding: 0.75rem;
}

.graph-status {
  min-width: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.compact-buttons {
  flex: 0 0 auto;
}

.graph-canvas {
  min-height: 36rem;
  background:
    radial-gradient(circle at 24px 24px, rgba(36, 33, 29, 0.065) 1px, transparent 1px),
    var(--surface);
  background-size: 24px 24px;
}

.load-error {
  position: absolute;
  inset: auto 1rem 1rem 1rem;
  border-radius: 0.5rem;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 0.75rem;
  font-size: 0.875rem;
}

.selected-card h3 {
  word-break: break-word;
}

.muted-text {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.connection-list {
  display: grid;
  gap: 0.5rem;
}

.connection-empty {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.connection-item {
  display: grid;
  gap: 0.35rem;
  border-top: 1px solid var(--line);
  padding-top: 0.625rem;
}

.connection-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.connection-main {
  min-width: 0;
  font-size: 0.875rem;
}

.connection-label {
  color: var(--text-muted);
}

.connection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.small-button {
  min-height: 1.875rem;
  padding: 0.375rem 0.5rem;
  font-size: 0.8125rem;
}

@media (max-width: 72rem) {
  .workspace {
    grid-template-columns: 17rem minmax(0, 1fr);
  }

  .details-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 54rem) {
  .app-shell {
    padding: 0.75rem;
  }

  .app-header {
    padding-top: 0.75rem;
  }

  .workspace,
  .details-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .graph-stage {
    grid-template-rows: auto minmax(28rem, 1fr);
  }

  .graph-canvas {
    min-height: 28rem;
  }

  .graph-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-buttons {
    justify-content: flex-start;
  }
}

@media (min-width: 54.01rem) {
  .app-header {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  h1 {
    font-size: 3rem;
  }
}

@media (max-width: 34rem) {
  .header-actions .button,
  .button-row .button,
  .edge-form .button {
    width: 100%;
  }
}
