/* =========================================================
   BENQI — Wikipedia-style article stylesheet
   ========================================================= */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: 24px;
    -webkit-text-size-adjust: 100%;
}

body {
    background: #ffffff;
    color: #202122;
    font-family: 'Linux Libertine', 'Georgia', 'Times New Roman', serif;
    font-size: 16px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Top bar ---------- */
.top-bar {
    border-bottom: 1px solid #a2a9b1;
    padding: 10px 20px;
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar .site-title {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: #202122;
    text-decoration: none;
}

.top-bar .site-title:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 30px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 30px 80px;
}

/* ---------- Sidebar / Table of contents ---------- */
.sidebar {
    position: sticky;
    top: 60px;
    align-self: start;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    padding-right: 8px;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #c8ccd1; border-radius: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.toc {
    border: 1px solid #a2a9b1;
    background: #f8f9fa;
    padding: 14px 16px;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 13px;
}

.toc-title {
    font-weight: 700;
    font-size: 14px;
    color: #202122;
    margin-bottom: 10px;
    border-bottom: 1px solid #c8ccd1;
    padding-bottom: 6px;
}

.toc ol {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: section;
}

.toc > ol > li {
    counter-increment: section;
    margin-bottom: 6px;
}

.toc > ol > li > a::before {
    content: counter(section) ". ";
    font-weight: 600;
}

.toc ol ol {
    list-style: none;
    margin: 4px 0 4px 14px;
    padding: 0;
    counter-reset: subsection;
}

.toc ol ol li {
    counter-increment: subsection;
    margin-bottom: 3px;
}

.toc ol ol li a::before {
    content: counters(section, ".") "." counter(subsection) " ";
    font-weight: 400;
    color: #54595d;
}

.toc a {
    color: #3366cc;
    text-decoration: none;
    display: block;
    padding: 2px 4px;
    border-left: 2px solid transparent;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1.35;
}

.toc a:hover {
    text-decoration: underline;
    background: #eaecf0;
}

.toc a.active {
    background: #eaf3ff;
    border-left-color: #3366cc;
    color: #1a4d99;
    font-weight: 600;
}

/* ---------- Main article ---------- */
.article {
    min-width: 0;
    max-width: 880px;
}

.article h1 {
    font-family: 'Linux Libertine', 'Georgia', 'Times New Roman', serif;
    font-size: 32px;
    font-weight: 400;
    margin: 0 0 4px;
    padding-bottom: 6px;
    border-bottom: 1px solid #a2a9b1;
    color: #202122;
}

.last-updated {
    font-size: 12px;
    color: #54595d;
    font-style: italic;
    margin-bottom: 18px;
    font-family: 'Helvetica Neue', Arial, sans-serif;
}

.article h2 {
    font-family: 'Linux Libertine', 'Georgia', 'Times New Roman', serif;
    font-size: 24px;
    font-weight: 400;
    margin: 36px 0 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid #a2a9b1;
    color: #202122;
    scroll-margin-top: 24px;
}

.article h3 {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 18px;
    font-weight: 700;
    margin: 26px 0 8px;
    color: #202122;
    scroll-margin-top: 24px;
}

.article h4 {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 15px;
    font-weight: 700;
    margin: 18px 0 6px;
    color: #202122;
}

.article p {
    margin: 0 0 14px;
    text-align: left;
}

.article ul, .article ol {
    margin: 0 0 14px 24px;
    padding: 0;
}

.article li { margin-bottom: 4px; }

.article strong { font-weight: 700; }

/* ---------- Lead section ---------- */
.lead {
    border: 1px solid #c8ccd1;
    background: #f8f9fa;
    padding: 16px 18px;
    margin-bottom: 24px;
}

.lead p { margin: 0 0 10px; }
.lead p:last-child { margin-bottom: 0; }

/* ---------- Infobox (top-right) ---------- */
.infobox {
    float: right;
    width: 290px;
    margin: 0 0 20px 24px;
    border: 1px solid #a2a9b1;
    background: #f8f9fa;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 13px;
    line-height: 1.45;
}

.infobox-title {
    background: #cedff2;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    padding: 8px 10px;
    border-bottom: 1px solid #a2a9b1;
    color: #202122;
}

.infobox table {
    width: 100%;
    border-collapse: collapse;
}

.infobox th, .infobox td {
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
    border-top: 1px solid #c8ccd1;
}

.infobox th {
    background: #eaecf0;
    font-weight: 700;
    width: 38%;
    color: #202122;
}

.infobox td { color: #202122; }

.infobox tr:first-child th,
.infobox tr:first-child td { border-top: none; }

/* ---------- Tables in article ---------- */
.article table.wiki-table {
    border-collapse: collapse;
    margin: 16px 0;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 13px;
    width: 100%;
}

.article table.wiki-table th,
.article table.wiki-table td {
    border: 1px solid #a2a9b1;
    padding: 8px 12px;
    text-align: left;
}

.article table.wiki-table th {
    background: #eaecf0;
    font-weight: 700;
}

/* ---------- Section anchors ---------- */
.article h2 a.anchor,
.article h3 a.anchor {
    margin-left: 8px;
    font-size: 13px;
    color: #a2a9b1;
    text-decoration: none;
    opacity: 0;
    transition: opacity 0.15s;
    font-family: 'Helvetica Neue', Arial, sans-serif;
}

.article h2:hover a.anchor,
.article h3:hover a.anchor { opacity: 1; }

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid #a2a9b1;
    margin-top: 60px;
    padding: 20px 30px;
    text-align: center;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    font-size: 12px;
    color: #54595d;
    background: #f8f9fa;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
        padding: 16px 18px 60px;
    }

    .sidebar {
        position: relative;
        top: 0;
        max-height: none;
        overflow-y: visible;
    }

    .infobox {
        float: none;
        width: 100%;
        margin: 0 0 20px 0;
    }

    .article h1 { font-size: 26px; }
    .article h2 { font-size: 21px; }
    .article h3 { font-size: 17px; }
}

@media (max-width: 480px) {
    body { font-size: 15px; }
    .layout { padding: 12px 14px 50px; }
    .top-bar { padding: 8px 14px; }
}

/* ---------- Print ---------- */
@media print {
    .sidebar, .top-bar, .site-footer { display: none; }
    .layout { grid-template-columns: 1fr; padding: 0; }
    body { font-size: 12pt; color: #000; }
    a { color: #000; text-decoration: none; }
}
