/* docs.qcode.cc 浏览体验样式
 *
 * 为什么不放 base.html 的内联 <style>：那段 CSS 每个 HTML 都要重传一遍（本来就有 20KB），
 * 而 HTML 响应没有 Cache-Control。放 static/ 走 VersionedStaticFiles 的 immutable 缓存，
 * 全站只下载一次。实测把这些规则内联会让文档页 gzip 后涨 16.3%，移出来后基本持平。
 *
 * 加载顺序：base.html 内联 <style>（含 :root 变量）→ theme.css（深色覆盖）→ 本文件。
 * 因此这里可以放心使用 var(--*)，也能覆盖前两者。
 */

/* ═══════════ 全站（base.html）═══════════ */
/* ───────── 键盘可达：跳到正文 ───────── */
.skip-link {
    position: absolute; left: 8px; top: -48px; z-index: 300;
    background: var(--primary); color: #fff; padding: 8px 16px;
    border-radius: 0 0 8px 8px; font-size: 13px; font-weight: 600;
    transition: top 0.15s;
}
.skip-link:focus { top: 0; text-decoration: none; color: #fff; }

/* ───────── 顶栏搜索框 ───────── */
.nav-search { position: relative; flex: 0 1 320px; min-width: 0; }
.nav-search input {
    width: 100%; height: 34px; padding: 0 34px 0 32px;
    background: rgba(255,255,255,0.07); color: #fff;
    border: 1px solid rgba(255,255,255,0.14); border-radius: 8px;
    font-size: 13px; font-family: inherit; outline: none;
    transition: border-color 0.15s, background 0.15s;
}
.nav-search input::placeholder { color: rgba(255,255,255,0.42); }
.nav-search input:focus {
    border-color: var(--primary); background: rgba(255,255,255,0.12);
}
.nav-search .nav-search-icon {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    width: 14px; height: 14px; opacity: 0.45; pointer-events: none;
}
.nav-search kbd {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    font-family: inherit; font-size: 10px; line-height: 1;
    color: rgba(255,255,255,0.4); border: 1px solid rgba(255,255,255,0.18);
    border-radius: 4px; padding: 3px 5px; pointer-events: none;
}
.nav-suggest {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 210;
    background: var(--bg-white); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
    overflow: hidden; max-height: 60vh; overflow-y: auto;
}
.nav-suggest-item {
    display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
    padding: 9px 14px; font-size: 13px; color: var(--text-700);
}
.nav-suggest-item:hover, .nav-suggest-item.is-active {
    background: var(--primary-light); color: var(--text-900); text-decoration: none;
}
.nav-suggest-cat { font-size: 11px; color: var(--text-400); flex: none; }

/* 顶栏右侧那组（定价/企业版/主站/语言）。display 写在这里而不是元素的 style 属性上：
   内联样式压得过媒体查询，窄屏就藏不掉——改动前它整组 398px 宽，是移动端横向溢出的主因。 */
.nav-desktop-only { display: flex; gap: 6px; align-items: center; }

/* ───────── 汉堡与抽屉 ───────── */
.nav-burger {
    display: none; align-items: center; justify-content: center;
    width: 36px; height: 36px; flex: none;
    background: transparent; border: 1px solid rgba(255,255,255,0.18);
    border-radius: 8px; color: rgba(255,255,255,0.8); cursor: pointer;
}
.nav-burger:hover { color: #fff; border-color: rgba(255,255,255,0.35); }
.nav-drawer {
    display: none; position: absolute; left: 0; right: 0; top: 64px;
    background: #0A0A0B; border-bottom: 1px solid rgba(255,255,255,0.1);
    padding: 12px 16px 18px; z-index: 190; max-height: calc(100vh - 64px);
    overflow-y: auto;
}
.nav-drawer.is-open { display: block; }
.nav-drawer a {
    display: block; padding: 10px 12px; border-radius: 8px;
    color: rgba(255,255,255,0.78); font-size: 14px;
}
.nav-drawer a:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.nav-drawer .drawer-group { border-top: 1px solid rgba(255,255,255,0.08); margin-top: 10px; padding-top: 10px; }
.nav-drawer .drawer-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
    color: rgba(255,255,255,0.35); padding: 4px 12px;
}
body.drawer-open { overflow: hidden; }

/* ───────── 代码块：复制按钮与语言标签 ───────── */
.code-block { position: relative; }
.code-block > .code-copy {
    position: absolute; top: 8px; right: 8px; z-index: 2;
    display: inline-flex; align-items: center; gap: 5px;
    height: 26px; padding: 0 8px;
    background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.75);
    border: 1px solid rgba(255,255,255,0.14); border-radius: 6px;
    font-size: 11px; font-family: inherit; cursor: pointer;
    opacity: 0; transition: opacity 0.15s, background 0.15s;
}
.code-block:hover > .code-copy,
.code-block > .code-copy:focus-visible { opacity: 1; }
.code-block > .code-copy:hover { background: rgba(255,255,255,0.16); color: #fff; }
.code-block > .code-copy.is-copied { background: rgba(52,199,89,0.22); color: #7ee2a8; opacity: 1; }
.code-block > .code-copy.is-failed { background: rgba(255,69,58,0.22); color: #ffb3ad; opacity: 1; }
.code-copy-icon {
    width: 12px; height: 12px; flex: none;
    border: 1.5px solid currentColor; border-radius: 3px;
    box-shadow: 2.5px -2.5px 0 -1.5px currentColor, 3.5px -3.5px 0 -1.5px currentColor;
}
.code-block.is-copied .code-copy-icon, .code-copy.is-copied .code-copy-icon { box-shadow: none; }
.code-block[data-lang]::before {
    content: attr(data-lang);
    position: absolute; top: 10px; left: 14px;
    font-size: 10.5px; letter-spacing: 0.04em; text-transform: lowercase;
    color: rgba(255,255,255,0.34); pointer-events: none;
}
.code-block[data-lang] pre { padding-top: 28px; }
/* 触屏没有 hover，按钮常显 */
@media (hover: none) {
    .code-block > .code-copy { opacity: 0.9; }
}

/* ───────── 目录当前位置 ───────── */
.doc-toc a.is-active {
    color: var(--primary); font-weight: 600;
    border-left: 2px solid var(--primary); margin-left: -8px; padding-left: 6px;
}

/* ───────── ≤1024px：导航收进抽屉 ───────── */
@media (max-width: 1024px) {
    .top-nav { padding: 0 12px; gap: 10px; }
    .nav-burger { display: inline-flex; }
    .nav-links, .nav-desktop-only { display: none; }
    .nav-brand span:not(.logo-mark) { display: none; }
    .nav-search { flex: 1 1 auto; }
    .nav-search kbd { display: none; }
}

/* ═══════════ 文档详情页（document.html）═══════════ */
.doc-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr) 200px;
    max-width: 1440px; margin: 0 auto;
    min-height: calc(100vh - 64px);
}

/* Sidebar */
.doc-sidebar {
    border-right: 1px solid var(--border);
    padding: 24px 12px; background: var(--bg-white);
    position: sticky; top: 64px; height: calc(100vh - 64px);
    overflow-y: auto;
}
.side-filter {
    width: 100%; height: 32px; margin-bottom: 14px; padding: 0 10px;
    font-size: 12.5px; font-family: inherit; color: var(--text-900);
    background: var(--bg-white); border: 1px solid var(--border);
    border-radius: 8px; outline: none;
}
.side-filter:focus { border-color: var(--primary); }
.side-section { margin-bottom: 10px; }
.side-section[hidden] { display: none; }
.side-section-title {
    font-size: 11px; font-weight: 700; color: var(--text-400);
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 6px 12px; margin-bottom: 2px;
    cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px;
    border-radius: 6px;
}
.side-section-title::-webkit-details-marker { display: none; }
.side-section-title:hover { background: var(--border-light); color: var(--text-700); }
.side-section-title::after {
    content: ''; margin-left: auto; width: 6px; height: 6px;
    border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg); transition: transform 0.15s;
}
.side-section[open] > .side-section-title::after { transform: rotate(45deg); }
.side-link {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 12px 7px 20px; font-size: 13px; color: var(--text-500);
    border-radius: 6px; border-left: 2px solid transparent;
    transition: all 0.1s; margin: 1px 0;
}
.side-link:hover { color: var(--text-900); background: var(--border-light); text-decoration: none; }
.side-link.active {
    color: var(--primary); background: var(--primary-light);
    border-left-color: var(--primary); font-weight: 600;
}
.side-link .lock { font-size: 10px; opacity: 0.6; }

