/* ============================================================
   Helmsman — Kubernetes Manifest Generator
   Design language: dark workspace, kubernetes-blue accent,
   Inter for UI, JetBrains Mono for code/identifiers.
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300..800;1,14..32,300..800&display=swap");
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap");

:root {
  --ink-0: #ffffff;
  --ink-1: #f4f4f5;
  --ink-2: #a1a1aa;
  --ink-3: #71717a;
  --ink-4: #3f3f46;
  --ink-5: #27272a;
  --ink-6: #18181b;
  --ink-7: #101012;
  --ink-8: #09090b;

  --surface-0: rgba(255,255,255,0.025);
  --surface-1: rgba(255,255,255,0.05);
  --surface-2: rgba(255,255,255,0.08);
  --surface-3: rgba(255,255,255,0.12);

  --border-0: rgba(255,255,255,0.05);
  --border-1: rgba(255,255,255,0.09);
  --border-2: rgba(255,255,255,0.15);

  --bg: #09090b;
  --bg-panel: #101012;
  --text: #f4f4f5;
  --text-soft: #a1a1aa;
  --text-muted: #71717a;

  /* Kubernetes blue as the single accent, purple/cyan as supporting hues */
  --accent: #4c8dff;
  --accent-deep: #326ce5;
  --accent-dim: rgba(76,141,255,0.14);
  --accent-glow: rgba(76,141,255,0.28);

  --purple: #8b5cf6;
  --cyan: #22d3ee;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #f87171;

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Fira Code", monospace;

  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-lg: 18px;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semi: 600;
  --weight-bold: 700;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-2xl: 24px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.6);
  --shadow-xl: 0 32px 80px rgba(0,0,0,0.7), 0 12px 32px rgba(0,0,0,0.5);

  --ease: cubic-bezier(0.22,1,0.36,1);
  --ease-spring: cubic-bezier(0.34,1.56,0.64,1);
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 320ms;

  --header-h: 58px;
}

[data-theme="light"] {
  --ink-0:#111827; --ink-1:#1f2937; --ink-2:#374151; --ink-3:#6b7280;
  --ink-4:#9ca3af; --ink-5:#d1d5db; --ink-6:#e5e7eb; --ink-7:#f3f4f6; --ink-8:#ffffff;
  --surface-0: rgba(0,0,0,.02); --surface-1: rgba(0,0,0,.04);
  --surface-2: rgba(0,0,0,.06); --surface-3: rgba(0,0,0,.09);
  --border-0: rgba(0,0,0,.06); --border-1: rgba(0,0,0,.1); --border-2: rgba(0,0,0,.16);
  --bg:#ffffff; --bg-panel:#f9fafb; --text:#111827; --text-soft:#374151; --text-muted:#6b7280;
  --accent-dim: rgba(37,99,235,0.08);
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; scroll-behavior: smooth; }
[data-theme="light"] html { color-scheme: light; }
body {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }

svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ────────────────────────────────────────────────────────────
   AMBIENT BACKGROUND
   ──────────────────────────────────────────────────────────── */
.bg-canvas { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 15%, black 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 15%, black 30%, transparent 100%);
}
.bg-blob { position: absolute; border-radius: 50%; filter: blur(120px); will-change: transform; }
.bg-blob-1 { width: 640px; height: 640px; top: -280px; right: -140px; background: radial-gradient(circle, rgba(76,141,255,0.09) 0%, transparent 70%); animation: blob-drift 24s ease-in-out infinite; }
.bg-blob-2 { width: 520px; height: 520px; bottom: -220px; left: -100px; background: radial-gradient(circle, rgba(139,92,246,0.06) 0%, transparent 70%); animation: blob-drift 30s ease-in-out infinite reverse; }
.bg-blob-3 { width: 380px; height: 380px; top: 42%; left: 45%; background: radial-gradient(circle, rgba(34,211,238,0.05) 0%, transparent 70%); animation: blob-drift 19s ease-in-out infinite 5s; }
@keyframes blob-drift { 0%,100%{transform:translate(0,0) scale(1);} 33%{transform:translate(40px,-30px) scale(1.05);} 66%{transform:translate(-20px,20px) scale(0.97);} }

.mouse-glow {
  position: fixed; width: 420px; height: 420px; pointer-events: none; z-index: 1; border-radius: 50%;
  background: radial-gradient(circle, rgba(76,141,255,0.07) 0%, transparent 70%);
  transform: translate(-50%,-50%); transition: opacity var(--dur-slow) ease; opacity: 0;
}

