:root {
  /* Light · fresh ocean / mint (no dark theme) */
  --bg: #f3f8fc;
  --bg-2: #e8f1f8;
  --panel: #ffffff;
  --panel-elevated: #f7fbfd;
  --line: #c5d8e8;
  --line-soft: rgba(20, 55, 80, 0.08);
  --text: #143248;
  --muted: #5a7388;
  --accent: #0d9488;
  --accent-dim: rgba(13, 148, 136, 0.12);
  --accent-2: #0284c7;
  --accent-2-dim: rgba(2, 132, 199, 0.12);
  --danger: #dc4a3d;
  --ready: #0d9488;
  --beta: #0284c7;
  --planned: #7a90a4;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 40px rgba(20, 50, 80, 0.08);
  --font-display: "Syne", sans-serif;
  --font-body: "IBM Plex Sans", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(ellipse 90% 55% at 5% -5%, rgba(13, 148, 136, 0.14) 0%, transparent 55%),
    radial-gradient(ellipse 70% 45% at 100% 0%, rgba(2, 132, 199, 0.12) 0%, transparent 50%),
    linear-gradient(180deg, #f7fbfd 0%, var(--bg) 40%, #eef6fb 100%);
  line-height: 1.5;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 28px 100px;
}

/* ── Header ── */
.brand {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 32px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-2);
  font-weight: 600;
}

.brand h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.4rem, 5vw, 3.2rem);
  letter-spacing: -0.04em;
  margin: 0;
  line-height: 1;
}

.brand h1 span { color: var(--accent); }

.tagline {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 48ch;
  font-size: 0.95rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 10px 16px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.82rem;
}

.brand-meta {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

a.guide-link {
  color: var(--accent-2);
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
}

a.guide-link:hover {
  text-decoration: none;
  color: var(--accent);
  background: var(--accent-dim);
  border-color: rgba(13, 148, 136, 0.25);
}

/* ── Workflow stepper ── */
.workflow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 28px;
  padding: 16px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.workflow-step {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  transition: color 0.2s, background 0.2s;
}

.workflow-step:hover { color: var(--text); }

.workflow-step.active {
  color: var(--text);
  background: var(--accent-dim);
}

.workflow-step.active .step-num {
  background: var(--accent);
  color: #ffffff;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-weight: 700;
}

.step-label {
  font-size: 0.88rem;
  font-weight: 600;
}

.workflow-line {
  flex: 1;
  max-width: 48px;
  height: 1px;
  background: var(--line);
  margin: 0 4px;
}

@media (max-width: 600px) {
  .workflow { flex-wrap: wrap; gap: 8px; }
  .workflow-line { display: none; }
  .step-label { display: none; }
}

/* ── Panels ── */
.step-panel {
  margin-bottom: 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 28px 32px;
  box-shadow: var(--shadow);
}

.panel-head {
  margin-bottom: 24px;
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 12px;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 700;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0;
  line-height: 1.5;
}

.hint code {
  background: var(--bg-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82em;
}

/* ── Upload zone ── */
.upload-zone {
  position: relative;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  margin-bottom: 20px;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.upload-zone:hover,
.upload-zone.dragover,
.upload-zone.has-file {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-zone-inner {
  padding: 36px 24px;
  text-align: center;
  pointer-events: none;
}

.upload-icon { font-size: 2rem; margin-bottom: 8px; opacity: 0.8; }
.upload-title { margin: 0 0 4px; font-weight: 600; font-size: 1rem; }
.upload-sub { margin: 0; color: var(--muted); font-size: 0.82rem; }
.upload-filename {
  margin: 12px 0 0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-2);
}

/* ── Forms ── */
label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}

input[type="text"],
input[type="number"],
input[type="file"],
select,
textarea {
  font: inherit;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-bottom: 0;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  min-height: 100px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
  resize: vertical;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.status-bar {
  min-height: 1.4em;
  font-size: 0.88rem;
  margin: 0 0 20px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
}

#status.error {
  color: var(--danger);
  background: rgba(220, 74, 61, 0.1);
  border: 1px solid rgba(220, 74, 61, 0.28);
}

#status.ok {
  color: #0f766e;
  background: var(--accent-dim);
  border: 1px solid rgba(13, 148, 136, 0.3);
}

#status.busy {
  color: #0369a1;
  background: rgba(2, 132, 199, 0.1);
  border: 1px solid rgba(2, 132, 199, 0.28);
}

