/* =============================================================================
   API reference. Same palette as the public page: paper, ink, one green, one gold.
   ========================================================================== */

:root {
  --ink: #0d1116;
  --ink-soft: #161c23;
  --ink-2: #3f4750;
  --ink-3: #79828c;
  --paper: #f7f4ec;
  --card: #fffdf8;
  --line: #e2ddd0;
  --line-dark: rgba(255, 255, 255, 0.1);
  --green: #1f6f4a;
  --green-deep: #14503a;
  --gold: #c8a24a;
  --gold-deep: #a8842f;
  --code-bg: #0b0e12;
  --top-h: 58px;
  --side-w: 268px;
}

* { box-sizing: border-box; }

body.docs {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15.5px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-deep); }

code, .mono, pre {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

code {
  font-size: 0.88em;
  background: rgba(31, 111, 74, 0.08);
  color: var(--green-deep);
  padding: 1px 5px;
  border-radius: 4px;
}

h1, h2, h3 { letter-spacing: -0.02em; }

/* -------------------------------- top bar -------------------------------- */

.docs-top {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--top-h);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  background: rgba(13, 17, 22, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-dark);
}

.docs-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #f1ede2;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.docs-brand svg { color: var(--gold); }
.docs-brand span { font-weight: 400; color: rgba(241, 237, 226, 0.6); }

.docs-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(241, 237, 226, 0.45);
  padding-left: 18px;
  border-left: 1px solid var(--line-dark);
}

.docs-key { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.docs-key input {
  width: 260px;
  max-width: 42vw;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line-dark);
  background: rgba(255, 255, 255, 0.06);
  color: #f1ede2;
  font-size: 13px;
  outline: none;
}
.docs-key input:focus { border-color: var(--gold); }
.docs-key input::placeholder { color: rgba(241, 237, 226, 0.4); }

.btn-mini {
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--gold);
  background: var(--gold);
  color: #16130a;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.btn-mini:hover { background: var(--gold-deep); }

.btn-mini.ghost { background: transparent; border-color: var(--line-dark); color: rgba(241, 237, 226, 0.7); }
.btn-mini.ghost:hover { border-color: var(--gold); color: var(--gold); }

.key-state {
  font-size: 11.5px;
  color: rgba(241, 237, 226, 0.45);
  min-width: 54px;
}
.key-state.set { color: #7fd3a3; }

/* --------------------------------- shell --------------------------------- */

.docs-shell {
  display: flex;
  align-items: flex-start;
  max-width: 1320px;
  margin: 0 auto;
  padding: calc(var(--top-h) + 26px) 20px 80px;
  gap: 40px;
}

.docs-side {
  position: sticky;
  top: calc(var(--top-h) + 22px);
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  max-height: calc(100vh - var(--top-h) - 44px);
  overflow-y: auto;
  padding-right: 6px;
  border-right: 1px solid var(--line);
  font-size: 13.5px;
}

.side-group {
  margin: 18px 0 8px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  font-weight: 700;
}
.side-group:first-child { margin-top: 0; }

.docs-side a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--ink-2);
  margin-bottom: 2px;
  line-height: 1.35;
}
.docs-side a:hover { background: rgba(13, 17, 22, 0.05); color: var(--ink); }
.docs-side a.active { background: rgba(200, 162, 74, 0.14); color: var(--ink); }

.side-foot { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }
.side-foot a { font-weight: 600; color: var(--gold-deep); padding-left: 0; }

.verb {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 4px;
  flex: 0 0 auto;
}
.verb.get { background: rgba(31, 111, 74, 0.12); color: var(--green-deep); }
.verb.post { background: rgba(200, 162, 74, 0.18); color: var(--gold-deep); }

/* --------------------------------- main ---------------------------------- */

.docs-main { flex: 1 1 auto; min-width: 0; max-width: 900px; }

/* ------------------------------ doc blocks ------------------------------- */

.doc { padding: 30px 0 40px; border-bottom: 1px solid var(--line); }
.doc:first-child { padding-top: 6px; }
.doc:last-child { border-bottom: 0; }

.doc-kicker {
  margin: 0 0 8px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--gold-deep);
}

.doc h1 { font-size: clamp(1.9rem, 3.2vw, 2.5rem); line-height: 1.1; margin: 0 0 14px; }
.doc h2 { font-size: 1.45rem; line-height: 1.2; margin: 26px 0 10px; }
.doc h3 { font-size: 1.05rem; margin: 22px 0 8px; }

