/* ==========================================================================
   Reader shell — shared across homepage and all article pages
   Variables, reset, left ebook-style TOC sidebar, mobile drawer
   ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f4f6f9;
    --bg-soft: #eceff4;
    --panel: #ffffff;
    --panel-2: #f7f9fb;
    --line: #dde3ec;
    --text: #1b2430;
    --text-dim: #566274;
    --text-faint: #8a94a3;
    --accent: #b3740a;
    --green: #0f9d6c;
    --red: #d43d3d;
    --blue: #2b7fc4;
    --mono: "SF Mono", "Cascadia Code", Consolas, ui-monospace, monospace;
    --sidebar-w: 288px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    line-height: 1.75;
    color: var(--text);
    background: var(--bg);
    padding-left: var(--sidebar-w);
}

a { color: inherit; }

/* ---------- sidebar (ebook toc) ---------- */
.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--sidebar-w);
    background: var(--panel);
    border-right: 1px solid var(--line);
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 60;
}
.sidebar-inner {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: 1.5rem 1.1rem 1.2rem;
    gap: 1.3rem;
}
.side-brand {
    display: block;
    padding: 0 0.4rem 1.1rem;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    color: inherit;
}
.side-brand-name {
    display: block;
    font-weight: 800;
    font-size: 1.02rem;
    line-height: 1.45;
    letter-spacing: 0.01em;
    color: var(--text);
}
.side-brand-tag {
    display: inline-block;
    margin-top: 0.55rem;
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.16em;
    color: var(--accent);
}
.side-nav {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
    flex: 1;
}
.side-group-title {
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    padding: 0 0.4rem 0.45rem;
    margin-bottom: 0.4rem;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.side-code {
    font-family: var(--mono);
    font-size: 0.66rem;
    color: var(--text-faint);
    letter-spacing: 0.1em;
}
.side-group-title:hover,
.side-group-title.active { color: var(--accent); }
.side-group-title:hover .side-code,
.side-group-title.active .side-code { color: var(--accent); }
.side-links {
    list-style: none;
    margin: 0;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.side-links li { margin: 0; }
.side-links a {
    display: block;
    padding: 0.42rem 0.55rem;
    border-left: 2px solid transparent;
    border-radius: 0 4px 4px 0;
    text-decoration: none;
    color: var(--text-dim);
    font-size: 0.84rem;
    line-height: 1.5;
    transition: color .15s, background .15s, border-color .15s;
}
.side-links a:hover {
    color: var(--accent);
    background: var(--panel-2);
}
.side-links a.active {
    color: var(--accent);
    background: #fdf4e3;
    border-left-color: var(--accent);
    font-weight: 600;
}
.side-foot {
    padding: 0.9rem 0.4rem 0;
    border-top: 1px solid var(--line);
    font-family: var(--mono);
    font-size: 0.66rem;
    line-height: 1.6;
    letter-spacing: 0.06em;
    color: var(--text-faint);
}

/* ---------- mobile drawer ---------- */
.mobile-bar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 55;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: rgba(244, 246, 249, 0.95);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}
.menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    font: inherit;
    font-size: 0.85rem;
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 4px;
    cursor: pointer;
}
.menu-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}
.mobile-brand {
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 27, 0.45);
    z-index: 59;
}

@media (max-width: 900px) {
    body { padding-left: 0; }
    body.nav-open { overflow: hidden; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 0 0 30px rgba(15, 20, 27, 0.18);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .scrim { display: block; }
    .mobile-bar { display: flex; }
}

/* ---------- 全站内容复核日期（partials/review-stamp.html） ---------- */
.review-stamp {
    margin: 0 0 1.2rem;
    font-size: 0.8rem;
    line-height: 1.7;
    color: #7a838f;
}
.review-stamp time { font-variant-numeric: tabular-nums; }

/* ---------- shared footer ---------- */
.site-footer {
    border-top: 1px solid var(--line);
    margin-top: 4rem;
    background: var(--bg-soft);
}
.site-footer .footer-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 1.6rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.82rem;
    color: var(--text-faint);
}
.site-footer .disclaimer {
    color: var(--accent);
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
}

@media (max-width: 640px) {
    .site-footer .footer-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* ---------- share widget ---------- */
.share {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 54;
}
.share-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 1rem;
    border: 1px solid var(--accent);
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(179, 116, 10, 0.28);
}
.share-toggle:hover {
    background: #8a5a05;
    border-color: #8a5a05;
    color: #fff;
}
.share-toggle svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}
.share-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 12px);
    width: 272px;
    padding: 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 14px 34px rgba(27, 36, 48, 0.18);
}
.share-panel[hidden] { display: none; }
.share-head {
    margin-bottom: 10px;
    font-size: 0.74rem;
    letter-spacing: 0.1em;
    color: var(--text-faint);
}
.share-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.share-item {
    padding: 9px 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
    color: var(--text-dim);
    font-size: 0.82rem;
    cursor: pointer;
}
.share-item:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.share-item.is-active {
    border-color: var(--accent);
    color: var(--accent);
    background: #fdf6ea;
}
.share-qr {
    margin-top: 12px;
    text-align: center;
}
.share-qr[hidden] { display: none; }
.share-qr-box {
    display: inline-block;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 0.72rem;
    line-height: 1.5;
    color: var(--text-faint);
    word-break: break-all;
}
.share-qr-box svg {
    display: block;
    width: 132px;
    height: 132px;
}
.share-qr p {
    margin-top: 6px;
    font-size: 0.74rem;
    color: var(--text-faint);
}
.share-hint {
    margin-top: 10px;
    min-height: 1.2em;
    font-size: 0.76rem;
    color: var(--accent);
}
.site-footer .footer-inner {
    padding-right: 118px;
}
@media (max-width: 640px) {
    .site-footer .footer-inner {
        padding-right: 1.25rem;
        padding-bottom: 4.4rem;
    }
}
@media (max-width: 640px) {
    .share {
        right: 14px;
        bottom: 14px;
    }
    .share-toggle {
        padding: 10px 14px;
        border-radius: 999px;
    }
    .share-panel { width: 250px; }
}
@media print {
    .share { display: none; }
}
