:root {
  /* Surfaces — layered dark slate with a faint cool undertone */
  --bg: #0b0e14;
  --bg-elev: #0f1320;
  --panel: #141925;
  --panel2: #1b2230;
  --panel3: #222b3b;
  --border: #28323f;
  --border-soft: #1f2733;
  --hairline: rgba(255,255,255,0.06);

  /* Text */
  --text: #e8ecf3;
  --text-dim: #b3bdcc;
  --muted: #7d8a9c;
  --faint: #5a6573;

  /* Brand / accents */
  --accent: #5b9dff;
  --accent-bright: #7db4ff;
  --accent-deep: #2f6fe0;
  --accent-grad: linear-gradient(135deg, #5b9dff 0%, #6f7bff 100%);
  --accent-glow: rgba(91,157,255,0.35);

  --green: #46c66a;
  --amber: #e0a82e;
  --red: #ff5d5d;
  --purple: #c678dd;
  --cyan: #56b6c2;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, "Cascadia Code", "JetBrains Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --code-bg: #0a0d14;
  --gutter: #3c4554;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.35);
  --shadow-lg: 0 24px 60px rgba(0,0,0,0.55);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image:
    radial-gradient(900px 500px at 15% -10%, rgba(91,157,255,0.10), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(111,123,255,0.08), transparent 55%);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s var(--ease); }
a:hover { color: var(--accent-bright); text-decoration: none; }

h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; margin: 0 0 20px; }
h2 { letter-spacing: -0.01em; }
h3 {
  font-size: 12px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); margin: 20px 0 8px;
}

/* ---------- Buttons ---------- */
button {
  background: var(--accent-grad);
  color: #fff; border: 0; border-radius: var(--radius-sm);
  padding: 8px 15px; cursor: pointer;
  font: 600 13.5px/1 var(--sans); letter-spacing: 0.01em;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.18);
  transition: transform 0.12s var(--ease), box-shadow 0.15s var(--ease), filter 0.15s var(--ease);
}
button:hover { filter: brightness(1.08); box-shadow: 0 4px 14px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.2); }
button:active { transform: translateY(1px); filter: brightness(0.98); }
button:disabled { opacity: 0.55; cursor: default; filter: none; box-shadow: none; }

button.ghost {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text-dim);
  box-shadow: var(--shadow-sm);
}
button.ghost:hover { background: var(--panel3); border-color: var(--accent); color: var(--text); filter: none; box-shadow: var(--shadow-sm); }
button.danger {
  background: transparent; border: 1px solid rgba(255,93,93,0.4); color: var(--red); box-shadow: none;
}
button.danger:hover { background: rgba(255,93,93,0.1); border-color: var(--red); filter: none; box-shadow: none; }

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

/* ---------- Inputs ---------- */
input, textarea, select {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 11px; font-size: 14px; width: 100%;
  font-family: var(--sans);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,157,255,0.16);
  background: var(--panel);
}
label { display: block; margin: 8px 0; color: var(--muted); font-size: 13px; }
label input { margin-top: 5px; }

/* ---------- Cards / layout ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow-md);
}
.centered { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login { width: 340px; }
.error { color: var(--red); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }

header.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 22px; border-bottom: 1px solid var(--border-soft);
  background: rgba(15,19,32,0.78);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  position: sticky; top: 0; z-index: 20;
}
.topbar strong { letter-spacing: -0.01em; }

/* Brand mark */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -0.01em; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: var(--accent-grad); color: #fff; flex: none;
  box-shadow: 0 2px 8px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.25);
}
.brand-mark svg { width: 15px; height: 15px; display: block; }

.wrap { padding: 28px 22px; max-width: 1180px; margin: 0 auto; }
.row { display: flex; gap: 10px; align-items: center; }

/* ---------- Bucket list (dashboard) ---------- */
.bucket-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.bucket-list li {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; justify-content: space-between; align-items: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.18s var(--ease);
}
.bucket-list li:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 10px 28px rgba(0,0,0,0.4), 0 0 0 1px rgba(91,157,255,0.18);
}
.bucket-list li a strong { font-size: 15px; letter-spacing: -0.01em; }
.bucket-list .count {
  font-family: var(--mono); font-size: 12px; color: var(--text-dim);
  background: var(--panel2); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 12px; white-space: nowrap;
}

/* Generic empty state */
.empty-state {
  text-align: center; padding: 56px 24px; color: var(--muted);
  border: 1px dashed var(--border); border-radius: var(--radius); background: rgba(20,25,37,0.5);
}
.empty-state .ico { color: var(--faint); margin-bottom: 14px; }
.empty-state .ico svg { width: 40px; height: 40px; }
.empty-state strong { display: block; color: var(--text-dim); font-size: 15px; margin-bottom: 6px; font-weight: 600; }

