/* =========================================================================
   Docbit — Portfolio SPA
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --accent: #1296db;
    --accent-hover: #0e7ab8;
    --accent-soft: rgba(18, 150, 219, 0.1);
    --accent-glow: rgba(18, 150, 219, 0.18);
    --accent-rgb: 18, 150, 219;
    --brand-rust: #d4237a;
    --brand-rust-soft: rgba(212, 35, 122, 0.1);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-pill: 999px;
    --radius-btn: 10px;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --header-h: 60px;
    --sidebar-w: 272px;
    --toc-w: 220px;
    --transition: 0.2s ease;
}

/* ── Dark theme ── */

[data-theme="dark"] {
    --bg: #0f1419;
    --bg-elevated: #161b22;
    --bg-card: #1c2128;
    --bg-input: #21262d;
    --border: #30363d;
    --border-hover: #484f58;
    --text: #c9d1d9;
    --text-muted: #8b949e;
    --text-bright: #f0f6fc;
    --header-bg: rgba(15, 20, 25, 0.92);
    --shadow: rgba(0, 0, 0, 0.35);
    --code-bg: #161b22;
    --purple: #a78bfa;
    --green: #34d399;
    --orange: #fb923c;
    --danger: #f85149;
    --danger-bg: rgba(248, 81, 73, 0.1);
    --danger-border: rgba(248, 81, 73, 0.3);
}

/* ── Light theme (default) ── */

[data-theme="light"] {
    --bg: #f8fafc;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f1f5f9;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --text: #334155;
    --text-muted: #64748b;
    --text-bright: #0f172a;
    --header-bg: rgba(248, 250, 252, 0.94);
    --shadow: rgba(15, 23, 42, 0.06);
    --code-bg: #f8fafc;
    --purple: #7c3aed;
    --green: #059669;
    --orange: #ea580c;
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.06);
    --danger-border: rgba(220, 38, 38, 0.2);
}

html {
    scroll-behavior: smooth;
    overflow-x: clip;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    transition: background var(--transition), color var(--transition);
    display: flex;
    flex-direction: column;
}

#app {
    flex: 1 0 auto;
}

.site-footer {
    flex-shrink: 0;
}

body.layout-home {
    display: flex;
    flex-direction: column;
}

body.layout-home #app {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

body.layout-home #app .page-home {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

/* ── Header ── */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    background: var(--header-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition), border-color var(--transition);
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 100%;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text-bright);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    flex-shrink: 0;
    transition: opacity var(--transition);
}

.brand:hover { opacity: 0.88; }

.brand-logo {
    display: block;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 10px;
    transition: transform var(--transition);
}

.brand:hover .brand-logo {
    transform: scale(1.04);
}

.brand-text {
    line-height: 1;
}

.main-nav {
    display: flex;
    gap: 0.15rem;
    justify-content: center;
}

.main-nav a {
    padding: 0.45rem 0.95rem;
    border-radius: var(--radius-pill);
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
}

.main-nav a:hover,
.main-nav a.active {
    color: var(--accent);
    background: var(--accent-soft);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-user-menu {
    display: flex;
    align-items: center;
}

.user-menu.guest {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.user-menu.logged-in {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.5rem 0.25rem 0.25rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-elevated);
    color: var(--text);
    cursor: pointer;
    font-size: 0.82rem;
    transition: all var(--transition);
}

.user-menu-trigger:hover {
    border-color: var(--accent);
}

.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.user-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px var(--shadow);
    padding: 0.35rem;
    z-index: 110;
}

.user-dropdown-meta {
    padding: 0.5rem 0.65rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
    word-break: break-all;
}

.user-dropdown-item,
a.user-dropdown-item {
    display: block;
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text);
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition);
}

.user-dropdown-item:hover,
a.user-dropdown-item:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.empty-hint {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--transition);
}

.icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

[data-theme="dark"] .icon-sun { display: inline; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: inline; }

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: all var(--transition);
}

.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Main ── */

#app {
    max-width: 1120px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
    min-height: calc(100vh - var(--header-h) - 80px);
}

#app:has(.page-home) {
    max-width: 1280px;
    padding-left: clamp(1rem, 2.5vw, 2rem);
    padding-right: clamp(1rem, 2.5vw, 2rem);
    padding-bottom: 0;
}