/* Content */
.doc-content {
    padding: 40px 56px; max-width: 920px;
    background: var(--bg-white);
}
.doc-meta { margin-bottom: 24px; }
.doc-meta .breadcrumb {
    font-size: 13px; color: var(--text-400); margin-bottom: 8px;
}
.doc-meta .breadcrumb a { color: var(--text-500); }

/* TOC */
.doc-toc {
    padding: 24px 16px;
    position: sticky; top: 64px; height: calc(100vh - 64px);
    overflow-y: auto;
}
.toc-title {
    font-size: 11px; font-weight: 700; color: var(--text-400);
    text-transform: uppercase; letter-spacing: 0.06em;
    margin-bottom: 12px;
}
.doc-toc a {
    display: block; font-size: 12px; color: var(--text-400);
    padding: 3px 0; line-height: 1.5;
    transition: color 0.1s;
    /* 环境变量名这类长串在 200px 宽的目录里会被直接切掉 */
    overflow-wrap: anywhere;
}
.doc-toc a:hover { color: var(--primary); text-decoration: none; }
.doc-toc ul { list-style: none; padding-left: 12px; }
.doc-toc > ul { padding-left: 0; }

/* Prev/Next */
.doc-nav {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
    margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border);
}
.doc-nav-item {
    padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg);
    transition: all 0.15s; color: var(--text-700);
}
.doc-nav-item:hover { border-color: var(--primary); background: var(--primary-light); text-decoration: none; color: var(--text-900); }
.doc-nav-item .label { font-size: 12px; color: var(--text-400); font-weight: 600; margin-bottom: 4px; }
.doc-nav-item .title { font-size: 14px; font-weight: 600; }