/* ---------- Split view (bucket page) ---------- */
.split { display: grid; grid-template-columns: 380px 1fr; gap: 0; height: calc(100vh - 124px); }
.reqlist { overflow-y: auto; border-right: 1px solid var(--border-soft); background: rgba(11,14,20,0.35); }
.reqlist .item {
  padding: 12px 16px; border-bottom: 1px solid var(--border-soft); cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.12s var(--ease), border-color 0.12s var(--ease);
}
.reqlist .item:hover { background: var(--panel2); }
.reqlist .item.active {
  background: linear-gradient(90deg, rgba(91,157,255,0.12), rgba(91,157,255,0.03));
  border-left-color: var(--accent);
}
.detail { overflow-y: auto; padding: 22px 26px; }
.detail > .row:first-child { gap: 10px; }

/* ---------- Badges ---------- */
.badge {
  font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 3px 8px;
  border-radius: 5px; background: var(--panel2); border: 1px solid var(--border);
  letter-spacing: 0.02em;
}
/* Method badges get a tinted pill */
.m-GET    { color: var(--green);  background: rgba(70,198,106,0.12);  border-color: rgba(70,198,106,0.3); }
.m-POST   { color: var(--accent); background: rgba(91,157,255,0.13);  border-color: rgba(91,157,255,0.32); }
.m-PUT,
.m-PATCH  { color: var(--amber);  background: rgba(224,168,46,0.12);  border-color: rgba(224,168,46,0.3); }
.m-DELETE { color: var(--red);    background: rgba(255,93,93,0.12);   border-color: rgba(255,93,93,0.3); }

/* Live connection indicator */
#live {
  display: inline-flex; align-items: center; gap: 6px;
  transition: color 0.2s var(--ease);
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.live-dot.on { animation: livePulse 1.9s var(--ease) infinite; }
@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 rgba(70,198,106,0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(70,198,106,0); }
  100% { box-shadow: 0 0 0 0 rgba(70,198,106,0); }
}

pre {
  background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 13px; overflow-x: auto; font-family: var(--mono); font-size: 12px;
  white-space: pre-wrap; word-break: break-word;
}

/* Key/value tables (headers) */
table.kv { width: 100%; border-collapse: collapse; }
table.kv td { padding: 6px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: top; font-size: 12px; }
table.kv tr:last-child td { border-bottom: 0; }
table.kv td:first-child { color: var(--accent-bright); font-family: var(--mono); white-space: nowrap; width: 1%; }
table.kv tr:hover td { background: rgba(255,255,255,0.02); }

/* Copyable capture URL bar */
.copy {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 10px 10px 14px; display: flex; justify-content: space-between; gap: 12px;
  align-items: center; box-shadow: var(--shadow-sm);
}
.copy .mono { color: var(--text-dim); overflow-x: auto; white-space: nowrap; }

