:root {
  color-scheme: dark;
  --bg: #0b1020;
  --bg-soft: rgba(13, 18, 35, 0.86);
  --panel: rgba(8, 12, 24, 0.9);
  --panel-border: rgba(173, 190, 255, 0.14);
  --text: #edf2ff;
  --muted: #9aa7c7;
  --accent: #7ae3ff;
  --accent-strong: #4cc8ff;
  --accent-warm: #ffb86b;
  --danger: #ff6a6a;
  --good: #72f1b8;
  --node: #f7fbff;
  --node-ring: #8ad7ff;
  --edge: rgba(181, 200, 255, 0.92);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 24px;
  --radius-sm: 14px;
  --font-title: "Trebuchet MS", "Segoe UI", sans-serif;
  --font-body: "Segoe UI", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(76, 200, 255, 0.18), transparent 28%),
    radial-gradient(circle at 90% 10%, rgba(255, 184, 107, 0.12), transparent 22%),
    linear-gradient(180deg, #09101f, #050814 70%);
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  padding: 20px;
}

.panel,
.canvas-frame {
  border: 1px solid var(--panel-border);
  background: var(--bg-soft);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.panel {
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-title);
  font-size: 2rem;
  line-height: 1.05;
  letter-spacing: 0.02em;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent-warm);
  font-size: 0.78rem;
  font-weight: 700;
}

.lede {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.toolbar,
.actions {
  display: grid;
  gap: 10px;
}

.tab-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px;
  gap: 10px;
  align-items: start;
}

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.tab-action {
  width: 100%;
  min-height: 100%;
}

.tab-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  padding: 10px 12px;
  text-align: left;
  background: rgba(255, 255, 255, 0.03);
}

.tab-chip-title {
  display: block;
  min-width: 0;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.tab-chip-meta {
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.tab-chip.active {
  border-color: rgba(122, 227, 255, 0.7);
  background: linear-gradient(135deg, rgba(122, 227, 255, 0.24), rgba(76, 200, 255, 0.1));
  box-shadow: 0 0 0 1px rgba(122, 227, 255, 0.15) inset;
}

.tab-chip.closed {
  opacity: 0.74;
}

.toolbar {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.actions-plan {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.actions-graph {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

button {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition:
    transform 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(122, 227, 255, 0.35);
}

button:active {
  transform: translateY(0);
}

button.active {
  background: linear-gradient(135deg, rgba(122, 227, 255, 0.22), rgba(76, 200, 255, 0.08));
  border-color: rgba(122, 227, 255, 0.55);
  box-shadow: 0 0 0 1px rgba(122, 227, 255, 0.1) inset;
}

button.secondary {
  background: rgba(255, 255, 255, 0.035);
}

button.primary {
  border-color: rgba(122, 227, 255, 0.38);
  background: linear-gradient(135deg, rgba(122, 227, 255, 0.18), rgba(122, 227, 255, 0.06));
}

button.danger {
  border-color: rgba(255, 106, 106, 0.25);
}

button.danger:hover {
  border-color: rgba(255, 106, 106, 0.5);
}

.info-card,
.status-card {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
}

.plan-card {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(122, 227, 255, 0.18);
  background:
    radial-gradient(circle at top right, rgba(255, 184, 107, 0.12), transparent 32%),
    rgba(255, 255, 255, 0.03);
  padding: 16px;
}

.info-card h2,
.plan-card h2,
.status-card span {
  margin: 0 0 10px;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-warm);
}

.plan-card p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

.plan-note {
  font-size: 0.92rem;
}

.info-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

#plan-preview {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.5;
}

#plan-preview li {
  margin-bottom: 6px;
}

.status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#status-text {
  color: var(--good);
  font-weight: 700;
}

.workspace {
  min-width: 0;
}

.canvas-frame {
  position: relative;
  width: 100%;
  height: calc(100vh - 40px);
  border-radius: var(--radius);
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    radial-gradient(circle at center, rgba(122, 227, 255, 0.08), transparent 65%),
    rgba(3, 7, 18, 0.9);
  background-size: 32px 32px, 32px 32px, 100% 100%, 100% 100%;
}

#graph-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
}

.file-input {
  position: fixed;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.edge {
  stroke: var(--edge);
  stroke-width: 3;
  stroke-linecap: round;
  pointer-events: stroke;
}

.edge.selected {
  stroke: var(--accent-warm);
  stroke-width: 4.5;
}

.layer-guide {
  pointer-events: none;
}

.layer-guide line {
  stroke: rgba(122, 227, 255, 0.16);
  stroke-width: 1;
  stroke-dasharray: 6 10;
  shape-rendering: crispEdges;
}

.layer-guide.depth-0 line {
  stroke: rgba(255, 184, 107, 0.22);
  stroke-width: 1.2;
}

.layer-guide text {
  fill: rgba(180, 220, 255, 0.7);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  user-select: none;
  pointer-events: none;
}

.layer-guide.depth-0 text {
  fill: rgba(255, 184, 107, 0.8);
}

.node {
  cursor: grab;
}

.node-halo {
  fill: none;
  pointer-events: none;
  opacity: 0;
}

.node circle {
  fill: var(--node);
  stroke: rgba(138, 215, 255, 0.95);
  stroke-width: 3;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.25));
}

.node.goal circle {
  fill: #ffe7bd;
  stroke: var(--accent-warm);
}

.node.step circle {
  fill: var(--node);
}

.node.done circle {
  fill: rgba(114, 241, 184, 0.18);
  stroke: var(--good);
}

.node-label {
  fill: #f3f8ff;
  font-weight: 700;
  font-size: 11px;
  line-height: 1;
  text-anchor: middle;
  dominant-baseline: hanging;
  pointer-events: none;
  user-select: none;
  paint-order: stroke fill;
  stroke: rgba(3, 7, 18, 0.82);
  stroke-width: 4px;
}

.node-label.goal {
  font-size: 12px;
  fill: #7ae3ff;
}

.node-label-bg {
  fill: rgba(4, 9, 21, 0.72);
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 1.5;
  pointer-events: none;
}

.node-label-bg.goal {
  fill: rgba(52, 34, 8, 0.74);
  stroke: rgba(255, 184, 107, 0.32);
}

.node.selected circle {
  fill: #fff8eb;
  stroke: #ffffff;
  stroke-width: 6;
  paint-order: stroke fill;
}

.node.selected .node-halo {
  opacity: 1;
  stroke: rgba(122, 227, 255, 0.95);
  stroke-width: 5;
  filter: drop-shadow(0 0 12px rgba(122, 227, 255, 0.85));
}

.node.connect-source circle {
  stroke: var(--good);
  stroke-width: 4;
}

.node.selected text {
  fill: #09101f;
}

.node.selected .node-label {
  fill: #7ae3ff;
  stroke: rgba(3, 7, 18, 0.9);
}

.node.goal .node-label {
  fill: #7ae3ff;
  stroke: rgba(3, 7, 18, 0.9);
}

.node.done .node-label {
  fill: #dffaf0;
}

.node.goal.connect-source circle {
  stroke: var(--good);
}

.node.connect-source .node-halo {
  opacity: 1;
  stroke: rgba(114, 241, 184, 0.92);
  stroke-width: 5;
  filter: drop-shadow(0 0 12px rgba(114, 241, 184, 0.7));
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .canvas-frame {
    height: 68vh;
  }
}
