/* docs.css — 共用於 /features 與 /tech 文檔頁（主題 token 對齊 index.css） */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #0c0c12;
    --card: rgba(255,255,255,0.05);
    --card-hover: rgba(255,255,255,0.08);
    --border: rgba(255,255,255,0.12);
    --border-hover: rgba(255,255,255,0.22);
    --text: #f0f0f3;
    --text-dim: #b0b0c0;
    --text-mid: #d0d0dc;
    --accent: #3b82f6;
    --accent2: #8b5cf6;
    --green: #34d399;
    --amber: #fbbf24;
    --nav-bg: rgba(12,12,18,0.7);
    --h1-grad: linear-gradient(135deg, #fff 0%, #fff 40%, rgba(59,130,246,0.85) 100%);
    --btn2-bg: rgba(255,255,255,0.04);
    --btn2-hover: rgba(255,255,255,0.08);
    --code-bg: rgba(0,0,0,0.55);
    --code-inline-bg: rgba(139,92,246,0.14);
    --code-inline-text: #d6c8ff;
    --toc-active-bg: rgba(59,130,246,0.12);
    --note-bg: rgba(59,130,246,0.08);
    --warn-bg: rgba(251,191,36,0.09);
    --warn-border: rgba(251,191,36,0.4);
    --road-bg: rgba(139,92,246,0.09);
    --road-border: rgba(139,92,246,0.4);
}

[data-theme="light"] {
    --bg: #f8f9fb;
    --card: rgba(0,0,0,0.02);
    --card-hover: rgba(0,0,0,0.04);
    --border: rgba(0,0,0,0.08);
    --border-hover: rgba(0,0,0,0.15);
    --text: #111827;
    --text-dim: #4b5563;
    --text-mid: #374151;
    --accent: #2563eb;
    --accent2: #7c3aed;
    --green: #059669;
    --amber: #b45309;
    --nav-bg: rgba(248,249,251,0.8);
    --h1-grad: linear-gradient(135deg, #111827 0%, #111827 40%, rgba(37,99,235,0.85) 100%);
    --btn2-bg: rgba(0,0,0,0.03);
    --btn2-hover: rgba(0,0,0,0.06);
    --code-bg: #1b1b28;
    --code-inline-bg: rgba(124,58,237,0.1);
    --code-inline-text: #6d28d9;
    --toc-active-bg: rgba(37,99,235,0.1);
    --note-bg: rgba(37,99,235,0.06);
    --warn-bg: rgba(180,83,9,0.07);
    --warn-border: rgba(180,83,9,0.35);
    --road-bg: rgba(124,58,237,0.06);
    --road-border: rgba(124,58,237,0.35);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.7;
    transition: background 0.3s, color 0.3s;
}

/* 導航（對齊首頁） */
.nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    padding: 1.1rem 2.5rem;
    display: flex; align-items: center; justify-content: space-between;
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border);
}
.nav-logo {
    display: flex; align-items: center; gap: 0.6rem;
    font-weight: 700; font-size: 1.15rem; letter-spacing: -0.02em;
    text-decoration: none; color: var(--text);
}
.nav-logo-img { width: 26px; height: 26px; object-fit: contain; }
.nav-right { display: flex; align-items: center; gap: 1.1rem; }
.nav-link {
    color: var(--text-dim); text-decoration: none;
    font-size: 0.875rem; font-weight: 500; transition: color 0.2s;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--accent); }
.nav-btn {
    background: var(--btn2-bg); border: 1px solid var(--border);
    color: var(--text-dim); padding: 0.4rem 0.65rem; border-radius: 8px;
    cursor: pointer; font-size: 0.8rem; font-weight: 500;
    transition: all 0.2s; font-family: inherit;
    display: flex; align-items: center; justify-content: center;
}
.nav-btn:hover { border-color: var(--border-hover); color: var(--text); background: var(--btn2-hover); }
.nav-btn svg { width: 16px; height: 16px; }
.lang-btn { padding: 0.4rem 0.85rem; }

