/* CoAI API Reference — standalone documentation site.
   Design tokens restated from frontend/src/editions/global/styles/global-landing.css
   so docs.aitoken.cocloud.com and aitoken.cocloud.com read as one product. */

:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --ink: #151827;
  --muted: #596276;
  --subtle: #7d8698;
  --accent: #125e7a;
  --accent-hover: #0e4c63;
  --accent-soft: rgb(18 94 122 / 0.09);
  --hairline: rgb(21 24 39 / 0.09);
  --hairline-strong: rgb(21 24 39 / 0.16);
  --danger: #b42318;
  --warn: #b54708;
  --ok: #067647;
  --code-bg: #0f1622;
  --code-ink: #d8e0ee;
  --code-key: #7fd1c6;
  --code-str: #b6d78a;
  --code-num: #f0b98a;
  --code-kw: #8fb8f0;
  --code-com: #6c7a90;
  --shadow-card: 0 24px 56px -46px rgb(29 34 61 / 0.55);
  --radius: 14px;
  --topbar-h: 60px;
  --sidebar-w: 286px;
  --toc-w: 224px;
  --font-sans:
    "Avenir Next", Avenir, "Segoe UI", "PingFang SC", "PingFang TC", "Hiragino Sans",
    "Yu Gothic UI", "Yu Gothic", "Malgun Gothic", ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --bg: #0d1017;
  --surface: #141924;
  --surface-2: #1b2130;
  --ink: #e7ebf3;
  --muted: #a3adbf;
  --subtle: #8590a3;
  --accent: #4fb6cf;
  --accent-hover: #79cde1;
  --accent-soft: rgb(79 182 207 / 0.14);
  --hairline: rgb(231 235 243 / 0.11);
  --hairline-strong: rgb(231 235 243 / 0.2);
  --danger: #f0857a;
  --warn: #e5a35a;
  --ok: #6ec99a;
  --code-bg: #0a0e16;
  --shadow-card: 0 24px 56px -46px rgb(0 0 0 / 0.9);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--surface);
  padding: 0.6rem 1rem;
  border-radius: 0 0 8px 0;
}

.skip-link:focus {
  left: 0;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--topbar-h);
  padding: 0 1.25rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--hairline);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  flex-shrink: 0;
}

.brand:hover {
  text-decoration: none;
  color: var(--ink);
}

/* The mark is the product logo on its own white plate, exactly as the landing
   header carries it: the artwork ships with a white field, so a transparent
   container would show a white square floating in the dark theme. */
.brand__mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 9px;
  overflow: hidden;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--hairline);
}

.brand__mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand__accent {
  color: var(--accent);
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand__name {
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand__sub {
  font-size: 0.7rem;
  color: var(--subtle);
  font-weight: 550;
}

.topbar__search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  max-width: 380px;
  margin-left: auto;
}

.topbar__search svg {
  position: absolute;
  left: 0.65rem;
  width: 15px;
  height: 15px;
  color: var(--subtle);
  pointer-events: none;
}

.topbar__search input {
  width: 100%;
  height: 34px;
  padding: 0 2.2rem 0 2.1rem;
  border-radius: 9px;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.85rem;
}

.topbar__search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.topbar__search kbd {
  position: absolute;
  right: 0.5rem;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--hairline);
  border-radius: 5px;
  color: var(--subtle);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: var(--surface);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 7px;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 8px;
  border-radius: 9px;
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--hairline-strong);
}

.topbar__menu {
  display: none;
}

[data-theme="light"] .icon-moon,
[data-theme="dark"] .icon-sun {
  display: none;
}

.topbar__console {
  padding: 0.35rem 0.85rem;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.topbar__console:hover {
  background: var(--accent-hover);
  color: #fff;
  text-decoration: none;
}

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  max-width: 1500px;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 1.4rem 0.9rem 3rem 1.25rem;
  border-right: 1px solid var(--hairline);
}

.nav-group + .nav-group {
  margin-top: 1.35rem;
}

.nav-group__title {
  padding: 0 0.6rem;
  margin-bottom: 0.4rem;
  color: var(--subtle);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.36rem 0.6rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
}

