:root {
  color-scheme: dark;
  --bg: #131313;
  --panel: rgba(30, 30, 31, 0.92);
  --panel-strong: rgba(42, 42, 44, 0.98);
  --panel-soft: rgba(54, 54, 58, 0.88);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #ece8de;
  --muted: #a7a49c;
  --accent: #d48c32;
  --accent-soft: rgba(212, 140, 50, 0.18);
  --danger: #d6644f;
  --success: #7fbf55;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --grid-major: rgba(255, 255, 255, 0.06);
  --grid-minor: rgba(255, 255, 255, 0.025);
  --node-body: rgba(43, 43, 46, 0.98);
  --node-border: rgba(255, 255, 255, 0.15);
  --node-shadow: 0 18px 38px rgba(0, 0, 0, 0.4);
  font-family: "Segoe UI Variable", "Segoe UI", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.04), transparent 24%),
    linear-gradient(180deg, #1a1a1b 0%, #121212 100%);
  color: var(--text);
}

body {
  min-height: 100vh;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(180deg, rgba(36, 36, 38, 0.96), rgba(28, 28, 30, 0.92));
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1,
.graph-empty-state h2,
.sidebar-card h2 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.brand-block {
  display: grid;
  gap: 0.35rem;
}

.topbar-copy {
  margin: 0;
  max-width: 48rem;
  color: var(--muted);
}

.topbar-copy[data-tone="error"] {
  color: #f2b6aa;
}

.topbar-copy[data-tone="success"] {
  color: #b6ddb0;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toolbar-global {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar-local {
  flex-wrap: wrap;
}

.toolbar-button {
  border: 1px solid rgba(212, 140, 50, 0.45);
  border-radius: 999px;
  padding: 0.75rem 1rem;
  background: linear-gradient(180deg, rgba(222, 153, 63, 0.2), rgba(186, 108, 20, 0.28));
  color: var(--text);
  cursor: pointer;
}

.toolbar-button-secondary {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
}

.toolbar-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.inline-link {
  color: var(--text);
  text-decoration-color: rgba(212, 140, 50, 0.65);
  text-underline-offset: 0.16em;
}

.inline-link:hover,
.inline-link:focus-visible,
.toolbar-link-button:hover,
.toolbar-link-button:focus-visible {
  filter: brightness(1.08);
}

.toolbar-chip {
  min-width: 3rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.toolbar-field {
  display: grid;
  gap: 0.35rem;
  min-width: min(19rem, 100%);
  color: var(--muted);
  font-size: 0.85rem;
}

.toolbar-field select {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  min-height: 0;
  overflow: hidden;
}

.editor-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(23, 23, 24, 0.96), rgba(18, 18, 18, 0.92));
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.breadcrumb-button,
.breadcrumb-separator {
  flex: 0 0 auto;
}

.breadcrumb-button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.breadcrumb-button[aria-current="page"] {
  border-color: rgba(212, 140, 50, 0.45);
  background: rgba(212, 140, 50, 0.18);
}

.breadcrumb-separator {
  color: var(--muted);
}

.graph-panel {
  position: relative;
  overflow: hidden;
  background: #181818;
  min-height: 0;
  touch-action: none;
  cursor: grab;
}

.graph-panel.is-panning {
  cursor: grabbing;
}

.graph-grid,
.graph-links,
.graph-world,
.graph-empty-state,
.dropzone-hint,
.minimap,
.hint-chips {
  position: absolute;
  inset: 0;
}

.graph-grid {
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 160px 160px, 160px 160px, 32px 32px, 32px 32px;
  background-position: center center;
  z-index: 0;
}

.graph-links {
  z-index: 1;
  pointer-events: none;
  display: block;
  width: 100%;
  height: 100%;
}

.graph-world {
  inset: auto;
  top: 50%;
  left: 50%;
  width: 1px;
  height: 1px;
  overflow: visible;
  transform-origin: 0 0;
  will-change: transform;
  z-index: 2;
}

.graph-empty-state,
.sidebar-card {
  max-width: 28rem;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(38, 38, 40, 0.95), rgba(26, 26, 28, 0.92));
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.graph-empty-state {
  z-index: 3;
  inset: auto;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.graph-empty-state.is-hidden {
  display: none;
}

.graph-empty-state p:last-child,
.sidebar-card p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.dropzone-hint {
  inset: auto;
  left: 50%;
  top: 1.5rem;
  transform: translateX(-50%);
  z-index: 5;
  width: max-content;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(212, 140, 50, 0.45);
  border-radius: 999px;
  background: rgba(16, 16, 17, 0.92);
  box-shadow: var(--shadow);
}

.minimap {
  inset: auto 1rem 1rem auto;
  width: 240px;
  height: 182px;
  z-index: 4;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: rgba(16, 16, 17, 0.85);
  backdrop-filter: blur(12px);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.minimap__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.minimap__caption {
  font-size: 0.72rem;
  text-transform: none;
  letter-spacing: 0;
}

.minimap svg {
  display: block;
  width: 100%;
  height: calc(100% - 38px);
  cursor: pointer;
}

.hint-chips {
  inset: auto auto 1rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  z-index: 4;
}

.hint-chips span,
.graph-chip,
.graph-value-chip,
.inspector-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  font-size: 0.75rem;
  max-width: 100%;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.graph-frame {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  pointer-events: none;
}

.graph-frame__label {
  position: absolute;
  top: 0.75rem;
  left: 1rem;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.graph-node {
  position: absolute;
  min-width: 180px;
  max-width: 420px;
  padding: 0;
  border: 1px solid var(--node-border);
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(52, 52, 55, 0.98), rgba(42, 42, 46, 0.98));
  box-shadow: var(--node-shadow);
  user-select: none;
  text-align: left;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
}

.graph-node--selected {
  border-color: rgba(212, 140, 50, 0.85);
  box-shadow:
    0 0 0 1px rgba(212, 140, 50, 0.7),
    0 20px 44px rgba(0, 0, 0, 0.45);
}

.graph-node--interactive {
  cursor: pointer;
}

.graph-node--dragging {
  cursor: grabbing;
}

.graph-node--muted {
  opacity: 0.72;
}

.graph-node--reroute {
  width: 42px;
  min-width: 42px;
  border-radius: 999px;
  background: rgba(48, 48, 50, 0.95);
}

.graph-node__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.7rem 0.85rem;
  background: linear-gradient(180deg, color-mix(in srgb, var(--header-color) 90%, #1d1d1f), #2a2a2d);
}

.graph-node__header-main {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  flex: 1 1 auto;
  min-width: 0;
}

.graph-node__title-block {
  min-width: 0;
}

.graph-node__collapse-button {
  flex: 0 0 auto;
  min-width: 0.8rem;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1;
  cursor: pointer;
  user-select: none;
}

.graph-node__collapse-button:hover {
  color: var(--text);
}

.graph-node__title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.2;
}

.graph-node__subtitle {
  margin: 0.2rem 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.graph-node__type-tag {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0.2rem 0.45rem;
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.85);
}

.graph-node__content {
  display: grid;
  gap: 0.7rem;
  padding: 0.85rem;
  background: var(--node-body);
}

.graph-node--collapsed .graph-node__header {
  align-items: center;
  padding: 0.58rem 0.75rem;
}

.graph-node--collapsed .graph-node__subtitle,
.graph-node--collapsed .graph-node__type-tag {
  display: none;
}

.graph-node--collapsed .graph-node__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

.graph-node--collapsed .graph-node__content {
  gap: 0.35rem;
  padding: 0 0.55rem 0.55rem;
}

.graph-node__collapsed-sockets {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.graph-node__socket-column {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  min-width: 0;
}

.graph-node__socket-column--output {
  align-items: flex-end;
}

.graph-node__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  min-height: 1.6rem;
}

.graph-node__row-center {
  min-width: 0;
  display: flex;
  justify-content: center;
}

.graph-node__row-placeholder {
  min-height: 1px;
}

.node-socket {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  max-width: 100%;
}

.node-socket--output {
  justify-self: end;
}

.node-socket--collapsed {
  gap: 0;
}

.node-socket--collapsed .node-socket__label {
  display: none;
}

.node-socket--collapsed .node-socket__dot {
  width: 10px;
  height: 10px;
}

.node-socket__dot {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.35);
  background: var(--socket-color);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.node-socket__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  line-height: 1.25;
}

.graph-value-chip {
  max-width: 10.5rem;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 0.78rem;
}

.graph-value-chip__swatch {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: var(--swatch-color);
}

.graph-node__properties {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.graph-chip {
  color: var(--text);
}

.graph-chip strong {
  color: var(--muted);
  font-weight: 500;
}

.graph-node__footer {
  padding-top: 0.15rem;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(18, 18, 19, 0.96), rgba(14, 14, 15, 0.98));
}

.status-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.sidebar {
  padding: 1rem;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20, 20, 21, 0.96), rgba(15, 15, 16, 0.98));
  overflow: auto;
  min-width: 0;
}