/* ────────────────────────────────────────────────────────────
   HEADER
   ──────────────────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  height: var(--header-h); padding: 0 20px;
  background: rgba(9,9,11,0.75);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-0);
  animation: fadeInDown var(--dur-slow) var(--ease) both;
}
[data-theme="light"] .app-header { background: rgba(255,255,255,0.85); }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 34px; height: 34px; flex-shrink: 0; filter: drop-shadow(0 0 10px rgba(76,141,255,0.35)); }
.brand-mark svg { width: 34px; height: 34px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--ink-0); letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--text-muted); }

.header-right { display: flex; align-items: center; gap: 6px; }
.header-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border: 1px solid var(--border-1); border-radius: var(--radius-md); background: var(--surface-0);
  color: var(--text-soft); font-size: var(--text-xs); font-weight: var(--weight-medium);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-spring);
}
.header-btn:hover { background: var(--surface-1); border-color: var(--border-2); color: var(--text); transform: translateY(-1px); }
.header-btn:active { transform: translateY(1px) scale(0.97); }
.header-btn.icon-only { padding: 0; width: 34px; justify-content: center; }

/* ────────────────────────────────────────────────────────────
   WORKSPACE / PANELS
   ──────────────────────────────────────────────────────────── */
.workspace { position: relative; z-index: 2; display: flex; height: calc(100vh - var(--header-h)); overflow: hidden; }
.panel { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.panel-left {
  width: 440px; min-width: 320px; max-width: 620px;
  border-right: 1px solid var(--border-0);
  background: rgba(9,9,11,0.4); flex-shrink: 0;
}
[data-theme="light"] .panel-left { background: rgba(255,255,255,0.5); }
.panel-right { flex: 1; min-width: 0; overflow-y: auto; padding: 24px; scrollbar-width: thin; scrollbar-color: var(--border-1) transparent; }

.resize-handle { width: 4px; background: var(--border-0); cursor: col-resize; transition: background var(--dur-fast) var(--ease); flex-shrink: 0; position: relative; z-index: 10; }
.resize-handle:hover, .resize-handle.dragging { background: var(--accent); }
.resize-handle::after { content: ''; position: absolute; inset: 0 -4px; }

/* ────────────────────────────────────────────────────────────
   TABS
   ──────────────────────────────────────────────────────────── */
.panel-header { padding: 12px 16px 0; border-bottom: 1px solid var(--border-0); flex-shrink: 0; position: relative; }
.panel-tabs { display: flex; gap: 2px; position: relative; }
.tab-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px;
  border: none; border-radius: var(--radius-md) var(--radius-md) 0 0; background: transparent;
  color: var(--text-muted); font-size: var(--text-sm); font-weight: var(--weight-medium);
  transition: color var(--dur-fast) var(--ease); position: relative;
}
.tab-btn svg { width: 13px; height: 13px; }
.tab-btn:hover { color: var(--text-soft); }
.tab-btn.active { color: var(--ink-0); }
.tab-indicator {
  position: absolute; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--accent);
  transition: left var(--dur-base) var(--ease), width var(--dur-base) var(--ease);
  box-shadow: 0 0 12px rgba(76,141,255,0.6); left: 16px; width: 88px;
}
.tab-pane { display: none; flex: 1; overflow: hidden; flex-direction: column; }
.tab-pane.active { display: flex; }

/* ────────────────────────────────────────────────────────────
   BUILDER FORM
   ──────────────────────────────────────────────────────────── */
.builder-scroll {
  flex: 1; overflow-y: auto; padding: 14px 16px 24px;
  scrollbar-width: thin; scrollbar-color: var(--border-1) transparent;
  display: flex; flex-direction: column; gap: 2px;
}
.builder-scroll::-webkit-scrollbar { width: 3px; }
.builder-scroll::-webkit-scrollbar-thumb { background: var(--border-1); border-radius: 10px; }

.builder-section { padding: 12px 0; border-bottom: 1px solid var(--border-0); animation: fadeInUp var(--dur-slow) var(--ease) both; }
.builder-section:last-of-type { border-bottom: none; }