.export-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.export-modal[hidden] {
  display: none !important;
}

.export-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 35, 55, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.export-modal-card {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(86vh, 720px);
  overflow: auto;
  padding: 22px 22px 18px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: linear-gradient(
    165deg,
    rgba(255, 255, 255, 0.78) 0%,
    rgba(247, 251, 253, 0.72) 100%
  );
  box-shadow:
    0 24px 60px rgba(15, 40, 70, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(18px) saturate(1.35);
  -webkit-backdrop-filter: blur(18px) saturate(1.35);
}

.export-ticket-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.export-ticket-head strong {
  display: block;
  font-size: 1.12rem;
  margin-bottom: 4px;
  color: #0f3a57;
  letter-spacing: -0.01em;
}

.export-ticket-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.export-modal.is-error .export-ticket-head p {
  color: #9f1239;
}

.export-ticket-list[hidden] {
  display: none !important;
}

.export-ticket {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(197, 216, 232, 0.85);
  background: rgba(255, 255, 255, 0.55);
}

.export-ticket .ticket-icon {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: #94a3b8;
}

.export-ticket .ticket-label {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
}

.export-ticket .ticket-detail {
  grid-column: 2 / 3;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
}

.export-ticket .ticket-state {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5a7388;
  margin-top: 3px;
}

.export-ticket.is-queued .ticket-icon { background: #94a3b8; }
.export-ticket.is-running {
  border-color: rgba(2, 132, 199, 0.4);
  background: rgba(2, 132, 199, 0.1);
}
.export-ticket.is-running .ticket-icon {
  background: #0284c7;
  animation: export-pulse 1s ease-in-out infinite;
}
.export-ticket.is-running .ticket-state { color: #0369a1; }
.export-ticket.is-done {
  border-color: rgba(13, 148, 136, 0.35);
  background: rgba(13, 148, 136, 0.1);
}
.export-ticket.is-done .ticket-icon { background: #0d9488; }
.export-ticket.is-done .ticket-state { color: #0f766e; }
.export-ticket.is-error {
  border-color: rgba(220, 74, 61, 0.4);
  background: rgba(220, 74, 61, 0.1);
}
.export-ticket.is-error .ticket-icon { background: #dc4a3d; }
.export-ticket.is-error .ticket-state { color: #dc4a3d; }

.export-modal-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(197, 216, 232, 0.7);
}

.export-ok-btn {
  min-width: 96px;
  background: linear-gradient(135deg, #0d9488, #0284c7) !important;
  color: #fff !important;
  border: none !important;
  font-weight: 600;
}

.export-ok-btn[hidden] {
  display: none !important;
}

.export-spinner {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border-radius: 50%;
  border: 2.5px solid rgba(2, 132, 199, 0.25);
  border-top-color: var(--accent-2);
  flex: 0 0 auto;
  animation: export-spin 0.8s linear infinite;
}

.export-modal.is-complete .export-spinner {
  animation: none;
  border-color: rgba(13, 148, 136, 0.35);
  border-top-color: #0d9488;
  background: radial-gradient(circle at center, #0d9488 45%, transparent 48%);
}

@keyframes export-spin {
  to { transform: rotate(360deg); }
}

@keyframes export-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.85; }
}

button.is-generating {
  opacity: 1 !important;
  cursor: wait !important;
}

body.export-modal-open {
  overflow: hidden;
}

/* ── Buttons ── */
button {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  cursor: pointer;
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.12s, opacity 0.12s, box-shadow 0.12s;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(13, 148, 136, 0.25);
}
button:active:not(:disabled) { transform: translateY(0); }

button.secondary {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}

button.secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: none;
}

button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary-lg {
  padding: 14px 32px;
  font-size: 1rem;
  min-width: 160px;
}

.tool-btn {
  padding: 10px 16px;
  font-size: 0.85rem;
}

/* ── Data section ── */
.data-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
}

@media (max-width: 800px) {
  .data-grid { grid-template-columns: 1fr; }
}

.data-block { min-width: 0; }

.empty-state {
  color: var(--muted);
  font-size: 0.88rem;
  padding: 24px 16px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
}

.table-wrap {
  overflow: auto;
  max-height: 320px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

th, td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 500;
  position: sticky;
  top: 0;
  background: var(--panel-elevated);
  z-index: 1;
}

tr:hover td { background: rgba(13, 148, 136, 0.05); }

.report-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 0.78rem;
  color: var(--muted);
}

.stat-card b {
  display: block;
  color: var(--text);
  font-size: 1.4rem;
  font-family: var(--font-display);
  margin-top: 6px;
  font-weight: 700;
}

/* ── Run section ── */
.run-config {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  padding: 20px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.config-field {
  flex: 1;
  min-width: 140px;
}

.tool-section {
  margin-bottom: 20px;
}

.tool-section-label {
  margin: 0 0 10px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}

.tool-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.adv-options {
  margin: 0 0 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  background: var(--bg-2);
}

.adv-options summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.adv-options[open] summary {
  margin-bottom: 16px;
  color: var(--accent);
}

.adv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.text-model {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  background: var(--bg-2);
}

.text-model summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
}

.text-model[open] summary {
  margin-bottom: 14px;
  color: var(--accent);
}

.text-model-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 700px) {
  .text-model-grid { grid-template-columns: 1fr; }
}

/* ── Results ── */
.path-diagram {
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 20% 20%, rgba(56, 189, 248, 0.08), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(13, 148, 136, 0.06), transparent 42%),
    var(--bg-2);
  padding: 16px;
  overflow: auto;
  margin-bottom: 24px;
}

.path-diagram-results {
  min-height: 580px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.path-diagram-results svg,
.path-diagram-main svg {
  min-height: 0;
  height: auto;
  max-height: 760px;
}

.path-diagram svg {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  display: block;
  overflow: visible;
}

.diagram-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.diagram-head h3 {
  margin: 0;
}

.diagram-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.diagram-toggles label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
}

.diagram-toggles input {
  accent-color: var(--accent);
}

.diagram-outer-mode select {
  margin-left: 4px;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.8rem;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tabs button {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 500;
  padding: 10px 18px;
}

.tabs button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.report-view { min-height: 120px; }

.preset-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px 14px;
  background: var(--surface-2, #f1f5f9);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.preset-bar label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}
.preset-bar select {
  min-width: min(100%, 320px);
  flex: 1;
}
.preset-hint {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.82rem;
}

.report-kind-bar {
  display: grid;
  gap: 4px;
  margin: 0 0 16px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #ecfdf5, #e0f2fe);
  border: 1px solid #99f6e4;
  border-radius: var(--radius-sm);
}
.report-kind-chip {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: #0f766e;
}
.report-kind-study {
  font-size: 0.92rem;
  color: var(--text);
}
.report-kind-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.report-view h3 { margin-top: 20px; color: var(--text); text-transform: none; letter-spacing: 0; }

.report-view .meta-line {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 12px;
}

.result-banner {
  background: var(--accent-dim);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px;
  margin: 0 0 18px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.result-banner .muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.report-block { margin-bottom: 12px; }

.pass { color: var(--accent-2); }
.warn { color: #b45309; }
.fail { color: var(--danger); }

.assessment-panel {
  margin: 1rem 0 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  background: color-mix(in srgb, var(--panel) 92%, var(--accent-2) 8%);
}
.assessment-panel h3 { margin: 0 0 0.35rem; }
.assessment-decision {
  margin: 0.5rem 0 0.85rem;
  font-weight: 600;
}
.assessment-stage {
  margin: 0.75rem 0;
}
.assessment-stage summary {
  cursor: pointer;
  font-weight: 600;
}
.assessment-stage .stage-score {
  font-weight: 400;
  opacity: 0.85;
  margin-left: 0.35rem;
}

.matrix-table td, .matrix-table th { text-align: right; }
.matrix-table th:first-child,
.matrix-table td:first-child { text-align: left; }

pre {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  overflow: auto;
  max-height: 480px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

/* ── Features grid ── */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.feature {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--bg-2);
  transition: border-color 0.15s, transform 0.15s;
}

.feature strong { display: block; font-size: 0.88rem; margin-bottom: 6px; }
.feature small { color: var(--muted); font-size: 0.78rem; }

.tag {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
  font-weight: 600;
}

.tag.ready { background: var(--accent-dim); color: #0f766e; }
.tag.beta { background: var(--accent-2-dim); color: #0369a1; }
.tag.planned { background: rgba(122, 144, 164, 0.18); color: #5a7388; }

.feature.clickable { cursor: pointer; }
.feature.clickable:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.feature.clickable small { display: block; margin-top: 6px; color: var(--accent); }

/* ── Model builder ── */
.model-builder { margin: 0; }

.builder-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.builder-toolbar .active-tool {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  background: var(--accent-dim) !important;
}

.builder-hint {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0 0 14px;
}

.builder-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.model-canvas {
  position: relative;
  height: 580px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 30% 20%, rgba(13, 148, 136, 0.08) 0%, transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(2, 132, 199, 0.07) 0%, transparent 40%),
    linear-gradient(rgba(197, 216, 232, 0.55) 1px, transparent 1px) 0 0 / 36px 36px,
    linear-gradient(90deg, rgba(197, 216, 232, 0.55) 1px, transparent 1px) 0 0 / 36px 36px,
    #f8fcff;
  overflow: auto;
  outline: none;
}

.model-edges {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  pointer-events: auto;
  z-index: 1;
}

.model-edges path,
.model-edges polygon { pointer-events: none; }
.model-edges path.model-edge-hit {
  pointer-events: stroke;
  cursor: pointer;
}

.model-nodes {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  pointer-events: none;
}

.model-node {
  position: absolute;
  box-sizing: border-box;
  width: 96px;
  height: 96px;
  padding: 10px 8px;
  border-radius: 50%;
  background: #38bdf8;
  border: 2.4px solid #0369a1;
  color: #0c4a6e;
  cursor: grab;
  user-select: none;
  touch-action: none;
  overflow: visible;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 8px 20px rgba(3, 105, 161, 0.18);
  transition: box-shadow 0.15s, border-color 0.15s;
  z-index: 4;
}

.model-node:hover {
  border-color: #075985;
}

.model-node.selected,
.model-node.link-from {
  border-color: #0284c7;
  box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.28), 0 8px 20px rgba(3, 105, 161, 0.2);
}

.model-node-title {
  font-weight: 700;
  font-size: 0.78rem;
  line-height: 1.2;
  max-width: 80px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.model-ind {
  position: absolute;
  box-sizing: border-box;
  height: 26px;
  padding: 0 8px;
  border-radius: 5px;
  background: #fef9c3;
  border: 1.5px solid #ca8a04;
  color: #713f12;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  user-select: none;
  z-index: 3;
  box-shadow: 0 2px 6px rgba(113, 63, 18, 0.12);
}

.model-ind:hover {
  border-color: #a16207;
}

.model-ind.selected {
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.3);
}

.model-port {
  position: absolute;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  top: 50%;
  transform: translateY(-50%);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.22);
  cursor: crosshair;
  z-index: 2;
}

.model-port.in { left: -7px; cursor: default; }
.model-port.out { right: -7px; }
.model-port.out:hover {
  background: var(--accent-2);
  transform: translateY(-50%) scale(1.15);
}

.builder-toolbar button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.builder-side {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  padding: 18px 20px;
  display: none;
}

.builder-side.is-open { display: block; }

.builder-side h3 {
  margin-top: 0;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  font-size: 1rem;
}

.builder-side-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 720px) {
  .builder-side-grid { grid-template-columns: 1fr; }
}

.ind-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  max-height: 160px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
}

.ind-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  margin: 0;
  cursor: pointer;
}

.ind-check input { width: auto; margin: 0; accent-color: var(--accent); }