/* 頁首 */
.doc-hero { max-width: 1180px; margin: 0 auto; padding: 7.5rem 2rem 1.5rem; }
.doc-eyebrow {
    display: inline-block; font-size: 0.78rem; font-weight: 600;
    letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent);
    margin-bottom: 0.9rem;
}
.doc-hero h1 {
    font-size: 3rem; font-weight: 800; line-height: 1.05; letter-spacing: -0.035em;
    margin-bottom: 1rem;
    background: var(--h1-grad);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.doc-hero p { font-size: 1.12rem; color: var(--text-dim); max-width: 640px; }

/* 主體佈局：sticky TOC + 內容 */
.doc-layout {
    max-width: 1180px; margin: 0 auto; padding: 1.5rem 2rem 4rem;
    display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 3rem; align-items: start;
}
.toc { position: sticky; top: 6rem; align-self: start; }
.toc-title {
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--text-dim); margin-bottom: 0.85rem; padding-left: 0.85rem;
}
.toc a {
    display: block; padding: 0.42rem 0.85rem; margin-bottom: 0.15rem;
    color: var(--text-dim); text-decoration: none; font-size: 0.86rem;
    border-left: 2px solid transparent; border-radius: 0 6px 6px 0;
    transition: all 0.15s;
}
.toc a:hover { color: var(--text); background: var(--card-hover); }
.toc a.active {
    color: var(--accent); border-left-color: var(--accent);
    background: var(--toc-active-bg); font-weight: 600;
}

.doc-content { min-width: 0; }

