:root {
  --wh-accent: #5b5bd6;
  --wh-accent-soft: rgba(91, 91, 214, 0.12);
  --wh-bg: #f6f7fb;
  --wh-surface: #ffffff;
  --wh-border: #e6e8ef;
  --wh-muted: #6b7280;
  --wh-code-bg: #f8f9fc;
  --wh-hover: #f1f2f8;
  --json-key: #7c3aed;
  --json-str: #0f766e;
  --json-num: #c2410c;
  --json-bool: #2563eb;
  --json-null: #9ca3af;
  --bs-primary: #5b5bd6;
  --bs-primary-rgb: 91, 91, 214;
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-border-color: var(--wh-border);
}
[data-bs-theme="dark"] {
  --wh-accent: #8b8bf5;
  --wh-accent-soft: rgba(139, 139, 245, 0.16);
  --wh-bg: #0f1117;
  --wh-surface: #161922;
  --wh-border: #262a36;
  --wh-muted: #9aa1b2;
  --wh-code-bg: #11141b;
  --wh-hover: #1d212c;
  --json-key: #c4b5fd;
  --json-str: #5eead4;
  --json-num: #fdba74;
  --json-bool: #93c5fd;
  --json-null: #6b7280;
  --bs-body-bg: #0f1117;
  --bs-primary: #8b8bf5;
  --bs-primary-rgb: 139, 139, 245;
  --bs-border-color: var(--wh-border);
}

html, body { height: 100%; }
body { background: var(--wh-bg); font-size: 14px; overflow: hidden; }
.font-mono, .code-block, .kv-table .k, .kv-table .v { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }

