/* NEAR Terminal API docs — dual mode: follows the reader's system (light or dark), and the
   moon/sun button overrides it (remembered per browser, docs.js). Code blocks stay dark in both. */
:root {
  --bg: #ffffff; --bg2: #f8fafc; --panel: #f5f7fa; --panel2: #eef2f6; --line: #e6ebf1; --line2: #d5dde7;
  --ink: #0b1220; --dim: #4a5768; --dimmer: #7b8798;
  --accent: #00a36a; --accent-ink: #ffffff; --accent-soft: rgba(0, 163, 106, .09);
  --blue: #2f7de1; --warn: #b7791f; --down: #e5484d; --up: #12a575;
  --code-bg: #0d1218; --code-ink: #dbe3ee; --code-bar: #111821; --code-line: #232d3b;
  --k: #7cc7ff; --s: #9fe3b8; --n: #ffcf7a; --b: #ff9ad5;
  --radius: 10px; --side: 270px; --toc: 220px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #07090c; --bg2: #0b0e13; --panel: #0f131a; --panel2: #141a23; --line: #1c2430; --line2: #263040;
  --ink: #e8edf4; --dim: #9aa6b6; --dimmer: #6b7787;
  --accent: #00ec97; --accent-ink: #04140e; --accent-soft: rgba(0, 236, 151, .12);
  --blue: #5aa2ff; --warn: #f0b90b; --down: #ff5c70; --up: #16c784;
  --code-bg: #0a0d12; --code-ink: #d6dde8; --code-bar: #0d1117; --code-line: #263040;
  color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #07090c; --bg2: #0b0e13; --panel: #0f131a; --panel2: #141a23; --line: #1c2430; --line2: #263040;
  --ink: #e8edf4; --dim: #9aa6b6; --dimmer: #6b7787;
  --accent: #00ec97; --accent-ink: #04140e; --accent-soft: rgba(0, 236, 151, .12);
  --blue: #5aa2ff; --warn: #f0b90b; --down: #ff5c70; --up: #16c784;
  --code-bg: #0a0d12; --code-ink: #d6dde8; --code-bar: #0d1117; --code-line: #263040;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.65 Inter, system-ui, -apple-system, Segoe UI, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
:not(pre) > code { font-size: .86em; background: var(--panel2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; color: var(--ink); white-space: nowrap; }

/* ------------------------------------------------------------------ top bar -- */
.top { position: sticky; top: 0; z-index: 30; height: 60px; display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.brand .tag { font: 600 11px Inter, sans-serif; color: var(--accent); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); padding: 2px 8px; border-radius: 99px; }
.top .search { flex: 1; max-width: 360px; margin-left: 12px; position: relative; }
.top .search input { width: 100%; height: 36px; border-radius: 8px; border: 1px solid var(--line2); background: var(--panel); color: var(--ink); padding: 0 12px 0 34px; font: inherit; font-size: 13.5px; }
.top .search svg { position: absolute; left: 11px; top: 10px; width: 16px; height: 16px; color: var(--dimmer); }
.top .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pill { font-size: 12.5px; color: var(--dim); border: 1px solid var(--line2); border-radius: 99px; padding: 4px 10px; white-space: nowrap; }
.pill b { color: var(--accent); font-weight: 600; }
.iconbtn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line2); background: var(--panel); color: var(--dim); cursor: pointer; }
.iconbtn:hover { color: var(--ink); }
.iconbtn svg { width: 17px; height: 17px; }
.menu-btn { display: none; }

/* ------------------------------------------------------------------- layout -- */
.wrap { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); }
nav.side { position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; padding: 18px 12px 40px 18px; border-right: 1px solid var(--line); background: var(--bg2); }
nav.side h4 { margin: 18px 8px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--dimmer); font-weight: 700; }
nav.side h4:first-child { margin-top: 2px; }
nav.side a { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 7px; color: var(--dim); font-size: 13.5px; line-height: 1.35; }
nav.side a:hover { background: var(--panel); color: var(--ink); text-decoration: none; }
nav.side a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
nav.side a .m { font: 700 9.5px "JetBrains Mono", monospace; color: var(--accent); width: 30px; flex: none; }
nav.side a.sub { padding-left: 18px; font-size: 13px; }
nav.side .hidden { display: none; }