/* 區塊卡片 */
.sec {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 18px; padding: 2rem 2.25rem; margin-bottom: 1.5rem;
    scroll-margin-top: 6rem;
}
.sec-head { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.4rem; }
.sec-ic { font-size: 1.5rem; line-height: 1; }
.sec h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.sec-lead { color: var(--text-dim); font-size: 0.98rem; margin: 0.35rem 0 1.25rem; }
/* 內文行內鏈接：品牌域名等（keylockr.app） */
.klink { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.klink:hover { text-decoration-thickness: 2px; }

.sec h3 {
    font-size: 1.05rem; font-weight: 650; margin: 1.6rem 0 0.6rem;
    letter-spacing: -0.01em; color: var(--text);
}
.sec h3:first-of-type { margin-top: 0.5rem; }
.sec p { color: var(--text-mid); font-size: 0.94rem; margin-bottom: 0.85rem; }
.sec p:last-child { margin-bottom: 0; }
.sec strong { color: var(--text); font-weight: 650; }

.sec ul, .sec ol { margin: 0 0 0.95rem 1.2rem; }
.sec li { color: var(--text-mid); font-size: 0.94rem; margin-bottom: 0.5rem; padding-left: 0.2rem; }
.sec li:last-child { margin-bottom: 0; }

/* 內聯 code */
code.k {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
    font-size: 0.85em; background: var(--code-inline-bg); color: var(--code-inline-text);
    padding: 0.1em 0.42em; border-radius: 5px; white-space: nowrap;
}

/* 代碼塊 */
.code {
    display: block; background: var(--code-bg); border: 1px solid var(--border);
    border-radius: 12px; padding: 1rem 1.2rem; margin: 0.4rem 0 1.1rem;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
    font-size: 0.83rem; line-height: 1.65; color: #d6e2ff;
    overflow-x: auto; white-space: pre;
}
.code .c { color: #7a8299; }        /* 註釋 */
.code .g { color: #34d399; }        /* 提示/成功 */
.code .kw { color: #c084fc; }       /* 關鍵字 */

/* 帶標題的代碼卡 */
.codecard { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin: 0.4rem 0 1.1rem; }
.codecard-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.55rem 1rem; background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem; color: var(--text-dim); font-family: ui-monospace, monospace;
}
.copy-btn {
    background: none; border: none; color: var(--text-dim);
    cursor: pointer; padding: 0.25rem; border-radius: 4px; display: flex; align-items: center;
    transition: all 0.2s;
}
.copy-btn:hover { color: var(--text); background: var(--btn2-hover); }
.copy-btn svg { width: 15px; height: 15px; }
.codecard .code { border: none; border-radius: 0; margin: 0; }

/* Callout */
.callout {
    border-radius: 12px; padding: 0.95rem 1.15rem; margin: 0.4rem 0 1.1rem;
    font-size: 0.9rem; color: var(--text-mid);
    border: 1px solid var(--border); background: var(--note-bg);
}
.callout.warn { background: var(--warn-bg); border-color: var(--warn-border); }
.callout.road { background: var(--road-bg); border-color: var(--road-border); }
.callout strong { display: inline; }
.callout .tag {
    display: inline-block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em;
    text-transform: uppercase; margin-right: 0.5rem; padding: 0.1rem 0.45rem; border-radius: 5px;
    background: var(--accent); color: #fff; vertical-align: 1px;
}
.callout.warn .tag { background: var(--amber); color: #1b1b28; }
.callout.road .tag { background: var(--accent2); color: #fff; }

/* 表格 */
.table-wrap { overflow-x: auto; margin: 0.4rem 0 1.1rem; border: 1px solid var(--border); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.65rem 1rem; border-bottom: 1px solid var(--border); }
th { color: var(--text); font-weight: 650; background: rgba(255,255,255,0.03); white-space: nowrap; }
td { color: var(--text-mid); }
tr:last-child td { border-bottom: none; }
td code, th code {
    font-family: ui-monospace, monospace; font-size: 0.85em;
    color: var(--code-inline-text); white-space: nowrap;
}

/* 特性網格（features 頁 hero 下的簡覽） */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin: 0.4rem 0 0.5rem; }
.grid-item {
    background: rgba(255,255,255,0.02); border: 1px solid var(--border);
    border-radius: 12px; padding: 1rem 1.15rem;
}
.grid-item .gi-ic { font-size: 1.25rem; margin-bottom: 0.4rem; }
.grid-item h4 { font-size: 0.95rem; font-weight: 650; margin-bottom: 0.3rem; }
.grid-item p { font-size: 0.86rem; color: var(--text-dim); margin: 0; }

/* CTA 命令行 */
.cta {
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    margin-top: 0.5rem;
}
.btn-primary {
    display: inline-flex; align-items: center; gap: 0.5rem;
    background: var(--accent); color: #fff; padding: 0.7rem 1.5rem;
    border-radius: 11px; text-decoration: none; font-weight: 600; font-size: 0.92rem;
    box-shadow: 0 4px 20px rgba(59,130,246,0.3); transition: box-shadow 0.3s;
}
.btn-primary:hover { box-shadow: 0 4px 30px rgba(59,130,246,0.45); }
.btn-ghost {
    display: inline-flex; align-items: center; gap: 0.4rem;
    color: var(--text-dim); text-decoration: none; font-size: 0.9rem; font-weight: 500;
    transition: color 0.2s;
}
.btn-ghost:hover { color: var(--text); }

/* Footer */
footer {
    max-width: 1180px; margin: 0 auto; padding: 2rem 2rem 3rem;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.footer-links { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.footer-links a { color: var(--text-dim); text-decoration: none; font-size: 0.85rem; transition: color 0.2s; }
.footer-links a:hover { color: var(--text); }
.copyright { color: var(--text-dim); font-size: 0.8rem; }

@media (max-width: 900px) {
    .doc-layout { grid-template-columns: 1fr; gap: 1rem; }
    .toc {
        position: static; top: auto;
        display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.5rem;
        margin-bottom: 0.5rem; -webkit-overflow-scrolling: touch;
    }
    .toc-title { display: none; }
    .toc a {
        white-space: nowrap; border-left: none; border: 1px solid var(--border);
        border-radius: 8px; padding: 0.4rem 0.8rem; margin: 0;
    }
    .toc a.active { border-color: var(--accent); }
}
@media (max-width: 640px) {
    .nav { padding: 1rem 1.25rem; }
    .nav-right { gap: 0.7rem; }
    .nav-link.hide-sm { display: none; }
    .doc-hero { padding: 6.5rem 1.25rem 1rem; }
    .doc-hero h1 { font-size: 2.2rem; }
    .doc-layout { padding: 1rem 1.25rem 3rem; }
    .sec { padding: 1.5rem 1.35rem; }
    footer { flex-direction: column; gap: 1rem; text-align: center; }
}
