:root {
  color-scheme: dark;
  --bg: #080d1a;
  --side: #0c1424;
  --card: #111b2e;
  --line: #233149;
  --blue: #3b82f6;
  --cyan: #22d3ee;
  --purple: #8b5cf6;
  --green: #22d3a6;
  --warning: #f59e0b;
  --red: #f43f5e;
  --ink: #f8fafc;
  --muted: #94a3b8;
  --blue-soft: rgba(59, 130, 246, 0.16);
  --cyan-soft: rgba(34, 211, 238, 0.14);
  --purple-soft: rgba(139, 92, 246, 0.18);
  --green-soft: rgba(34, 211, 166, 0.14);
  --warning-soft: rgba(245, 158, 11, 0.14);
  --red-soft: rgba(244, 63, 94, 0.14);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: rgba(59, 130, 246, 0.45); }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
::placeholder { color: #64748b; }

.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--side);
  color: var(--ink);
  padding: 18px 12px 12px;
  border-right: 1px solid var(--line);
}
.sidebar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--purple), var(--cyan));
}
.sidebar a { color: inherit; text-decoration: none; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px; }
.brand strong {
  display: block;
  font-family: Newsreader, Georgia, serif;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
}
.brand small { color: var(--muted); font-size: 12px; }
.brand.light { color: var(--ink); }
.brand.light small { color: var(--muted); }
.mark {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 50%, var(--cyan) 0 3px, transparent 3.5px),
    radial-gradient(circle at 50% 50%, transparent 0 8px, var(--blue) 8.5px 9.5px, transparent 10px),
    #162033;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.45);
}
.side-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 8px 8px;
  color: var(--muted);
  font-size: 13px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(34, 211, 166, 0.16);
}
.nav { overflow: auto; flex: 1; padding: 8px 0; }
.nav a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 2px;
  color: var(--muted);
}
.nav a small { display: block; color: var(--muted); font-size: 12px; }
.nav a.is-on,
.nav a:hover { background: var(--blue-soft); color: var(--ink); }
.nav-label {
  margin: 16px 10px 6px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.side-user {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 12px 8px 4px;
}
.side-user strong { display: block; font-size: 14px; }
.side-user small { display: block; color: var(--muted); font-size: 12px; word-break: break-all; }
.btn-side {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
}
.btn-side:hover { border-color: var(--blue); }

.main { min-width: 0; }
.page { max-width: 1080px; padding: 28px 36px 72px; }
h1 {
  margin: 0;
  font-family: Newsreader, Georgia, serif;
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
h2 { margin: 0; font-size: 18px; font-weight: 600; }
.lede { margin: 8px 0 0; max-width: 64ch; color: var(--muted); }
.muted, .hint { color: var(--muted); }
.hint { margin: 6px 0 0; font-size: 13px; }
.crumb { display: flex; gap: 6px; align-items: center; margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.crumb a { color: var(--cyan); }

.stack { display: flex; flex-direction: column; gap: 14px; }
.section { margin-top: 22px; }
.title-row, .split {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.mini-stats { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 8px; color: var(--muted); }
.mini-stats strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
}
.flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 10px;
  margin: 22px 0;
}
.flow article {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.flow article:nth-child(1) { box-shadow: inset 3px 0 0 var(--blue); }
.flow article:nth-child(3) { box-shadow: inset 3px 0 0 var(--purple); }
.flow article:nth-child(5) { box-shadow: inset 3px 0 0 var(--cyan); }
.flow strong { display: block; }
.flow span { color: var(--muted); font-size: 14px; }
.arrow { align-self: center; color: var(--cyan); font-size: 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 30px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-hint { color: var(--muted); font-size: 13px; }
.stat:nth-child(1) .stat-value { color: var(--blue); }
.stat:nth-child(2) .stat-value { color: var(--purple); }
.stat:nth-child(3) .stat-value { color: var(--cyan); }
.stat:nth-child(4) .stat-value { color: var(--green); }

.cards, .instance-list { display: grid; gap: 10px; }
.instance-list { grid-template-columns: 1fr 1fr; }
.gcard, .icard {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
}
.gcard:hover, .icard:hover { border-color: var(--blue); }
.gcard p, .icard p { margin: 6px 0 0; }
.row-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.field span { font-size: 14px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 9px 11px;
  font-weight: 400;
  color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  box-shadow: 0 0 0 1000px var(--bg) inset;
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: 16px; height: 16px; accent-color: var(--blue); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 8px 14px;
  font-weight: 500;
  background: transparent;
}
.btn-primary { background: var(--blue); color: var(--ink); }
.btn-primary:hover { background: #60a5fa; }
.btn-ghost { border-color: var(--line); background: transparent; color: var(--ink); }
.btn-ghost:hover { border-color: var(--blue); }
.btn-danger { border-color: rgba(244, 63, 94, 0.45); color: var(--red); background: var(--red-soft); }

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-ok { background: var(--green-soft); color: var(--green); }
.pill-off { background: var(--warning-soft); color: var(--warning); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0; overflow: auto; }
.tab {
  text-decoration: none;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 500;
  white-space: nowrap;
}
.tab.is-on { color: var(--cyan); border-color: var(--cyan); }

.banner {
  background: var(--warning-soft);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--warning);
  border-radius: 12px;
  padding: 12px 14px;
}
.checklist { list-style: none; margin: 0; padding: 0; counter-reset: step; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: grid; grid-template-columns: 28px 1fr; gap: 8px; align-items: start; }
.checklist li::before {
  counter-increment: step;
  content: counter(step);
  width: 28px;
  height: 28px;
  border-radius: 99px;
  display: grid;
  place-items: center;
  background: var(--purple-soft);
  color: #c4b5fd;
  font-weight: 600;
}

.chart { height: 96px; display: flex; align-items: flex-end; gap: 3px; }
.bar {
  flex: 1;
  height: var(--h);
  min-height: 3px;
  background: rgba(59, 130, 246, 0.55);
  border-radius: 3px 3px 0 0;
}
.bar:last-child { background: var(--cyan); }

.endpoint { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.key, .snippet-pre, .play-log, .secret-box, textarea.code {
  font-family: "IBM Plex Mono", Consolas, monospace;
}
.key {
  font-size: 13px;
  background: var(--blue-soft);
  color: var(--cyan);
  border-radius: 6px;
  padding: 2px 6px;
  word-break: break-all;
}
.snippet {
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
}
.snippet-bar { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 8px; }
.snippet-bar div { display: flex; gap: 4px; }
.snippet-bar button { color: var(--ink); border-color: var(--line); background: transparent; }
.snippet-bar button.is-on { background: var(--blue); border-color: var(--blue); }
.snippet-pre {
  margin: 0;
  padding: 4px 16px 16px;
  overflow: auto;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 13px; }
th, td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }

.access { display: flex; flex-direction: column; gap: 8px; }
.access-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.fold { border-top: 1px solid var(--line); padding-top: 8px; }
.fold summary { cursor: pointer; color: var(--cyan); font-weight: 500; }
.fold summary::-webkit-details-marker { display: none; }
.fold .stack { margin-top: 12px; }

.feed { display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow: auto; }
.feed-item {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.feed-item time, .feed-item span { color: var(--muted); font-size: 13px; }
.feed-item pre, .plog pre {
  margin: 4px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 12.5px;
}

.play-grid { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 16px; align-items: start; }
.play-log {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 280px;
  max-height: 560px;
  overflow: auto;
  padding: 12px;
}
.play-empty { color: var(--muted); margin: 0; }
.plog { padding: 8px 0; border-bottom: 1px solid var(--line); }
.plog time { color: var(--muted); font-size: 12px; margin-right: 6px; }
.tag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 99px;
  padding: 1px 6px;
  margin-right: 6px;
}
.tag.in { background: var(--green-soft); color: var(--green); }
.tag.out { background: var(--cyan-soft); color: var(--cyan); }
.tag.note { background: var(--purple-soft); color: #c4b5fd; }
.plog p { margin: 4px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 10px;
}
.chip:hover { border-color: var(--cyan); }

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(8, 13, 26, 0.72);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}
.modal { width: min(480px, 100%); box-shadow: var(--shadow); }
.secret-box {
  background: var(--bg);
  color: var(--cyan);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  word-break: break-all;
}
.is-hidden { display: none !important; }

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  background: var(--blue);
  color: var(--ink);
  border-radius: 10px;
  padding: 12px 14px;
  max-width: min(360px, calc(100% - 32px));
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.toast.show { opacity: 1; transform: none; }

.boot, .auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card { width: min(460px, 100%); }

@media (max-width: 900px) {
  .shell { display: block; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: auto;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand user"
      "nav nav";
    align-items: center;
    gap: 4px 12px;
    padding: 12px 12px 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand { grid-area: brand; padding: 0; }
  .nav { grid-area: nav; display: flex; gap: 6px; overflow: auto; flex: none; padding: 0; }
  .nav a { white-space: nowrap; }
  .side-user { grid-area: user; border: 0; padding: 0; }
  .brand small, .side-status, .side-user small, .nav-label { display: none; }
  .page { padding: 20px 16px 56px; }
  .tabs { scroll-margin-top: 96px; }
  .stat-grid, .flow, .row-2, .instance-list, .play-grid, .feed-item { grid-template-columns: 1fr; }
  .arrow { display: none; }
  h1 { font-size: 30px; }
  .title-row, .split, .access-top { flex-direction: column; }
}
