:root {
  --bg: #0a0c10;
  --panel: #11141a;
  --panel-2: #171b22;
  --line: #262c36;
  --line-bright: #394252;
  --text: #f3f5f7;
  --muted: #8d97a7;
  --accent: #a7f34b;
  --accent-ink: #122000;
  --blue: #65a8ff;
  --orange: #ffad5a;
  --red: #ff6b6b;
  --purple: #c99aff;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 70% -20%, #20311b 0, transparent 28rem), var(--bg); }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
code, pre, kbd { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.topbar { height: 64px; padding: 0 22px; border-bottom: 1px solid var(--line); background: rgba(10, 12, 16, .88); backdrop-filter: blur(18px); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; }
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--accent-ink); background: var(--accent); font-weight: 900; box-shadow: 0 0 28px #a7f34b33; }
.brand strong, .brand small { display: block; line-height: 1.05; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 4px; letter-spacing: .08em; text-transform: uppercase; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; font-size: 12px; }
.status-pill i { width: 7px; height: 7px; background: var(--orange); border-radius: 50%; box-shadow: 0 0 10px currentColor; }
.status-pill.online { color: var(--accent); }
.status-pill.online i { background: var(--accent); }
.status-pill.offline { color: var(--red); }
.status-pill.offline i { background: var(--red); }
.identity-select { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.identity-select select { color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 26px 7px 9px; }

.layout { min-height: calc(100vh - 64px); display: grid; grid-template-columns: 330px minmax(0, 1fr); }
.sidebar { border-right: 1px solid var(--line); background: #0d1015; position: sticky; top: 64px; height: calc(100vh - 64px); overflow: auto; }
.tabs { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: 1fr 1fr; padding: 14px; gap: 5px; background: #0d1015; }
.tab, .filter { border: 0; color: var(--muted); background: transparent; border-radius: 8px; padding: 9px; font-size: 12px; font-weight: 650; }
.tab.active, .filter.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); }
.side-view { padding: 0 14px 24px; }
.side-heading { display: flex; justify-content: space-between; align-items: flex-start; padding: 10px 4px 16px; }
.side-heading strong, .side-heading small { display: block; }
.side-heading small { color: var(--muted); font-size: 11px; margin-top: 4px; }
.side-heading > span { color: var(--accent); font-size: 12px; }

.workflow-list { padding: 0; margin: 0; list-style: none; display: grid; gap: 5px; counter-reset: steps; }
.workflow-item { position: relative; counter-increment: steps; }
.workflow-item button { width: 100%; border: 1px solid transparent; border-radius: 10px; color: var(--text); background: transparent; text-align: left; display: grid; grid-template-columns: 28px 1fr 18px; gap: 9px; padding: 10px 8px; }
.workflow-item button:hover, .workflow-item.active button { background: var(--panel-2); border-color: var(--line); }
.step-number { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); background: var(--panel); font-size: 11px; }
.step-number::before { content: counter(steps); }
.workflow-item.complete .step-number { color: var(--accent-ink); background: var(--accent); }
.workflow-item.complete .step-number::before { content: "✓"; }
.workflow-copy strong, .workflow-copy small { display: block; }
.workflow-copy strong { font-size: 13px; }
.workflow-copy small { color: var(--muted); font-size: 11px; line-height: 1.35; margin-top: 3px; }
.step-arrow { color: var(--line-bright); align-self: center; }

.search { height: 39px; border: 1px solid var(--line); border-radius: 10px; display: flex; align-items: center; gap: 7px; padding: 0 10px; background: var(--panel); }
.search span { color: var(--muted); font-size: 20px; transform: translateY(-1px); }
.search input { min-width: 0; flex: 1; color: var(--text); border: 0; outline: 0; background: transparent; font-size: 12px; }
.filter-row { display: flex; gap: 4px; margin: 10px 0 14px; }
.filter { padding: 6px 9px; }
.endpoint-list { display: grid; gap: 14px; }
.endpoint-group h3 { margin: 0 4px 6px; color: var(--muted); font-size: 10px; letter-spacing: .11em; text-transform: uppercase; }
.endpoint-button { width: 100%; border: 1px solid transparent; background: transparent; color: var(--text); display: grid; grid-template-columns: 48px 1fr 8px; align-items: center; gap: 7px; text-align: left; border-radius: 9px; padding: 8px 7px; }
.endpoint-button:hover, .endpoint-button.active { background: var(--panel-2); border-color: var(--line); }
.endpoint-button small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; font-family: "SFMono-Regular", monospace; font-size: 9px; }
.ready-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.ready-dot.blocked { background: var(--orange); }

