:root {
  --bg: #0f172a;
  --panel: #111827;
  --muted: #94a3b8;
  --text: #e2e8f0;
  --accent: #22d3ee;
  --accent-2: #f97316;
  --border: rgba(148, 163, 184, 0.2);
  --shadow: 0 20px 40px rgba(15, 23, 42, 0.35);
  --radius: 14px;
  --side-col-width: 420px;
  font-synthesis-weight: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, rgba(34,211,238,0.15), transparent 45%),
              radial-gradient(circle at top right, rgba(249,115,22,0.12), transparent 45%),
              linear-gradient(180deg, #0b1020, #0f172a 35%, #0b1120 100%);
  min-height: 100vh;
}

.shell {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 24px 28px 48px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
}

.dot {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.6);
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.06);
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.06);
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.status .small {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 999px;
}

.user-status .small {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 999px;
}

.pill {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

code {
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  color: var(--accent);
}

.panel {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  backdrop-filter: blur(8px);
}

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

.panel-header__actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.panel-header h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-subactions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
  padding-right: 6px;
}

.panel-body {
  margin-top: 12px;
}

.panel-toggle {
  background: rgba(15, 23, 42, 0.6);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
}

.panel.is-collapsed .panel-body {
  display: none;
}

.panel h2 {
  margin-top: 0;
}

.panel h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.subtitle {
  margin: 6px 0 10px;
  color: #a5b4fc;
  font-size: 13px;
  letter-spacing: 0.05em;
}

.subtitle.small {
  font-size: 12px;
  letter-spacing: 0.04em;
}

.section-desc {
  margin: 0 0 16px;
  color: #e2e8f0;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 10px;
  border-left: 3px solid rgba(94, 234, 212, 0.7);
  background: rgba(15, 23, 42, 0.4);
}

.pipeline {
  margin: 10px 0 18px;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: radial-gradient(circle at top left, rgba(30, 64, 175, 0.25), rgba(15, 23, 42, 0.8));
  box-shadow: 0 14px 30px rgba(2, 6, 23, 0.35);
}

.pipeline-head h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.pipeline-head p {
  margin: 0 0 14px;
  color: #cbd5f5;
  font-size: 14px;
}

.pipeline-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
}

.pipeline-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(56, 189, 248, 0.2);
  background: rgba(15, 23, 42, 0.55);
  min-width: 210px;
  flex: 1 1 210px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.pipeline-step:hover {
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 8px 18px rgba(34, 211, 238, 0.15);
  transform: translateY(-1px);
}