.doc-lede { font-size: 16.5px; color: var(--ink-2); max-width: 66ch; }
.doc p { color: var(--ink-2); }
.doc .doc-note { font-size: 14px; }

.fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 24px;
  margin: 20px 0 8px;
  font-size: 14px;
  color: var(--ink-2);
}
.fact-grid > div { border-top: 1px solid var(--line); padding-top: 10px; }
.fact-k { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-3); margin-bottom: 4px; font-weight: 700; }

.doc-steps { padding-left: 20px; color: var(--ink-2); }
.doc-steps li { margin-bottom: 6px; }

.callout {
  margin: 20px 0 0;
  padding: 14px 16px;
  border-left: 3px solid var(--gold);
  background: var(--card);
  border-radius: 10px;
  font-size: 14px;
  color: var(--ink-2);
}
.callout strong { color: var(--ink); }

/* ------------------------------ endpoints -------------------------------- */

.ep-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ep-path { font-size: 14.5px; font-weight: 600; background: rgba(13, 17, 22, 0.05); color: var(--ink); padding: 4px 9px; border-radius: 6px; }
.ep-auth { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-3); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.ep-desc { color: var(--ink-2); max-width: 68ch; }

.doc-table { width: 100%; border-collapse: collapse; font-size: 13.8px; margin: 14px 0; }
.doc-table th, .doc-table td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.doc-table th { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-3); font-weight: 700; }
.doc-table td:first-child { white-space: nowrap; }

/* ------------------------------ code blocks ------------------------------ */

.code-block { margin: 14px 0; border-radius: 12px; overflow: hidden; background: var(--code-bg); }

.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-dark);
  color: rgba(241, 237, 226, 0.55);
  font-size: 11.5px;
  letter-spacing: 0.04em;
}

.copy {
  border: 1px solid var(--line-dark);
  background: transparent;
  color: rgba(241, 237, 226, 0.7);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 6px;
  cursor: pointer;
}
.copy:hover { border-color: var(--gold); color: var(--gold); }

.code-block pre { margin: 0; padding: 16px 16px 18px; overflow-x: auto; color: #dfe7e1; font-size: 12.6px; line-height: 1.62; }
.code-block code { background: none; color: inherit; padding: 0; font-size: inherit; }

/* -------------------------------- try it --------------------------------- */

.try {
  margin: 16px 0 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 14px 16px;
}

.try-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-3); }
.try-note { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 12px; color: var(--ink-3); }

.try-body, .try-param {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbf9f3;
  color: var(--ink);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12.6px;
  line-height: 1.55;
  padding: 10px 12px;
  margin-bottom: 8px;
  outline: none;
}
.try-param { max-width: 320px; }
.try-body:focus, .try-param:focus { border-color: var(--gold); }

.try-send {
  border: 1px solid var(--gold);
  background: var(--gold);
  color: #16130a;
  font-weight: 700;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 9px;
  cursor: pointer;
}
.try-send:hover { background: var(--gold-deep); }
.try-send[disabled] { opacity: 0.6; cursor: progress; }

.try-out {
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: 9px;
  background: var(--code-bg);
  color: #dfe7e1;
  font-size: 12.2px;
  line-height: 1.55;
  overflow: auto;
  max-height: 360px;
  white-space: pre-wrap;
  word-break: break-word;
}

.try-meta { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 11.5px; color: var(--ink-3); margin-top: 8px; }

/* --------------------------------- pills --------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  white-space: nowrap;
}
.pill-wait { color: #a5741f; background: #f6ecd6; }
.pill-live { color: #eaf4ee; background: var(--green); }
.pill-work { color: #2a5f8a; background: #e4eef6; }
.pill-ask { color: #8a5a00; background: #fbf2e0; }
.pill-done { color: #eaf4ee; background: var(--green-deep); }
.pill-bad { color: #a32626; background: #fbeaea; }
.pill-refund { color: var(--ink-2); background: #efeee8; }
.pill-muted { color: var(--ink-3); background: #efeee8; }

.life { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
.life-arrow { color: var(--ink-3); }

/* ---------------------------------- cta ---------------------------------- */

