/* TapeAPI Docs. Hand-written; the pages around it are generated by scripts/build-docs.mjs.
   Same tokens as the datasheet (site/style.css), but system faces: the datasheet's embedded fonts are subset to its
   own characters and would show missing glyphs here. No external resources (DeWEB SPEC 8).
   手写样式；页面由 scripts/build-docs.mjs 生成。沿用官网的颜色变量，但用系统字体：官网内嵌字体只含它自己用到的字符。 */
:root {
  color-scheme: light;
  --bg:        #EEF0F3;
  --panel:     #FFFFFF;
  --well:      #E4E7EC;
  --ink:       #0C0F14;
  --ink-2:     #3D4550;
  --ink-3:     #78818E;
  --hair:      #CCD2DA;
  --hair-2:    #E2E6EB;
  --amber:     #B4660A;
  --amber-ink: #8A4E06;
  --amber-well:#FDF1DE;
  --code-bg:   #F4F6F8;
  --shadow:    0 1px 0 rgba(12,15,20,.04), 0 12px 32px -20px rgba(12,15,20,.35);
  --top:       56px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:        #0A0C10;
    --panel:     #12161D;
    --well:      #0D1015;
    --ink:       #EEF1F5;
    --ink-2:     #A9B2BF;
    --ink-3:     #6E7887;
    --hair:      #262D38;
    --hair-2:    #1A202A;
    --amber:     #FFB224;
    --amber-ink: #FFC759;
    --amber-well:#231803;
    --code-bg:   #0D1015;
    --shadow:    0 0 0 1px rgba(255,255,255,.02), 0 20px 50px -30px #000;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #0A0C10;
  --panel:     #12161D;
  --well:      #0D1015;
  --ink:       #EEF1F5;
  --ink-2:     #A9B2BF;
  --ink-3:     #6E7887;
  --hair:      #262D38;
  --hair-2:    #1A202A;
  --amber:     #FFB224;
  --amber-ink: #FFC759;
  --amber-well:#231803;
  --code-bg:   #0D1015;
  --shadow:    0 0 0 1px rgba(255,255,255,.02), 0 20px 50px -30px #000;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top) + 16px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--amber-ink); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--amber) 40%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--amber); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
code, pre, kbd { font-family: var(--mono); }

/* ── top bar ─────────────────────────────────────────────── */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 10px 14px;
  height: var(--top); padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--hair);
}
.top .brand {
  font-weight: 800; font-size: 14px; letter-spacing: .26em; color: var(--ink); text-decoration: none;
}
.top .section {
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--amber-ink); text-decoration: none; border-left: 1px solid var(--hair); padding-left: 14px;
}
.top .sp { flex: 1 1 auto; }
.ctl {
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; line-height: 1;
  background: transparent; color: var(--ink-3); border: 1px solid var(--hair); border-radius: 0;
  padding: 7px 11px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.ctl:hover { color: var(--ink); border-color: var(--ink-3); }
.ctl.menu { display: none; }

.search { position: relative; flex: 0 1 300px; min-width: 0; margin-left: 12px; }
.search input {
  width: 100%; font: inherit; font-size: 14px; color: var(--ink);
  background: var(--panel); border: 1px solid var(--hair); border-radius: 0; padding: 7px 10px;
}
.search input::placeholder { color: var(--ink-3); }
.results {
  position: absolute; top: calc(100% + 6px); left: 0; width: min(520px, calc(100vw - 32px));
  max-height: min(70vh, 520px); overflow: auto;
  background: var(--panel); border: 1px solid var(--hair); box-shadow: var(--shadow);
}
.results a { display: block; padding: 10px 14px; border-bottom: 1px solid var(--hair-2); color: var(--ink); text-decoration: none; }
.results a:last-child { border-bottom: 0; }
.results a:hover, .results a[aria-selected="true"] { background: var(--amber-well); }
.results .rt { font-size: 14px; font-weight: 600; }
.results .rt span { color: var(--ink-3); font-weight: 400; }
.results .rx { font-size: 13px; color: var(--ink-2); line-height: 1.5; margin-top: 2px; }
.results mark { background: transparent; color: var(--amber-ink); font-weight: 600; }
.results .none { padding: 12px 14px; font-size: 14px; color: var(--ink-3); }

/* ── layout ──────────────────────────────────────────────── */
.layout {
  display: grid; grid-template-columns: 250px minmax(0, 1fr) 220px; gap: 0 40px;
  max-width: 1320px; margin: 0 auto; padding: 0 20px;
}
.side, .toc {
  position: sticky; top: calc(var(--top) + env(safe-area-inset-top, 0px)); align-self: start;
  max-height: calc(100vh - var(--top)); overflow-y: auto; padding: 28px 0 40px;
}
.gtitle {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3); margin: 0 0 8px;
}
.side .group + .group { margin-top: 24px; }
.side ul, .toc ul { list-style: none; margin: 0; padding: 0; }
.side a {
  display: block; padding: 6px 10px; margin-left: -10px; font-size: 14.5px; line-height: 1.4;
  color: var(--ink-2); text-decoration: none; border-left: 2px solid transparent;
}
.side a:hover { color: var(--ink); background: var(--well); }
.side a[aria-current="page"] { color: var(--ink); font-weight: 600; border-left-color: var(--amber); background: var(--panel); }
.toc { font-size: 13px; }
.toc li a { display: block; padding: 4px 0 4px 12px; color: var(--ink-3); text-decoration: none; border-left: 1px solid var(--hair); line-height: 1.4; }
.toc li.l3 a { padding-left: 24px; }
.toc li a:hover { color: var(--ink); }
.toc li a.on { color: var(--amber-ink); border-left-color: var(--amber); }

