/* Brand fonts, self-hosted (SIL OFL): Kanit for headings, Inter for text. Same files as delivahere.com. */
@font-face { font-family: "Kanit"; font-style: normal; font-weight: 400; font-display: swap; src: url("assets/fonts/kanit-400.woff2") format("woff2"); }
@font-face { font-family: "Kanit"; font-style: normal; font-weight: 500; font-display: swap; src: url("assets/fonts/kanit-500.woff2") format("woff2"); }
@font-face { font-family: "Kanit"; font-style: normal; font-weight: 600; font-display: swap; src: url("assets/fonts/kanit-600.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("assets/fonts/inter-var.woff2") format("woff2"); }

:root {
  --bg: #fbfbf9;
  --surface: #ffffff;
  --surface-2: #f3f4f1;
  --border: #e3e5df;
  --text: #1b1f1d;
  --muted: #5d6661;
  --faint: #8a928d;
  --brand: #085133;
  --brand-soft: #e8f5e3;
  --brand-bright: #64bc49;
  --accent: #c2410c;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --ok: #157f3d;
  --code-bg: #f4f5f2;
  --get: #1f6feb;
  --post: #085133;
  --on-method: #ffffff;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.04);
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Kanit", var(--sans);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111413;
    --surface: #171b19;
    --surface-2: #1e2320;
    --border: #2b312e;
    --text: #e8ebe9;
    --muted: #a4ada8;
    --faint: #75807a;
    --brand: #66bc48;
    --brand-soft: #18301a;
    --brand-bright: #66bc48;
    --accent: #fb923c;
    --danger: #f97066;
    --danger-soft: #3a1714;
    --warn: #f5c451;
    --warn-soft: #34290f;
    --ok: #4ade80;
    --code-bg: #1b201d;
    --get: #6aa8ff;
    --post: #66bc48;
    --on-method: #0e1210;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111413;
  --surface: #171b19;
  --surface-2: #1e2320;
  --border: #2b312e;
  --text: #e8ebe9;
  --muted: #a4ada8;
  --faint: #75807a;
  --brand: #66bc48;
  --brand-soft: #18301a;
    --brand-bright: #66bc48;
  --accent: #fb923c;
  --danger: #f97066;
  --danger-soft: #3a1714;
  --warn: #f5c451;
  --warn-soft: #34290f;
  --ok: #4ade80;
  --code-bg: #1b201d;
  --get: #6aa8ff;
  --post: #66bc48;
  --on-method: #0e1210;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--sans);
}
a { color: var(--brand); }
a:hover { text-decoration-thickness: 2px; }
code, pre, kbd { font-family: var(--mono); font-size: 0.86em; }
:not(pre) > code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.05em 0.35em;
  overflow-wrap: anywhere;
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.5;
  margin: 0;
}
h1, h2, h3, h4 { font-family: var(--display); font-weight: 500; line-height: 1.25; letter-spacing: 0; }
h1 { font-size: 1.9rem; margin: 0 0 0.4em; }
h2 { font-size: 1.3rem; margin: 2em 0 0.6em; padding-top: 0.2em; }
h3 { font-size: 1.05rem; margin: 1.6em 0 0.5em; }
p, ul, ol { margin: 0 0 1em; }
li { margin: 0.25em 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.92em; margin: 0 0 1.2em; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.03em; }
.table-wrap { overflow-x: auto; margin: 0 0 1.2em; }
.table-wrap table { margin: 0; }
.muted { color: var(--muted); }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; top: 8px; left: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo.on-light { display: none; }
  :root:not([data-theme="light"]) .brand-logo.on-dark { display: block; }
}
:root[data-theme="dark"] .brand-logo.on-light { display: none; }
:root[data-theme="dark"] .brand-logo.on-dark { display: block; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  height: 58px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand-logo { display: block; height: 28px; width: auto; }
.brand-logo.on-dark { display: none; }
.brand-label {
  font: 500 1.05rem var(--display); color: var(--brand);
  padding-left: 12px; border-left: 1px solid var(--border);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid transparent; background: none; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.nav-toggle { display: none; }

.env-switch {
  display: flex; padding: 3px; gap: 2px; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.env-switch button {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  font: 600 0.82rem var(--sans); padding: 5px 12px; border-radius: 6px;
}
.env-switch button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.env-switch button[data-env="live"][aria-checked="true"] { color: var(--danger); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font: 600 0.86rem var(--sans); padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--bg); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--brand); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: none; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.on { background: var(--ok); }

/* Layout */
.layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: calc(100vh - 58px); }
.sidebar {
  position: sticky; top: 58px; height: calc(100vh - 58px); overflow-y: auto;
  border-right: 1px solid var(--border); padding: 16px 12px 24px; background: var(--bg);
}
.search input {
  width: 100%; font: 0.88rem var(--sans); padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.nav-group { margin-top: 18px; }
.nav-group-title { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); padding: 0 10px 6px; }
.nav-sub { font-size: 0.78rem; font-weight: 600; color: var(--muted); padding: 10px 10px 4px; }
.nav-link {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 7px;
  color: var(--text); text-decoration: none; font-size: 0.88rem; line-height: 1.35;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; box-shadow: inset 3px 0 0 var(--brand-bright); }
.nav-link .method { flex: none; }
.nav-link .label { overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot { margin-top: 24px; padding: 12px 10px 0; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--muted); }

main { padding: 32px 40px 80px; min-width: 0; outline: none; }
.loading { color: var(--muted); }
.page { max-width: 1200px; }
.prose { max-width: 760px; }
.lede { font-size: 1.08rem; color: var(--muted); max-width: 720px; }

.method {
  display: inline-block; min-width: 42px; text-align: center;
  font: 700 0.68rem var(--mono); letter-spacing: 0.04em; padding: 2px 6px; border-radius: 5px;
  color: var(--on-method); background: var(--post);
}
.method.get { background: var(--get); }
.method.event { background: var(--accent); }

.endpoint-line {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 0.92rem; padding: 10px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); margin: 0 0 1.2em;
}
.endpoint-line .path { overflow-wrap: anywhere; min-width: 0; flex: 1 1 0; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 1em; }
.badge { font-size: 0.74rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); background: var(--surface); }
.badge.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.badge.danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.badge.brand { color: var(--brand); background: var(--brand-soft); border-color: transparent; }