.builder-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.section-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-label { font-size: 10px; font-weight: var(--weight-semi); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 10px; font-weight: var(--weight-semi); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.form-label .required { color: var(--error); }

.form-input, .form-select {
  width: 100%; height: 36px; padding: 0 12px;
  border: 1px solid var(--border-1); border-radius: var(--radius-md);
  background: var(--surface-0); color: var(--text); font-size: var(--text-sm); outline: none;
  transition: border-color var(--dur-base) var(--ease), background var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.mono-input { font-family: var(--font-mono); font-size: 12.5px; }
.form-input::placeholder { color: var(--text-muted); }
.form-input:focus, .form-select:focus { border-color: var(--accent); background: rgba(76,141,255,0.05); box-shadow: 0 0 0 3px rgba(76,141,255,0.12); }
.form-input:disabled, .form-select:disabled { opacity: 0.4; cursor: not-allowed; }
.form-select { appearance: none; cursor: pointer; }

.select-wrap { position: relative; }
.select-chevron { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; stroke: var(--text-muted); pointer-events: none; }

/* Pill toggle (single/multiple output format) */
.pill-toggle { display: inline-flex; padding: 3px; gap: 3px; border: 1px solid var(--border-1); border-radius: var(--radius-pill); background: var(--surface-0); }
.pill-toggle-opt {
  border: none; background: transparent; color: var(--text-muted); font-size: var(--text-xs); font-weight: var(--weight-medium);
  padding: 6px 14px; border-radius: var(--radius-pill); transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.pill-toggle-opt.active { background: var(--accent-dim); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(76,141,255,0.35); }
.pill-toggle-opt:hover:not(.active) { color: var(--text-soft); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--radius-pill); background: var(--surface-2); color: var(--text-muted); font-size: 10px; font-weight: var(--weight-semi);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.badge.has-items { background: var(--accent-dim); color: var(--accent); }

/* Dynamic rows (ports / env / secrets) */
.dynamic-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.dynamic-row {
  display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 6px; align-items: center;
  padding: 8px; border: 1px solid var(--border-0); border-radius: var(--radius-md); background: var(--surface-0);
  animation: slide-in var(--dur-base) var(--ease-spring) both;
}
.dynamic-row.two-field { grid-template-columns: 1fr 1fr auto; }
.dynamic-row .form-input, .dynamic-row .form-select { height: 32px; font-size: 12.5px; }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

.btn-remove-row {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border: 1px solid var(--border-1); border-radius: var(--radius-sm); background: transparent; color: var(--text-muted);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.btn-remove-row svg { width: 13px; height: 13px; }
.btn-remove-row:hover { background: rgba(248,113,113,0.1); border-color: rgba(248,113,113,0.3); color: var(--error); }

.btn-add-row {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border: 1px dashed var(--border-1); border-radius: var(--radius-md); background: transparent;
  color: var(--text-muted); font-size: var(--text-xs); font-weight: var(--weight-medium); width: 100%; justify-content: center;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.btn-add-row svg { width: 12px; height: 12px; }
.btn-add-row:hover { background: var(--surface-0); border-color: var(--accent); color: var(--accent); border-style: solid; }

/* Collapsible sections */
.collapse-toggle {
  display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 6px 0;
  border: none; background: transparent; color: var(--text-soft); font-size: var(--text-sm); font-weight: var(--weight-medium);
  transition: color var(--dur-fast) var(--ease);
}
.collapse-toggle > span:first-child { display: flex; align-items: center; gap: 8px; }
.collapse-toggle svg { width: 14px; height: 14px; opacity: 0.65; }
.collapse-toggle:hover { color: var(--text); }
.collapse-meta { display: flex; align-items: center; gap: 10px; }
.chevron { transition: transform var(--dur-base) var(--ease); }
.collapse-body { overflow: hidden; padding-top: 10px; }
.collapsible[aria-expanded="false"] .collapse-body { display: none; }
.collapsible[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.probe-block { padding: 10px; border: 1px solid var(--border-0); border-radius: var(--radius-md); background: var(--surface-0); margin-bottom: 10px; display: flex; flex-direction: column; gap: 10px; }
.probe-block:last-child { margin-bottom: 0; }
.probe-block-head { display: flex; align-items: center; justify-content: space-between; }
.probe-block-title { font-size: var(--text-xs); font-weight: var(--weight-semi); color: var(--text-soft); }

/* Mini switch */
.mini-switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.mini-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.mini-switch-track {
  width: 34px; height: 19px; border-radius: var(--radius-pill); background: var(--surface-2);
  border: 1px solid var(--border-1); position: relative; flex-shrink: 0; transition: all var(--dur-base) var(--ease-spring);
}
.mini-switch-track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--text-muted); transition: all var(--dur-base) var(--ease-spring);
}
.mini-switch input:checked + .mini-switch-track { background: var(--accent-deep); border-color: var(--accent); }
.mini-switch input:checked + .mini-switch-track::after { transform: translateX(15px); background: #fff; }
.mini-switch input:focus-visible + .mini-switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.mini-switch-label { font-size: var(--text-xs); color: var(--text-soft); }
.mini-switch-standalone { height: 36px; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch-row-title { display: block; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text); }
.switch-row-sub { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.form-range {
  width: 100%; -webkit-appearance: none; appearance: none; height: 4px; border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--fill,80%), var(--surface-2) var(--fill,80%));
  outline: none;
}
.form-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--ink-0);
  border: 2px solid var(--accent); cursor: pointer; box-shadow: 0 0 0 4px rgba(76,141,255,0.15);
}
.form-range:disabled { opacity: 0.4; }

/* Dropzone */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 32px 16px; border: 1.5px dashed var(--border-1); border-radius: var(--radius-lg);
  background: var(--surface-0); text-align: center; cursor: pointer;
  transition: background var(--dur-base) var(--ease), border-color var(--dur-base) var(--ease);
}
.dropzone:hover, .dropzone.drag-over { background: rgba(76,141,255,0.05); border-color: var(--accent); }
.dropzone-icon { width: 30px; height: 30px; color: var(--text-muted); margin-bottom: 4px; }
.dropzone-title { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-soft); }
.dropzone-sub { font-size: 11px; color: var(--text-muted); }

