:root {
  --ink: #1a2530;
  --muted: #5c6b79;
  --surface: #ffffff;
  --line: #d4dde8;
  --accent: #0b6e99;
  --accent-2: #0ea27e;
  --warn: #ad3f02;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 10%, #ffe19d 0%, transparent 28%),
    radial-gradient(circle at 84% 92%, #b7f0e4 0%, transparent 30%),
    #f3f7fb;
  overflow: hidden;
}

.bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(transparent 95%, rgba(42, 67, 101, 0.06) 95%),
    linear-gradient(90deg, transparent 95%, rgba(42, 67, 101, 0.06) 95%);
  background-size: 34px 34px;
}

.layout {
  position: relative;
  z-index: 1;
  height: 100vh;
  padding: 14px;
  display: grid;
  gap: 14px;
  grid-template-columns: 340px 1fr;
  overflow: hidden;
}

.panel {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(16, 40, 71, 0.16);
}

.controls {
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.controls h1 {
  margin: 0;
  font-size: 1.45rem;
}

.controls p {
  color: var(--muted);
  margin-top: 8px;
  margin-bottom: 12px;
}

.controls label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

.controls select,
.controls button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 40px;
  padding: 8px 10px;
  font: inherit;
}

.variant-controls {
  margin-top: 10px;
}

.variant-label {
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 0.86rem;
}

.variant-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.variant-btn {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f6fbff;
  color: #225074;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 8px;
}

.variant-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

button {
  cursor: pointer;
  background: var(--surface);
}

#pngBtn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#pngBtn:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

details {
  margin-top: 12px;
}

summary {
  font-weight: 700;
  cursor: pointer;
}

pre {
  white-space: pre-wrap;
  background: #edf4fa;
  border: 1px solid #cfe0ef;
  border-radius: 10px;
  padding: 10px;
  color: #183248;
  font-family: "IBM Plex Mono", "Consolas", monospace;
  font-size: 0.87rem;
}

/* ── Embed mode (iframed in KB docs) ────────────────────────── */
.embed-mode .controls h1,
.embed-mode .controls > p,
.embed-mode .controls > label,
.embed-mode #flowSelect,
.embed-mode #variantControls,
.embed-mode details {
  display: none;
}

.embed-mode .controls h2 {
  margin-top: 0;
}

.embed-mode .layout {
  grid-template-columns: 260px 1fr;
}

.embed-mode {
  overflow: hidden;
}
/* ──────────────────────────────────────────────────────────── */

.meta-box {
  background: #edf4fa;
  border: 1px solid #cfe0ef;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #183248;
  min-height: 3.5rem;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.canvas-panel {
  padding: 10px;
  position: relative;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

#graph {
  width: 100%;
  height: auto;
  flex: 1;
  min-height: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #f1f8ff 100%);
}

.embed-mode .controls {
  overflow: hidden;
}

.embed-mode .meta-box {
  overflow: auto;
}

.graph-tools {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 5;
  display: none;
  gap: 6px;
}

.embed-mode .graph-tools {
  display: flex;
}

.graph-tools button {
  min-width: 34px;
  min-height: 34px;
  border: 1px solid #b9cbdc;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  color: #1f3e57;
  font-weight: 700;
  padding: 0 10px;
}

.graph-tools button:hover {
  background: #eaf4fb;
}

#fitBtn {
  min-width: 44px;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  #graph {
    height: 72vh;
  }

  .controls {
    min-height: 420px;
  }

  .variant-buttons {
    grid-template-columns: 1fr;
  }
}
