:root {
  color-scheme: dark;
  --bg: #05080c;
  --panel: rgba(13, 18, 24, 0.92);
  --panel-2: rgba(17, 23, 31, 0.84);
  --line: rgba(186, 204, 222, 0.16);
  --text: #eef4f8;
  --muted: #9aa9b5;
  --soft: #c7d1d9;
  --accent: #f4b942;
  --accent-2: #28c4ba;
  --danger: #f05b52;
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  min-height: 720px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 44%, rgba(41, 53, 62, 0.58), transparent 34%),
    linear-gradient(180deg, #071018 0%, var(--bg) 58%, #030507 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  cursor: pointer;
}

button:hover,
button.active,
button[aria-pressed="true"] {
  border-color: rgba(244, 185, 66, 0.72);
  background: rgba(244, 185, 66, 0.13);
}

.app-shell {
  display: grid;
  width: 100vw;
  height: 100vh;
  grid-template-columns: 76px minmax(660px, 1fr) 392px;
  grid-template-rows: 56px 1fr 116px;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
}

.topbar {
  z-index: 5;
  display: flex;
  grid-column: 1 / 4;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(4, 8, 12, 0.92);
  padding: 0 20px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  border: 0;
  background:
    linear-gradient(90deg, rgba(40, 196, 186, 0.14), transparent 72%),
    transparent;
  padding: 0 16px 0 0;
  cursor: pointer;
}

.brand-logo:hover,
.brand-logo:focus-visible {
  outline: none;
  background:
    linear-gradient(90deg, rgba(40, 196, 186, 0.2), transparent 74%),
    transparent;
}

.kuon-logo {
  width: 36px;
  height: 36px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 0 14px rgba(40, 196, 186, 0.34));
}

.kuon-wordmark {
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.1;
  white-space: nowrap;
}

.left-panel {
  z-index: 4;
  display: block;
  border-right: 1px solid var(--line);
  background: rgba(5, 9, 14, 0.82);
  overflow: hidden;
}

.tool-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 9px;
}

.rail-button {
  --swatch: var(--accent-2);
  display: grid;
  width: 56px;
  min-height: 46px;
  place-items: center;
  gap: 2px;
  border-color: color-mix(in srgb, var(--swatch), transparent 65%);
  color: var(--soft);
  font-weight: 800;
  padding: 4px 3px;
}

.overview-swatch {
  color: var(--accent-2);
}

.full-map-swatch {
  color: var(--accent);
}

.full-map-button {
  margin-top: 5px;
}

.rail-glyph {
  color: var(--swatch);
  font-size: 11px;
  line-height: 1;
  text-shadow: 0 0 12px color-mix(in srgb, var(--swatch), transparent 35%);
}

.rail-button small {
  max-width: 48px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-button.active small {
  color: var(--text);
}

.graph-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#graph {
  width: 100%;
  height: 100%;
}

.label-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.graph-label {
  position: absolute;
  left: var(--label-x);
  top: var(--label-y);
  max-width: 210px;
  transform: translate(10px, -50%);
  border: 1px solid color-mix(in srgb, var(--label-color), transparent 44%);
  border-radius: 999px;
  background: rgba(4, 8, 12, 0.76);
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.48);
  color: #f5fbff;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 8px #000;
  white-space: nowrap;
}

.graph-label.branch {
  background: color-mix(in srgb, var(--label-color), rgba(4, 8, 12, 0.84) 76%);
  font-size: 12px;
}

.graph-label.selected {
  border-color: rgba(244, 185, 66, 0.92);
  background: rgba(89, 64, 14, 0.88);
  color: #fff4c8;
}

.graph-label.left {
  transform: translate(calc(-100% - 10px), -50%);
}

.hint-strip {
  position: absolute;
  left: 20px;
  bottom: 20px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hint-strip span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(5, 9, 14, 0.68);
  color: var(--muted);
  padding: 7px 10px;
  font-size: 12px;
}

.right-panel {
  z-index: 4;
  min-width: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
}

.detail-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
}

.detail-tabs button {
  height: 48px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.detail-tabs button.active {
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.node-details {
  height: calc(100vh - 56px - 48px);
  overflow: auto;
  padding: 20px 22px 140px;
}

.node-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.node-title {
  margin: 8px 0 4px;
  font-size: 24px;
  line-height: 1.16;
}

.node-subtitle {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.detail-section {
  border-top: 1px solid var(--line);
  padding: 16px 0;
}

.detail-section h3 {
  margin: 0 0 10px;
  color: #e6eef5;
  font-size: 13px;
}

.detail-section p {
  margin: 0;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.52;
}

.property-grid {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 10px 12px;
  color: var(--soft);
  font-size: 13px;
}

.property-grid dt {
  color: var(--muted);
}

.property-grid dd {
  margin: 0;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--soft);
  padding: 6px 9px;
  font-size: 12px;
}

.action-chip {
  text-align: left;
  transition:
    border-color 160ms ease,
    color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.action-chip:hover,
.action-chip:focus-visible {
  border-color: rgba(40, 196, 186, 0.76);
  background: rgba(40, 196, 186, 0.12);
  color: #eaffff;
  outline: none;
  transform: translateY(-1px);
}

.action-chip.pending {
  border-color: rgba(244, 185, 66, 0.76);
  color: #f8d98b;
}

.chip.accent {
  border-color: rgba(244, 185, 66, 0.42);
  color: #f8d98b;
}

.action-status {
  min-height: 34px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding-top: 12px;
  font-size: 12px;
  line-height: 1.4;
}

.action-status.success {
  color: #8bd9c9;
}

.action-status.warning {
  color: #f8d98b;
}

.trail-panel {
  z-index: 5;
  display: grid;
  grid-column: 2 / 4;
  grid-template-columns: 132px 1fr;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--line);
  background: rgba(8, 12, 17, 0.94);
  padding: 14px 18px;
}

.selected-trail {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}

.trail-card {
  display: grid;
  min-width: 150px;
  max-width: 260px;
  min-height: 64px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 10px 12px;
}

.trail-card strong {
  overflow: hidden;
  color: var(--accent);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trail-card span {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trail-arrow {
  color: var(--muted);
}

@media (max-width: 1280px) {
  body {
    min-width: 1024px;
  }

  .app-shell {
    grid-template-columns: 76px minmax(420px, 1fr) 340px;
  }
}
