:root {
  color-scheme: dark;
  --bg: #10100f;
  --panel: rgba(20, 21, 20, 0.84);
  --panel-strong: rgba(28, 29, 28, 0.94);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f6f1e8;
  --muted: #aaa39a;
  --content: #74f2ce;
  --nav: #9f8cff;
  --header: #ff7d92;
  --footer: #f1c75b;
  --aside: #98d66d;
  --external: #ffad58;
  --danger: #ff6b63;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-rows: 52px 1fr;
  background:
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    #10100f;
  background-size: 42px 42px;
}

.topbar {
  z-index: 5;
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 15, 14, 0.82);
  backdrop-filter: blur(14px);
}

.brand {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.brand strong {
  font-size: 16px;
  letter-spacing: 0;
}

.brand span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.controls-panel {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 4;
  display: grid;
  gap: 14px;
  width: min(300px, calc(100vw - 32px));
  max-height: calc(100vh - 84px);
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.controls-panel[hidden],
.panel-tab[hidden] {
  display: none;
}

.panel-body {
  display: grid;
  gap: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.panel-button,
.panel-tab {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.panel-button:hover,
.panel-tab:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.11);
}

.panel-tab {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 4;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.search-box {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.search-box input {
  width: 100%;
}

.search-box input {
  height: 34px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 11px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  outline: none;
}

.search-box input:focus {
  border-color: rgba(116, 242, 206, 0.7);
  box-shadow: 0 0 0 3px rgba(116, 242, 206, 0.12);
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.toolbar button {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 11px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  cursor: pointer;
}

.toolbar button:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.11);
}

.toolbar button[aria-pressed="false"] {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
}

.control-section {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.section-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  height: 32px;
  padding: 0 9px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.toggle-row input {
  accent-color: var(--content);
  flex: 0 0 auto;
}

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

#graphCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#graphCanvas.dragging {
  cursor: grabbing;
}

.details-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 4;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 112px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.details-panel[hidden] {
  display: none;
}

.details-panel .eyebrow {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.details-panel h1 {
  margin: 6px 0 14px;
  font-size: 20px;
  line-height: 1.16;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.details-panel dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.details-panel dl > div {
  display: grid;
  gap: 3px;
}

.details-panel dt {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.details-panel dd {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.details-panel a {
  color: var(--content);
  text-decoration: none;
}

.details-panel a:hover {
  text-decoration: underline;
}

.tooltip {
  position: absolute;
  z-index: 8;
  max-width: 280px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(14, 15, 14, 0.94);
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
  box-shadow: var(--shadow);
}

.status-message {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 10;
  transform: translate(-50%, -50%);
  max-width: min(520px, calc(100vw - 32px));
  padding: 16px 18px;
  border: 1px solid rgba(255, 107, 99, 0.42);
  border-radius: 8px;
  background: rgba(31, 18, 17, 0.96);
  color: var(--text);
  box-shadow: var(--shadow);
}

@media (max-width: 780px) {
  .app-shell {
    grid-template-rows: 52px 1fr;
  }

  .topbar {
    padding-inline: 10px;
  }

  .details-panel {
    top: auto;
    right: 10px;
    left: 10px;
    bottom: 10px;
    width: auto;
    max-height: 34vh;
  }

  .controls-panel {
    left: 10px;
    top: 10px;
    width: min(300px, calc(100vw - 20px));
    max-height: 38vh;
    padding: 12px;
  }

  .panel-tab {
    left: 10px;
    top: 10px;
  }

  .toggle-grid {
    grid-template-columns: 1fr;
  }
}