.file-chip {
  display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 8px 10px;
  border: 1px solid var(--border-1); border-radius: var(--radius-md); background: var(--surface-1);
  font-size: var(--text-xs); color: var(--text-soft); animation: pill-in var(--dur-base) var(--ease-spring) both;
}
.file-chip svg { width: 14px; height: 14px; color: var(--accent); flex-shrink: 0; }
.file-chip span { flex: 1; font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip button { background: transparent; border: none; color: var(--text-muted); font-size: 11px; }
.file-chip button:hover { color: var(--error); }
@keyframes pill-in { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

.builder-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--border-0); flex-shrink: 0;
}

/* ────────────────────────────────────────────────────────────
   BUTTONS
   ──────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 18px;
  border: 1px solid rgba(76,141,255,0.6); border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-deep), #1d4ed8); color: #fff;
  font-size: var(--text-sm); font-weight: var(--weight-semi);
  transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast) var(--ease);
  box-shadow: 0 0 20px rgba(76,141,255,0.3), 0 1px 0 rgba(255,255,255,0.1) inset;
  position: relative; overflow: hidden;
}
.btn-primary::before {
  content: ''; position: absolute; top: 0; left: -100%; width: 200%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent); transition: left 0.4s ease;
}
.btn-primary:hover::before { left: 100%; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 0 32px rgba(76,141,255,0.5), 0 4px 16px rgba(0,0,0,0.3); }
.btn-primary:active { transform: translateY(1px) scale(0.97); }
.btn-primary svg { width: 13px; height: 13px; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-ghost-sm {
  display: inline-flex; align-items: center; height: 38px; padding: 0 14px;
  border: 1px solid var(--border-1); border-radius: var(--radius-md); background: transparent;
  color: var(--text-muted); font-size: var(--text-sm); font-weight: var(--weight-medium);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.btn-ghost-sm:hover { background: var(--surface-1); border-color: var(--border-2); color: var(--text-soft); }

/* ────────────────────────────────────────────────────────────
   RIGHT PANEL — EMPTY / ERROR STATE
   ──────────────────────────────────────────────────────────── */
.empty-state, .error-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100%; gap: 12px; padding: 40px; text-align: center;
}
.empty-illustration { animation: hex-float 4.5s ease-in-out infinite; }
@keyframes hex-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.empty-title { font-size: var(--text-base); font-weight: var(--weight-semi); color: var(--text-soft); }
.empty-sub { font-size: var(--text-sm); color: var(--text-muted); max-width: 360px; }
.empty-arrow { color: var(--text-muted); animation: bounce-left 1.8s ease-in-out infinite; opacity: 0.4; transform: rotate(0deg); }
.empty-arrow svg { width: 20px; height: 20px; }
@keyframes bounce-left { 0%,100% { transform: translateX(0); } 50% { transform: translateX(-6px); } }
.error-icon { width: 40px; height: 40px; color: var(--error); }