/* 宽表：滚动交给外层容器。表格自身保持 display:table，
   否则 width:max-content 会让窄表也缩成一团。min-width:max-content 保证宽表不被压扁。 */
.prose .table-wrap {
    overflow-x: auto; max-width: 100%; margin: 16px 0;
    border: 1px solid var(--border); border-radius: 12px;
    /* 右边还有列没显示时给个阴影提示。表格本来就能横向滚，但滚动条是 overlay 式的，
       不滚就看不见——审计里"数据被裁掉且找不回来"说的就是这个观感。
       local 背景跟着内容滚，scroll 背景固定：滚到尽头时白色把阴影盖住，提示自然消失。 */
    background:
        linear-gradient(to right, var(--bg-white) 30%, rgba(255, 255, 255, 0)) left / 32px 100% no-repeat local,
        linear-gradient(to left, var(--bg-white) 30%, rgba(255, 255, 255, 0)) right / 32px 100% no-repeat local,
        radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0)) left / 14px 100% no-repeat scroll,
        radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0)) right / 14px 100% no-repeat scroll;
}
.prose .table-wrap > table {
    display: table; width: 100%; min-width: max-content;
    margin: 0; border: none; border-radius: 0;
}
.prose pre { overflow-x: auto; max-width: 100%; }

/* 行内 code 与长链接：ANTHROPIC_BASE_URL、完整 URL 这类不含空格的长串在窄屏顶得出屏。
   anywhere 只在放不下时才断，正常行宽下与不加一样。 */
.prose { overflow-wrap: break-word; }
.prose :not(pre) > code, .prose a { overflow-wrap: anywhere; }

/* 移动端才出现的两个入口：左侧目录抽屉、正文顶部的本页目录 */
.doc-mobile-bar { display: none; gap: 8px; margin-bottom: 14px; }
.doc-mobile-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 12px; font-size: 13px; font-weight: 600;
    color: var(--text-700); background: var(--bg-white);
    border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.doc-mobile-btn:hover { border-color: var(--primary); color: var(--primary); }
.doc-toc-inline { display: none; margin: 0 0 20px; }
.doc-toc-inline > summary {
    cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-700);
    padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg-white); list-style: none;
}
.doc-toc-inline > summary::-webkit-details-marker { display: none; }
.doc-toc-inline[open] > summary { border-radius: 8px 8px 0 0; }
.doc-toc-inline .toc { border: 1px solid var(--border); border-top: none;
    border-radius: 0 0 8px 8px; padding: 10px 14px; }
.doc-toc-inline a { display: block; font-size: 13px; color: var(--text-500); padding: 4px 0; }
.doc-toc-inline ul { list-style: none; padding-left: 14px; margin: 0; }
.doc-toc-inline > details > ul, .doc-toc-inline .toc > ul { padding-left: 0; }
.doc-updated { font-size: 12px; color: var(--text-400); margin-top: 6px; }

