:root {
  color-scheme: light;
  --graph-navy: #18398a;
  --graph-blue: #2563eb;
  --graph-ink: #172033;
  --graph-muted: #667085;
  --graph-line: #d9dee8;
  --graph-soft: #f4f7fb;
  --graph-panel: #ffffff;
}

* { box-sizing: border-box; }

html,
body { width: 100%; height: 100%; margin: 0; overflow: hidden; }

body.ce-graph-body {
  min-width: 0;
  padding: 0;
  background: var(--graph-soft);
  color: var(--graph-ink);
  font: 15px/1.4 Inter, "Segoe UI", system-ui, sans-serif;
}

.ce-graph-app {
  display: grid;
  grid-template-columns: minmax(280px, 350px) minmax(0, 1fr);
  width: 100%;
  height: 100%;
}

.ce-graph-sidebar {
  position: relative;
  z-index: 2;
  display: flex;
  min-width: 0;
  flex-direction: column;
  background: var(--graph-panel);
  border-right: 1px solid var(--graph-line);
  box-shadow: 4px 0 18px rgba(24, 57, 138, .08);
}

.ce-graph-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 78px;
  padding: 15px 16px 14px 20px;
  color: #fff;
  background: linear-gradient(135deg, #132f74, var(--graph-navy));
}

.ce-graph-kicker {
  margin: 0 0 2px;
  color: #bcd0ff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.ce-graph-header h1 { margin: 0; color: #fff; font-size: 20px; line-height: 1.15; }

.ce-graph-add {
  width: 40px;
  height: 40px;
  padding: 0 0 3px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 11px;
  color: #fff;
  background: rgba(255,255,255,.12);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.ce-graph-add:hover { background: rgba(255,255,255,.22); }

.ce-graph-rows { flex: 1; min-height: 0; overflow: auto; padding: 8px 0; }

.ce-graph-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 30px;
  gap: 9px;
  align-items: start;
  min-height: 67px;
  padding: 12px 10px 10px 12px;
  border-bottom: 1px solid #e8ebf1;
}

.ce-graph-color {
  width: 29px;
  height: 29px;
  margin-top: 1px;
  padding: 0;
  border: 4px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #aab2c1;
  cursor: pointer;
}

.ce-graph-color.is-hidden { background: #fff !important; box-shadow: inset 0 0 0 2px currentColor, 0 0 0 1px #aab2c1; opacity: .55; }

.ce-graph-expression { min-width: 0; }

.ce-graph-expression label {
  display: block;
  margin-bottom: 3px;
  color: var(--graph-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.ce-graph-input {
  width: 100%;
  padding: 3px 1px 7px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  outline: none;
  background: transparent;
  color: var(--graph-ink);
  font: 19px/1.25 Cambria, "Times New Roman", serif;
}

.ce-graph-input:focus { border-bottom-color: var(--graph-blue); }
.ce-graph-input[aria-invalid="true"] { border-bottom-color: #dc2626; }

.ce-graph-error {
  min-height: 16px;
  margin-top: 3px;
  color: #b42318;
  font-size: 11px;
  line-height: 1.25;
}

.ce-graph-remove {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: #8a94a6;
  background: transparent;
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
}

.ce-graph-remove:hover { color: #b42318; background: #fff0ee; }

.ce-graph-help {
  padding: 12px 18px 14px;
  border-top: 1px solid var(--graph-line);
  color: var(--graph-muted);
  background: #fafbfe;
  font-size: 12px;
}

.ce-graph-help p { margin: 0 0 6px; }
.ce-graph-help p:last-child { margin-bottom: 0; }
.ce-graph-help code, .ce-graph-help kbd { color: #26395e; background: #edf2ff; }

.ce-graph-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #fff; touch-action: none; }
#ceGraphCanvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
#ceGraphCanvas.is-panning { cursor: grabbing; }

.ce-graph-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  grid-template-columns: repeat(3, 38px);
  overflow: hidden;
  border: 1px solid #cbd2df;
  border-radius: 11px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 5px 18px rgba(19,47,116,.14);
}

.ce-graph-controls button {
  height: 38px;
  padding: 0;
  border: 0;
  border-right: 1px solid #dce1e9;
  color: #26395e;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
}

.ce-graph-controls button:last-child { border-right: 0; }
.ce-graph-controls button:hover { background: #edf2ff; }

.ce-graph-coordinates {
  position: absolute;
  right: 14px;
  bottom: 13px;
  padding: 6px 10px;
  border: 1px solid #dce1e9;
  border-radius: 8px;
  color: #3b465b;
  background: rgba(255,255,255,.9);
  font: 12px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  pointer-events: none;
}

.ce-graph-empty {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 14px;
  border-radius: 10px;
  color: #667085;
  background: rgba(255,255,255,.9);
  box-shadow: 0 2px 14px rgba(23,32,51,.08);
  pointer-events: none;
}

@media (max-width: 720px) {
  .ce-graph-app { grid-template-columns: 1fr; grid-template-rows: minmax(190px, 38vh) minmax(0, 1fr); }
  .ce-graph-sidebar { border-right: 0; border-bottom: 1px solid var(--graph-line); }
  .ce-graph-header { min-height: 62px; padding-block: 10px; }
  .ce-graph-header h1 { font-size: 17px; }
  .ce-graph-help { display: none; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