/* ────────────────────────────────────────────────────────────
   LOADING STATE — MANIFEST CONSTELLATION
   ──────────────────────────────────────────────────────────── */
.loading-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100%; gap: 22px; padding: 40px;
}
.constellation { width: min(420px, 90%); height: auto; overflow: visible; }

.const-node-circle {
  fill: var(--surface-1); stroke: var(--border-2); stroke-width: 1.3;
  transition: fill 0.4s ease, stroke 0.4s ease;
}
.const-node.active .const-node-circle {
  fill: rgba(76,141,255,0.16); stroke: var(--accent);
  filter: drop-shadow(0 0 8px rgba(76,141,255,0.55));
  animation: node-pulse 1.1s ease-in-out infinite;
}
.const-node.done .const-node-circle { fill: rgba(34,197,94,0.14); stroke: var(--success); filter: none; animation: none; }
@keyframes node-pulse { 0%,100% { stroke-width: 1.3; } 50% { stroke-width: 2.4; } }

.const-node-icon { stroke: var(--text-muted); fill: none; stroke-width: 1.6; transition: stroke 0.4s ease; }
.const-node.active .const-node-icon, .const-node.done .const-node-icon { stroke: var(--ink-0); }

.const-node-label {
  font-family: var(--font); font-size: 7.5px; font-weight: 600; fill: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; transition: fill 0.4s ease;
}
.const-node.active .const-node-label, .const-node.done .const-node-label { fill: var(--text-soft); }

.const-hub-circle { fill: rgba(76,141,255,0.08); stroke: var(--accent); stroke-width: 1.4; animation: hub-spin 6s linear infinite; transform-origin: center; }
.const-hub-ring { fill: none; stroke: var(--accent-glow); stroke-width: 1; stroke-dasharray: 3 5; animation: hub-spin 14s linear infinite reverse; transform-origin: center; }
@keyframes hub-spin { to { transform: rotate(360deg); } }
.const-hub-icon { stroke: var(--accent); fill: none; stroke-width: 1.6; }
.const-hub-dot { fill: var(--accent); stroke: none; }

.const-link {
  fill: none; stroke: var(--border-1); stroke-width: 1.2; stroke-dasharray: 4 200; stroke-dashoffset: 0;
  transition: stroke 0.4s ease;
}
.const-link.drawing { stroke: var(--accent); stroke-dasharray: 200; stroke-dashoffset: 200; animation: draw-link 0.7s var(--ease) forwards; }
.const-link.drawn { stroke: rgba(76,141,255,0.45); }
@keyframes draw-link { to { stroke-dashoffset: 0; } }

.build-log {
  width: min(420px, 90%); display: flex; flex-direction: column; gap: 7px;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); min-height: 76px;
}
.build-log-line { display: flex; align-items: center; gap: 8px; opacity: 0; transform: translateY(4px); animation: log-in 0.35s var(--ease) forwards; }
.build-log-line .log-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; box-shadow: 0 0 6px rgba(76,141,255,0.7); }
.build-log-line.log-done { color: var(--text-soft); }
.build-log-line.log-done .log-dot { background: var(--success); box-shadow: 0 0 6px rgba(34,197,94,0.6); }
@keyframes log-in { to { opacity: 1; transform: translateY(0); } }

/* ────────────────────────────────────────────────────────────
   RESULTS STATE
   ──────────────────────────────────────────────────────────── */
.results-state { display: flex; flex-direction: column; gap: 18px; animation: fadeInUp var(--dur-slow) var(--ease) both; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: translateY(0); } }

.results-summary {
  padding: 18px 20px; border: 1px solid var(--border-0); border-radius: var(--radius-xl); background: var(--surface-0);
}
.results-summary-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.summary-badge-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.badge-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 12px;
  border: 1px solid var(--border-1); border-radius: var(--radius-pill); background: var(--surface-1);
  font-size: 11px; font-weight: var(--weight-medium); color: var(--text-soft);
}
.badge-pill svg { width: 12px; height: 12px; }
.badge-pill-ok { color: var(--success); border-color: rgba(34,197,94,0.35); background: rgba(34,197,94,0.08); }

.results-summary-text { font-size: var(--text-sm); color: var(--text-soft); line-height: 1.6; margin-bottom: 12px; }