.nav-item[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Request format. Four sibling POST rows take four different request bodies,
   so the mark is what separates them; it sits at the end of the row where the
   eye lands after the name, and never competes with the method badge. */
.format {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.32rem;
  color: var(--format-tone, var(--subtle));
}

.format__icon {
  display: block;
  height: 14px;
  width: 14px;
}

.format__icon svg {
  display: block;
  height: 100%;
  width: 100%;
}

.format--labelled {
  border-radius: 999px;
  padding: 0.2rem 0.55rem 0.2rem 0.45rem;
  background: color-mix(in srgb, var(--format-tone) 12%, transparent);
}

.format--labelled .format__icon {
  height: 15px;
  width: 15px;
}

.format__label {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* The sidebar row dims its mark until the row matters, so a column of icons
   does not read as louder than the page titles beside them. */
.nav-item .format {
  opacity: 0.72;
}

.nav-item:hover .format,
.nav-item[aria-current="page"] .format {
  opacity: 1;
}

.method {
  flex-shrink: 0;
  min-width: 38px;
  padding: 0.05rem 0.3rem;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-align: center;
  color: #fff;
}

.method--get {
  background: #067647;
}

.method--post {
  background: #1d64c9;
}

.nav-empty {
  padding: 0.6rem;
  color: var(--subtle);
  font-size: 0.85rem;
}

.sidebar-scrim {
  display: none;
}

.main {
  min-width: 0;
  padding: 2.2rem 2.6rem 4rem;
}

.toc {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 2.4rem 1.25rem 3rem 0.5rem;
}

.toc__title {
  color: var(--subtle);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.toc a {
  display: block;
  padding: 0.2rem 0.55rem;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.toc a:hover {
  color: var(--ink);
  text-decoration: none;
}

.toc a.is-active {
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.toc a[data-level="3"] {
  padding-left: 1.2rem;
  font-size: 0.775rem;
}

/* ---------- document ---------- */

.doc {
  max-width: 860px;
}

.doc__eyebrow {
  color: var(--subtle);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.doc h1 {
  margin: 0.35rem 0 0.5rem;
  font-size: 2rem;
  font-weight: 680;
  letter-spacing: -0.035em;
  line-height: 1.18;
}

.doc__lede {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 1.02rem;
}

.doc h2 {
  margin: 2.4rem 0 0.75rem;
  padding-top: 0.4rem;
  font-size: 1.28rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  scroll-margin-top: calc(var(--topbar-h) + 12px);
}

.doc h3 {
  margin: 1.7rem 0 0.6rem;
  font-size: 1.02rem;
  font-weight: 650;
  scroll-margin-top: calc(var(--topbar-h) + 12px);
}

.doc h2 .anchor,
.doc h3 .anchor {
  margin-left: 0.4rem;
  color: var(--subtle);
  opacity: 0;
  font-weight: 400;
  text-decoration: none;
}

.doc h2:hover .anchor,
.doc h3:hover .anchor {
  opacity: 1;
}

.doc p {
  margin: 0.7rem 0;
}

.doc ul,
.doc ol {
  margin: 0.7rem 0;
  padding-left: 1.3rem;
}

.doc li {
  margin: 0.32rem 0;
}

.doc code {
  padding: 0.1rem 0.32rem;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 0.84em;
  word-break: break-word;
}

.doc strong {
  font-weight: 650;
}

/* endpoint banner */

.endpoint {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 1.1rem 0;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-card);
  overflow-x: auto;
}

.endpoint .method {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  min-width: 52px;
}

.endpoint__path {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
}

.endpoint__host {
  color: var(--subtle);
  font-weight: 500;
}

/* Pushed to the trailing edge so the method and path stay a single unit. */
.endpoint .format--labelled {
  margin-left: auto;
}

/* tables */

.table-wrap {
  margin: 1rem 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.855rem;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  text-align: left;
  font-weight: 650;
  white-space: nowrap;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--hairline);
}

tbody td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td code,
th code {
  background: var(--surface-2);
  white-space: nowrap;
}

td:first-child code {
  color: var(--accent);
}

.req {
  color: var(--danger);
  font-size: 0.76rem;
  font-weight: 650;
  white-space: nowrap;
}

.opt {
  color: var(--subtle);
  font-size: 0.76rem;
  white-space: nowrap;
}

/* code blocks */

.code {
  margin: 1rem 0;
  border-radius: var(--radius);
  background: var(--code-bg);
  border: 1px solid var(--hairline);
  overflow: hidden;
}

.code__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem 0.4rem 0.9rem;
  background: rgb(255 255 255 / 0.04);
  border-bottom: 1px solid rgb(255 255 255 / 0.07);
}

.code__tabs {
  display: flex;
  gap: 0.15rem;
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.code__tabs::-webkit-scrollbar {
  display: none;
}

.code__tab {
  border: 0;
  background: transparent;
  color: #93a0b5;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.22rem 0.6rem;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}

.code__tab:hover {
  color: #dce4f0;
}

.code__tab[aria-selected="true"] {
  background: rgb(255 255 255 / 0.1);
  color: #fff;
}

.code__label {
  flex: 1 1 auto;
  color: #93a0b5;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.code__copy {
  flex-shrink: 0;
  border: 1px solid rgb(255 255 255 / 0.14);
  background: transparent;
  color: #b9c4d4;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 7px;
  cursor: pointer;
}

.code__copy:hover {
  background: rgb(255 255 255 / 0.1);
  color: #fff;
}

.code pre {
  margin: 0;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  color: var(--code-ink);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.62;
  tab-size: 2;
}

.code pre code {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: inherit;
  color: inherit;
  white-space: pre;
}

.tok-str {
  color: var(--code-str);
}

.tok-key {
  color: var(--code-key);
}

.tok-num {
  color: var(--code-num);
}

.tok-kw {
  color: var(--code-kw);
}

.tok-com {
  color: var(--code-com);
}

/* callouts */

.note {
  display: flex;
  gap: 0.7rem;
  margin: 1.1rem 0;
  padding: 0.75rem 0.95rem;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: var(--surface);
  font-size: 0.9rem;
}

.note::before {
  content: "i";
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-top: 0.16rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

.note--warn {
  border-color: color-mix(in srgb, var(--warn) 34%, var(--hairline));
  background: color-mix(in srgb, var(--warn) 7%, var(--surface));
}

.note--warn::before {
  content: "!";
  background: var(--warn);
}

.note p:first-child {
  margin-top: 0;
}

.note p:last-child {
  margin-bottom: 0;
}

/* cards on the overview page */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: 0.8rem;
  margin: 1.2rem 0;
}

.card {
  display: block;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-card);
}

.card:hover {
  border-color: var(--accent);
  color: var(--ink);
  text-decoration: none;
}

.card__title {
  font-weight: 650;
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
}

.card__text {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

/* pager */

.pager {
  display: flex;
  gap: 0.8rem;
  max-width: 860px;
  margin-top: 3rem;
}

.pager a {
  flex: 1 1 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
}

.pager a:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.pager a.is-next {
  text-align: right;
}

.pager__dir {
  display: block;
  color: var(--subtle);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pager__title {
  font-weight: 600;
  font-size: 0.92rem;
}

.doc-footer {
  max-width: 860px;
  margin-top: 2.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--hairline);
  color: var(--subtle);
  font-size: 0.82rem;
}

.doc-footer__sep {
  margin: 0 0.4rem;
}

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  .toc {
    display: none;
  }

  .main {
    padding: 2rem 2rem 4rem;
  }
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar {
    gap: 0.6rem;
    padding: 0 0.85rem;
  }

  .topbar__menu {
    display: grid;
  }

  .brand__sub {
    display: none;
  }

  .topbar__search {
    max-width: none;
  }

  .topbar__search kbd,
  .topbar__console {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    z-index: 35;
    width: min(320px, 86vw);
    background: var(--surface);
    transform: translateX(-104%);
    transition: transform 0.18s ease;
  }

  .sidebar.is-open {
    transform: none;
    box-shadow: 0 24px 60px -30px rgb(0 0 0 / 0.5);
  }

  .sidebar-scrim:not([hidden]) {
    display: block;
    position: fixed;
    inset: var(--topbar-h) 0 0;
    z-index: 30;
    background: rgb(9 12 20 / 0.42);
  }

  .main {
    padding: 1.5rem 1.1rem 3rem;
  }

  .doc h1 {
    font-size: 1.6rem;
  }

  .pager {
    flex-direction: column;
  }
}

@media print {
  .topbar,
  .sidebar,
  .toc,
  .pager {
    display: none;
  }
}