.btn-gold {
  background: var(--gold);
  border: 1px solid var(--gold);
  color: #16130a;
  font-weight: 700;
  border-radius: 10px;
  padding: 10px 18px;
}
.btn-gold:hover { background: var(--gold-deep); border-color: var(--gold-deep); color: #16130a; }

.doc-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 26px;
  padding: 20px 22px;
  border-radius: 14px;
  background: var(--ink);
  color: #f1ede2;
}
.doc-cta strong { display: block; font-size: 15.5px; margin-bottom: 4px; }
.doc-cta p { margin: 0; color: rgba(241, 237, 226, 0.66); font-size: 13.5px; }

/* ------------------------------- responsive ------------------------------ */

@media (max-width: 991.98px) {
  .docs-shell { flex-direction: column; gap: 22px; padding-top: calc(var(--top-h) + 18px); }

  .docs-side {
    position: static;
    width: 100%;
    flex: 0 0 auto;
    max-height: none;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 0 12px;
    font-size: 13px;
  }

  .side-group, .side-foot { display: none; }

  .docs-side a {
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 12px;
    margin: 0;
    background: var(--card);
  }
  .docs-side a.active { border-color: var(--gold); background: rgba(200, 162, 74, 0.14); }

  .fact-grid { grid-template-columns: 1fr; }
  .docs-label { display: none; }
  .docs-key input { width: 150px; }
}

@media (max-width: 575.98px) {
  .docs-top { gap: 10px; padding: 0 12px; }
  .docs-key input { width: 118px; }
  .key-state { display: none; }
  .docs-shell { padding-left: 14px; padding-right: 14px; }
  .doc h1 { font-size: 1.7rem; }
  .try-param { max-width: 100%; }
}

/* --------------------------- small screens, tightened ---------------------
   The bar and the sidebar are the two things that break first, so they are
   pinned here rather than left to the generic rules above. */

@media (max-width: 991.98px) {
  .docs-top {
    flex-wrap: nowrap;
    gap: 10px;
  }

  .docs-brand {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 13.5px;
  }

  .docs-key {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-end;
  }

  .docs-key input {
    flex: 1 1 auto;
    width: auto;
    min-width: 90px;
    max-width: none;
  }

  .docs-side {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .docs-side a {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .docs-side::-webkit-scrollbar { height: 6px; }
  .docs-side::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
}

@media (max-width: 420px) {
  #keyForget { display: none; }
  .docs-key input { min-width: 70px; }
}

/* The mobile contents strip: the links sit inside <nav>, so that is the row that has to
   scroll. Making .docs-side a flex row only laid out its single child. */
@media (max-width: 991.98px) {
  .docs-side {
    display: block;
    overflow: visible;
    padding: 0 0 10px;
  }

  .docs-side nav {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    scrollbar-width: thin;
  }

  .docs-side nav::-webkit-scrollbar { height: 6px; }
  .docs-side nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

  .docs-side a {
    flex: 0 0 auto;
    white-space: nowrap;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 12px;
    margin: 0;
    background: var(--card);
  }
}

/* ---------------------- mobile contents menu ------------------------------
   Small screens get a menu button instead of a strip that has to be dragged. */

.docs-mobilebar { display: none; }

@media (max-width: 991.98px) {
  .docs-side { display: none; }

  .docs-mobilebar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: var(--top-h);
    z-index: 20;
    padding: 10px 0 12px;
    margin-bottom: 4px;
    background: rgba(247, 244, 236, 0.96);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
  }

  .docs-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13.5px;
    font-weight: 600;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
  }
  .docs-menu-btn:hover { border-color: var(--gold); }
  .docs-menu-btn:active { transform: scale(0.98); }

  .docs-mobilebar-note { font-size: 11.5px; color: var(--ink-3); letter-spacing: 0.02em; }

  .docs-menu { width: min(86vw, 360px); background: var(--paper); }
  .docs-menu .offcanvas-header { border-bottom: 1px solid var(--line); }

  .docs-menu .offcanvas-body a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line);
    color: var(--ink-2);
    font-size: 14.5px;
    transition: color 0.15s ease, padding-left 0.15s ease;
  }
  .docs-menu .offcanvas-body a:hover { color: var(--ink); padding-left: 3px; }
  .docs-menu-foot { margin-top: 22px; }
}

/* --------------------------- request spinner ------------------------------ */

.try-send {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.18s ease, transform 0.15s ease, box-shadow 0.18s ease;
}
.try-send:hover { box-shadow: 0 6px 18px -10px rgba(200, 162, 74, 0.8); }
.try-send:active { transform: translateY(1px); }