.resource-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.resource-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px;
  border: 1px solid var(--border-1); border-radius: var(--radius-md); background: var(--surface-1);
  font-size: 11.5px; font-weight: var(--weight-medium); color: var(--text-soft);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-spring);
}
.resource-pill:hover { transform: translateY(-1px); border-color: var(--border-2); }
.resource-pill.active { background: var(--accent-dim); border-color: rgba(76,141,255,0.4); color: var(--accent); }
.resource-pill .rk-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* SQL/YAML code panel */
.sql-code-panel { border: 1px solid var(--border-1); border-radius: var(--radius-xl); overflow: hidden; background: rgba(0,0,0,0.4); box-shadow: var(--shadow-md); }
[data-theme="light"] .sql-code-panel { background: #0d1117; }
.sql-code-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px 0; border-bottom: 1px solid var(--border-0); background: rgba(255,255,255,0.02); flex-wrap: wrap; }
.file-tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.file-tab {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: transparent;
  color: var(--text-muted); font-size: 11.5px; font-weight: var(--weight-medium); font-family: var(--font-mono);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.file-tab:hover { color: var(--text-soft); }
.file-tab.active { color: var(--ink-0); background: rgba(255,255,255,0.03); box-shadow: inset 0 -2px 0 var(--accent); }
.sql-code-actions { display: flex; align-items: center; gap: 4px; padding-bottom: 8px; }
.toolbar-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px;
  border: 1px solid var(--border-1); border-radius: var(--radius-sm); background: var(--surface-0);
  color: var(--text-muted); font-size: 11px; font-weight: var(--weight-medium);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-spring);
}
.toolbar-btn svg { width: 12px; height: 12px; }
.toolbar-btn:hover { background: var(--surface-1); border-color: var(--border-2); color: var(--text-soft); transform: translateY(-1px); }
.toolbar-btn:active { transform: scale(0.95); }
.toolbar-btn.success-flash { background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.3); color: var(--success); }

.sql-code {
  margin: 0; padding: 20px 22px; overflow-x: auto; font-family: var(--font-mono); font-size: 13px; line-height: 1.8;
  color: #e2e8f0; white-space: pre; tab-size: 2; max-height: 520px;
  scrollbar-width: thin; scrollbar-color: var(--border-1) transparent;
}
.sql-code::-webkit-scrollbar { height: 4px; }
.sql-code::-webkit-scrollbar-thumb { background: var(--border-1); border-radius: 10px; }