/* ---------- Body / code panel ---------- */
.body-panel {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 4px;
  box-shadow: var(--shadow-sm);
}
.body-header {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel2) 100%);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.body-header .grow { flex: 1; }
.body-header .ct { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.body-header .sep { color: var(--border); }
.ghost-sm {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 5px; padding: 4px 10px; font-size: 11px; cursor: pointer;
  font-family: inherit; box-shadow: none;
  transition: color 0.12s var(--ease), border-color 0.12s var(--ease), background 0.12s var(--ease);
}
.ghost-sm:hover { color: var(--text); border-color: var(--accent); background: rgba(91,157,255,0.06); filter: none; box-shadow: none; }
.ghost-sm.active {
  color: var(--accent); border-color: var(--accent);
  background: rgba(91,157,255,0.1);
}
.lang-badge {
  font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  padding: 3px 8px; border-radius: 5px;
  background: rgba(91,157,255,0.14); color: var(--accent);
  border: 1px solid rgba(91,157,255,0.3);
}
.lang-badge.lang-xml, .lang-badge.lang-html {
  background: rgba(224,168,46,0.12); color: var(--amber);
  border-color: rgba(224,168,46,0.35);
}
.lang-badge.lang-form {
  background: rgba(70,198,106,0.12); color: var(--green);
  border-color: rgba(70,198,106,0.35);
}
.lang-badge.lang-text {
  background: rgba(125,138,156,0.12); color: var(--muted);
  border-color: rgba(125,138,156,0.35);
}
.lang-badge.lang-yaml {
  background: rgba(198,120,221,0.12); color: var(--purple);
  border-color: rgba(198,120,221,0.35);
}

.code-area { max-height: 600px; overflow: auto; background: var(--code-bg); }
.code-pre {
  margin: 0; padding: 0; background: transparent; border: 0; border-radius: 0;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  counter-reset: line;
  color: #abb2bf;
}
.code-pre.nowrap { white-space: pre; }
.code-content { display: block; padding: 10px 0; }
.code-line {
  display: block;
  padding-left: 60px; padding-right: 14px;
  position: relative;
  min-height: 1.65em;
}
.code-line::before {
  counter-increment: line;
  content: counter(line);
  position: absolute; left: 0; top: 0;
  width: 46px;
  text-align: right; padding-right: 12px;
  color: var(--gutter); user-select: none;
  font-size: 11px; line-height: 1.65;
  border-right: 1px solid var(--border-soft);
}
.code-line:hover { background: rgba(255,255,255,0.03); }

.empty-body {
  padding: 36px 16px; text-align: center;
  color: var(--muted); font-style: italic; font-size: 13px;
}

/* Token colours (One Dark inspired) */
.tok.key      { color: #e06c75; }
.tok.string   { color: #98c379; }
.tok.number   { color: #d19a66; }
.tok.boolean  { color: var(--cyan); font-weight: 500; }
.tok.null     { color: var(--cyan); font-style: italic; }
.tok.punct    { color: #abb2bf; }
.tok.tag      { color: #e06c75; }
.tok.attr     { color: #d19a66; }
.tok.comment  { color: #5c6370; font-style: italic; }
.tok.cdata, .tok.decl { color: var(--purple); }

/* ---------- Filter bar ---------- */
.filterbar {
  display: flex; gap: 8px; align-items: center; padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(15,19,32,0.9);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 2;
}
.filterbar input.search { flex: 1; padding: 7px 11px; font-size: 13px; }
.filterbar select { width: auto; padding: 7px 9px; font-size: 13px; }
.reqlist .item .fwd { font-family: var(--mono); font-size: 10px; margin-left: 6px;
  padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); }
.fwd-ok { color: var(--green); border-color: rgba(70,198,106,0.4) !important; background: rgba(70,198,106,0.08); }
.fwd-bad { color: var(--red); border-color: rgba(255,93,93,0.4) !important; background: rgba(255,93,93,0.08); }
.fwd-pending { color: var(--amber); border-color: rgba(224,168,46,0.4) !important; background: rgba(224,168,46,0.08); }
/* Pulse a freshly-arrived live item. */
@keyframes flash {
  0% { background: rgba(91,157,255,0.22); border-left-color: var(--accent); }
  100% { background: transparent; border-left-color: transparent; }
}
.reqlist .item.new { animation: flash 1.3s var(--ease); }

/* ---------- Modal / settings ---------- */
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,7,11,0.6);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 50;
  animation: backdropIn 0.15s var(--ease);
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  width: 560px; max-width: calc(100vw - 32px); max-height: calc(100vh - 64px);
  overflow-y: auto; padding: 24px 26px; box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s var(--ease);
}
.modal h2 { margin: 0 0 4px; font-size: 17px; letter-spacing: -0.01em; }
.modal .hint { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; line-height: 1.5; }
.modal label { color: var(--text-dim); font-size: 12px; font-weight: 500; margin: 16px 0 5px; }
.modal textarea { font-family: var(--mono); font-size: 12px; resize: vertical; min-height: 68px; }
.modal .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal .actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 22px; }
.modal .actions .right { display: flex; gap: 8px; }
.field-err { color: var(--red); font-size: 12px; min-height: 16px; }

/* Forward / replay panel in the detail pane */
.fwd-box { background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.fwd-row { display: flex; gap: 8px; align-items: center; }
.fwd-row input { flex: 1; }
.replay-result { margin-top: 10px; }

/* Form-encoded body table */
.form-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12.5px; }
.form-table tr { border-bottom: 1px solid var(--border-soft); }
.form-table tr:last-child { border-bottom: 0; }
.form-table tr:hover { background: rgba(255,255,255,0.02); }
.form-table td { padding: 8px 14px; vertical-align: top; }
.form-table td.k { color: #e06c75; white-space: nowrap; width: 1%; border-right: 1px solid var(--border-soft); }
.form-table td.v { color: #98c379; word-break: break-word; }

/* ---------- Scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--panel3) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--panel3); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #2f3a4d; background-clip: padding-box; border: 3px solid transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .split { grid-template-columns: 1fr; height: auto; }
  .reqlist { border-right: 0; border-bottom: 1px solid var(--border-soft); max-height: 45vh; }
  .modal .grid2 { grid-template-columns: 1fr; }
}

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