/* ============================================================
   Datasheet Theme
   ============================================================ */

:root {
    --bg: #fff;
    --text: #000;
    --text-muted: #333;
    --heading: #000;
    --accent: #003d7c;
    --th-bg: #f2f2f2;
    --th-border: #ccc;
    --stripe: #fafafa;
    --link: #000;
    --note-bg: #f7f7f7;
    --note-border: #999;

    --font-body: "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", Georgia, serif;
    --font-heading: "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
    --font-mono: "Cascadia Code", "Fira Code", Consolas, monospace;
    --size: 16px;
    --line: 1.75;
}

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

html { font-size: var(--size); }

body {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: var(--line);
    color: var(--text);
    background: var(--bg);
    max-width: 900px;
    margin: 0 auto;
    padding: 0;
}

/* ---------- Cover ---------- */
.cover-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 4em 2.5em;
    margin: 0 0 3em 0;
    position: relative;
    text-align: center;
}

.cover-top { margin-bottom: 4em; }

.cover-top .product-family {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    letter-spacing: 0.5em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
}

.cover-body { max-width: 100%; }

.cover-body h1 {
    font-family: var(--font-heading);
    font-size: 2.6rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.5em;
    color: var(--heading);
    border: none;
    padding: 0;
}

.cover-body h1 .model { font-weight: 800; display: inline; }

.cover-body h1 .zh-name {
    font-weight: 600;
    color: var(--text-muted);
    display: inline;
}

.cover-body .subtitle {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

.cover-bottom {
    position: absolute;
    bottom: 3.5em;
    left: 0; right: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: var(--font-heading);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.2em;
}

.cover-bottom .rev { font-weight: 700; color: var(--heading); }
.cover-bottom .author { white-space: nowrap; }

/* ---------- Chapters ---------- */
.chapter { padding: 2em 2.5em; }

/* ---------- Headings ---------- */
h1 {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--heading);
    margin: 2em 0 0.8em;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--heading);
}
h2 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--heading);
    margin: 1.5em 0 0.6em;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--th-border);
}
h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--heading);
    margin: 1.2em 0 0.5em;
}
h4 {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin: 1em 0 0.4em;
}

/* ---------- Body ---------- */
p { margin: 0.6em 0; text-align: justify; color: var(--text); }
ul, ol { margin: 0.6em 0; padding-left: 2em; color: var(--text); }
li { margin: 2px 0; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { font-weight: 700; color: var(--heading); }

/* ---------- Tables ---------- */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    font-size: 0.92rem;
}
thead th {
    background-color: var(--th-bg);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.88rem;
    text-align: left;
    padding: 6px 10px;
    border: 1px solid var(--th-border);
    border-bottom: 2px solid var(--heading);
    white-space: nowrap;
    color: var(--heading);
}
tbody td {
    padding: 5px 10px;
    border: 1px solid var(--th-border);
    vertical-align: top;
}
tbody tr:nth-child(even) { background-color: var(--stripe); }
table.compact { font-size: 0.85rem; }
table.compact thead th { font-size: 0.82rem; padding: 3px 7px; }
table.compact tbody td { padding: 3px 7px; }
td.addr, td.bits, td.reset-val { font-family: var(--font-mono); font-size: 0.85em; white-space: nowrap; }
td.bits { text-align: center; }

.perm-rw { color: var(--text); font-weight: 700; }
.perm-ro { color: var(--text); font-weight: 700; }
.perm-wc { color: var(--text); font-weight: 700; }

/* ---------- Code ---------- */
code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--note-bg);
    padding: 1px 5px;
    border-radius: 2px;
    border: 1px solid var(--th-border);
    color: var(--text);
}
pre {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: var(--note-bg);
    border: 1px solid var(--th-border);
    border-left: 3px solid var(--heading);
    padding: 12px;
    margin: 1em 0;
    overflow-x: auto;
    line-height: 1.5;
    color: var(--text);
}
pre code { background: none; padding: 0; border: none; font-size: inherit; }

.code-block {
    margin: 1em 0;
    border: 1px solid var(--th-border);
    overflow: hidden;
}
.code-header {
    background: var(--th-bg);
    font-family: var(--font-heading);
    font-size: 0.8rem;
    padding: 4px 10px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--th-border);
    font-weight: 700;
}
.code-lines {
    margin: 0; border: none; border-left: none;
    font-size: 0.82rem; line-height: 1.55;
    padding: 8px 0; background: var(--stripe);
    color: var(--text);
}
.code-lines .ln {
    display: inline-block; width: 40px;
    text-align: right; color: var(--text-muted);
    user-select: none; padding-right: 12px;
    margin-right: 8px; border-right: 1px solid var(--th-border);
}
.code-lines .lc { color: var(--text); }

/* ---------- Figures ---------- */
figure { margin: 1.2em auto; text-align: center; max-width: 75%; }
figure img { max-width: 100%; max-height: 420px; height: auto; border-radius: 2px; }
figure figcaption {
    font-family: var(--font-heading); font-size: 0.85rem;
    color: var(--text-muted); margin-top: 4px; font-weight: 700;
}
p img { max-width: 75%; max-height: 400px; height: auto; display: block; margin: 0.8em auto; border-radius: 2px; }
td img { max-width: 100%; max-height: 180px; margin: 0; }
.img-row { display: flex; gap: 1em; justify-content: center; align-items: flex-start; margin: 1em 0; }
.img-row img { flex: 0 0 auto; margin: 0; border-radius: 2px; }

/* ---------- Notes ---------- */
blockquote {
    margin: 1em 0; padding: 10px 16px;
    border-left: 3px solid var(--heading);
    background: var(--note-bg); font-size: 0.92rem;
    color: var(--text);
}

.reg-summary { font-size: 0.9rem; }
.reg-summary strong { margin-right: 4px; }
.reg-summary code { margin-right: 12px; }

.warning {
    background: #f5f5f5; border: 1px solid #999;
    padding: 10px; margin: 10px 0; color: var(--text);
}

/* ---------- Utility ---------- */
.text-center { text-align: center; }
.text-mono { font-family: var(--font-mono); }
.page-break { margin: 2em 0; }

/* ---------- Auto-numbering ---------- */
body.auto-numbering { counter-reset: section; }
body.auto-numbering .chapter h1 { counter-increment: section; counter-reset: subsection; }
body.auto-numbering .chapter h1::before { content: counter(section) ". "; font-weight: 800; }
body.auto-numbering .chapter h2 { counter-increment: subsection; counter-reset: subsubsection; }
body.auto-numbering .chapter h2::before { content: counter(section) "." counter(subsection) " "; font-weight: 700; }
body.auto-numbering .chapter h3 { counter-increment: subsubsection; }
body.auto-numbering .chapter h3::before { content: counter(section) "." counter(subsection) "." counter(subsubsection) " "; font-weight: 700; }