.tok-kw  { color: #c792ea; font-weight: 500; }
.tok-key { color: #82aaff; }
.tok-str { color: #c3e88d; }
.tok-num { color: #f78c6c; }
.tok-cmt { color: #546e7a; font-style: italic; }
.tok-pun { color: #89ddff; }
.tok-dash { color: #ffcb6b; }
.tok-anchor { color: #f78c6c; }

.qg-why, .fc-why, .km-why, .rg-why {
  --why-card-bg:        rgba(255,255,255,0.035);
  --why-card-bg-hover:  rgba(255,255,255,0.065);
  --why-card-border:    rgba(255,255,255,0.075);
  --why-card-border-hover: rgba(255,255,255,0.14);
  --why-icon-bg:        rgba(255,255,255,0.07);
  --why-icon-border:    rgba(255,255,255,0.1);
  --why-icon-color:     rgba(255,255,255,0.72);
  --why-heading-color:  #ffffff;
  --why-label-color:    rgba(255,255,255,0.92);
  --why-desc-color:     rgba(255,255,255,0.45);
  --why-sub-color:      rgba(255,255,255,0.45);
}
.km-why {
  width: 100%;
  max-width: 960px;
  margin: 4rem auto 2rem;
  padding: 0 1.5rem;
}
 
.km-why-heading {
  font-size: clamp(1.4rem, 2.8vw, 1.85rem);
  font-weight: 700;
  color: var(--why-heading-color);
  text-align: center;
  margin: 0 0 0.55rem;
  letter-spacing: -0.022em;
}
 
.km-why-sub {
  font-size: 0.9rem;
  color: var(--why-sub-color);
  text-align: center;
  max-width: 520px;
  margin: 0 auto 2.25rem;
  line-height: 1.65;
}
 
.km-why-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
 
@media (max-width: 780px) { .km-why-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .km-why-grid { grid-template-columns: 1fr; } }
 
.km-why-card {
  background: var(--why-card-bg);
  border: 1px solid var(--why-card-border);
  border-radius: 14px;
  padding: 1.3rem 1.15rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
 
.km-why-card:hover {
  background: var(--why-card-bg-hover);
  border-color: var(--why-card-border-hover);
  transform: translateY(-2px);
}
 
.km-why-icon {
  width: 34px;
  height: 34px;
  background: var(--why-icon-bg);
  border: 1px solid var(--why-icon-border);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.3rem;
  flex-shrink: 0;
}
 
.km-why-icon svg {
  width: 16px;
  height: 16px;
  color: var(--why-icon-color);
}
 
.km-why-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--why-label-color);
  margin: 0;
}
 
.km-why-desc {
  font-size: 0.855rem;
  color: var(--why-desc-color);
  line-height: 1.65;
  margin: 0;
}

/* ────────────────────────────────────────────────────────────
   MODAL
   ──────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  animation: fadeIn var(--dur-base) var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box { width: min(460px, 100%); border: 1px solid var(--border-1); border-radius: var(--radius-xl); background: rgba(12,12,14,0.98); box-shadow: var(--shadow-xl); overflow: hidden; animation: scale-in var(--dur-base) var(--ease-spring); }
[data-theme="light"] .modal-box { background: #ffffff; }
@keyframes scale-in { from { opacity: 0; transform: scale(0.95) translateY(-10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border-0); }
.modal-head h3 { font-size: var(--text-base); font-weight: var(--weight-semi); color: var(--ink-1); }
.modal-close {
  display: flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  border: 1px solid var(--border-1); border-radius: var(--radius-sm); background: transparent; color: var(--text-muted);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease-spring);
}
.modal-close svg { width: 13px; height: 13px; }
.modal-close:hover { background: var(--surface-1); color: var(--text); transform: rotate(90deg); }
.modal-body { padding: 18px 20px; }
.modal-hint { font-size: 11.5px; color: var(--text-muted); line-height: 1.6; margin-top: 12px; }
.modal-hint code { font-family: var(--font-mono); color: var(--accent); }

/* ────────────────────────────────────────────────────────────
   TOAST
   ──────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 380px; padding: 12px 16px;
  border: 1px solid var(--border-1); border-radius: var(--radius-lg); background: rgba(15,15,16,0.97);
  backdrop-filter: blur(20px); box-shadow: var(--shadow-xl); font-size: var(--text-sm); font-weight: var(--weight-medium);
  color: var(--text); pointer-events: all; animation: toast-in 0.28s var(--ease-spring) both; position: relative; overflow: hidden;
}
.toast::after { content: ''; position: absolute; bottom: 0; left: 0; height: 2px; width: 100%; background: var(--accent); animation: toast-progress linear forwards; animation-duration: var(--barDur, 3.8s); transform-origin: left; }
.toast.toast-success::after { background: var(--success); }
.toast.toast-error::after { background: var(--error); }
@keyframes toast-progress { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(10px) scale(0.95); } }
.toast.removing { animation: toast-out 0.2s var(--ease) both; }
.toast-icon { width: 16px; height: 16px; flex-shrink: 0; }
.toast.toast-success .toast-icon { color: var(--success); }
.toast.toast-error .toast-icon { color: var(--error); }
.toast-close { margin-left: auto; display: flex; align-items: center; justify-content: center; width: 18px; height: 18px; border: none; border-radius: 50%; background: var(--surface-1); color: var(--text-muted); font-size: 11px; transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); flex-shrink: 0; }
.toast-close:hover { background: var(--surface-2); color: var(--text); }

/* ────────────────────────────────────────────────────────────
   RESPONSIVE
   ──────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .panel-left { width: 380px; }
}
@media (max-width: 768px) {
  .workspace { flex-direction: column; height: auto; min-height: calc(100vh - var(--header-h)); }
  .panel-left { width: 100%; min-width: unset; max-width: unset; border-right: none; border-bottom: 1px solid var(--border-0); max-height: 60vh; }
  .panel-right { min-height: 50vh; }
  .resize-handle { display: none; }
  .brand-sub { display: none; }
  .builder-row.two-col { grid-template-columns: 1fr; }
  .dynamic-row { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .header-btn:not(.icon-only) span { display: none; }
  .panel-right { padding: 16px; }
  .results-summary-top { flex-direction: column; align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

.header-btn.bookmarked {
  color: var(--accent);
  border-color: rgba(76, 141, 255, 0.4);
  background: var(--accent-dim);
}

.header-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}