#app.docs-page {
    max-width: none;
    padding: 0;
    margin: 0;
    min-height: calc(100vh - var(--header-h));
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 4rem;
    color: var(--text-muted);
}

.page { animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Hero ── */

.hero {
    text-align: center;
    padding: 2.5rem 0 2.75rem;
}

.hero-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.hero-logo {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    padding: 0.35rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    box-shadow: 0 8px 28px var(--shadow);
}

.hero-tag {
    display: inline-block;
    padding: 0.3rem 0.85rem;
    border-radius: 20px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 1rem;
    border: 1px solid rgba(var(--accent-rgb), 0.15);
    letter-spacing: 0.01em;
}

.hero h1 {
    font-size: clamp(1.85rem, 4.5vw, 2.75rem);
    font-weight: 800;
    color: var(--text-bright);
    letter-spacing: -0.03em;
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.05rem;
    max-width: 520px;
    margin: 0 auto;
    line-height: 1.7;
}

/* ── Section ── */

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 1.1rem;
    letter-spacing: -0.01em;
}

.section-title::before {
    display: none;
}

.work-card-logo {
    width: 36px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
    margin-bottom: 0.15rem;
}

.logo-wide {
    width: auto;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.logo-square {
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex-shrink: 0;
}

.detail-logo-row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 0.75rem;
}

.detail-logo-row .logo-wide {
    height: 36px;
}

.detail-logo-row .logo-square {
    width: 48px;
    height: 48px;
}

/* ── Work cards ── */

.works-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.work-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.35rem 1.4rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.22s ease;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    position: relative;
    overflow: hidden;
}

.work-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}

.work-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: 0 12px 32px var(--shadow);
}

.work-card:hover::before { opacity: 1; }

.work-card.featured {
    border-color: rgba(var(--accent-rgb), 0.35);
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(var(--accent-rgb), 0.06) 100%);
}

.work-card-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.work-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-bright);
    line-height: 1.35;
}

.work-card .subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.work-card .desc {
    font-size: 0.9rem;
    color: var(--text);
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.work-card-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: auto;
    padding-top: 0.75rem;
}

/* ── Tags & badges ── */

.tag {
    display: inline-block;
    padding: 0.22rem 0.65rem;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 500;
    background: color-mix(in srgb, var(--bg-input) 88%, transparent);
    color: var(--text-muted);
    border: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
    line-height: 1.4;
    white-space: nowrap;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 1rem;
}

.detail-meta {
    margin-bottom: 0.5rem;
}

.badge {
    display: inline-block;
    padding: 0.22rem 0.65rem;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    flex-shrink: 0;
}

.badge-framework { background: var(--accent-soft); color: var(--accent); }
.badge-product   { background: rgba(16, 185, 129, 0.15); color: var(--green); }
.badge-article   { background: rgba(139, 92, 246, 0.15); color: var(--purple); }

/* ── Buttons ── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    border-radius: var(--radius-pill);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition);
}

.btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: #fff;
    border-color: var(--accent-hover);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.btn-row {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

.page-work .btn-row .layui-btn {
    margin: 0;
}

/* ── Page logo watermark (work, docs, blog) — icon only, no color blobs ── */

.page-deco {
    position: absolute;
    pointer-events: none;
    user-select: none;
    z-index: 0;
}

.page-deco-logo {
    display: block;
    width: clamp(180px, 22vw, 280px);
    height: auto;
    opacity: 0.04;
}

[data-theme="dark"] .page-deco-logo {
    opacity: 0.065;
}

/* Shell / blog / docs — bottom-right, clipped inside main column */
.page-deco--br {
    right: 0;
    bottom: 0;
    transform: translate(6%, 22%);
}

/* Work detail — right edge, above fold */
.page-deco--work {
    right: 0;
    top: 0;
    transform: translate(8%, -8%);
}

.page-deco--work .page-deco-logo {
    width: clamp(200px, 28vw, 300px);
    opacity: 0.035;
}

[data-theme="dark"] .page-deco--work .page-deco-logo {
    opacity: 0.055;
}

/* ── Work detail ── */

.detail-header { margin-bottom: 2rem; }
.detail-header h1 {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 800;
    color: var(--text-bright);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}
