:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-code: #f3f4f6;
  --border: #e3e5ea;
  --text: #1b1f27;
  --muted: #5d6573;
  --accent: #2456d6;
  --accent-soft: #e8eefc;
  --ok: #157f3b;
  --err: #c0362c;
  --warn: #a26200;
  --info: #3b5b8f;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b;
    --bg-soft: #181c24;
    --bg-code: #1d222c;
    --border: #2a303c;
    --text: #e6e9ef;
    --muted: #9aa3b2;
    --accent: #7aa2ff;
    --accent-soft: #1d2a48;
    --ok: #4cc27a;
    --err: #ff7b6e;
    --warn: #f0b04a;
    --info: #8fb0e8;
  }
}
:root[data-theme="dark"] {
  --bg: #12151b; --bg-soft: #181c24; --bg-code: #1d222c; --border: #2a303c; --text: #e6e9ef;
  --muted: #9aa3b2; --accent: #7aa2ff; --accent-soft: #1d2a48; --ok: #4cc27a; --err: #ff7b6e; --warn: #f0b04a; --info: #8fb0e8;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, textarea, input, select { font-family: var(--mono); }
code { font-size: 0.88em; background: var(--bg-code); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
pre { background: var(--bg-code); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; overflow-x: auto; font-size: 13px; line-height: 1.5; }
pre code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 20px; background: var(--bg); border-bottom: 1px solid var(--border); }
.brand { font-weight: 650; color: var(--text); font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-block; background: var(--accent); color: var(--bg); border-radius: 6px; padding: 1px 7px; margin-right: 6px; font-size: 13px; letter-spacing: 0.5px; }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; }
.spacer { flex: 1; }
.top-link { font-size: 14px; }
.menu-btn { display: none; background: none; border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 4px 10px; font-size: 16px; cursor: pointer; }

.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; padding: 18px 12px 40px 20px; border-right: 1px solid var(--border); background: var(--bg-soft); }
.sidebar a { display: block; padding: 4px 10px; border-radius: 6px; color: var(--muted); font-size: 14px; }
.sidebar a:hover { background: var(--accent-soft); color: var(--text); text-decoration: none; }
.sidebar a.active { color: var(--accent); background: var(--accent-soft); font-weight: 550; }
.sidebar a.sub { padding-left: 22px; font-size: 13px; }
.nav-group { margin: 18px 10px 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }
.nav-group:first-child { margin-top: 0; }

.content { max-width: 880px; padding: 28px 40px 80px; }
section { padding: 18px 0 26px; border-bottom: 1px solid var(--border); }
h1 { font-size: 32px; line-height: 1.2; margin: 6px 0 14px; letter-spacing: -0.3px; }
h2 { font-size: 23px; margin: 8px 0 12px; letter-spacing: -0.2px; }
h3 { font-size: 17px; margin: 22px 0 8px; }
h4 { font-size: 15px; margin: 0; }
.lede { font-size: 17px; color: var(--text); }
.note { color: var(--muted); font-size: 13.5px; }

table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px; }
th, td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.4px; }
table.kv th { text-transform: none; letter-spacing: 0; font-size: 14px; width: 210px; color: var(--text); }
td.yes { color: var(--ok); font-weight: 600; white-space: nowrap; }
td.no { color: var(--muted); font-weight: 600; white-space: nowrap; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 20px 0; }
.card { display: block; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-soft); color: var(--text); }
.card:hover { border-color: var(--accent); text-decoration: none; }
.card strong { display: block; margin-bottom: 4px; }
.card span { color: var(--muted); font-size: 14px; }

.defs dt { font-weight: 650; margin-top: 12px; }
.defs dd { margin: 2px 0 0; color: var(--text); }
.steps li { margin-bottom: 8px; }
.notes li { margin-bottom: 10px; }

.endpoint { border: 1px solid var(--border); border-radius: 10px; margin: 16px 0; overflow: hidden; }
.endpoint-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; background: var(--bg-soft); border-bottom: 1px solid var(--border); }
.endpoint-body { padding: 4px 16px 14px; }
.method { font: 700 11px var(--mono); padding: 3px 7px; border-radius: 5px; background: var(--accent); color: var(--bg); }
.api-badge { font: 600 11px var(--mono); padding: 2px 7px; border-radius: 5px; border: 1px solid var(--border); color: var(--muted); }
.endpoint-path { font: 600 14px var(--mono); }
.endpoint-head .spacer { flex: 1; }
.req { font-size: 11px; color: var(--warn); font-weight: 600; white-space: nowrap; }

.tool { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin: 14px 0; background: var(--bg-soft); }
.tool label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.tool label.check { flex-direction: row; align-items: center; gap: 6px; align-self: flex-end; margin-bottom: 18px; flex: 0 0 auto; }
.tool label.check input { width: auto; }
.tool .row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.tool .row > label { flex: 1 1 150px; }
.tool .row > label.grow { flex: 1 1 260px; }
.tool .buttons { align-items: center; margin-top: 4px; }
textarea, input, select { width: 100%; font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px; }
textarea { resize: vertical; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { font: 600 13.5px var(--sans); padding: 8px 14px; border-radius: 7px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
button.secondary { background: var(--bg); }
button.try { padding: 4px 10px; font-size: 12.5px; }
.status { font-size: 13px; color: var(--muted); }

.steps-out { display: grid; gap: 8px; margin: 6px 0; }
.step { border-left: 3px solid var(--accent); background: var(--bg); border-radius: 0 7px 7px 0; padding: 8px 12px; }
.step-label { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 3px; }
.step-value { font: 12.5px/1.5 var(--mono); overflow-wrap: anywhere; white-space: pre-wrap; }
pre.response { max-height: 460px; overflow: auto; background: var(--bg); }

.notes-out { list-style: none; padding: 0; margin: 10px 0; }
.notes-out li { padding: 4px 0 4px 26px; position: relative; font-size: 14px; }
.notes-out li::before { position: absolute; left: 0; font-weight: 700; }
.notes-out li.ok::before { content: "✓"; color: var(--ok); }
.notes-out li.error::before { content: "✕"; color: var(--err); }
.notes-out li.warning::before { content: "!"; color: var(--warn); }
.notes-out li.info::before, .notes-out li.question::before { content: "i"; color: var(--info); }

video { width: 100%; max-height: 420px; background: #000; border-radius: 8px; margin-top: 10px; }
.catalog { display: grid; gap: 8px; }
.cat-lib h4 { margin: 10px 0 6px; }
.cat-item { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: center; padding: 6px; border-radius: 8px; }
.cat-item:hover { background: var(--bg-soft); }
.cat-item img { width: 96px; height: 54px; object-fit: cover; border-radius: 5px; background: var(--bg-code); }
.cat-meta { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.pill { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--border); margin-left: 6px; color: var(--muted); }
.pill.lock { color: var(--warn); border-color: var(--warn); }

.footer { padding: 24px 0; color: var(--muted); font-size: 13px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-block; }
  .tag { display: none; }
  .sidebar { position: fixed; top: 56px; left: 0; width: 280px; z-index: 30; transform: translateX(-100%); transition: transform 0.2s; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
  .sidebar.open { transform: none; }
  .content { padding: 20px 16px 60px; }
  h1 { font-size: 26px; }
  table.kv th { width: auto; }
  th, td { padding: 7px 6px; }
}
