/* CloakCTL API documentation — self-contained stylesheet.
   No external fonts, no CDN. Light and dark themes follow the OS setting. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #16181d;
  --muted: #5c6470;
  --border: #dde1e7;
  --border-strong: #c3c9d2;
  --accent: #0b6bcb;
  --accent-soft: #e5f0fb;
  --code-bg: #101621;
  --code-fg: #e6edf3;
  --code-head: #1a2331;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.05);
  --radius: 10px;
  --warn-bg: #fff7e6;
  --warn-border: #f0b429;
  --note-bg: #ecf5ff;
  --note-border: #3d8bd6;
  --ok-bg: #e9f9ef;
  --ok-border: #2f9e5f;
  --danger-bg: #fdecec;
  --danger-border: #d14343;
  --tok-key: #7ee787;
  --tok-str: #ffd580;
  --tok-num: #79c0ff;
  --tok-lit: #ff9bce;
  --tok-comment: #8b949e;
  --tok-kw: #ff7b72;
  --tok-var: #d2a8ff;
  --tok-flag: #79c0ff;
  font-synthesis: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f16;
    --surface: #111823;
    --surface-2: #172030;
    --text: #e6edf3;
    --muted: #9aa6b5;
    --border: #23304a;
    --border-strong: #34456a;
    --accent: #58a6ff;
    --accent-soft: #14263d;
    --code-bg: #080d14;
    --code-head: #0e1521;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.35);
    --warn-bg: #2b2310;
    --warn-border: #b7791f;
    --note-bg: #11233a;
    --note-border: #2f6da3;
    --ok-bg: #102a1b;
    --ok-border: #2f9e5f;
    --danger-bg: #2b1414;
    --danger-border: #b04b4b;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", "Liberation Sans", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 0 0 8px 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, kbd, samp {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Code", "Cascadia Mono",
    Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9em;
}

/* ------------------------------------------------------------------ header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .site-header { background: var(--surface); }
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 1.05rem;
}
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); font-size: 1.15rem; }
.brand-sub {
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 2px;
}

.site-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1 1 auto;
}
.site-nav a {
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.site-nav a.active { background: var(--accent-soft); color: var(--accent); }

.header-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.search { position: relative; }
.search input {
  width: 230px;
  max-width: 46vw;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.9rem;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); background: var(--surface); }

.search-results {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 360px;
  max-width: 82vw;
  max-height: 60vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px;
  font-size: 0.88rem;
}
.search-results .sr-label {
  margin: 4px 8px 6px;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.search-results a {
  display: block;
  padding: 7px 8px;
  border-radius: 7px;
  color: var(--text);
}
.search-results a:hover { background: var(--surface-2); text-decoration: none; }
.search-results .sr-section { color: var(--muted); font-size: 0.8rem; display: block; }
.search-results .sr-empty { padding: 8px; color: var(--muted); }

.lang-switch {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.lang-switch:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* -------------------------------------------------------------------- page */
.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 34px 20px 70px;
}