.detail-header .meta { color: var(--text-muted); font-size: 0.95rem; }
.detail-body { font-size: 1rem; line-height: 1.75; max-width: 720px; }

/* ── Blog ── */

.blog-list { display: flex; flex-direction: column; gap: 1rem; }

.blog-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    text-decoration: none;
    color: inherit;
    transition: all var(--transition);
}

.blog-item:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 16px var(--shadow);
    transform: translateX(4px);
}

.blog-item h3 { font-size: 1.1rem; color: var(--text-bright); margin-bottom: 0.35rem; }
.blog-item .summary { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.blog-item .date { font-size: 0.8rem; color: var(--text-muted); }

/* ── Markdown (markdown-it + highlight.js) ── */

.markdown-body {
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text);
    word-wrap: break-word;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    color: var(--text-bright);
    font-weight: 700;
    scroll-margin-top: calc(var(--header-h) + 1.5rem);
}

.markdown-body h1 {
    font-size: 1.85rem;
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.markdown-body h2 {
    font-size: 1.4rem;
    margin: 2rem 0 0.85rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}

.markdown-body h3 { font-size: 1.15rem; margin: 1.5rem 0 0.65rem; }
.markdown-body h4 { font-size: 1rem; margin: 1.25rem 0 0.5rem; }

.markdown-body p { margin-bottom: 1rem; }
.markdown-body ul, .markdown-body ol { margin: 0 0 1rem 1.5rem; }
.markdown-body li { margin-bottom: 0.4rem; }
.markdown-body li > ul, .markdown-body li > ol { margin-top: 0.35rem; }

.markdown-body a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition);
}

.markdown-body a:hover { border-bottom-color: var(--accent); }

.markdown-body blockquote {
    border-left: 4px solid var(--accent);
    padding: 0.75rem 1rem;
    margin: 0 0 1rem;
    background: var(--accent-soft);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-muted);
}

.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    display: block;
    overflow-x: auto;
}

.markdown-body th, .markdown-body td {
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    text-align: left;
}

.markdown-body th {
    background: var(--bg-elevated);
    color: var(--text-bright);
    font-weight: 600;
}

.markdown-body tr:nth-child(even) { background: rgba(var(--accent-rgb), 0.03); }

.markdown-body code {
    font-family: var(--mono);
    font-size: 0.85em;
    background: var(--code-bg);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.markdown-body pre {
    position: relative;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.markdown-body pre code {
    display: block;
    padding: 1rem 1.15rem;
    overflow-x: auto;
    background: none;
    border: none;
    font-size: 0.82rem;
    line-height: 1.6;
}

.markdown-body pre .code-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition);
}

.markdown-body pre:hover .code-copy-btn { opacity: 1; }
.markdown-body pre .code-copy-btn:hover { color: var(--accent); border-color: var(--accent); }
.markdown-body pre .code-copy-btn.copied { color: var(--green); border-color: var(--green); }

.markdown-body .header-anchor {
    color: var(--text-muted);
    text-decoration: none;
    margin-left: 0.35rem;
    opacity: 0;
    transition: opacity var(--transition);
    font-weight: 400;
}

.markdown-body h1:hover .header-anchor,
.markdown-body h2:hover .header-anchor,
.markdown-body h3:hover .header-anchor,
.markdown-body h4:hover .header-anchor { opacity: 0.6; }

.markdown-body img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ── Docs layout (full-width) ── */

.docs-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: calc(100vh - var(--header-h));
    width: 100%;
}

.docs-shell.has-toc {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
}

.docs-sidebar {
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.doc-nav-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.75rem 1.25rem;
    scrollbar-width: thin;
}

.docs-sidebar-header {
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

.docs-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
}

.docs-brand .logo-wide {
    height: 22px;
}

.docs-brand h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-bright);
    line-height: 1.35;
    margin: 0;
}

.docs-sidebar h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-bright);
    line-height: 1.3;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem;
}

.doc-nav { list-style: none; }

.doc-nav li { margin-bottom: 0; }

.doc-nav a {
    display: block;
    padding: 0.35rem 0.6rem;
    border-radius: 5px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.8125rem;
    line-height: 1.45;
    transition: all 0.12s;
}