.step-num {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #0b1120;
  background: linear-gradient(135deg, #38bdf8, #22d3ee);
  flex-shrink: 0;
}

.step-body h3 {
  margin: 0 0 4px;
  font-size: 14px;
  color: #e2e8f0;
}

.step-body p {
  margin: 0;
  font-size: 12px;
  color: #94a3b8;
}

.pipeline-arrow {
  display: grid;
  place-items: center;
  color: #7dd3fc;
  font-weight: 700;
  padding: 0 4px;
}

.step-badge {
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #0b1120;
  background: linear-gradient(135deg, #38bdf8, #22d3ee);
  flex-shrink: 0;
}

.step-badge.small {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 6px;
  font-size: 11px;
}

@media (max-width: 900px) {
  .pipeline-arrow {
    display: none;
  }
}

.login {
  max-width: 420px;
  margin: 40px auto;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  color: #e2e8f0;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.35);
  box-shadow: 0 6px 16px rgba(2, 6, 23, 0.2);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

label:focus-within {
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15), 0 8px 20px rgba(2, 6, 23, 0.25);
}

input, textarea, select {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Prevent text fields from overflowing their container. */
input:not([type="checkbox"]):not([type="radio"]),
textarea,
select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

textarea {
  resize: vertical;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.7);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #0b1120;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

button.ghost {
  background: rgba(15, 23, 42, 0.6);
  color: var(--text);
  border: 1px solid var(--border);
}

#neo4jToggle.mode-serma {
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
}

#neo4jToggle.mode-slb {
  border-color: rgba(34, 211, 238, 0.6);
  color: #a5f3fc;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled,
button[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

button:disabled:hover,
button[aria-disabled="true"]:hover {
  transform: none;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(226, 232, 240, 0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s ease, transform 0.2s ease;
  animation: spin 1s linear infinite;
}

form.is-loading .spinner {
  opacity: 1;
  transform: scale(1);
}

form.is-loading button {
  opacity: 0.7;
  pointer-events: none;
}

.nav {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.chat-cta {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b1120;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(34, 211, 238, 0.25);
}

.chat-cta.muted {
  background: rgba(15, 23, 42, 0.6);
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: none;
}

.chat-cta.small {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 10px;
}

.chat-floating {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.chat-inline {
  margin: 10px 0 18px;
}

.chat-cta.big {
  display: block;
  width: 100%;
  text-align: center;
  padding: 16px 18px;
  font-size: 18px;
  border-radius: 14px;
  box-shadow: 0 16px 32px rgba(34, 211, 238, 0.25);
}


.nav button.ghost {
  margin-left: 0;
}

.user-badge {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.6);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 10px minmax(320px, var(--side-col-width));
  gap: 24px;
  align-items: stretch;
}

.split-handle {
  grid-column: 2;
  width: 10px;
  margin: 0 -12px;
  border-radius: 999px;
  cursor: col-resize;
  background: rgba(148, 163, 184, 0.10);
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: 0 10px 20px rgba(2, 6, 23, 0.15);
}

.split-handle:hover,
.split-handle:focus {
  outline: none;
  background: rgba(34, 211, 238, 0.16);
  border-color: rgba(34, 211, 238, 0.35);
}

body.is-col-resize {
  cursor: col-resize;
  user-select: none;
}

.side-col {
  position: relative;
  align-self: stretch;
}

.sticky {
  position: sticky;
  top: 4px;
}

.qa-panel {
  display: grid;
  gap: 12px;
}

.qa-settings {
  display: grid;
  gap: 10px;
}

.qa-chat {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(8, 12, 24, 0.7);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 220px;
  max-height: 360px;
  overflow: auto;
}

.qa-msg {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.qa-msg.user {
  align-self: flex-end;
  background: rgba(34, 211, 238, 0.18);
  border: 1px solid rgba(34, 211, 238, 0.35);
}

.qa-msg.assistant {
  align-self: flex-start;
  background: rgba(148, 163, 184, 0.18);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.qa-input textarea {
  resize: vertical;
  min-height: 70px;
}

.qa-debug {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.6);
}

.qa-debug summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

.output.compact {
  min-height: 80px;
  max-height: 180px;
}

.output {
  margin-top: 12px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 10px;
  padding: 12px;
  min-height: 100px;
  overflow: auto;
  font-size: 12px;
  color: #cbd5f5;
  white-space: pre-wrap;
  word-break: break-word;
}

.output.loading {
  opacity: 0.7;
}

.artifact-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.json-panel {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.65);
  overflow: hidden;
}

.json-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  background: rgba(15, 23, 42, 0.55);
}

.json-panel__title {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7dd3fc;
  font-weight: 700;
}

.json-panel__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.json-viewer {
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 12px;
  color: #cbd5f5;
  padding: 10px 12px 12px;
  overflow: auto;
  max-height: 420px;
}

.jnode {
  display: block;
}

.jline {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 0;
  white-space: nowrap;
}

.jtoggle {
  width: 18px;
  flex: 0 0 18px;
  display: inline-block;
  color: rgba(226, 232, 240, 0.75);
  cursor: pointer;
  user-select: none;
}

.jtoggle.is-empty {
  cursor: default;
  opacity: 0.35;
}

.jkey {
  color: #a5b4fc;
}

.jsep {
  opacity: 0.6;
}

.jval {
  color: #cbd5f5;
}

.jval.jtype-null {
  color: #fca5a5;
}

.jval.jtype-bool {
  color: #86efac;
}

.jval.jtype-num {
  color: #7dd3fc;
}

.jval.jtype-str {
  color: #fdba74;
}

.jchildren {
  margin-left: 18px;
  border-left: 1px dashed rgba(148, 163, 184, 0.18);
  padding-left: 10px;
  display: none;
}

.jnode.is-open > .jchildren {
  display: block;
}

.error {
  color: #fca5a5;
  margin-top: 8px;
}

.row {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.switch-row {
  justify-content: space-between;
}

.switch-row .row-label {
  flex: 1 1 auto;
  min-width: 0;
}

.switch {
  --sw-w: 44px;
  --sw-h: 24px;
  position: relative;
  width: var(--sw-w);
  height: var(--sw-h);
  flex: 0 0 auto;
}

.switch input[type="checkbox"] {
  position: absolute;
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.switch-ui {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  border: 1px solid rgba(148, 163, 184, 0.28);
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.25);
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(var(--sw-h) - 6px);
  height: calc(var(--sw-h) - 6px);
  border-radius: 999px;
  background: rgba(226, 232, 240, 0.95);
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.35);
  transition: transform 0.18s ease;
}

.switch input[type="checkbox"]:checked + .switch-ui {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.95), rgba(249, 115, 22, 0.95));
  border-color: transparent;
  box-shadow: 0 12px 26px rgba(34, 211, 238, 0.16);
}

.switch input[type="checkbox"]:checked + .switch-ui::after {
  transform: translateX(calc(var(--sw-w) - var(--sw-h)));
}

.switch input[type="checkbox"]:focus-visible + .switch-ui {
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.22), 0 14px 30px rgba(2, 6, 23, 0.35);
}

.switch input[type="checkbox"]:disabled {
  cursor: not-allowed;
}

.switch input[type="checkbox"]:disabled + .switch-ui {
  opacity: 0.5;
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  width: min(1000px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.92);
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.55);
  padding: 14px 14px 16px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 10px;
}