.try-send.is-loading { pointer-events: none; opacity: 0.9; }

.try-send.is-loading::after {
  content: "";
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid rgba(22, 19, 10, 0.25);
  border-top-color: #16130a;
  animation: hub-spin 0.65s linear infinite;
}

@keyframes hub-spin { to { transform: rotate(360deg); } }

/* Smooth, quiet transitions across the reading surface. */
.docs-side a, .copy, .btn-mini { transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease; }
.try-out { transition: opacity 0.2s ease; }

@media (prefers-reduced-motion: reduce) {
  .try-send.is-loading::after { animation-duration: 1.6s; }
  .docs-menu-btn, .try-send, .docs-side a { transition: none; }
}

/* --------------------------- the key bar's two homes ----------------------
   One element, moved by script: header on a wide screen, Authentication on a
   phone, where the header keeps only the menu button. */

.key-slot { margin-left: auto; }

.key-box { display: flex; align-items: center; gap: 8px; }
.key-label { display: none; }

.key-box input {
  width: 260px;
  max-width: 42vw;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line-dark);
  background: rgba(255, 255, 255, 0.06);
  color: #f1ede2;
  font-size: 13px;
  outline: none;
}
.key-box input:focus { border-color: var(--gold); }
.key-box input::placeholder { color: rgba(241, 237, 226, 0.4); }

.docs-menu-btn--icon { display: none; }

@media (max-width: 991.98px) {
  #keySlotHeader { display: none; }

  .docs-menu-btn--icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--line-dark);
    background: transparent;
    color: #f1ede2;
    transition: border-color 0.18s ease, color 0.18s ease;
  }
  .docs-menu-btn--icon:hover { border-color: var(--gold); color: var(--gold); }

  #keySlotContent { display: block; margin: 18px 0 6px; }

  .key-box.in-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
  }

  .key-box.in-content .key-label {
    display: block;
    grid-column: 1 / -1;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--ink-3);
  }

  .key-box.in-content input {
    width: 100%;
    max-width: none;
    height: 42px;
    font-size: 13.5px;
    background: #fbf9f3;
    border-color: var(--line);
    color: var(--ink);
  }
  .key-box.in-content input::placeholder { color: var(--ink-3); }
  .key-box.in-content input:focus { border-color: var(--gold); }
  .key-box.in-content #keyState { display: none; }
  .key-box.in-content .btn-mini.ghost { color: var(--ink-2); border-color: var(--line); }
}

@media (max-width: 420px) {
  .key-box.in-content { grid-template-columns: minmax(0, 1fr) auto; }
  .key-box.in-content #keyForget { grid-column: 2; }
}

/* ------------------------- nothing may run off-screen ---------------------
   Two causes, both real. A closed Bootstrap offcanvas sits translated a full
   viewport to the right and still adds to the document's scroll width; and the
   shell is a flex column, so `align-items: flex-start` sized the article column
   to its widest table instead of the screen. */

html, body {
  max-width: 100%;
  overflow-x: clip;
}

@supports not (overflow: clip) {
  html, body { overflow-x: hidden; }
}

@media (max-width: 991.98px) {
  /* Column flex: stretch, or every child sizes to its own content. */
  .docs-shell { align-items: stretch; }
}

/* A wide table scrolls inside its card rather than widening the page. */
.table-scroll {
  overflow-x: auto;
  margin: 14px 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.table-scroll .doc-table { margin: 0; min-width: 480px; }
.table-scroll::-webkit-scrollbar { height: 6px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }


/* The menu button is the only control in a phone header, so it gets a real tap target:
   48px square, 26px glyph, and a visible pressed state. */
@media (max-width: 991.98px) {
  .docs-menu-btn--icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    flex: 0 0 auto;
  }
  .docs-menu-btn--icon svg { width: 26px; height: 26px; }
  .docs-menu-btn--icon:active { background: rgba(255, 255, 255, 0.08); }
}


/* The glyph is a flex child inside the button, so it will shrink unless told not to.
   Pinned size, no shrink, and a slightly taller stroke for a phone screen. */
@media (max-width: 991.98px) {
  .docs-menu-btn--icon {
    width: 52px;
    height: 52px;
    padding: 0;
  }
  .docs-menu-btn--icon svg {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    flex: 0 0 auto;
  }
}