.page-head { margin-bottom: 22px; }
.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.page-head h1 {
  margin: 0;
  font-size: clamp(1.65rem, 2.6vw, 2.25rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.content h2 {
  margin: 2.4em 0 0.7em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
  font-size: 1.42rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.content h3 { margin: 1.9em 0 0.6em; font-size: 1.13rem; line-height: 1.35; }
.content h4 { margin: 1.5em 0 0.5em; font-size: 0.97rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.content p { margin: 0.75em 0; }
.content ul, .content ol { margin: 0.7em 0; padding-left: 1.4em; }
.content li { margin: 0.28em 0; }
.content li > ul, .content li > ol { margin: 0.2em 0; }
.content hr { border: 0; border-top: 1px solid var(--border); margin: 2.2em 0; }
.content strong { font-weight: 650; }
.content blockquote { margin: 1em 0; }

.content a.anchor {
  color: var(--muted);
  font-weight: 400;
  opacity: 0;
  margin-left: 8px;
}
.content :is(h2, h3, .endpoint-head):hover a.anchor { opacity: 1; }
.content a.anchor:hover { text-decoration: none; color: var(--accent); }

/* ---------------------------------------------------------------- callouts */
.callout {
  margin: 1.1em 0;
  padding: 12px 15px;
  border: 1px solid var(--note-border);
  border-left-width: 4px;
  border-radius: 8px;
  background: var(--note-bg);
}
.callout-title { margin: 0 0 4px; font-weight: 650; font-size: 0.92rem; }
.callout p:last-child { margin-bottom: 0; }
.callout-tip { border-color: var(--ok-border); background: var(--ok-bg); }
.callout-warning { border-color: var(--warn-border); background: var(--warn-bg); }
.callout-caution { border-color: var(--danger-border); background: var(--danger-bg); }

/* ------------------------------------------------------------------ tables */
.table-wrap {
  margin: 1em 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
table { border-collapse: collapse; width: 100%; font-size: 0.91rem; }
th, td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th {
  background: var(--surface-2);
  font-size: 0.8rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

/* ------------------------------------------------------------------- code */
.code {
  margin: 1em 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--code-bg);
  box-shadow: var(--shadow);
}
.code-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: var(--code-head);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: #9aa6b5;
  font-size: 0.76rem;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}
.code-caption { color: #c9d4e2; font-weight: 600; }
.code-lang { text-transform: uppercase; letter-spacing: 0.08em; margin-left: auto; }
.copy-btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: #c9d4e2;
  border-radius: 6px;
  padding: 2px 9px;
  font-size: 0.74rem;
  font-family: inherit;
  cursor: pointer;
}
.copy-btn:hover { background: rgba(255, 255, 255, 0.1); }
html:not(.js) .copy-btn { display: none; }

.code pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  color: var(--code-fg);
  line-height: 1.55;
  tab-size: 2;
}
.code code { font-size: 0.86rem; }

.tok-key { color: var(--tok-key); }
.tok-str { color: var(--tok-str); }
.tok-num { color: var(--tok-num); }
.tok-lit { color: var(--tok-lit); }
.tok-comment { color: var(--tok-comment); font-style: italic; }
.tok-kw { color: var(--tok-kw); }
.tok-var { color: var(--tok-var); }
.tok-flag { color: var(--tok-flag); }

p code, li code, td code, h2 code, h3 code, h4 code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  white-space: break-spaces;
}

/* --------------------------------------------------------------- endpoints */
.endpoint {
  margin: 1.6em 0;
  padding: 4px 20px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.endpoint-head h3 { margin-top: 0.9em; }
.endpoint-line {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin: 0.2em 0 0.7em;
}
.path {
  background: var(--code-bg);
  color: #dbe7f3;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.9rem;
}
.method {
  display: inline-block;
  min-width: 58px;
  text-align: center;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
}
.method-get { background: #1f7a4d; }
.method-post { background: #1d5fae; }
.method-patch { background: #9a6207; }
.method-delete { background: #a8332f; }
.method-put { background: #6b4bb5; }

.scope-line { margin: 0.2em 0; }
.chip {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 0.8rem;
  margin: 2px 4px 2px 0;
}
.chip code { background: transparent; border: 0; padding: 0; }
a.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip-scope { background: var(--accent-soft); border-color: var(--accent-soft); }
.chip-label { color: var(--muted); font-size: 0.85rem; }
.error-chips { margin: 0.9em 0 0.2em; }

.notes {
  margin: 1em 0 0.3em;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 0.92rem;
}
.notes-title { margin: 0 0 4px; font-weight: 650; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.notes ul { margin: 0.3em 0; }

/* --------------------------------------------------------------------- toc */
.page-toc {
  margin: 1.4em 0 2em;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.toc-title { margin: 0 0 6px; font-weight: 650; font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.page-toc ul { list-style: none; margin: 0; padding: 0; columns: 2 260px; column-gap: 28px; }
.page-toc li { margin: 2px 0; break-inside: avoid; font-size: 0.9rem; }
.page-toc .toc-level-3 { margin-left: 14px; font-size: 0.86rem; }
.page-toc a { color: var(--text); }
.page-toc a:hover { color: var(--accent); }

/* ---------------------------------------------------------------- footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 22px 20px 30px;
  font-size: 0.86rem;
  color: var(--muted);
}
.footer-inner { max-width: 1040px; margin: 0 auto; }
.footer-inner p { margin: 0.25em 0; }
.muted { color: var(--muted); }

/* ------------------------------------------------------------- filtering */
.is-filtered-out { display: none !important; }
.search-hint {
  margin: 0 0 14px;
  font-size: 0.86rem;
  color: var(--muted);
}

/* --------------------------------------------------------------- responsive */
@media (max-width: 880px) {
  .header-inner { gap: 10px; }
  .site-nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .header-tools { order: 2; }
  .search input { width: 170px; }
  .page { padding-top: 24px; }
  .page-toc ul { columns: 1; }
}

@media print {
  .site-header, .site-footer, .page-toc, .copy-btn, .search { display: none; }
  body { background: #fff; color: #000; }
  .endpoint, .code, .table-wrap { box-shadow: none; }
  .code pre { white-space: pre-wrap; }
}
