/* instan box — tokens lifted from the VoltAgent system: abyss black, carbon panels,
   warm charcoal hairlines, one emerald signal colour. */

:root {
  --bg: #050507;
  --surface: #101010;
  --well: #08080a;
  --line: #3d3a39;
  --line-soft: #232120;
  --text: #f2f2f2;
  --muted: #b8b3b0;
  --faint: #8b949e;
  --accent: #00d992;
  --accent-mint: #2fd6a1;
  --accent-ink: #04120c;
  --danger: #fb565b;
  --warning: #ffba00;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  --sans: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --radius: 8px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, textarea { font: inherit; }

::selection { background: rgba(0, 217, 146, 0.28); color: #ffffff; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- top bar ---------- */

.topbar {
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  z-index: 5;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  color: var(--accent);
  text-decoration: none;
}

.brand-mark { align-self: center; }

.brand-name {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text);
}

.brand-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 0 rgba(0, 217, 146, 0.5);
}

.status.is-live .status-dot {
  background: var(--accent);
  animation: pulse 2.6s ease-out infinite;
}

.status.is-down .status-dot { background: var(--danger); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 217, 146, 0.42); }
  70% { box-shadow: 0 0 0 6px rgba(0, 217, 146, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 217, 146, 0); }
}

/* ---------- layout ---------- */

.workbench {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
}

.rail {
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow-y: auto;
  background: var(--bg);
}

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

.rail-title {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--faint);
}

.spec-list { margin: 0; display: grid; gap: 7px; }

.spec-list div {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--mono);
  font-size: 9px;
}

.spec-list dt { color: var(--faint); letter-spacing: 0.2px; }

.spec-list div::after {
  content: "";
  order: 1;
  flex: 1;
  border-bottom: 1px dotted #2e2b29;
  transform: translateY(-3px);
}

.spec-list dd {
  order: 2;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.example-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.example-list button {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  margin: 0 -8px;
  width: calc(100% + 16px);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 120ms ease, color 120ms ease;
}

.example-list button::before {
  content: "›";
  font-family: var(--mono);
  color: #7d7874;
  transition: color 120ms ease;
}

.example-list button:hover { background: var(--surface); color: var(--text); }
.example-list button:hover::before { color: var(--accent); }

.rail-foot { margin-top: auto; display: grid; gap: 10px; }

.rail-note {
  margin: 0;
  font-size: 11px;
  line-height: 1.55;
  color: var(--faint);
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}

.rail-stat {
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* ---------- stage ---------- */

.stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(240px, 1.2fr) minmax(200px, 0.8fr);
  background: var(--surface);
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.editor-pane { border-bottom: 1px solid var(--line); }

.pane-head {
  flex: 0 0 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 0 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}

.pane-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--faint);
}

.pane-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: 100%;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  background: none;
  border: 0;
  padding: 0 12px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 120ms ease;
}

.tab:hover { color: var(--muted); }

.tab.is-active { color: var(--text); }

.tab.is-active::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, opacity 120ms ease;
  white-space: nowrap;
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.btn.ghost:hover { border-color: #56514e; color: var(--text); }

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  padding-right: 8px;
  font-weight: 600;
}

.btn.primary:hover { background: var(--accent-mint); border-color: var(--accent-mint); }

.btn.primary kbd {
  font-family: var(--mono);
  font-size: 9px;
  border: 1px solid rgba(4, 18, 12, 0.28);
  border-radius: 3px;
  padding: 1px 4px;
  color: rgba(4, 18, 12, 0.72);
}

.btn[disabled] { opacity: 0.55; cursor: default; }

.btn.primary.is-running { background: #0d2a21; border-color: #17523f; color: var(--accent-mint); }

.btn.primary.is-running kbd { display: none; }

.btn.primary.is-running::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--accent);
  animation: blink 1s steps(2, start) infinite;
}

@keyframes blink { to { visibility: hidden; } }

.editor-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
  white-space: nowrap;
}

/* ---------- editor ---------- */

.editor {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  background: var(--well);
}

.gutter {
  padding: 14px 10px 24px 0;
  text-align: right;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 21px;
  color: #7d7874;
  overflow: hidden;
  user-select: none;
  border-right: 1px solid #171514;
  font-variant-numeric: tabular-nums;
}

#code {
  width: 100%;
  height: 100%;
  min-height: 0;
  background: transparent;
  color: #e9e6e2;
  border: 0;
  outline: none;
  resize: none;
  padding: 14px 18px 24px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 21px;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
  caret-color: var(--accent);
}

#code::selection { background: rgba(0, 217, 146, 0.22); }

/* ---------- output ---------- */

.output-pane { background: var(--surface); }

.chips { display: flex; gap: 6px; min-width: 0; }

.chip {
  font-family: var(--mono);
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.chip.ok { border-color: rgba(0, 217, 146, 0.45); color: var(--accent-mint); }
.chip.bad { border-color: rgba(251, 86, 91, 0.45); color: var(--danger); }
.chip.warn { border-color: rgba(255, 186, 0, 0.4); color: var(--warning); }

.terminal {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 18px;
  background: var(--well);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.62;
}

.empty {
  position: relative;
  border: 1px dashed #2f2c2a;
  border-radius: var(--radius);
  padding: 26px 20px;
  text-align: left;
  color: var(--faint);
  max-width: 460px;
}

.empty-title { margin: 0; font-family: var(--mono); font-size: 12px; color: var(--muted); }

.empty-hint { margin: 6px 0 0; font-size: 12px; color: var(--faint); }

.empty kbd {
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 4px;
  margin-left: 2px;
  color: var(--muted);
}

.output { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.output .cmd { color: var(--faint); }
.output .cmd::before { content: "$ "; color: #7d7874; }
.output .stdout { color: #dedad6; }
.output .stderr { color: var(--danger); }
.output .note { color: var(--warning); }

.statusbar {
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
}

.statusbar .sb-right { margin-left: auto; color: var(--faint); }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  body { height: auto; min-height: 100dvh; overflow: auto; }

  .topbar { padding: 0 14px; }
  .brand-sub { display: none; }

  .workbench { grid-template-columns: 1fr; }

  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .rail .specs, .rail .rail-foot, .examples .rail-title { display: none; }

  .examples { flex: 0 0 auto; }
  .example-list { grid-auto-flow: column; grid-auto-columns: max-content; gap: 6px; }

  .example-list button {
    width: auto;
    margin: 0;
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 11px;
  }

  .stage {
    grid-template-rows: minmax(300px, 56vh) minmax(240px, 40vh);
  }

  .pane-head { gap: 8px; padding: 0 8px 0 6px; }
  .tab { padding: 0 8px; font-size: 11px; }
  .editor-meta { display: none; }
  .btn { padding: 6px 9px; }
  .editor { grid-template-columns: 36px minmax(0, 1fr); }
  .gutter { padding-right: 7px; font-size: 12px; }
  #code { font-size: 12.5px; padding: 14px 12px 24px; }
}

@media (max-width: 460px) {
  .btn.ghost#share { display: none; }
  .status { font-size: 10px; padding: 4px 9px; }
}

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