/* Long-read pages: legal documents, docs, API. Nav | text (68–72ch) | on-page TOC; one column on phones. */
.doc { background: var(--bg); color: var(--text); }
.doc-progress { position: fixed; inset: 0 0 auto; height: 3px; z-index: 60; pointer-events: none; }
.doc-progress i { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }
.doc-top { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 10px; padding: 12px clamp(16px, 3vw, 40px);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.doc-wrap { display: grid; grid-template-columns: 240px minmax(0, 72ch) 220px; gap: clamp(24px, 4vw, 64px); justify-content: center;
  padding: 32px clamp(16px, 3vw, 40px) 80px; }
.doc-wrap-index { grid-template-columns: 240px minmax(0, 960px); }

.doc-nav, .doc-toc { position: sticky; top: 84px; align-self: start; max-height: calc(100dvh - 100px); overflow-y: auto; font-size: 15px; }
.doc-nav-h { margin: 18px 0 8px; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.doc-nav-h:first-child { margin-top: 0; }
.doc-nav ul, .doc-toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.doc-nav a, .doc-toc a { display: block; padding: 8px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; line-height: 1.35; }
.doc-nav a:hover, .doc-toc a:hover { background: var(--surface-2); color: var(--text); }
.doc-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
.doc-toc a { padding: 6px 12px; border-left: 2px solid var(--line); border-radius: 0 8px 8px 0; font-size: 14px; }
.doc-toc a.on { border-left-color: var(--accent); color: var(--text); }

.doc-main { min-width: 0; outline: none; }
.doc-crumbs { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.doc-crumbs a { color: inherit; }
.doc-main h1 { font: 600 clamp(32px, 4vw, 46px)/1.1 var(--serif); margin: 0 0 12px; letter-spacing: -.01em; }
.doc-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.doc-lead { font-size: 20px; line-height: 1.5; color: var(--text); margin: 0 0 24px; }
.doc-body { font-size: 17px; line-height: 1.7; }
.doc-body h2 { font: 600 28px/1.2 var(--serif); margin: 48px 0 12px; scroll-margin-top: 84px; display: flex; gap: 10px; align-items: baseline; }
.doc-body h2 .num { color: var(--accent-text); font-variant-numeric: tabular-nums; }
.doc-body h3 { font-size: 19px; margin: 28px 0 8px; scroll-margin-top: 84px; }
.doc-body p, .doc-body ul, .doc-body ol { margin: 0 0 14px; }
.doc-body ul, .doc-body ol { padding-left: 22px; }
.doc-body li { margin: 4px 0; }
.doc-body a { color: var(--accent-text); text-underline-offset: 3px; }
.doc-body code { font: 600 .88em ui-monospace, 'Cascadia Mono', Consolas, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; overflow-wrap: anywhere; }
.doc-body pre { margin: 10px 0 14px; padding: 14px 16px; border-radius: 14px; background: #1b1511; color: #f5ece2; overflow-x: auto; font-size: 13.5px; line-height: 1.55; }
.doc-body pre code { background: none; padding: 0; color: inherit; font-weight: 500; overflow-wrap: normal; }
.anchor { margin-left: 6px; opacity: 0; color: var(--muted) !important; text-decoration: none; font-size: .7em; transition: opacity var(--dur-2); }
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }

.doc-tldr { margin: 0 0 32px; padding: 18px 22px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.doc-tldr h2 { font: 800 13px var(--font); letter-spacing: .08em; text-transform: uppercase; margin: 0 0 8px; color: var(--accent-text); display: block; }
.doc-tldr ul { margin: 0; padding-left: 20px; }
.doc-callout { margin: 18px 0; padding: 16px 20px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); }
.doc-callout p { margin: 0; }
.doc-ref { font-size: 14px; color: var(--muted); line-height: 1.55; }
.doc-ref .doc-ref { display: block; margin-top: 4px; }
.todo { background: var(--warn-soft, #fff1d6); color: var(--warn, #8a4600); padding: 1px 6px; border-radius: 6px; font-weight: 600; }

/* definition list as cards, instead of a table */
.doc-dl { display: grid; gap: 10px; margin: 12px 0 18px; }
.doc-dl > div { display: grid; grid-template-columns: minmax(150px, 30%) 1fr; gap: 6px 18px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); }
.doc-dl dt { font-weight: 700; line-height: 1.45; }
.doc-dl dd { margin: 0; line-height: 1.55; }
.doc-tag { display: inline-block; margin: 6px 6px 0 0; padding: 2px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 700; }

.doc-steps { list-style: none; padding: 0 !important; counter-reset: st; display: grid; gap: 10px; }
.doc-steps li { counter-increment: st; position: relative; padding: 4px 0 4px 48px; margin: 0; }
.doc-steps li::before { content: counter(st); position: absolute; left: 0; top: 2px; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 800; font-size: 15px; }

/* API */
.api { margin: 14px 0 18px; padding: 16px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); }
.api > p { margin: 8px 0; }
.ep { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.ep code { font-size: 15px; background: none; padding: 0; }
.m { display: inline-block; min-width: 56px; padding: 3px 8px; border-radius: 8px; font: 800 12px ui-monospace, Consolas, monospace; text-align: center; letter-spacing: .03em; }
.m.get { background: #dff1e6; color: #166b3f; } .m.post { background: #fde4d2; color: #9a3206; } .m.put, .m.patch { background: #e2ecff; color: #1f4fae; } .m.del { background: #ffe4e1; color: #b42318; }
.role { margin-left: auto; font-size: 13px; color: var(--muted); font-weight: 700; }
.ep-list { list-style: none; padding: 0 !important; display: grid; gap: 6px; }
.ep-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 10px 12px; margin: 0; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); line-height: 1.5; }
.ep-list code { background: none; padding: 0; }

/* index */
.doc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin: 16px 0 36px; }
.doc-card { display: grid; gap: 6px; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--text);
  transition: transform var(--dur-2) var(--ease), border-color var(--dur-2); }
.doc-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.doc-card b { font: 600 20px var(--serif); }
.doc-card span { color: var(--muted); line-height: 1.5; }
.doc-main > h2 { font: 600 26px var(--serif); margin: 8px 0 0; }

/* mobile TOC */
.doc-toc-m { display: none; margin: 0 0 24px; }
.doc-toc-m button { width: 100%; display: flex; justify-content: space-between; align-items: center; min-height: 48px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; color: var(--text); }
.doc-toc-m button .ico { transition: transform var(--dur-2); }
.doc-toc-m button[aria-expanded="true"] .ico { transform: rotate(180deg); }
.doc-toc-m ol { list-style: none; margin: 6px 0 0; padding: 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.doc-toc-m a { display: block; padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 600; }

/* data request form */
.doc-form { margin: 16px 0 24px; padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 16px; line-height: 1.5; }
.doc-form .fgroup { display: grid; gap: 8px; margin: 0 0 18px; border: 0; padding: 0; min-width: 0; }
.doc-form .flabel { font-weight: 700; }
.doc-form .hint { color: var(--muted); font-size: 14px; }
.doc-form .ferr { color: var(--err); font-size: 14px; font-weight: 700; min-height: 0; }
.doc-form .ferr:empty { display: none; }
.doc-form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.doc-form .withbtn { display: flex; gap: 8px; }
.doc-form .withbtn .input { flex: 1; font-family: ui-monospace, Consolas, monospace; }
.doc-form [aria-invalid="true"] { border-color: var(--err); }
.doc-form .err-sum { display: none; margin: 0 0 16px; padding: 12px 16px; border-radius: 12px; background: var(--err-soft); color: var(--err); font-weight: 700; }
.doc-form .err-sum.on { display: block; }
.doc-done { text-align: left; }
.doc-done h3 { font: 600 26px var(--serif); margin: 0 0 8px; outline: none; }
.doc-done .code { font: 800 22px ui-monospace, Consolas, monospace; letter-spacing: .04em; color: var(--accent-text); }

.doc-foot { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; padding: 24px clamp(16px, 3vw, 40px); border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.doc-foot a { color: inherit; }

@media (max-width: 1240px) { .doc-wrap { grid-template-columns: 220px minmax(0, 72ch); } .doc-toc { display: none; } .doc-toc-m { display: block; } }
@media (max-width: 860px) {
  .doc-wrap, .doc-wrap-index { grid-template-columns: minmax(0, 1fr); padding-top: 20px; }
  .doc-nav { display: none; }
  .doc-body { font-size: 16.5px; }
  .doc-lead { font-size: 18px; }
  .doc-dl > div { grid-template-columns: 1fr; }
  .doc-form { padding: 16px; }
  .doc-form .row2 { grid-template-columns: 1fr; }
  .doc-form .withbtn { flex-direction: column; }
  .doc-top .btn.ghost { display: none; }
}
@media (prefers-reduced-motion: reduce) { .doc-card:hover { transform: none; } }