main { min-width: 0; padding: 40px 56px 120px; max-width: 1180px; }
section.doc { padding-bottom: 28px; margin-bottom: 36px; border-bottom: 1px solid var(--line); }
section.doc:last-child { border-bottom: none; }
h1 { font-size: 38px; line-height: 1.15; letter-spacing: -.025em; margin: 0 0 14px; }
h2 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 12px; line-height: 1.25; }
h3 { font-size: 18.5px; margin: 30px 0 8px; letter-spacing: -.01em; }
h4 { font-size: 15px; margin: 20px 0 6px; }
p { margin: 0 0 14px; color: var(--ink); }
.lead { font-size: 17.5px; color: var(--dim); max-width: 760px; }
.dim { color: var(--dim); }
ul, ol { padding-left: 22px; margin: 0 0 14px; }
li { margin: 4px 0; }
hr { border: none; border-top: 1px solid var(--line); margin: 28px 0; }
.anchor { color: var(--dimmer); margin-left: 8px; font-weight: 400; opacity: 0; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }

.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; align-items: start; margin-bottom: 10px; }
.hero > *, .compare > *, .endpoint > * { min-width: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 18px 0 8px; }
.card { display: block; padding: 16px 16px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); transition: border-color .15s, transform .15s; }
.card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); text-decoration: none; transform: translateY(-1px); }
.card b { display: flex; align-items: center; gap: 8px; font-size: 14.5px; margin-bottom: 4px; }
.card span { font-size: 13px; color: var(--dim); line-height: 1.5; display: block; }
.card span span { display: inline; font-size: inherit; }
.card .ic { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.card .ic svg { width: 16px; height: 16px; }

.callout { display: flex; gap: 12px; padding: 13px 15px; border-radius: var(--radius); border: 1px solid var(--line2); background: var(--panel); margin: 16px 0; font-size: 14px; }
.callout svg { flex: none; width: 18px; height: 18px; margin-top: 2px; }
.callout p:last-child { margin: 0; }
.callout.info { border-color: color-mix(in srgb, var(--blue) 40%, var(--line)); background: color-mix(in srgb, var(--blue) 7%, var(--panel)); }
.callout.info svg { color: var(--blue); }
.callout.tip { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: color-mix(in srgb, var(--accent) 6%, var(--panel)); }
.callout.tip svg { color: var(--accent); }
.callout.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: color-mix(in srgb, var(--warn) 7%, var(--panel)); }
.callout.warn svg { color: var(--warn); }

table { width: 100%; border-collapse: collapse; margin: 10px 0 18px; font-size: 13.5px; }
th { text-align: left; font-weight: 600; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line2); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td:first-child { white-space: nowrap; }
.tablewrap { overflow-x: auto; }