/* ── article ─────────────────────────────────────────────── */
.doc { min-width: 0; padding: 36px 0 64px; }
article { max-width: 760px; }
article h1 {
  font-size: clamp(30px, 4.4vw, 40px); line-height: 1.12; letter-spacing: -.02em; font-weight: 700;
  margin: 0 0 20px; text-wrap: balance;
}
article h2 {
  font-size: 23px; line-height: 1.3; letter-spacing: -.01em; font-weight: 650;
  margin: 48px 0 14px; padding-top: 18px; border-top: 1px solid var(--hair); text-wrap: balance;
}
article h3 { font-size: 18px; line-height: 1.4; font-weight: 650; margin: 32px 0 10px; }
article h2, article h3 { position: relative; }
.anchor {
  position: absolute; left: -1.1em; width: 1em; color: var(--ink-3); text-decoration: none; opacity: 0;
  font-weight: 400;
}
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }
article p { margin: 0 0 16px; color: var(--ink-2); }
article li { color: var(--ink-2); }
article strong { color: var(--ink); font-weight: 650; }
article ul, article ol { margin: 0 0 16px; padding-left: 1.4em; }
article li { margin: 6px 0; }
article li > ul, article li > ol { margin: 6px 0 0; }
article li::marker { color: var(--ink-3); }
article ol > li::marker { font-family: var(--mono); font-size: .9em; }
article :not(pre) > code {
  font-size: .86em; background: var(--well); color: var(--ink); padding: .12em .38em; border-radius: 3px;
  overflow-wrap: anywhere;
}
article a code { color: inherit; }
blockquote {
  margin: 0 0 18px; padding: 12px 16px; background: var(--amber-well); border-left: 3px solid var(--amber);
}
blockquote p { margin: 0; color: var(--ink); }
blockquote p + p { margin-top: 8px; }

.code { position: relative; margin: 0 0 18px; }
.code pre {
  margin: 0; padding: 16px 18px; overflow-x: auto;
  background: var(--code-bg); border: 1px solid var(--hair-2);
  font-size: 13px; line-height: 1.6; color: var(--ink); tab-size: 2;
}
.code pre[data-lang]::before {
  content: attr(data-lang); position: absolute; top: 0; right: 0;
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3); padding: 5px 9px;
}
.code .copy {
  position: absolute; bottom: 8px; right: 8px; opacity: 0; transition: opacity .15s;
  background: var(--panel);
}
.code:hover .copy, .code .copy:focus-visible { opacity: 1; }
@media (hover: none) { .code .copy { opacity: 1; } }

.table { overflow-x: auto; margin: 0 0 20px; border: 1px solid var(--hair-2); background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; line-height: 1.5; }
th, td { text-align: left; vertical-align: top; padding: 10px 14px; border-bottom: 1px solid var(--hair-2); }
th { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; background: var(--well); }
tr:last-child td { border-bottom: 0; }
td { color: var(--ink-2); }
td code { white-space: nowrap; }

.pn { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 760px; margin-top: 56px; }
.pn a {
  display: block; padding: 14px 16px; border: 1px solid var(--hair); background: var(--panel);
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px;
}
.pn a:hover { border-color: var(--amber); }
.pn a span { display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 400; margin-bottom: 4px; }
.pn .next { text-align: right; }
.edit { max-width: 760px; margin: 24px 0 0; font-size: 13px; }
.edit a { color: var(--ink-3); }

/* ── narrow screens ──────────────────────────────────────── */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 230px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 820px) {
  .top { padding: 0 16px; gap: 8px; }
  .top .section, .top a.ctl { display: none; }
  .ctl.menu { display: inline-block; }
  .search { margin-left: 0; flex: 1 1 auto; }
  .layout { display: block; padding: 0 16px; }
  .side {
    position: fixed; z-index: 15; left: 0; right: 0; bottom: 0; align-self: stretch; overflow-y: auto;
    top: calc(var(--top) + env(safe-area-inset-top, 0px)); max-height: none;
    padding: 20px 16px calc(40px + env(safe-area-inset-bottom, 0px)); background: var(--bg);
    border-top: 1px solid var(--hair); display: none;
  }
  body.nav-open .side { display: block; }
  body.nav-open { overflow: hidden; }
  .doc { padding-top: 24px; }
  article h2 { margin-top: 40px; }
  .anchor { display: none; }
  .pn { grid-template-columns: 1fr; }
  .pn .next { text-align: left; }
}
@media (max-width: 420px) {
  .top .brand { letter-spacing: .16em; }
  #theme-btn { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