.btn-primary { --bs-btn-bg: var(--wh-accent); --bs-btn-border-color: var(--wh-accent); --bs-btn-hover-bg: #4a4ac4; --bs-btn-hover-border-color: #4a4ac4; --bs-btn-active-bg: #4040b0; }
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0f1117; --bs-btn-hover-color: #0f1117; --bs-btn-hover-bg: #a3a3f8; --bs-btn-hover-border-color: #a3a3f8; }
.btn-icon { border: 1px solid var(--wh-border); background: var(--wh-surface); color: var(--bs-body-color); width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.btn-icon:hover { background: var(--wh-hover); }
.form-control:focus { border-color: var(--wh-accent); box-shadow: 0 0 0 .2rem var(--wh-accent-soft); }

.brand-mark { width: 32px; height: 32px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 16px;
  background: linear-gradient(135deg, #5b5bd6 0%, #8b5cf6 100%); box-shadow: 0 4px 12px rgba(91, 91, 214, .35); }

/* ---------- login ---------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; overflow: auto; padding: 16px;
  background: radial-gradient(1200px 600px at 10% -10%, var(--wh-accent-soft), transparent), var(--wh-bg); }
.login-card { width: 100%; max-width: 400px; border-radius: 16px; background: var(--wh-surface); }

/* ---------- top bar ---------- */
.topbar { height: 60px; display: flex; align-items: center; padding: 0 16px; background: var(--wh-surface); }
.url-box { max-width: 760px; }
.url-box .form-control { background: var(--wh-code-bg); font-size: 12.5px; }
.url-box .input-group-text { background: var(--wh-surface); color: var(--wh-muted); font-size: 12.5px; }

.live-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--wh-border); color: var(--wh-muted); white-space: nowrap; }
.live-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; }
.live-pill.online { color: #15803d; border-color: rgba(34, 197, 94, .35); background: rgba(34, 197, 94, .08); }
[data-bs-theme="dark"] .live-pill.online { color: #4ade80; }
.live-pill.online .dot { background: #22c55e; animation: pulse 2s infinite; }
.live-pill.offline .dot { background: #f59e0b; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.6); } 70% { box-shadow: 0 0 0 7px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
@media (max-width: 575.98px) { .live-pill .label { display: none; } .live-pill { padding: 6px; } }

/* ---------- layout ---------- */
.app-shell { display: flex; height: calc(100vh - 60px); }
.sidebar { width: 360px; flex-shrink: 0; display: flex; flex-direction: column; background: var(--wh-surface); }
.sidebar-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--wh-border); }
.request-list { overflow-y: auto; flex: 1; }
.detail { flex: 1; min-width: 0; overflow-y: auto; }

.chip { border: 1px solid var(--wh-border); background: transparent; color: var(--wh-muted); font-size: 11.5px; font-weight: 500; padding: 2px 10px; border-radius: 999px; }
.chip:hover { background: var(--wh-hover); }
.chip.active { background: var(--wh-accent-soft); border-color: transparent; color: var(--wh-accent); }

/* ---------- request list items ---------- */
.req-item { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--wh-border); background: transparent; padding: 11px 14px; color: inherit; position: relative; }
.req-item:hover { background: var(--wh-hover); }
.req-item.active { background: var(--wh-accent-soft); }
.req-item.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--wh-accent); }
.req-item .row1 { display: flex; align-items: center; gap: 8px; }
.req-item .path { font-family: "JetBrains Mono", monospace; font-size: 12.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-item .time { font-size: 11.5px; color: var(--wh-muted); white-space: nowrap; }
.req-item .row2 { display: flex; gap: 10px; margin-top: 4px; font-size: 11.5px; color: var(--wh-muted); }
.req-item .preview { font-family: "JetBrains Mono", monospace; font-size: 11.5px; color: var(--wh-muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-item.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: rgba(34, 197, 94, .18); } to { background: transparent; } }
.list-empty { padding: 32px 16px; text-align: center; color: var(--wh-muted); font-size: 13px; }

.method-badge { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .03em; padding: 2px 7px; border-radius: 6px; min-width: 52px; text-align: center; font-family: "JetBrains Mono", monospace; }
.m-POST   { background: rgba(34,197,94,.14);  color: #15803d; }
.m-GET    { background: rgba(59,130,246,.14); color: #1d4ed8; }
.m-PUT    { background: rgba(245,158,11,.16); color: #b45309; }
.m-PATCH  { background: rgba(168,85,247,.14); color: #7e22ce; }
.m-DELETE { background: rgba(239,68,68,.14);  color: #b91c1c; }
.m-OTHER  { background: rgba(107,114,128,.16); color: #4b5563; }
[data-bs-theme="dark"] .m-POST { color: #4ade80; } [data-bs-theme="dark"] .m-GET { color: #93c5fd; }
[data-bs-theme="dark"] .m-PUT { color: #fcd34d; } [data-bs-theme="dark"] .m-PATCH { color: #d8b4fe; }
[data-bs-theme="dark"] .m-DELETE { color: #fca5a5; } [data-bs-theme="dark"] .m-OTHER { color: #d1d5db; }

/* ---------- detail ---------- */
.detail-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 12px 24px; background: var(--wh-surface); border-bottom: 1px solid var(--wh-border); min-width: 0; }
.detail-body { padding: 20px 24px 40px; max-width: 1200px; }
.meta-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
@media (max-width: 1199.98px) { .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.meta-card { background: var(--wh-surface); border: 1px solid var(--wh-border); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.meta-label { font-size: 11.5px; color: var(--wh-muted); font-weight: 500; margin-bottom: 4px; }
.meta-label i { margin-right: 3px; }
.meta-value { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-sub { font-size: 11.5px; color: var(--wh-muted); }

.nav-underline .nav-link { color: var(--wh-muted); font-weight: 500; font-size: 13.5px; }
.nav-underline .nav-link.active { color: var(--wh-accent); border-bottom-color: var(--wh-accent); }
[data-bs-theme="dark"] .badge.text-bg-light { background: var(--wh-hover) !important; color: var(--wh-muted) !important; }

.code-block { background: var(--wh-code-bg); border: 1px solid var(--wh-border); border-radius: 12px; padding: 16px 18px; font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; color: var(--bs-body-color); max-height: none; }
.card .code-block { border: 0; border-radius: 0 0 12px 12px; }
.j-key { color: var(--json-key); } .j-str { color: var(--json-str); } .j-num { color: var(--json-num); }
.j-bool { color: var(--json-bool); font-weight: 500; } .j-null { color: var(--json-null); font-style: italic; }
.code-empty { color: var(--wh-muted); font-style: italic; font-family: "Inter", sans-serif; }

.kv-table { border: 1px solid var(--wh-border); border-radius: 12px; overflow: hidden; background: var(--wh-surface); }
.kv-row { display: grid; grid-template-columns: minmax(140px, 32%) 1fr; border-bottom: 1px solid var(--wh-border); }
.kv-row:last-child { border-bottom: 0; }
.kv-row:hover { background: var(--wh-hover); }
.kv-table .k { padding: 9px 14px; font-size: 12px; color: var(--json-key); font-weight: 500; word-break: break-all; }
.kv-table .v { padding: 9px 14px; font-size: 12px; word-break: break-all; border-left: 1px solid var(--wh-border); }
.kv-empty { padding: 20px; text-align: center; color: var(--wh-muted); }

/* ---------- empty state ---------- */
.empty-state { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 24px; }
.empty-icon { width: 72px; height: 72px; border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 32px; color: var(--wh-accent); background: var(--wh-accent-soft); margin-bottom: 18px; }
.empty-state .card { background: var(--wh-surface); border-radius: 12px; }

.toast { background: var(--bs-body-color); color: var(--wh-surface); }
.toast .btn-close { filter: invert(1); }
[data-bs-theme="dark"] .toast .btn-close { filter: none; }

/* ---------- mobile: list OR detail ---------- */
@media (max-width: 991.98px) {
  .sidebar { width: 100%; border-right: 0 !important; }
  .detail { display: none; }
  body.show-detail .sidebar { display: none; }
  body.show-detail .detail { display: block; }
  .detail-head, .detail-body { padding-left: 16px; padding-right: 16px; }
  .topbar { padding: 0 12px; }
}
.btn-link { --bs-btn-color: var(--wh-accent); --bs-btn-hover-color: var(--wh-accent); }
