/* ============================================================
   LANSyncBox 文档 · 样式
   布局参考常见产品文档站：白色页面、贴边侧栏、单一细线分隔。
   侧栏不做卡片，不使用阴影；强调色只用于当前项和少量提示。
   ============================================================ */

:root {
    --accent: #12808F;
    --accent-dark: #0B5C67;
    --accent-soft: #E7F3F5;
    --dark: #1F2E37;
    --sub: #4A606C;
    --faint: #8FA1AA;
    --bg: #FFFFFF;
    --white: #FFFFFF;
    --paper: #F7FAFA;
    --line: #E3EBEE;
    --line-strong: #D2DFE3;
    --radius: 8px;
    --nav-h: 64px;
    --maxw: 1280px;
    --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'PingFang SC',
        'Microsoft YaHei', 'Hiragino Sans GB', sans-serif;
    --mono: 'Cascadia Mono', Consolas, 'SFMono-Regular', Menlo, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
    scroll-behavior: smooth;
    background: var(--bg);
}

/* 锚点留出顶栏高度。不用 scroll-padding-top：它会连带影响
   输入框光标滚动，导致在搜索框打字时页面被顶上去。 */
.doc-section,
.doc h3[id] {
    scroll-margin-top: calc(var(--nav-h) + 24px);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--sub);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection { background: #D6EDF0; }

a { color: var(--accent-dark); }
h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; color: var(--dark); }
p { margin: 0; }
img { max-width: 100%; display: block; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 32px; }

/* ---------- 顶栏 ---------- */
.top {
    position: sticky; top: 0; z-index: 50;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: saturate(1.2) blur(10px);
    -webkit-backdrop-filter: saturate(1.2) blur(10px);
}
.top .container {
    height: var(--nav-h);
    display: flex; align-items: center; gap: 20px;
}

.brand {
    display: flex; align-items: center; gap: 9px;
    flex: none; text-decoration: none; color: var(--dark);
    font-weight: 700; font-size: 16.5px; letter-spacing: -.01em;
}
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.doc-tag {
    font-style: normal; font-size: 12px; font-weight: 400;
    color: var(--faint);
    margin-left: 3px; padding-left: 12px;
    border-left: 1px solid var(--line);
    line-height: 1.2;
}