.steps { counter-reset: step; list-style: none; padding: 0; margin: 14px 0 20px; }
.steps > li { counter-increment: step; position: relative; padding: 0 0 18px 46px; margin: 0; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: -1px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13.5px; border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.steps > li::after { content: ""; position: absolute; left: 15px; top: 34px; bottom: 4px; width: 1px; background: var(--line2); }
.steps > li:last-child::after { display: none; }
.steps > li > b:first-child { display: block; margin-bottom: 2px; }

.flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin: 16px 0 22px; }
.flow .node { flex: 1 1 150px; padding: 12px 13px; border: 1px solid var(--line2); border-radius: var(--radius); background: var(--panel); font-size: 13px; }
.flow .node b { display: block; font-size: 13.5px; margin-bottom: 3px; }
.flow .node span { color: var(--dim); }
.flow .arrow { align-self: center; color: var(--dimmer); font-size: 18px; }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0 18px; }
.compare > div { border: 1px solid var(--line2); border-radius: var(--radius); background: var(--panel); padding: 14px 16px; }
.compare h4 { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.compare ul { margin: 0; font-size: 13.5px; }
.badge { font: 700 10.5px Inter, sans-serif; padding: 2px 7px; border-radius: 5px; text-transform: uppercase; letter-spacing: .04em; }
.badge.g { background: var(--accent-soft); color: var(--accent); }
.badge.b { background: color-mix(in srgb, var(--blue) 15%, transparent); color: var(--blue); }

/* --------------------------------------------------------------------- code -- */
.code { position: relative; border: 1px solid var(--line2); border-radius: var(--radius); background: var(--code-bg); margin: 12px 0 18px; overflow: hidden; }
.code .bar { display: flex; align-items: center; gap: 2px; padding: 0 6px 0 4px; height: 38px; border-bottom: 1px solid var(--code-line); background: var(--code-bar); }
.code .bar button.tab { background: none; border: none; color: #8994a5; font: 500 12.5px Inter, sans-serif; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.code .bar button.tab.on { color: #fff; background: #1a2230; }
.code .bar .label { color: #8994a5; font: 500 12px Inter, sans-serif; padding: 0 8px; }
.code .copy { margin-left: auto; background: none; border: 1px solid #263040; color: #a3adbd; font: 500 11.5px Inter, sans-serif; border-radius: 6px; padding: 4px 9px; cursor: pointer; }
.code .copy:hover { color: #fff; border-color: #3a4658; }
.code pre { margin: 0; padding: 14px 16px; overflow: auto; font-size: 12.8px; line-height: 1.6; color: var(--code-ink); max-height: 560px; }
.code pre[hidden] { display: none; }
.tk-k { color: var(--k); } .tk-s { color: var(--s); } .tk-n { color: var(--n); } .tk-b { color: var(--b); } .tk-c { color: #6b7787; font-style: italic; }

/* --------------------------------------------------------------- reference -- */
.endpoint { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; padding: 30px 0 34px; border-top: 1px solid var(--line); }
.endpoint:first-of-type { border-top: none; }
.endpoint h3 { margin: 0 0 8px; font-size: 20px; }
.route { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font: 500 13.5px "JetBrains Mono", monospace; flex-wrap: wrap; }
.method { font: 700 11px "JetBrains Mono", monospace; padding: 3px 8px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.method.sse { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 35%, transparent); }
.route .path { color: var(--ink); word-break: break-all; }
.params { margin: 6px 0 16px; border-top: 1px solid var(--line); }
.param { padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.param .n { font: 600 13px "JetBrains Mono", monospace; color: var(--ink); }
.param .t { font: 12px "JetBrains Mono", monospace; color: var(--dimmer); margin-left: 6px; }
.param .req { font: 700 10px Inter, sans-serif; color: var(--down); text-transform: uppercase; letter-spacing: .05em; margin-left: 6px; }
.param .def { font-size: 12px; color: var(--dimmer); margin-left: 6px; }
.param p { margin: 3px 0 0; color: var(--dim); }
.param .enum { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px; }
.param .enum code { font-size: 11.5px; }
.sticky { position: sticky; top: 76px; }

.try { border: 1px solid var(--line2); border-radius: var(--radius); background: var(--panel); margin: 4px 0 16px; overflow: hidden; }
.try summary { cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: 13.5px; list-style: none; display: flex; align-items: center; gap: 8px; }
.try summary::-webkit-details-marker { display: none; }
.try summary svg { width: 14px; height: 14px; color: var(--accent); }
.try .body { padding: 4px 14px 14px; border-top: 1px solid var(--line); }
.try label { display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: center; gap: 10px; margin: 8px 0; font: 12.5px "JetBrains Mono", monospace; color: var(--dim); }
.try input, .try select { height: 32px; border-radius: 7px; border: 1px solid var(--line2); background: var(--bg); color: var(--ink); padding: 0 9px; font: 12.5px "JetBrains Mono", monospace; min-width: 0; }
.btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 8px; border: none; background: var(--accent); color: var(--accent-ink); font: 600 13px Inter, sans-serif; cursor: pointer; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.ghost { background: none; color: var(--ink); border: 1px solid var(--line2); }
.try .out { margin-top: 12px; }
.try .status { font: 600 12px "JetBrains Mono", monospace; margin-bottom: 6px; }
.try .status.ok { color: var(--up); } .try .status.err { color: var(--down); }

.keybox { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border: 1px dashed var(--line2); border-radius: var(--radius); background: var(--panel); margin: 14px 0; }
.keybox input { flex: 1; min-width: 220px; height: 34px; border-radius: 7px; border: 1px solid var(--line2); background: var(--bg); color: var(--ink); padding: 0 10px; font: 12.5px "JetBrains Mono", monospace; }
.keybox span { font-size: 12.5px; color: var(--dim); }

footer.foot { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); color: var(--dimmer); font-size: 13px; display: flex; gap: 18px; flex-wrap: wrap; }

.no-results { display: none; padding: 8px; font-size: 13px; color: var(--dimmer); }

/* ------------------------------------------------------------------- mobile -- */
@media (max-width: 1100px) {
  .endpoint { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .sticky { position: static; }
  main { padding: 32px 32px 100px; }
}
@media (max-width: 860px) {
  .wrap { grid-template-columns: minmax(0, 1fr); }
  nav.side { position: fixed; top: 60px; left: 0; width: 290px; z-index: 25; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 10px 40px rgba(0, 0, 0, .4); }
  body.nav-open nav.side { transform: none; }
  .menu-btn { display: grid; }
  .top .search { display: none; }
  .top .pill { display: none; }
  .top { padding: 0 12px; gap: 10px; }
  .brand { min-width: 0; }
  .top .right { gap: 6px; }
}
@media (max-width: 480px) {
  .brand .tag { display: none; }
  .hero, .compare { grid-template-columns: minmax(0, 1fr); }
  main { padding: 26px 16px 90px; }
  h1 { font-size: 30px; }
  .try label { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}

/* ------------------------------------------------------------------- portal -- */
.portal { border: 1px solid var(--line2); border-radius: 12px; background: var(--panel); padding: 16px 18px; margin: 14px 0; }
.pk-login { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pk-login > div { display: flex; flex-direction: column; gap: 2px; max-width: 560px; }
.pk-login .dim { font-size: 13px; }
.pk-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13.5px; margin-bottom: 12px; }
.pk-create { display: flex; gap: 8px; flex-wrap: wrap; }
.pk-create input { flex: 1; min-width: 220px; height: 36px; border-radius: 8px; border: 1px solid var(--line2); background: var(--bg); color: var(--ink); padding: 0 11px; font: inherit; font-size: 13.5px; }
.pk-fresh { border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.pk-keyrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pk-keyrow code { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: normal !important; font-size: 13px !important; padding: 8px 10px !important; background: var(--bg) !important; }
.pk-msg { margin-top: 10px; font-size: 13px; color: var(--up); }
.pk-msg.err { color: var(--down); }
.pk-table { margin-top: 14px; }
.pk-table tr.revoked td { color: var(--dimmer); }
.linkbtn { background: none; border: none; color: var(--down); font: 600 12.5px Inter, sans-serif; cursor: pointer; padding: 0; }

/* Light mode depth: hairline borders alone look flat on white. */
:root:not([data-theme="dark"]) .card, :root:not([data-theme="dark"]) .portal, :root:not([data-theme="dark"]) .try { box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .card, :root:not([data-theme="light"]) .portal, :root:not([data-theme="light"]) .try { box-shadow: none; } }
/* Theme button: a moon in light mode (switch to dark), a sun in dark mode. */
#theme .i-sun { display: none; }
:root[data-theme="dark"] #theme .i-sun { display: block; }
:root[data-theme="dark"] #theme .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #theme .i-sun { display: block; }
  :root:not([data-theme="light"]) #theme .i-moon { display: none; }
}