.sidebar-card {
  width: 100%;
  max-width: none;
  min-width: 0;
}

.inspector-content {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.inspector-content h2,
.inspector-content h3 {
  margin: 0;
  overflow-wrap: anywhere;
}

.inspector-section {
  display: grid;
  gap: 0.7rem;
  min-width: 0;
}

.inspector-section + .inspector-section {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.inspector-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.65rem 1rem;
}

.inspector-grid dt,
.inspector-grid dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.inspector-grid dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.inspector-grid dd {
  text-align: right;
  word-break: break-word;
}

.inspector-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  min-width: 0;
}

.inspector-image-preview {
  display: grid;
  gap: 0.65rem;
  margin: 0;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
}

.inspector-image-preview img {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: 10px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.05) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.05) 75%),
    rgba(10, 10, 10, 0.75);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.inspector-image-preview__mount {
  display: grid;
  place-items: center;
  min-height: 180px;
  border-radius: 10px;
  overflow: hidden;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.05) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.05) 75%),
    rgba(10, 10, 10, 0.75);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.inspector-image-preview__canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 240px;
}

.inspector-image-preview__message {
  margin: 0;
  padding: 1rem;
  color: var(--muted);
  text-align: center;
  font-size: 0.82rem;
}

.inspector-image-preview figcaption {
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.inspector-list {
  display: grid;
  gap: 0.55rem;
}

.inspector-list__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.85rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  min-width: 0;
}

.inspector-list__item > div {
  min-width: 0;
}

.inspector-list__item strong {
  display: block;
  font-size: 0.84rem;
}

.inspector-list__meta {
  color: var(--muted);
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.inspector-list__value {
  color: var(--text);
  text-align: right;
  font-size: 0.82rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.inspector-empty {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(60vh, 1fr) auto;
  }

  .sidebar {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .minimap {
    width: 220px;
    height: 170px;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .toolbar-button {
    flex: 1 1 10rem;
  }

  .toolbar-field {
    min-width: 100%;
  }

  .editor-toolbar,
  .statusbar {
    flex-direction: column;
    align-items: stretch;
  }

  .minimap {
    inset: auto 0.75rem 0.75rem auto;
    width: 200px;
    height: 155px;
  }

  .hint-chips {
    max-width: calc(100% - 1.5rem);
  }

  .inspector-grid {
    grid-template-columns: 1fr;
  }

  .inspector-grid dd {
    text-align: left;
  }

  .inspector-list__item {
    grid-template-columns: 1fr;
  }

  .inspector-list__value {
    text-align: left;
  }
}