/* ---------- 搜索 ---------- */
.search { position: relative; flex: 1 1 auto; max-width: 400px; margin-left: 12px; }
.search-ico {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--faint); display: inline-flex; pointer-events: none;
}
.search input {
    width: 100%; height: 36px; padding: 0 38px 0 34px;
    font: inherit; font-size: 13.5px; color: var(--dark);
    background: #F4F8F8;
    border: 1px solid transparent; border-radius: 8px;
    outline: none; appearance: none; -webkit-appearance: none;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.search input::placeholder { color: var(--faint); }
.search input:hover { background: #F0F5F5; }
.search input:focus {
    background: #fff;
    border-color: var(--line-strong);
    box-shadow: 0 0 0 3px rgba(18, 128, 143, .08);
}
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-kbd {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    font-family: var(--mono); font-size: 10.5px; line-height: 1;
    color: var(--faint);
    border: 1px solid var(--line); border-radius: 4px;
    padding: 2px 5px; background: #fff; pointer-events: none;
}
.search input:focus ~ .search-kbd { opacity: 0; }

/* 搜索结果 */
.search-panel {
    position: absolute; left: 0; right: 0; top: calc(100% + 8px);
    max-height: 420px; overflow: auto;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(31, 46, 55, .12);
    padding: 6px;
}
.search-item {
    display: block; width: 100%; padding: 9px 10px;
    border: 0; border-radius: 6px; background: transparent;
    text-align: left; cursor: pointer; font: inherit; color: var(--sub);
}
.search-item:hover,
.search-item[aria-selected="true"] { background: #F4F8F8; }
.search-item b { display: block; font-size: 13.5px; font-weight: 600; color: var(--dark); }
.search-item .res-group {
    display: inline-block; margin-left: 7px;
    font-size: 11px; color: var(--faint);
}
.search-item .res-snippet {
    display: block; margin-top: 3px;
    font-size: 12.5px; line-height: 1.55; color: var(--sub);
}
.search-item mark {
    background: #D9EEF2; color: var(--accent-dark);
    font-weight: 600; border-radius: 2px; padding: 0 1px;
}
.search-empty { padding: 14px 10px; font-size: 13.5px; line-height: 1.65; color: var(--sub); }

/* ---------- 语言切换：纯文本 ---------- */
.lang {
    display: inline-flex; align-items: center;
    flex: none;
}
.lang-slider { display: none; }
.lang-option {
    position: relative;
    display: inline-flex; align-items: center;
    padding: 0; height: auto;
    border: 0; background: transparent; cursor: pointer;
    font: inherit; font-size: 12.5px; font-weight: 500; line-height: 1.4;
    color: var(--faint);
    transition: color .15s ease;
    -webkit-tap-highlight-color: transparent;
}
.lang-option + .lang-option::before {
    content: '/'; margin: 0 6px; color: var(--line-strong); font-weight: 400;
}
.lang-option:hover { color: var(--dark); }
.lang-option.active, .lang-option[aria-pressed="true"] { color: var(--dark); font-weight: 600; }
.lang-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 切换语言时的柔和过渡 */
[data-i18n], [data-i18n-html] { transition: opacity .16s ease; }
body.i18n-switching [data-i18n],
body.i18n-switching [data-i18n-html] { opacity: .16; }

/* ---------- 顶栏按钮 ---------- */
.site-btn {
    display: inline-flex; align-items: center; gap: 5px;
    flex: none; margin-left: auto;
    height: 32px; padding: 0 12px;
    background: #fff; color: var(--dark);
    border: 1px solid var(--line-strong);
    border-radius: 8px; text-decoration: none;
    font-size: 12.5px; font-weight: 500; letter-spacing: .01em;
    transition: border-color .16s ease, color .16s ease, background .16s ease;
}
.site-btn svg { opacity: .5; transition: opacity .16s ease; }
.site-btn:hover { color: var(--accent-dark); border-color: var(--accent-dark); }
.site-btn:hover svg { opacity: 1; }

.side-toggle {
    display: none; flex: none; align-items: center; gap: 6px;
    height: 32px; padding: 0 11px;
    font: inherit; font-size: 12.5px; color: var(--dark);
    background: #fff; border: 1px solid var(--line-strong);
    border-radius: 8px; cursor: pointer;
}
.side-toggle:hover { color: var(--accent-dark); border-color: var(--accent-dark); }

/* ---------- 布局：贴边侧栏 + 正文 ---------- */
.layout {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    gap: 64px;
    padding-top: 0;
    padding-bottom: 0;
}

/* ---------- 侧栏：平铺，不做卡片 ---------- */
.side {
    position: sticky; top: var(--nav-h);
    align-self: start;
    height: calc(100vh - var(--nav-h));
    display: flex; flex-direction: column;
    padding: 36px 20px 18px 0;
    border-right: 1px solid var(--line);
    overflow: hidden;
}
.side-nav {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}
.side-nav::-webkit-scrollbar { width: 5px; }
.side-nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.side-nav::-webkit-scrollbar-track { background: transparent; }
/* 仅内容超出时上下渐隐，避免半截文字 */
.side-nav.can-scroll:not(.at-top):not(.at-bottom) {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18px, #000 calc(100% - 18px), transparent);
    mask-image: linear-gradient(to bottom, transparent 0, #000 18px, #000 calc(100% - 18px), transparent);
}
.side-nav.can-scroll:not(.at-top).at-bottom {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18px);
    mask-image: linear-gradient(to bottom, transparent 0, #000 18px);
}
.side-nav.can-scroll.at-top:not(.at-bottom) {
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 18px), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 18px), transparent);
}

.side-group + .side-group { margin-top: 26px; }
.side-group h4 {
    margin: 0 0 4px; padding: 0 8px 0 10px;
    font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
    color: #71838C;
}
.side a {
    position: relative;
    display: block; padding: 6px 26px 6px 10px; margin-bottom: 1px;
    font-size: 13.5px; line-height: 1.5; color: var(--sub);
    text-decoration: none; border-radius: 5px;
    transition: color .15s ease, background .15s ease;
}
.side a:hover { color: var(--dark); background: #F4F8F8; }

/* 父章节：当前所在章节加重，但不抢子项的强调 */
.side a.active,
.side a.in-section {
    color: var(--dark); font-weight: 600;
    background: #F3F8F8;
}
/* 当前父章节左侧一条短线，比整块底色更容易定位 */
.side-group > a.active::before {
    content: '';
    position: absolute; left: 0; top: 7px; bottom: 7px;
    width: 2px; border-radius: 2px;
    background: var(--accent);
}

/* 展开箭头 */
.side-group > a.has-sub::after {
    content: '';
    position: absolute; right: 11px; top: 50%;
    width: 5px; height: 5px; margin-top: -4px;
    border-right: 1.5px solid #B0BEC5;
    border-bottom: 1.5px solid #B0BEC5;
    transform: rotate(-45deg);
    transition: transform .18s ease, border-color .15s ease;
}
.side-group > a.has-sub:hover::after { border-color: var(--sub); }
.side-group > a.has-sub.open::after {
    transform: rotate(45deg);
    border-color: var(--accent-dark);
}

/* 子项：只展开当前章节 */
/* 子项：只展开当前章节，展开/收起用高度过渡避免整块跳变 */
.side-sub {
    display: block;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    margin: 0 0 0 10px;
    padding-left: 9px;
    border-left: 1px solid #DDE7EA;
    transition: max-height .22s cubic-bezier(.22, .61, .36, 1),
        margin .22s cubic-bezier(.22, .61, .36, 1),
        opacity .16s ease,
        visibility 0s linear .22s;
}
.side-sub.open {
    opacity: 1;
    visibility: visible;
    margin-bottom: 4px;
    transition: max-height .22s cubic-bezier(.22, .61, .36, 1),
        margin .22s cubic-bezier(.22, .61, .36, 1),
        opacity .18s ease,
        visibility 0s linear 0s;
}
.side-sub a {
    padding: 4px 8px 4px 9px;
    margin-bottom: 0;
    font-size: 13px;
    line-height: 1.5;
    color: #566B76;
}
.side-sub a:hover { color: var(--dark); background: #F4F8F8; }
.side-sub a.active {
    color: var(--accent-dark); background: var(--accent-soft);
    font-weight: 600;
}

/* 侧栏底部：固定在视口底部 */
.side-foot {
    display: flex; align-items: center; justify-content: space-between;
    flex: none;
    margin-top: 18px; padding-top: 16px;
    border-top: 1px solid var(--line);
}
.side-foot-label {
    padding-left: 10px;
    font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
    color: #8598A1;
}

/* ---------- 正文 ---------- */
.doc { min-width: 0; max-width: 780px; padding: 46px 0 100px; }

.doc-head { padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.doc-head h1 {
    font-size: clamp(30px, 2.9vw, 38px);
    line-height: 1.2;
    letter-spacing: -.022em;
}
.lead {
    margin-top: 14px; color: var(--sub);
    font-size: 15.5px; line-height: 1.8; max-width: 660px;
}

.doc-section { padding-top: 44px; }
.doc-section + .doc-section { border-top: 1px solid var(--line); }
.doc-section:first-of-type { padding-top: 40px; }
.doc-section h2 { font-size: 24px; letter-spacing: -.015em; margin-bottom: 14px; }
.doc-section h3 { font-size: 17px; margin: 30px 0 8px; }
.doc-section p { margin-bottom: 12px; color: var(--sub); font-size: 15.5px; }
.doc-section ul,
.doc-section ol { margin: 0 0 14px; padding-left: 24px; color: var(--sub); font-size: 15.5px; }
.doc-section li { margin-bottom: 7px; }
.doc-section li b,
.doc-section p b { color: var(--dark); font-weight: 600; }

/* 正文链接：细下划线，悬停加深 */
.doc-section a,
.lead a,
.doc-foot a {
    color: var(--accent-dark);
    text-decoration: none;
    border-bottom: 1px solid rgba(11, 92, 103, .25);
    transition: border-color .15s ease;
}
.doc-section a:hover,
.lead a:hover,
.doc-foot a:hover { border-bottom-color: var(--accent-dark); }

/* 步骤：使用原生序号，去掉圆形装饰 */
.steps { list-style: decimal; padding-left: 24px !important; }
.steps li { padding-left: 2px; }
.steps li::marker { color: var(--accent-dark); font-weight: 600; }

/* 提示块：左侧细强调线 */
.note {
    margin: 18px 0;
    padding: 13px 16px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-left: 2px solid var(--accent);
    border-radius: 6px;
    color: var(--sub); font-size: 14.5px;
}

/* 表格 */
.table-wrap {
    margin: 14px 0 18px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.doc-table {
    width: 100%; min-width: 460px;
    border-collapse: collapse;
    font-size: 14.5px; line-height: 1.65;
}
.doc-table th,
.doc-table td {
    padding: 10px 14px;
    text-align: left; vertical-align: top;
    border-bottom: 1px solid var(--line);
    color: var(--sub);
}
.doc-table th {
    background: #F4F8F8;
    color: var(--sub);
    font-size: 12px; font-weight: 600;
    white-space: nowrap;
}
.doc-table tbody tr:last-child td { border-bottom: 0; }
.doc-table tbody tr:hover { background: #FAFCFC; }
.doc-table code { white-space: nowrap; }
.quick-table { min-width: 480px; table-layout: fixed; }
.quick-table th:first-child { width: 36%; }
.quick-table th:last-child { width: 64px; }
.quick-table td:first-child { color: var(--dark); font-weight: 600; }
.quick-table td:last-child { white-space: nowrap; }
.quick-table a { border-bottom: 1px solid rgba(11, 92, 103, .25); }
.quick-table a:hover { border-bottom-color: var(--accent-dark); }

/* 排障：可能原因 / 处理步骤 */
.cause {
    margin: 10px 0 14px !important;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-left: 2px solid var(--accent);
    border-radius: 6px;
    font-size: 14.5px !important;
}
.cause .tag {
    display: inline-block; margin-right: 7px;
    color: var(--accent-dark); font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}
.step-label {
    margin: 16px 0 8px !important;
    color: var(--faint) !important;
    font-size: 12px !important; font-weight: 600;
    letter-spacing: .02em;
}

/* 代码 */
code {
    font-family: var(--mono); font-size: .88em;
    color: #2C3E50;
    background: #F2F7F8;
    border-radius: 4px;
    padding: 1px 5px;
    word-break: break-all;
}
pre.code {
    margin: 12px 0 16px;
    padding: 14px 16px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow-x: auto;
}
pre.code code {
    border: 0; background: transparent; padding: 0;
    font-size: 13px; color: #2C3E50;
}

kbd {
    font-family: var(--mono); font-size: 11px;
    background: #fff; border: 1px solid var(--line-strong);
    border-bottom-width: 2px; border-radius: 4px;
    padding: 1px 5px; color: var(--dark);
}

/* 搜索跳转后的短暂高亮 */
.doc-section.flash { animation: flash 1.5s ease; }
@keyframes flash {
    0%, 100% { background: transparent; }
    22% { background: var(--accent-soft); }
}

.doc-foot {
    margin-top: 56px; padding-top: 24px;
    border-top: 1px solid var(--line);
    font-size: 13px; color: var(--faint);
}
.doc-foot p { margin: 0 0 6px; }
.inline { border-bottom: 1px solid rgba(11, 92, 103, .25); }
.inline:hover { border-bottom-color: var(--accent-dark); }

/* ---------- 中等宽度 ---------- */
@media (max-width: 1180px) {
    .layout { grid-template-columns: 240px minmax(0, 1fr); gap: 48px; }
    .doc { max-width: 720px; }
}

/* ---------- 窄屏 ---------- */
@media (max-width: 900px) {
    :root { --nav-h: 108px; }

    .top .container {
        height: auto; padding: 12px 20px 14px;
        display: grid;
        grid-template-columns: 1fr auto auto;
        grid-template-areas:
            "brand site toggle"
            "search search search";
        gap: 10px 12px;
        align-items: center;
    }
    .brand { grid-area: brand; }
    .site-btn { grid-area: site; margin-left: 0; }
    .side-toggle { grid-area: toggle; display: inline-flex; }
    .search { grid-area: search; max-width: none; margin-left: 0; }
    .search-kbd { display: none; }

    .layout {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 0 20px;
    }

    .doc { padding: 30px 0 80px; }
    .doc-head h1 { font-size: 30px; }
    .doc-section { padding-top: 38px; }
    .doc-section h2 { font-size: 22px; }

    /* 侧栏抽屉 */
    .side {
        position: fixed; z-index: 45;
        top: var(--nav-h); left: 0;
        width: 300px; max-height: none;
        height: calc(100vh - var(--nav-h));
        height: calc(100dvh - var(--nav-h));
        display: flex; flex-direction: column;
        padding: 24px 20px 20px;
        background: #fff;
        border-right: 1px solid var(--line);
        box-shadow: 24px 0 60px rgba(31, 46, 55, .1);
        transform: translateX(-102%);
        transition: transform .26s cubic-bezier(.2, .7, .3, 1);
        overflow: hidden;
    }
    .side-foot { border-top-color: var(--line); }
    body.side-open .side { transform: none; }
    .side-mask {
        position: fixed; inset: var(--nav-h) 0 0 0; z-index: 44;
        background: rgba(31, 46, 55, .28);
        opacity: 0; pointer-events: none;
        transition: opacity .26s ease;
    }
    body.side-open .side-mask { opacity: 1; pointer-events: auto; }
}

@media (max-width: 560px) {
    .doc-tag { display: none; }
}

@media (max-width: 440px) {
    .brand span { display: none; }
    .side-toggle { padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .side, .side-mask, .search input, .lang-option,
    .side-sub, .side-sub.open { transition: none; }
    [data-i18n], [data-i18n-html] { transition: none; }
    body.i18n-switching [data-i18n],
    body.i18n-switching [data-i18n-html] { opacity: 1; }
    .doc-section.flash { animation: none; }
}