.op-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr); gap: 36px; align-items: start; }
.op-grid > .console-col { position: sticky; top: 78px; }

.callout {
  border-radius: var(--radius); padding: 12px 14px; margin: 0 0 1.2em;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 0.92rem;
}
.callout > :last-child { margin-bottom: 0; }
.callout.warn { background: var(--warn-soft); border-color: transparent; }
.callout.danger { background: var(--danger-soft); border-color: transparent; }
.callout.brand { background: var(--brand-soft); border-color: transparent; }

/* Schema tree */
.schema { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin: 0 0 1.4em; }
.field { padding: 10px 14px; border-top: 1px solid var(--border); }
.schema > .field:first-child { border-top: 0; }
.field-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.field-name { font: 600 0.88rem var(--mono); overflow-wrap: anywhere; }
.field-type { font: 0.78rem var(--mono); color: var(--muted); }
.field-req { font-size: 0.72rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
.field-desc { font-size: 0.88rem; color: var(--muted); margin-top: 3px; }
.field-desc p { margin: 0 0 0.4em; }
.field-desc > :last-child { margin-bottom: 0; }
.enum { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.enum code { font-size: 0.74rem; }
.children { margin: 8px 0 0 2px; border-left: 2px solid var(--border); padding-left: 0; }
.children > .field { border-top: 0; padding: 6px 0 6px 12px; }
details.more > summary { cursor: pointer; color: var(--brand); font-size: 0.82rem; margin-top: 6px; }
.variant-title { font: 600 0.8rem var(--sans); color: var(--muted); padding: 10px 14px 0; text-transform: uppercase; letter-spacing: 0.04em; }

.responses .resp { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 8px; }
.responses summary { cursor: pointer; padding: 10px 14px; display: flex; gap: 10px; align-items: baseline; }
.responses summary .code { font: 700 0.85rem var(--mono); }
.code.c2 { color: var(--ok); } .code.c4 { color: var(--warn); } .code.c5 { color: var(--danger); }
.resp-body { padding: 0 14px 14px; }
.resp-body pre { font-size: 0.8rem; max-height: 420px; }

/* Console */
.console { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.console-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.console-head h3 { margin: 0; font-size: 0.9rem; }
.console-head .env-pill { margin-left: auto; }
.env-pill { font: 700 0.72rem var(--sans); padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.env-pill.live { background: var(--danger-soft); color: var(--danger); }
.console-body { padding: 14px; display: grid; gap: 12px; }
.console label.f { display: grid; gap: 4px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.console label.f .hint { font-weight: 400; color: var(--faint); }
.sender-panel { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; }
.console input[type="text"], .console input[type="password"], .console input[type="number"], .console input[type="tel"], .console input[type="email"], .console select, .console textarea,
.dialog-body input {
  width: 100%; font: 0.86rem var(--mono); padding: 7px 10px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.console textarea { min-height: 220px; resize: vertical; line-height: 1.45; tab-size: 2; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.console-section-title { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
.result { border-top: 1px solid var(--border); }
.result-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-size: 0.82rem; flex-wrap: wrap; }
.result pre { border: 0; border-radius: 0; max-height: 460px; font-size: 0.8rem; }
.tabs { display: flex; gap: 4px; padding: 0 14px; border-bottom: 1px solid var(--border); }
.tabs button { border: 0; background: none; color: var(--muted); font: 600 0.8rem var(--sans); padding: 8px 6px; cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--brand-bright); }
.notice { font-size: 0.8rem; padding: 8px 10px; border-radius: 7px; background: var(--warn-soft); color: var(--text); }
.notice.danger { background: var(--danger-soft); }

.code-tabs { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 0 0 1.2em; background: var(--code-bg); }
.code-tabs .tabs { background: var(--surface-2); }
.code-tabs pre { border: 0; border-radius: 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 0 0 1.6em; }
.card { display: block; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; }
.card:hover { border-color: var(--brand-bright); }
.card strong { display: block; margin-bottom: 2px; }
.card span { color: var(--muted); font-size: 0.88rem; }

.flow { counter-reset: step; list-style: none; padding: 0; }
.flow li { position: relative; padding: 0 0 14px 40px; }
.flow li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font: 700 0.8rem var(--sans);
  background: var(--brand-soft); color: var(--brand);
}

.status-flow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 1.2em; font: 600 0.78rem var(--mono); }
.status-flow span { padding: 4px 9px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); }
.status-flow i { color: var(--faint); font-style: normal; }

/* Dialog */
dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgb(0 0 0 / 0.25); }
dialog::backdrop { background: rgb(0 0 0 / 0.4); }
.dialog-body { padding: 20px; }
.dialog-body h2 { margin: 0 0 0.4em; font-size: 1.15rem; }
.dialog-body fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 12px; padding: 10px 12px 12px; display: grid; gap: 8px; }
.dialog-body legend { font-weight: 700; font-size: 0.85rem; padding: 0 4px; }
.dialog-body label { display: grid; gap: 4px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.copy { margin-left: auto; }
.tab-label { padding: 8px 0; font-size: 0.78rem; color: var(--muted); }
.notice.ok { background: var(--brand-soft); }
.notice.spaced { margin: 10px 14px 0; }
.status-code { font: 700 0.9rem var(--mono); }
.small { margin: 0; font-size: 0.8rem; }
li.task { list-style: none; margin-left: -1.3em; }
li.task input { margin-right: 6px; }

@media (max-width: 1180px) {
  .op-grid { grid-template-columns: minmax(0, 1fr); }
  .op-grid > .console-col { position: static; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .nav-toggle { display: grid; }
  .sidebar {
    position: fixed; top: 58px; left: 0; bottom: 0; width: min(320px, 86vw); z-index: 30;
    transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  main { padding: 24px 16px 64px; }
  .brand-label { display: none; }
  .brand-logo { height: 24px; }
  #keysLabel { display: none; }
  h1 { font-size: 1.55rem; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
