:root {
  --bg:      #0e1116;
  --bg-2:    #151a21;
  --bg-3:    #1b212a;
  --line:    #242c37;
  --line-2:  #313b49;
  --txt:     #e7ebf0;
  --muted:   #8a95a3;
  --faint:   #5b6472;
  --accent:  #34c3d6;
  --accent-2:#1b93a6;
  --accent-ink:#04161a;

  --get:    #4cc38a;
  --post:   #57a5e6;
  --put:    #e0a648;
  --patch:  #b183e0;
  --delete: #e5687a;

  --ok:   #4cc38a;
  --warn: #e0a648;
  --err:  #e5687a;
  --info: #57a5e6;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --r: 7px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body { overflow: hidden; }

a { color: var(--accent); text-decoration: none; }

.app { display: grid; grid-template-rows: 52px 1fr; height: 100vh; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.brand .dot { color: var(--accent); }

.nav { display: flex; gap: 2px; }
.nav a {
  font-size: 13px; color: var(--muted);
  padding: 6px 12px; border-radius: var(--r);
}
.nav a:hover { color: var(--txt); background: var(--bg-3); }
.nav a.active { color: var(--txt); background: var(--bg-3); box-shadow: inset 0 0 0 1px var(--line-2); }

.topbar .spacer { margin-left: auto; }
.logout-form { margin-left: auto; }
.logout-btn {
  font: inherit; font-size: 12px; color: var(--muted);
  background: none; border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 6px 12px; cursor: pointer;
}
.logout-btn:hover { color: var(--txt); border-color: var(--faint); }

/* ---------- Inspector grid ---------- */
.inspector {
  display: grid;
  grid-template-columns: 250px 360px 1fr;
  height: 100%;
  min-height: 0;
}
.col { min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.col.endpoints { background: var(--bg-2); border-right: 1px solid var(--line); }
.col.list      { background: var(--bg); border-right: 1px solid var(--line); }
.col.detail    { background: var(--bg); }

.col-head {
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px; min-height: 46px;
  border-bottom: 1px solid var(--line);
}
.col-head h2 {
  margin: 0; font-size: 11px; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.col-head .path-title { font-family: var(--mono); color: var(--txt); text-transform: none; letter-spacing: 0; }
.clear-all-btn {
  margin-left: auto;
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  color: var(--muted); background: var(--bg-3);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 10px; cursor: pointer; white-space: nowrap;
}
.clear-all-btn:hover { color: var(--err); border-color: var(--err); background: color-mix(in srgb, var(--err) 12%, transparent); }
.clear-all-btn:disabled { opacity: 0.5; cursor: default; }

.scroll { overflow-y: auto; flex: 1; min-height: 0; }
.scroll::-webkit-scrollbar { width: 10px; }
.scroll::-webkit-scrollbar-thumb { background: #2a323d; border-radius: 6px; border: 3px solid transparent; background-clip: padding-box; }

/* ---------- Endpoints ---------- */
.ep {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; cursor: pointer; border-left: 2px solid transparent;
}
.ep:hover { background: var(--bg-3); }
.ep.active { background: var(--bg-3); border-left-color: var(--accent); }
.ep-path {
  flex: 1; min-width: 0;
  font-family: var(--mono); font-size: 12.5px; color: var(--txt);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ep.active .ep-path { color: #fff; }
.ep-count {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  background: #0d1117; border: 1px solid var(--line);
  border-radius: 20px; padding: 0 7px; line-height: 18px;
}
.ep-trash { color: var(--faint); flex: none; padding: 2px 4px; border-radius: 4px; }
.ep-trash:hover { color: var(--err); background: color-mix(in srgb, var(--err) 14%, transparent); }

.col-empty { padding: 24px 16px; color: var(--faint); text-align: center; }

/* ---------- Request rows ---------- */
.req {
  position: relative;
  display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 10px;
  padding: 9px 14px; cursor: pointer; border-bottom: 1px solid #191f27;
}
.req:hover { background: var(--bg-2); }
.req.active { background: var(--bg-3); }
.req.active::before { content: ""; position: absolute; left: 0; width: 2px; height: 100%; background: var(--accent); }

.method { font-family: var(--mono); font-size: 10.5px; font-weight: 700; text-align: center; }
.m-GET { color: var(--get); } .m-POST { color: var(--post); } .m-PUT { color: var(--put); }
.m-PATCH { color: var(--patch); } .m-DELETE { color: var(--delete); }
.m-HEAD, .m-OPTIONS { color: var(--muted); }

.req-mid { min-width: 0; }
.req-time { font-family: var(--mono); font-size: 12px; color: var(--txt); font-variant-numeric: tabular-nums; }
.req-id { font-size: 11px; color: var(--faint); }

.status { font-family: var(--mono); font-size: 11px; font-weight: 700; border-radius: 4px; padding: 1px 6px; }
.status.none { color: var(--faint); background: none; }
.s-2 { color: var(--ok);   background: color-mix(in srgb, var(--ok) 14%, transparent); }
.s-3 { color: var(--info); background: color-mix(in srgb, var(--info) 14%, transparent); }
.s-4 { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.s-5 { color: var(--err);  background: color-mix(in srgb, var(--err) 16%, transparent); }

/* ---------- List tools / live tail ---------- */
.listtools { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.search {
  flex: 1; display: flex; align-items: center; gap: 7px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--r); padding: 5px 9px;
}
.search:focus-within { border-color: var(--accent); }
.search input { background: none; border: 0; color: var(--txt); font-family: var(--mono); font-size: 12px; width: 100%; outline: none; }
.search svg { color: var(--faint); flex: none; }

.live-toggle {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 11px; font-weight: 600; color: var(--ok);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
  border-radius: 20px; padding: 4px 10px; cursor: pointer; white-space: nowrap;
}
.live-toggle.paused { color: var(--muted); background: var(--bg-3); border-color: var(--line); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: pulse 2s infinite; flex: none; }
.live-toggle.paused .live-dot { background: var(--faint); animation: none; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); }
  70%  { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.list-note { padding: 8px 14px; font-size: 11px; color: var(--faint); text-align: center; border-top: 1px solid var(--line); }

.req.new { animation: flyin 1.6s ease-out; }
@keyframes flyin {
  from { background: color-mix(in srgb, var(--accent) 22%, transparent); }
  to   { background: transparent; }
}

/* ---------- Detail ---------- */
.detail-empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--faint); padding: 40px; }
.detail-head { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.detail-title { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.detail-title .method { font-size: 13px; min-width: 46px; }
.detail-title .p { font-family: var(--mono); font-size: 14px; color: #fff; word-break: break-all; }
.detail-sub { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11.5px; color: var(--muted); }
.detail-sub b { color: var(--txt); font-weight: 600; }

.actions { display: flex; gap: 8px; margin-top: 13px; flex-wrap: wrap; }
.btn {
  font: inherit; font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--r); cursor: pointer;
  border: 1px solid var(--line-2); background: var(--bg-3); color: var(--txt);
}
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #45d3e6; }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); background: color-mix(in srgb, var(--err) 12%, transparent); }

.tabs { display: flex; gap: 2px; padding: 10px 14px 0; border-bottom: 1px solid var(--line); }
.tab {
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted);
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 7px 12px 10px; cursor: pointer;
}
.tab:hover { color: var(--txt); }
.tab.active { color: var(--txt); border-bottom-color: var(--accent); }

.pane { padding: 16px 18px; }
.pane.hidden { display: none; }
.section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--faint); margin: 0 0 8px;
}
.section-label + .code + .section-label,
.section-label:not(:first-child) { margin-top: 22px; }

.code {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  background: #0a0d12; border: 1px solid var(--line); border-radius: var(--r);
  padding: 13px 15px; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
  color: #cdd6e0; position: relative; margin: 0;
}
.code .k { color: var(--accent); }
.code .s { color: var(--get); }
.code .n { color: var(--put); }
.code .b { color: var(--patch); }
.code .empty { color: var(--faint); }
.copy-inline {
  position: absolute; top: 8px; right: 8px;
  font-size: 10px; color: var(--muted); background: var(--bg-3);
  border: 1px solid var(--line); border-radius: 5px; padding: 3px 7px; cursor: pointer;
}
.copy-inline:hover { color: var(--txt); border-color: var(--line-2); }

table.headers { width: 100%; border-collapse: collapse; }
table.headers td {
  font-family: var(--mono); font-size: 12px; padding: 6px 10px;
  border-bottom: 1px solid #191f27; vertical-align: top;
}
table.headers td.h-key { color: var(--accent); width: 38%; white-space: nowrap; }
table.headers td.h-val { color: var(--txt); word-break: break-all; }

.resp-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 10px 13px; margin-bottom: 16px;
}
.resp-banner .target { font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-all; }
.resp-banner .err { color: var(--err); font-family: var(--mono); font-size: 12px; }

/* ---------- Config editor ---------- */
.editor { display: grid; grid-template-columns: 300px 1fr; height: 100%; min-height: 0; }
.form { padding: 22px 26px; overflow-y: auto; max-width: 760px; }
.form h1 { font-size: 18px; margin: 0 0 4px; letter-spacing: -0.01em; font-family: var(--mono); }
.form .lead { color: var(--muted); margin: 0 0 22px; font-size: 12.5px; max-width: 60ch; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.field .hint { font-size: 11.5px; color: var(--faint); margin-top: 5px; }
.field .hint code { color: var(--patch); }
.input, .textarea {
  width: 100%; font-family: var(--mono); font-size: 13px; color: var(--txt);
  background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--r);
  padding: 9px 11px; outline: none;
}
.input:focus, .textarea:focus { border-color: var(--accent); }
.textarea { min-height: 140px; resize: vertical; line-height: 1.6; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.55);
  align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 20px; width: min(520px, 92vw);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.modal h3 { margin: 0 0 6px; font-size: 15px; }
.modal p { margin: 0 0 14px; color: var(--muted); font-size: 12.5px; }
.modal .input { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--line-2); border-left: 3px solid var(--accent);
  border-radius: var(--r); padding: 11px 15px; min-width: 240px; max-width: 360px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  animation: toastin 0.25s cubic-bezier(0.2,0.8,0.2,1);
}
.toast.ok  { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast .tt { font-weight: 600; font-size: 12.5px; }
.toast .td { font-size: 11.5px; color: var(--muted); word-break: break-word; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Login ---------- */
.login-wrap { height: 100vh; display: grid; place-items: center; }
.login-card {
  width: min(360px, 92vw);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 28px 26px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.login-card .brand { text-align: center; font-size: 22px; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--faint); font-size: 12px; margin-bottom: 22px; }
.login-card .field { margin-bottom: 14px; }
.login-card .input { font-family: var(--sans); }
.login-error { color: var(--err); font-size: 12px; margin-bottom: 12px; }
.btn.block { width: 100%; justify-content: center; }

/* ---------- Readme / Docs ---------- */
.readme-wrap { overflow-y: auto; padding: 32px 24px 64px; }
.readme {
  max-width: 820px; margin: 0 auto;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 32px 40px;
}
.readme h1, .readme h2, .readme h3, .readme h4 {
  line-height: 1.25; margin: 1.6em 0 0.6em; font-weight: 700;
}
.readme h1 { font-size: 24px; margin-top: 0; }
.readme h2 { font-size: 19px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.readme h3 { font-size: 15px; }
.readme p, .readme ul, .readme ol { margin: 0.7em 0; color: var(--txt); }
.readme ul, .readme ol { padding-left: 1.4em; }
.readme li { margin: 0.3em 0; }
.readme a { color: var(--accent); }
.readme a:hover { text-decoration: underline; }
.readme code {
  font-family: var(--mono); font-size: 12px;
  background: var(--bg-3); border: 1px solid var(--line-2);
  border-radius: 4px; padding: 1px 5px;
}
.readme pre {
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px 16px; overflow-x: auto;
}
.readme pre code { background: none; border: none; padding: 0; }
.readme blockquote {
  margin: 0.9em 0; padding: 4px 16px; color: var(--muted);
  border-left: 3px solid var(--line-2);
}
.readme table { border-collapse: collapse; margin: 1em 0; display: block; overflow-x: auto; }
.readme th, .readme td { border: 1px solid var(--line); padding: 6px 12px; text-align: left; }
.readme th { background: var(--bg-3); }
.readme img { max-width: 100%; }
.readme hr { border: none; border-top: 1px solid var(--line); margin: 1.6em 0; }

@media (max-width: 900px) {
  body { overflow: auto; }
  .inspector, .editor { grid-template-columns: 1fr; }
  .col.endpoints, .editor .col.list { max-height: 30vh; }
  .readme { padding: 22px 20px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