/* Middle breakpoint: 1024-1280px — drop the right TOC/CTA rail to give
   content room. Keep left sidebar for navigation. */
@media (max-width: 1280px) {
    .doc-layout { grid-template-columns: 240px minmax(0, 1fr); max-width: 1180px; }
    .doc-toc { display: none; }
    .doc-toc-inline { display: block; }   /* 右栏没了，目录挪到正文顶部 */
    .doc-content { padding: 32px 40px; max-width: none; }
}

/* 窄屏 / 平板：单列。
   🔴 中列必须写成 minmax(0, 1fr)：grid item 的默认 min-width 是 auto，
   写 1fr 会被最宽的那行代码整个撑开——改动前 390px 视口下正文实际宽 1149px，
   标题、正文、引用全部被裁到屏幕外。1280 与桌面断点本来就是 minmax(0,1fr)，
   唯独这一处漏了。 */
@media (max-width: 1024px) {
    .doc-layout { grid-template-columns: minmax(0, 1fr); }
    .doc-toc { display: none; }
    .doc-content { padding: 20px 16px; max-width: 100%; min-width: 0; }
    .doc-mobile-bar { display: flex; }
    /* 侧栏改成抽屉：66 条导航在窄屏原本是 display:none，等于完全没有导航 */
    .doc-sidebar {
        position: fixed; left: 0; top: 64px; bottom: 0; width: min(320px, 86vw);
        z-index: 180; transform: translateX(-100%); transition: transform 0.2s;
        box-shadow: var(--shadow-lg); height: auto;
    }
    .doc-sidebar.is-open { transform: translateX(0); }
    .prose h1 { font-size: 26px; }
    .prose h2 { font-size: 20px; }
}

/* ═══════════ 首屏「60 秒接上」三步（首页 + /docs hub 共用）═══════════ */
.qs-steps { max-width: 1100px; margin: 0 auto; padding: 28px 24px 8px; }
.qs-head {
    font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--text-400); margin-bottom: 14px;
}
.qs-grid {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px;
}
.qs-card {
    position: relative; padding: 18px 18px 16px;
    background: var(--bg-white); border: 1px solid var(--border);
    border-radius: var(--radius-xl); min-width: 0;
    display: flex; flex-direction: column;
}
/* 第三张卡装着一排工具，比前两张高不少；把链接压到卡片底部，三张看起来才是一组 */
.qs-card > .qs-link:last-child, .qs-card > .qs-tools { margin-top: auto; }
.qs-num {
    position: absolute; top: 14px; right: 16px;
    font-size: 22px; font-weight: 800; color: var(--border); line-height: 1;
}
.qs-title { font-size: 15px; font-weight: 700; color: var(--text-900); margin-bottom: 6px; }
.qs-desc { font-size: 13px; color: var(--text-500); line-height: 1.55; margin-bottom: 12px; }
.qs-link {
    display: inline-block; font-size: 13px; font-weight: 600;
    color: var(--primary); text-decoration: none;
}
.qs-link:hover { text-decoration: underline; }
.qs-link-sub { display: block; margin-top: 6px; font-weight: 500; color: var(--text-500); }
.qs-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.qs-tool {
    display: inline-block; padding: 5px 10px; font-size: 12.5px;
    color: var(--text-700); background: var(--border-light);
    border: 1px solid transparent; border-radius: 999px; text-decoration: none;
}
.qs-tool:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.qs-tool-more { background: transparent; color: var(--primary); font-weight: 600; }
@media (max-width: 900px) {
    .qs-grid { grid-template-columns: minmax(0, 1fr); }
    .qs-steps { padding: 20px 16px 4px; }
}

/* 搜索结果里的关键词高亮（ts_headline 的记号在路由里转义后换成 <mark>） */
.result-excerpt mark {
    background: var(--primary-light); color: var(--primary-hover);
    padding: 0 2px; border-radius: 3px; font-weight: 600;
}

/* hub 分类卡片副标题：来自 _meta.json 的分类 description（四语） */
.cat-desc { font-size: 12.5px; color: var(--text-400); font-weight: 400;
            margin-left: 10px; flex: 1 1 auto; min-width: 0;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 860px) { .cat-desc { display: none; } }