.doc-nav a:hover,
.doc-nav a.active {
    color: var(--accent);
    background: var(--accent-soft);
    font-weight: 500;
}

.doc-nav .nav-section {
    display: block;
    font-weight: 600;
    line-height: 1.4;
}

.doc-nav .nav-depth-0 {
    padding: 0.85rem 0.6rem 0.3rem;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.doc-nav .nav-depth-0:first-child {
    padding-top: 0.35rem;
}

.doc-nav .nav-depth-1 {
    padding: 0.45rem 0.6rem 0.2rem;
    font-size: 0.8rem;
    color: var(--text-bright);
}

.doc-nav .children.depth-2 {
    margin-left: 0;
    padding-left: 0.5rem;
    border-left: 2px solid var(--border);
    margin-bottom: 0.35rem;
}

.doc-nav .nav-leaf a {
    padding-left: 0.75rem;
}

.docs-main {
    min-width: 0;
    padding: 1.5rem clamp(1.25rem, 2.5vw, 2.5rem) 3rem;
}

.docs-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.docs-toolbar .docs-breadcrumb {
    margin-bottom: 0;
}

.docs-breadcrumb {
    font-size: 0.8125rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.docs-breadcrumb a {
    color: var(--accent);
    text-decoration: none;
}

.docs-breadcrumb a:hover { text-decoration: underline; }

.docs-article {
    max-width: none;
}

.docs-toc-panel {
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
    padding: 1.25rem 1rem 2rem;
    border-left: 1px solid var(--border);
    background: var(--bg);
    scrollbar-width: thin;
}

.docs-toc-panel:empty {
    display: none;
}

.docs-toc {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
}

.docs-toc h5 {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.docs-toc ul { list-style: none; }

.docs-toc li { margin-bottom: 0.15rem; }

.docs-toc a {
    display: block;
    padding: 0.28rem 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    border-radius: 0 4px 4px 0;
    transition: all 0.12s;
    line-height: 1.4;
}

.docs-toc a:hover,
.docs-toc a.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-soft);
}

.docs-toc .toc-h3 { padding-left: 0.75rem; font-size: 0.72rem; }

.sidebar-overlay {
    display: none;
}

#sidebar-open { display: none; }

/* ── Footer (brand · 备案 · meta) ── */

.site-footer {
    border-top: 1px solid var(--border);
    transition: border-color var(--transition);
    padding: 1.25rem clamp(1.25rem, 3vw, 2rem) 1rem;
    background: var(--bg-elevated);
    border-radius: 0;
}

.footer-inner,
.site-footer-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 1.5rem;
    align-items: center;
}

.footer-brand {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    min-width: 0;
}