.workspace { width: min(1040px, 100%); padding: 42px clamp(22px, 5vw, 72px) 80px; }
.workspace-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 30px; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
h1 { font-size: clamp(27px, 3.2vw, 42px); letter-spacing: -.04em; margin: 7px 0 8px; }
.workspace-head p { color: var(--muted); margin: 0; max-width: 670px; line-height: 1.5; font-size: 13px; }
.requirements { min-height: 32px; display: flex; flex-wrap: wrap; gap: 6px; margin: 20px 0 9px; }
.chip { font-size: 10px; padding: 5px 8px; border-radius: 999px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); }
.chip.ready { color: var(--accent); border-color: #a7f34b3b; }
.chip.missing { color: var(--orange); border-color: #ffad5a42; }
.chip.warning { color: var(--red); border-color: #ff6b6b42; }

.button { border: 1px solid var(--line); color: var(--text); background: var(--panel-2); border-radius: 9px; padding: 9px 12px; font-weight: 700; font-size: 12px; }
.button:hover { border-color: var(--line-bright); transform: translateY(-1px); }
.button.primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.button.danger { color: var(--red); background: #2a1719; border-color: #58292d; }
.button.ghost { background: transparent; }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.count { min-width: 18px; height: 18px; padding: 0 5px; display: inline-grid; place-items: center; border-radius: 99px; color: var(--muted); background: var(--panel-2); font-size: 10px; }

.request-card, .response-card, .history-card { background: linear-gradient(145deg, #141820, #0f1217); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.request-line { min-height: 64px; display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.request-line code { overflow: auto; color: #d7dce4; font-size: 13px; white-space: nowrap; }
.method { display: inline-grid; place-items: center; min-width: 45px; padding: 5px 7px; border-radius: 6px; font-size: 10px; font-weight: 900; letter-spacing: .04em; }
.method.GET { color: var(--blue); background: #15243a; }
.method.POST { color: var(--accent); background: #1d2c16; }
.method.PUT, .method.PATCH { color: var(--orange); background: #312316; }
.method.DELETE { color: var(--red); background: #32191c; }
.method.PATCH { color: var(--purple); background: #291d35; }
.request-line .button { min-width: 140px; display: flex; justify-content: center; align-items: center; gap: 12px; }
kbd { color: #476b1d; font-size: 9px; border: 1px solid #6ca52c; border-radius: 4px; padding: 2px 4px; }
.form-section { padding: 14px; border-bottom: 1px solid var(--line); }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; color: var(--muted); font-size: 11px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 14px; }
.form-section .field-grid { padding: 0; }
.field { display: grid; gap: 5px; color: var(--muted); font-size: 10px; }
.field input, .context-field input, .field select { width: 100%; color: var(--text); background: #0d1015; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; outline: none; font-size: 12px; }
.field input:focus, .context-field input:focus, .code-editor:focus { border-color: #83bd43; box-shadow: 0 0 0 3px #a7f34b10; }
.code-editor { display: block; width: 100%; min-height: 170px; resize: vertical; color: #dfe5ed; background: #0a0d11; border: 1px solid var(--line); border-radius: 9px; padding: 13px; outline: none; line-height: 1.55; font-size: 12px; tab-size: 2; }
.text-button { border: 0; color: var(--blue); background: transparent; padding: 4px; font-size: 11px; }
.request-options { min-height: 45px; padding: 0 15px; display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 11px; }
.request-options label { display: flex; align-items: center; gap: 6px; }
input[type="checkbox"] { accent-color: var(--accent); }

.response-card { margin-top: 14px; }
.response-head { min-height: 48px; padding: 0 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; font-size: 11px; }
.response-status { display: inline-flex; align-items: center; gap: 7px; font-weight: 800; }
.response-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.response-status.success::before { background: var(--accent); }
.response-status.error::before { background: var(--red); }
.response-status.running::before { background: var(--orange); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.debug-request { border-bottom: 1px solid var(--line); padding: 12px 15px; color: var(--muted); background: #0c0f13; font: 10px/1.6 "SFMono-Regular", monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.response-body { min-height: 190px; max-height: 480px; margin: 0; overflow: auto; padding: 16px; color: #dbe2eb; background: #0a0d11; font-size: 11px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.history-card { margin-top: 14px; color: var(--muted); }
.history-card summary { cursor: pointer; padding: 13px 15px; font-size: 12px; }
.history-row { display: grid; grid-template-columns: 46px 55px 1fr auto; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding: 9px 15px; font-size: 10px; }
.history-row code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

dialog { width: min(780px, calc(100vw - 28px)); max-height: calc(100vh - 40px); color: var(--text); background: var(--panel); border: 1px solid var(--line-bright); border-radius: 16px; padding: 0; box-shadow: 0 30px 100px #000b; }
dialog::backdrop { background: #050608c7; backdrop-filter: blur(5px); }
.dialog-shell { padding: 22px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-head h2 { margin: 5px 0 0; }
.dialog-shell > p { color: var(--muted); font-size: 12px; line-height: 1.5; }
.icon-button { width: 32px; height: 32px; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 8px; font-size: 20px; }
.context-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-height: 55vh; overflow: auto; padding: 5px 2px; }
.context-field { display: grid; gap: 5px; color: var(--muted); font-size: 10px; }
.context-field small { color: #586171; }
.dialog-actions { margin-top: 18px; display: flex; justify-content: space-between; }
.toast { position: fixed; right: 20px; bottom: 20px; transform: translateY(20px); opacity: 0; pointer-events: none; color: var(--text); background: #20262f; border: 1px solid var(--line-bright); border-radius: 10px; padding: 11px 14px; font-size: 12px; box-shadow: 0 15px 50px #0008; transition: .2s ease; z-index: 50; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: relative; top: 0; height: auto; max-height: 48vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .workspace { padding: 28px 16px 60px; }
  .status-pill { display: none; }
  .request-line { grid-template-columns: 52px minmax(0, 1fr); }
  .request-line .button { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .topbar { padding: 0 12px; }
  .brand strong { font-size: 13px; }
  .identity-select { font-size: 0; }
  .field-grid, .context-fields { grid-template-columns: 1fr; }
  .workspace-head { display: block; }
  #copy-curl { margin-top: 14px; }
  .request-options { flex-wrap: wrap; padding: 10px 15px; }
}
