:root {
  --bg: #f3f5f7;
  --card: #ffffff;
  --line: #e1e6ea;
  --text: #1c2730;
  --muted: #6b7c88;
  --accent: #007acd;
  --accent-light: #e7f1fb;
  --mock: #8a5a00;
  --mock-bg: #fff4d6;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
code { font-family: var(--mono); font-size: 12px; background: #eef1f4; padding: 1px 4px; border-radius: 3px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; margin: 0 0 10px; color: #3b4a55; }
.muted { color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; margin: -4px 0 10px; line-height: 1.45; }
.error { color: #c62828; font-size: 12px; min-height: 1em; margin: 6px 0 0; }

/* ── Topbar ─────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__nav { display: flex; align-items: center; gap: 16px; }
.topbar__nav a { color: var(--muted); text-decoration: none; font-weight: 600; }
.topbar__nav a.is-active, .topbar__nav a:hover { color: var(--accent); }
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  background: var(--accent-light); color: var(--accent);
  font-size: 11px; font-weight: 700;
}
.pill--mock { background: var(--mock-bg); color: var(--mock); }

/* ── Layout ─────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr) 420px;
  gap: 16px;
  padding: 16px;
  align-items: start;
}
.panel { display: flex; flex-direction: column; gap: 16px; }
.panel--events { position: sticky; top: 66px; max-height: calc(100vh - 82px); }
.stage { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stage__frame {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 16px;
  overflow: hidden;
}
@media (max-width: 1350px) {
  .layout { grid-template-columns: 330px minmax(0, 1fr); }
  .panel--events { grid-column: 1 / -1; position: static; max-height: none; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

/* ── Cards ──────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}
.card--grow { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card__head h2 { margin: 0; }
.card--code pre { margin: 0; max-height: 320px; overflow: auto; background: #0f1c24; color: #d7e3ea; border-radius: 8px; padding: 12px; font-size: 12px; line-height: 1.5; }
.card--code code { background: none; color: inherit; padding: 0; }

/* ── Form controls ──────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; border: 0; padding: 0; font-weight: 600; font-size: 12px; color: #3b4a55; }
.field legend { padding: 0; margin-bottom: 6px; }
.field--inline { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
.field select, .field input[type="range"] { font: inherit; font-weight: 400; }
.field select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.check { display: flex; gap: 6px; align-items: center; font-weight: 400; margin: 3px 0; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg label {
  font-weight: 400; display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
}
.seg label:has(input:checked) { border-color: var(--accent); background: var(--accent-light); color: var(--accent); }
.seg input { margin: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; cursor: pointer; font: inherit; font-size: 12px;
}
.swatch.is-active { border-color: var(--text); }
.swatch i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
textarea {
  width: 100%; min-height: 260px; resize: vertical;
  font-family: var(--mono); font-size: 11px; line-height: 1.4;
  border: 1px solid var(--line); border-radius: 6px; padding: 8px;
}

.row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.row--tight { margin: 0; }
.btn {
  font: inherit; font-size: 12px; font-weight: 600;
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
}
.btn:hover { filter: brightness(1.08); }
.btn--ghost { background: #fff; color: var(--accent); }
.btn--ghost:hover { background: var(--accent-light); filter: none; }
.btn--sm { padding: 3px 8px; font-size: 11px; }

/* ── Demo cases ─────────────────────────────────── */
.cases { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 6px; }
.case {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.case:hover { border-color: var(--accent); }
.case.is-active { border-color: var(--accent); background: var(--accent-light); }
.case__title { font-weight: 700; font-size: 13px; }
.case__desc { color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.4; }
.case__tags { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.case__tags span { font-family: var(--mono); font-size: 10px; background: #eef1f4; padding: 1px 5px; border-radius: 3px; color: #3b4a55; }

/* ── Event console ──────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.filters label {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 2px 6px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer;
}
.filters label:has(input:not(:checked)) { opacity: .45; }
.filters input { margin: 0; }
.events {
  list-style: none; margin: 0; padding: 0;
  overflow: auto; flex: 1; min-height: 240px; max-height: 60vh;
  font-family: var(--mono); font-size: 11.5px;
  border-top: 1px solid var(--line);
}
.ev { border-bottom: 1px solid var(--line); }
.ev summary { display: grid; grid-template-columns: 62px 168px 1fr; gap: 6px; padding: 5px 2px; cursor: pointer; list-style: none; align-items: baseline; }
.ev summary::-webkit-details-marker { display: none; }
.ev summary:hover { background: #f7f9fa; }
.ev__time { color: var(--muted); }
.ev__type { font-weight: 700; }
.ev__sum { color: #3b4a55; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev pre { margin: 0 0 6px; padding: 8px; background: #0f1c24; color: #d7e3ea; border-radius: 6px; max-height: 320px; overflow: auto; font-size: 11px; }
.ev--new { animation: flash 1s ease; }
@keyframes flash { from { background: #fff7d1; } to { background: transparent; } }
.cat-cycle .ev__type { color: #6a1b9a; }
.cat-nav .ev__type { color: #00796b; }
.cat-answer .ev__type { color: #1565c0; }
.cat-estimation .ev__type { color: #e65100; }
.cat-error .ev__type { color: #c62828; }
.cat-api .ev__type { color: #5d6d7a; }
.payload { margin: 0; max-height: 220px; overflow: auto; font-family: var(--mono); font-size: 11px; background: #f7f9fa; border-radius: 6px; padding: 8px; }
