:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #1c2430;
  --muted: #5f6b7a;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --ok: #15803d;
  --ok-bg: #e3f5e9;
  --err: #b91c1c;
  --err-bg: #fde8e8;
  --warn: #92600a;
  --get: #0e7490;
  --post: #6d28d9;
  --other: #475569;
  --code-key: #7c3aed;
  --code-str: #0f766e;
  --code-num: #b45309;
  --code-bool: #be185d;
  --code-null: #64748b;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

:root[data-theme='dark'] {
  --bg: #0f141b;
  --surface: #171e27;
  --surface-2: #1f2833;
  --border: #2d3947;
  --text: #e6ebf2;
  --muted: #94a1b2;
  --accent: #6ea0ff;
  --accent-ink: #0b1220;
  --ok: #4ade80;
  --ok-bg: #12301f;
  --err: #f87171;
  --err-bg: #3a1717;
  --warn: #f5b84a;
  --get: #38bdf8;
  --post: #b69cff;
  --other: #a3b0c2;
  --code-key: #c4a8ff;
  --code-str: #5eead4;
  --code-num: #fbbf24;
  --code-bool: #f472b6;
  --code-null: #94a3b8;
  --shadow: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f141b;
    --surface: #171e27;
    --surface-2: #1f2833;
    --border: #2d3947;
    --text: #e6ebf2;
    --muted: #94a1b2;
    --accent: #6ea0ff;
    --accent-ink: #0b1220;
    --ok: #4ade80;
    --ok-bg: #12301f;
    --err: #f87171;
    --err-bg: #3a1717;
    --warn: #f5b84a;
    --get: #38bdf8;
    --post: #b69cff;
    --other: #a3b0c2;
    --code-key: #c4a8ff;
    --code-str: #5eead4;
    --code-num: #fbbf24;
    --code-bool: #f472b6;
    --code-null: #94a3b8;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

code, pre, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 16px; font-weight: 650; }
.privacy { color: var(--muted); font-size: 12px; }
.topbar-actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }

.btn {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 2px 8px; font-size: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Landing */
.landing { max-width: 640px; margin: 48px auto; }
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.drag { border-color: var(--accent); background: var(--surface-2); }
.dz-title { font-size: 18px; font-weight: 600; margin: 0 0 8px; }
.dz-sub { color: var(--muted); margin: 8px 0; }
.paste { margin-top: 20px; }
.paste summary { cursor: pointer; color: var(--muted); }
.paste textarea {
  display: block;
  width: 100%;
  margin: 10px 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
}
.hint { color: var(--err); margin-top: 16px; }

/* Header blocks */
.session-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
}
.session-bar strong { color: var(--text); }
.chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: var(--shadow);
}
.stat .v { font-size: 20px; font-weight: 650; line-height: 1.2; }
.stat .l { color: var(--muted); font-size: 12px; }
.stat.bad .v { color: var(--err); }

/* Minimap */
.minimap-wrap { margin-bottom: 16px; }
.minimap {
  position: relative;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
}
.mm-tick {
  position: absolute;
  top: 5px;
  bottom: 5px;
  width: 4px;
  margin-inline-start: -2px;
  border-radius: 2px;
  background: var(--ok);
  opacity: 0.75;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.mm-tick.error { background: var(--err); opacity: 1; top: 2px; bottom: 2px; }
.mm-tick:hover, .mm-tick.active { opacity: 1; outline: 2px solid var(--accent); z-index: 2; }
.minimap-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 2px; }

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  position: sticky;
  top: 52px;
  z-index: 10;
  padding: 8px 0;
  background: var(--bg);
}
.filters input[type='search'], .filters select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.filters input[type='search'] { flex: 1 1 260px; min-width: 0; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.count { color: var(--muted); margin-inline-start: auto; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-start: 11px;
  width: 2px;
  background: var(--border);
}
.gap {
  position: relative;
  padding: 4px 0 4px 36px;
  color: var(--muted);
  font-size: 12px;
}
.gap.long { color: var(--warn); font-weight: 600; }
.item { position: relative; padding-inline-start: 36px; margin: 0 0 6px; }
.item::before {
  content: '';
  position: absolute;
  inset-inline-start: 5px;
  top: 14px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ok);
  border: 3px solid var(--bg);
  box-sizing: border-box;
  width: 16px;
  height: 16px;
  inset-inline-start: 4px;
}
.item.error::before { background: var(--err); }
.item.unknown::before { background: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  scroll-margin-top: 110px;
}
.item.error .card { border-color: var(--err); }
.item.flash .card { outline: 2px solid var(--accent); }
.card > summary {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.card > summary::-webkit-details-marker { display: none; }
.card > summary::before {
  content: '\25B8';
  color: var(--muted);
  transition: transform 0.12s;
}
.card[open] > summary::before { transform: rotate(90deg); }
.idx { color: var(--muted); font-size: 12px; min-width: 2.2em; }
.name { font-weight: 650; }
.badge {
  display: inline-block;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid currentColor;
}
.badge.GET { color: var(--get); }
.badge.POST { color: var(--post); }
.badge.other { color: var(--other); }
.badge.ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.badge.error { color: var(--err); background: var(--err-bg); border-color: transparent; }
.badge.unknown { color: var(--muted); }
.path { color: var(--muted); overflow-wrap: anywhere; flex: 1 1 200px; }
.time { color: var(--muted); font-variant-numeric: tabular-nums; margin-inline-start: auto; }
.errline { flex-basis: 100%; color: var(--err); padding-inline-start: 1.4em; }

.detail { border-top: 1px solid var(--border); padding: 12px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 5px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.tab[aria-selected='true'] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab .n { color: var(--muted); font-weight: 400; font-size: 11px; }
.pane[hidden] { display: none; }
.pane-tools { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv a { color: var(--accent); }
.section-title { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.section-title:first-child { margin-top: 0; }

/* JSON tree */
.json { margin: 0; padding: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.55; }
.json details { margin: 0; }
.json details > summary { list-style: none; cursor: pointer; }
.json details > summary::-webkit-details-marker { display: none; }
.json details > summary::before { content: '\25B8'; display: inline-block; width: 1em; color: var(--muted); }
.json details[open] > summary::before { content: '\25BE'; }
.json .children { margin-inline-start: 1.1em; border-inline-start: 1px dotted var(--border); padding-inline-start: 0.7em; }
.json .leaf { padding-inline-start: 1em; }
.k { color: var(--code-key); }
.s { color: var(--code-str); overflow-wrap: anywhere; white-space: pre-wrap; }
.num { color: var(--code-num); }
.bool { color: var(--code-bool); }
.nul { color: var(--code-null); }
.hint-inline { color: var(--muted); }
.json .more { color: var(--accent); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

pre.raw {
  margin: 0;
  padding: 10px;
  background: var(--surface-2);
  border-radius: 6px;
  max-height: 520px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.empty-pane { color: var(--muted); font-style: italic; }
.empty { text-align: center; color: var(--muted); padding: 32px; }

.toast {
  position: fixed;
  inset-block-end: 16px;
  inset-inline-start: 50%;
  transform: translate(-50%, 20px);
  background: var(--text);
  color: var(--bg);
  padding: 6px 14px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  main { padding: 12px; }
  .filters { top: 88px; }
  .time { margin-inline-start: 0; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
}
