/* Design tokens, typography and base controls. */
:root {
  --wall:
    radial-gradient(1200px 800px at 12% 8%, #c7d7fe 0%, transparent 60%),
    radial-gradient(1000px 700px at 92% 18%, #fbcfe8 0%, transparent 55%),
    radial-gradient(1200px 900px at 70% 100%, #bae6fd 0%, transparent 60%),
    linear-gradient(160deg, #eef2ff 0%, #f5f3ff 50%, #ecfeff 100%);
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eef0f3;
  --glass: rgba(255, 255, 255, .62);
  --glass-strong: rgba(255, 255, 255, .82);
  --glass-line: rgba(255, 255, 255, .7);
  --line: rgba(15, 23, 42, .08);
  --line-strong: rgba(15, 23, 42, .14);
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --accent-soft: color-mix(in srgb, var(--accent) 11%, transparent);
  --ok: #059669; --ok-soft: rgba(5, 150, 105, .12);
  --warn: #d97706; --warn-soft: rgba(217, 119, 6, .12);
  --danger: #dc2626; --danger-soft: rgba(220, 38, 38, .1);
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 22px;
  --sh-1: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 1px rgba(15, 23, 42, .04);
  --sh-2: 0 4px 14px rgba(15, 23, 42, .08), 0 1px 3px rgba(15, 23, 42, .06);
  --sh-win: 0 24px 60px -12px rgba(15, 23, 42, .28), 0 8px 20px -8px rgba(15, 23, 42, .16), 0 0 0 1px rgba(15, 23, 42, .06);
  --sh-win-dim: 0 12px 32px -12px rgba(15, 23, 42, .18), 0 0 0 1px rgba(15, 23, 42, .05);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
  --t-fast: 120ms; --t: 200ms; --t-slow: 320ms;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --term-bg: #0d1117;
  color-scheme: light;
}
/* dark tokens: applied by theme.js (light / dark / follow system) */
:root[data-theme="dark"] {
    --wall:
      radial-gradient(1200px 800px at 12% 8%, #312e81 0%, transparent 60%),
      radial-gradient(1000px 700px at 92% 18%, #4a1d4e 0%, transparent 55%),
      radial-gradient(1200px 900px at 70% 100%, #0c4a6e 0%, transparent 60%),
      linear-gradient(160deg, #0b1020 0%, #111827 100%);
    --surface: #161b26; --surface-2: #1c2230; --surface-3: #232a3a;
    --glass: rgba(22, 27, 38, .6); --glass-strong: rgba(22, 27, 38, .84); --glass-line: rgba(255, 255, 255, .08);
    --line: rgba(255, 255, 255, .07); --line-strong: rgba(255, 255, 255, .13);
    --text: #e5e7eb; --text-2: #a1a8b8; --text-3: #6b7385;
    --accent: #818cf8; --accent-2: #a5b4fc; --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent);
    --ok: #34d399; --ok-soft: rgba(52, 211, 153, .14);
    --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .14);
    --danger: #f87171; --danger-soft: rgba(248, 113, 113, .14);
    --sh-win: 0 24px 60px -12px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .07);
    --sh-win-dim: 0 12px 32px -12px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .05);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 13.5px/1.5 var(--font); color: var(--text); background: var(--wall); background-attachment: fixed;
  overflow: hidden; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01"; letter-spacing: -.003em;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--accent); }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: .93em; }
.spacer { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* thin scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* icons (Lucide sprite) */
.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.85;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.i-lg { width: 20px; height: 20px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font-weight: 500; cursor: pointer; white-space: nowrap;
  box-shadow: var(--sh-1); text-decoration: none; user-select: none;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast) var(--ease), box-shadow var(--t-fast);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: #fff; border-color: transparent;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 35%, transparent), inset 0 1px 0 rgba(255, 255, 255, .18); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: transparent; }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: transparent; }
.btn.danger.solid:hover { filter: brightness(1.06); background: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.icon { width: 32px; padding: 0; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.sm.icon { width: 28px; }
.btn.block { width: 100%; height: 40px; }

/* fields */
input, select, textarea {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 7px 10px; min-height: 34px; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
input[type=checkbox] { appearance: none; width: 16px; height: 16px; min-height: 0; padding: 0; border-radius: 5px;
  display: inline-grid; place-content: center; cursor: pointer; flex: none; }
input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
input[type=checkbox]:checked::after { content: ""; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0;
  transform: translateY(-1px) rotate(-45deg); }
.field { display: flex; flex-direction: column; gap: 5px; margin: 12px 0; }
.field > label, .label { font-weight: 550; font-size: 12.5px; color: var(--text-2); }
.hint { font-size: 12px; color: var(--text-3); }
.check { display: flex; gap: 9px; align-items: center; margin: 8px 0; cursor: pointer; }
.form-error { display: flex; gap: 8px; align-items: flex-start; background: var(--danger-soft); color: var(--danger);
  padding: 9px 12px; border-radius: var(--r-sm); font-size: 13px; animation: shake .35s var(--ease); }

/* chips, badges, status dots */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 550; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.node-chip { background: color-mix(in srgb, var(--node) 13%, transparent); color: color-mix(in srgb, var(--node) 80%, var(--text)); }
.node-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--node); }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-running, .st-online, .st-succeeded { background: var(--ok-soft); color: var(--ok); }
.st-running::before, .st-starting::before { animation: pulse 1.4s ease-in-out infinite; }
.st-failed, .st-timed_out, .st-offline { background: var(--danger-soft); color: var(--danger); }
.st-unknown, .st-starting { background: var(--warn-soft); color: var(--warn); }
.st-cancelled, .st-stopped { background: var(--surface-3); color: var(--text-3); }

.kbd { font: 11px var(--mono); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--text-2); }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: 6px; }

@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .9s linear infinite; }

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