:root {
  --bg: #050711;
  --bg-soft: #0a1020;
  --surface: rgba(14, 21, 40, 0.92);
  --surface-strong: rgba(18, 29, 56, 0.98);
  --text: #f4f8ff;
  --muted: #94a3b8;
  --primary: #22d3ee;
  --secondary: #a855f7;
  --success: #4ade80;
  --warning: #facc15;
  --danger: #fb7185;
  --info: #60a5fa;
  --border: rgba(34, 211, 238, 0.24);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --radius-small: 10px;
  --font-family: Inter, system-ui, sans-serif;
  --font-mono: "Cascadia Code", Consolas, monospace;
  --sidebar-width: 270px;
  --content-width: 1500px;
  --panel-padding: 20px;
  --transition-speed: 280ms;
  --grid-size: 24px;
}
* {
  box-sizing: border-box;
}
html {
  color-scheme: dark;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background:
    radial-gradient(
      circle at 80% 0,
      color-mix(in srgb, var(--secondary) 13%, transparent),
      transparent 30%
    ),
    var(--bg);
  color: var(--text);
  font-family: var(--font-family);
  min-height: 100vh;
}
a {
  color: inherit;
  text-decoration: none;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
}
::selection {
  background: var(--primary);
  color: var(--bg);
}
:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 70%, transparent);
  outline-offset: 2px;
}
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-soft) 94%, transparent);
  backdrop-filter: blur(18px);
  overflow: auto;
  z-index: 20;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 8px 22px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: var(--bg);
  font-weight: 900;
}
.brand strong,
.brand small {
  display: block;
}
.brand small {
  color: var(--muted);
  font-size: 0.72rem;
}
.nav-section {
  margin: 16px 8px 8px;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  margin: 3px 0;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  color: var(--muted);
  transition: var(--transition-speed);
}
.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: color-mix(in srgb, var(--primary) 9%, transparent);
  border-color: var(--border);
}
.nav-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-strong);
  font: 700 0.7rem var(--font-mono);
  color: var(--primary);
}
.sidebar.compact {
  --sidebar-width: 88px;
}
.sidebar.compact .brand-copy,
.sidebar.compact .nav-label,
.sidebar.compact .nav-section {
  display: none;
}
.main {
  min-width: 0;
}
.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(18px, 3vw, 42px);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 15;
}
.topbar h1 {
  font-size: 1.05rem;
  margin: 0;
}
.topbar p {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 2px 0 0;
}
.page-content {
  width: min(100%, var(--content-width));
  margin: auto;
  padding: clamp(20px, 3vw, 44px);
}
.panel {
  background: linear-gradient(
    145deg,
    var(--surface),
    color-mix(in srgb, var(--surface-strong) 80%, transparent)
  );
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--panel-padding);
  box-shadow: var(--shadow);
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.panel-header h2,
.panel-header h3 {
  margin: 0;
}
.muted,
.help {
  color: var(--muted);
}
.help {
  font-size: 0.85rem;
}
.grid {
  display: grid;
  gap: 18px;
}
.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.btn {
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 9px 14px;
  background: var(--surface-strong);
  color: var(--text);
  transition: var(--transition-speed);
}
.btn:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}
.btn-primary {
  background: linear-gradient(
    135deg,
    var(--primary),
    color-mix(in srgb, var(--primary) 65%, var(--secondary))
  );
  border-color: transparent;
  color: var(--bg);
  font-weight: 750;
}
.btn-danger {
  color: var(--danger);
}
.btn-small {
  padding: 6px 10px;
  font-size: 0.8rem;
}
.field {
  display: grid;
  gap: 6px;
}
.field label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}
.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--bg-soft);
  color: var(--text);
  padding: 10px 12px;
}
.textarea,
.code-editor {
  font-family: var(--font-mono);
  line-height: 1.6;
  resize: vertical;
}
.code-editor {
  min-height: 230px;
}
.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.72rem;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}
.status {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 420px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  z-index: 100;
}
.status.success {
  border-color: var(--success);
}
.status.error {
  border-color: var(--danger);
}
.status.warning {
  border-color: var(--warning);
}
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th {
  color: var(--primary);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tr:last-child td {
  border-bottom: 0;
}
.empty {
  text-align: center;
  padding: 36px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-small);
}
.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
}
.stat-label {
  color: var(--muted);
  font-size: 0.8rem;
}
.split {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
}
.list {
  display: grid;
  gap: 8px;
}
.list-item {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
}
.node {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface-strong);
}
.node.active {
  border-color: var(--primary);
  box-shadow: 0 0 24px color-mix(in srgb, var(--primary) 22%, transparent);
}
.flow {
  display: flex;
  gap: 12px;
  align-items: stretch;
  overflow: auto;
  padding: 10px 2px;
}
.flow .node {
  min-width: 150px;
  position: relative;
}
.flow .node:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -11px;
  top: 50%;
  color: var(--primary);
}
.workspace-canvas {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--bg-soft);
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
}
.transition-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  display: grid;
  place-items: center;
  transition: opacity var(--transition-speed);
}
.transition-overlay.visible {
  opacity: 1;
  visibility: visible;
}
.transition-loader {
  display: none;
  text-align: center;
  color: var(--muted);
}
.transition-loader.visible {
  display: block;
}
.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 10px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 88px minmax(0, 1fr);
  }
  .sidebar {
    --sidebar-width: 88px;
  }
  .brand-copy,
  .nav-label,
  .nav-section {
    display: none;
  }
  .grid-4,
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .split {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 640px) {
  .app-shell {
    display: block;
  }
  .sidebar {
    position: fixed;
    inset: auto 0 0;
    height: 64px;
    width: auto;
    padding: 7px;
    display: flex;
    overflow-x: auto;
    border-right: 0;
    border-top: 1px solid var(--border);
  }
  .brand,
  .nav-section {
    display: none;
  }
  .sidebar nav {
    display: flex;
  }
  .nav-link {
    margin: 0 3px;
    padding: 8px;
  }
  .main {
    padding-bottom: 68px;
  }
  .topbar {
    height: auto;
    min-height: 64px;
  }
  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .page-content {
    padding: 16px;
  }
  .flow {
    flex-direction: column;
  }
  .flow .node::after {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