.footer-rocket {
    font-size: 1.25rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.footer-motto {
    display: block;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 0.25rem;
    line-height: 1.35;
}

.footer-tagline {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.footer-meta {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.footer-built {
    margin: 0 0 0.25rem;
    line-height: 1.4;
}

.footer-built strong {
    color: var(--accent);
    font-weight: 600;
}

.footer-copy-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
    margin: 0;
    line-height: 1.4;
}

.footer-logo {
    opacity: 0.88;
    flex-shrink: 0;
}

/* ── Scrollbar: theme-aware (Webkit + Firefox) ── */
html {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

[data-theme="dark"] html {
    scrollbar-color: #30363d transparent;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #30363d;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

/* Shell sidebar / doc nav / TOC — slightly thinner with no track */
.content-sidebar-body,
.content-toc-panel,
.doc-nav-wrap,
.docs-toc-panel {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

[data-theme="dark"] .content-sidebar-body,
[data-theme="dark"] .content-toc-panel,
[data-theme="dark"] .doc-nav-wrap,
[data-theme="dark"] .docs-toc-panel {
    scrollbar-color: #30363d transparent;
}

.content-sidebar-body::-webkit-scrollbar,
.content-toc-panel::-webkit-scrollbar,
.doc-nav-wrap::-webkit-scrollbar,
.docs-toc-panel::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.content-sidebar-body::-webkit-scrollbar-track,
.content-toc-panel::-webkit-scrollbar-track,
.doc-nav-wrap::-webkit-scrollbar-track,
.docs-toc-panel::-webkit-scrollbar-track {
    background: transparent;
}

.content-sidebar-body::-webkit-scrollbar-thumb,
.content-toc-panel::-webkit-scrollbar-thumb,
.doc-nav-wrap::-webkit-scrollbar-thumb,
.docs-toc-panel::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.content-sidebar-body::-webkit-scrollbar-thumb:hover,
.content-toc-panel::-webkit-scrollbar-thumb:hover,
.doc-nav-wrap::-webkit-scrollbar-thumb:hover,
.docs-toc-panel::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

[data-theme="dark"] .content-sidebar-body::-webkit-scrollbar-thumb,
[data-theme="dark"] .content-toc-panel::-webkit-scrollbar-thumb,
[data-theme="dark"] .doc-nav-wrap::-webkit-scrollbar-thumb,
[data-theme="dark"] .docs-toc-panel::-webkit-scrollbar-thumb {
    background: #30363d;
}

[data-theme="dark"] .content-sidebar-body::-webkit-scrollbar-thumb:hover,
[data-theme="dark"] .content-toc-panel::-webkit-scrollbar-thumb:hover,
[data-theme="dark"] .doc-nav-wrap::-webkit-scrollbar-thumb:hover,
[data-theme="dark"] .docs-toc-panel::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

.footer-beian {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.footer-beian--center {
    justify-self: center;
}

.footer-beian a {
    color: var(--text-muted);
    text-decoration: none;
}

.footer-beian a:hover {
    color: var(--accent);
}

.footer-sep {
    margin: 0 0.35rem;
    opacity: 0.45;
    user-select: none;
}

.site-footer p { margin: 0; }

@media (max-width: 900px) {
    .footer-inner,
    .site-footer-inner {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 1.25rem;
    }

    .footer-brand {
        justify-content: center;
    }

    .footer-beian--center {
        justify-self: center;
    }

    .footer-meta {
        text-align: center;
    }

    .footer-copy-row {
        justify-content: center;
    }
}

/* ── Spinner & error ── */

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    border-radius: var(--radius);
    padding: 1.75rem;
    color: var(--danger);
    max-width: 480px;
    margin: 2rem auto;
    text-align: center;
}

.error-box strong { display: block; font-size: 1.1rem; margin-bottom: 0.5rem; }

/* ── Back to top ── */

.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--accent);
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 4px 16px var(--shadow);
    transition: all var(--transition);
    z-index: 90;
}

.back-to-top:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    transform: translateY(-2px);
}

.back-to-top[hidden] { display: none; }

/* ── Responsive ── */

@media (max-width: 1200px) {
    .docs-shell.has-toc {
        grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    }
    .docs-toc-panel { display: none; }
}

@media (max-width: 768px) {
    .nav-toggle { display: flex; }

    .header-inner {
        grid-template-columns: auto 1fr auto;
        gap: 0.75rem;
    }

    .user-menu.guest .btn-sm {
        padding: 0.35rem 0.55rem;
        font-size: 0.75rem;
    }

    .user-name { display: none; }

    .main-nav {
        position: fixed;
        top: var(--header-h);
        left: 0;
        right: 0;
        background: var(--header-bg);
        backdrop-filter: blur(14px);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 0.75rem 1rem 1rem;
        transform: translateY(-110%);
        opacity: 0;
        pointer-events: none;
        transition: all 0.25s ease;
        z-index: 99;
    }

    .main-nav.open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    #sidebar-open { display: inline-flex; }

    .docs-shell,
    .docs-shell.has-toc {
        grid-template-columns: 1fr;
    }

    .docs-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(300px, 88vw);
        height: 100vh;
        z-index: 200;
        transform: translateX(-105%);
        transition: transform 0.28s ease;
        box-shadow: 4px 0 24px var(--shadow);
    }

    .docs-sidebar.open { transform: translateX(0); }

    .sidebar-close { display: block; }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 199;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s;
    }

    .sidebar-overlay.visible {
        opacity: 1;
        pointer-events: auto;
    }

    .docs-main {
        padding: 1rem 1rem 2.5rem;
        max-width: none;
    }

    .works-grid { grid-template-columns: 1fr; }
    .hero { padding: 2rem 0 1.5rem; }
    #app:not(.docs-page) { padding: 1.25rem 1rem 3rem; }
    .back-to-top { bottom: 1.25rem; right: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}