.modal-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7dd3fc;
}

.modal-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.modal-head__actions {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.modal-card .output {
  margin-top: 0;
  min-height: 320px;
  max-height: calc(100vh - 160px);
  overflow: auto;
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre;
  word-break: normal;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(11, 17, 32, 0.92);
  color: #cbd5f5;
}

.health {
  margin: 6px 0 18px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.6);
  font-size: 14px;
  white-space: pre-wrap;
}

.help-block {
  margin: 10px 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.25);
  background: linear-gradient(135deg, rgba(14, 116, 144, 0.35), rgba(15, 23, 42, 0.65));
  color: #cbd5f5;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.25);
}

.help-title {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7dd3fc;
  margin-bottom: 6px;
  font-weight: 600;
}

.help-block ul {
  margin: 6px 0 0 18px;
}

.field-hint {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  margin-top: 4px;
}

.health.ok {
  border-color: rgba(34, 211, 238, 0.5);
  color: var(--accent);
}

.health.fail {
  border-color: rgba(248, 113, 113, 0.5);
  color: #fca5a5;
}

.ui-logs {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.7);
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 520px;
}

.ui-logs__title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.ui-logs__body {
  font-size: 14px;
  color: var(--text);
  max-height: 500px;
  overflow: auto;
  display: grid;
  gap: 6px;
}

.ui-log {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.ui-log__time {
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  flex: 0 0 auto;
}

.ui-log__msg {
  flex: 1 1 auto;
  min-width: 0;
}

.ui-log__line {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.ui-log__badges {
  display: inline-flex;
  gap: 6px;
  margin-right: 8px;
  flex-wrap: wrap;
}

.ui-log__badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.55);
  color: #cbd5f5;
}

.ui-log__badge.level-info {
  border-color: rgba(34, 211, 238, 0.35);
  color: #a5f3fc;
}

.ui-log__badge.level-warn {
  border-color: rgba(249, 115, 22, 0.35);
  color: #fdba74;
}

.ui-log__badge.level-error {
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.ui-log__badge.tag {
  border-color: rgba(129, 140, 248, 0.35);
  background: rgba(129, 140, 248, 0.12);
  color: #c7d2fe;
}

.ui-log__badge.user {
  border-color: rgba(34, 211, 238, 0.35);
  background: rgba(34, 211, 238, 0.12);
  color: #a5f3fc;
}

.ui-log details {
  margin-top: 6px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(15, 23, 42, 0.45);
}

.ui-log details > summary {
  cursor: pointer;
  color: #7dd3fc;
  font-size: 12px;
  user-select: none;
}

.ui-log details[open] > summary {
  color: var(--accent);
}

.ui-log__json {
  margin-top: 8px;
  font-family: "JetBrains Mono", "SFMono-Regular", monospace;
  font-size: 12px;
  max-height: 360px;
  overflow: auto;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(15, 23, 42, 0.65);
}

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

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .nav {
    flex-wrap: wrap;
  }
  .split {
    grid-template-columns: 1fr;
  }
  .split-handle {
    display: none;
  }
}
