:root {
  --bg: #0f1420;
  --bg-2: #161d2c;
  --bg-3: #1d2537;
  --border: #2a344a;
  --text: #e6ebf5;
  --text-dim: #8b97ae;
  --accent: #4f8cff;
  --accent-dark: #3a6fd8;
  --green: #34c98a;
  --red: #f2585b;
  --amber: #f5a742;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

/* Author styles beat the browser's own [hidden] { display: none } rule, so any
   class here that sets `display` silently defeats the hidden attribute. This
   keeps `el.hidden = true` working for .token-hint, .resp-meta and .params. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

h1, h2, h3 { margin: 0; font-weight: 600; }

code, pre, .token-input, .code-input { font-family: var(--mono); }

.muted { color: var(--text-dim); }
.small { font-size: 12px; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 14px 22px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 10px;
  letter-spacing: .3px;
}

.topbar h1 { font-size: 16px; }
.brand-sub { margin: 0; font-size: 12px; color: var(--text-dim); }

.authbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 460px;
  justify-content: flex-end;
}

.auth-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .6px; }

.token-input {
  flex: 1 1 260px;
  max-width: 420px;
  min-width: 160px;
  padding: 8px 11px;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  outline: none;
}
.token-input:focus { border-color: var(--accent); }

.pill {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-off { background: rgba(242, 88, 91, .14); color: var(--red); }
.pill-on  { background: rgba(52, 201, 138, .14); color: var(--green); }

/* ---------- Buttons ---------- */

.btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #26314a; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-ghost { background: transparent; }
.btn-tiny { padding: 4px 10px; font-size: 11px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-send {
  margin-top: 14px;
  padding: 10px 22px;
  background: var(--green);
  border-color: var(--green);
  color: #06281c;
}
.btn-send:hover:not(:disabled) { background: #2bb87c; }

/* ---------- Session timer ---------- */

.session-timer {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}
.session-timer.renewed {
  color: var(--green);
  border-color: rgba(52, 201, 138, .5);
}
.session-timer.low {
  color: var(--amber);
  border-color: rgba(245, 167, 66, .5);
}

/* ---------- Session notice ---------- */

.session-notice {
  padding: 11px 22px;
  background: rgba(245, 167, 66, .12);
  border-bottom: 1px solid rgba(245, 167, 66, .35);
  color: #ffce8a;
  font-size: 13px;
  font-weight: 500;
}

/* ---------- Layout ---------- */

.layout {
  display: grid;
  /* Wide enough that the longest endpoint name fits without truncation. */
  grid-template-columns: 340px 1fr;
  align-items: start;
  min-height: calc(100vh - 68px);
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  position: sticky;
  top: 0;
}

.sidebar-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-dim);
  margin-bottom: 12px;
  padding-left: 6px;
}

.group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-dim);
  margin: 16px 0 6px;
  padding-left: 6px;
}
.group-label:first-child { margin-top: 0; }

.api-item {
  display: flex;
  /* flex-start, not center: the longest name sits right at the wrap boundary,
     so the badge and lock must stay aligned to the first line either way. */
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 3px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.api-item:hover { background: var(--bg-2); }
.api-item.active { background: var(--bg-3); border-color: var(--accent); }
/* Wrap rather than clip: a truncated endpoint name ("3. Full Telemetry (every
   p...") tells the reader nothing, and these names are the primary navigation. */
.api-item .name {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
  line-height: 1.35;
}

.method {
  flex-shrink: 0;
  min-width: 46px;
  padding: 2px 7px;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  letter-spacing: .4px;
}
.method-GET    { background: rgba(79, 140, 255, .16); color: #7aa9ff; }
.method-POST   { background: rgba(52, 201, 138, .16); color: var(--green); }
.method-PUT    { background: rgba(245, 167, 66, .16); color: var(--amber); }
.method-DELETE { background: rgba(242, 88, 91, .16); color: var(--red); }

/* Nudge the sidebar badge and lock onto the first line of the name. Scoped to
   .api-item so the detail header's larger badge is unaffected. */
.api-item .method,
.api-item .lock { margin-top: 1px; }

.lock { font-size: 11px; opacity: .75; }

/* ---------- Detail panel ---------- */

/* Roomy but still readable: JSON payloads here run wide (telemetry rows carry
   ~35 fields), so the cap sits well above prose width. */
.panel { padding: 26px 34px 60px; max-width: 1400px; }

.empty { padding: 90px 0; text-align: center; color: var(--text-dim); }
.empty-icon { font-size: 30px; margin: 0 0 8px; }
.empty p { margin: 4px 0; }

.detail-head { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.detail-head .method { font-size: 11px; padding: 4px 9px; }
.path { font-size: 15px; font-weight: 600; }
.detail-desc { margin: 0 0 18px; color: var(--text-dim); }

.warning {
  padding: 11px 14px;
  margin-bottom: 18px;
  background: rgba(245, 167, 66, .1);
  border: 1px solid rgba(245, 167, 66, .35);
  border-left-width: 3px;
  border-radius: 7px;
  color: #ffce8a;
  font-size: 13px;
}
.warning code { background: rgba(0,0,0,.25); padding: 1px 5px; border-radius: 4px; }

.block {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 18px;
  margin-bottom: 20px;
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}
.block-head h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-dim);
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.params { display: grid; gap: 12px; margin-bottom: 16px; }
.param-input {
  width: 100%;
  padding: 8px 11px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  outline: none;
}
.param-input:focus { border-color: var(--accent); }

.code-input {
  width: 100%;
  padding: 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  outline: none;
  resize: vertical;
  tab-size: 2;
}
.code-input:focus { border-color: var(--accent); }

.resp-meta { display: flex; align-items: center; gap: 10px; }

.status-chip {
  padding: 3px 10px;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}
.status-ok   { background: rgba(52, 201, 138, .16); color: var(--green); }
.status-warn { background: rgba(245, 167, 66, .16); color: var(--amber); }
.status-err  { background: rgba(242, 88, 91, .16); color: var(--red); }

.token-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 13px;
  background: rgba(52, 201, 138, .1);
  border: 1px solid rgba(52, 201, 138, .35);
  border-radius: 7px;
  font-size: 13px;
  color: #9fe6c4;
}

.output {
  margin: 0;
  padding: 14px;
  /* Full telemetry returns 100 rows a page; 460px showed only a couple. */
  max-height: 640px;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .panel { padding: 20px 16px 50px; }
  .authbar { justify-content: flex-start; }
}
