/* ==========================================================
   upx8wiki · base
   变量层 / 重置 / 排版 / 通用原子类
   所有颜色只在这里定义，组件层一律引用变量
   ========================================================== */

:root,
html[data-theme="light"] {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #fbfcfd;
    --line: #e8ebef;
    --line-2: #f1f3f6;

    --tx: #1f2328;
    --tx-2: #5c6470;
    --tx-3: #8b93a1;
    --tx-4: #b3b9c2;

    --accent: #2563eb;
    --accent-soft: #eff6ff;
    --new: #dc2626;
    --warn: #d97706;
    --warn-bg: #fffbeb;

    --code-bg: #f8fafc;
    --hd-bg: rgba(255, 255, 255, .86);
    --shadow: 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 8px 28px rgba(16, 24, 40, .08);

    --r: 8px;
    --r-sm: 5px;
    --wrap: 1200px;
    --prose: 820px;
}

html[data-mode="dark"]:not([data-theme]),
html[data-theme="dark"] {
    --bg: #0e1014;
    --surface: #16181d;
    --surface-2: #12141a;
    --line: #252932;
    --line-2: #1d2027;

    --tx: #e7e9ee;
    --tx-2: #9aa3af;
    --tx-3: #6b7480;
    --tx-4: #4d5561;

    --accent: #60a5fa;
    --accent-soft: #16233a;
    --new: #f87171;
    --warn: #fbbf24;
    --warn-bg: #241a08;

    --code-bg: #0b0d11;
    --hd-bg: rgba(14, 16, 20, .84);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 8px 28px rgba(0, 0, 0, .45);
}

@media (prefers-color-scheme: dark) {
    html[data-mode="auto"]:not([data-theme]) {
        --bg: #0e1014;
        --surface: #16181d;
        --surface-2: #12141a;
        --line: #252932;
        --line-2: #1d2027;

        --tx: #e7e9ee;
        --tx-2: #9aa3af;
        --tx-3: #6b7480;
        --tx-4: #4d5561;

        --accent: #60a5fa;
        --accent-soft: #16233a;
        --new: #f87171;
        --warn: #fbbf24;
        --warn-bg: #241a08;

        --code-bg: #0b0d11;
        --hd-bg: rgba(14, 16, 20, .84);
        --shadow: 0 1px 2px rgba(0, 0, 0, .3);
        --shadow-lg: 0 8px 28px rgba(0, 0, 0, .45);
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--tx);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
    font-size: 14px;
    line-height: 1.62;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color .18s ease, color .18s ease;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, ul, ol, dl {
    margin: 0;
}

ul, ol {
    padding: 0;
    list-style: none;
}

a {
    color: inherit;
    text-decoration: none;
}

img, svg, video {
    display: block;
    max-width: 100%;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

input, textarea, select {
    font: inherit;
    color: inherit;
}

code, kbd, pre, samp {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

::selection {
    background: var(--accent);
    color: #fff;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
}

/* ---------- 布局容器 ---------- */

.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- 可访问性 ---------- */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- 通用原子 ---------- */

.rnew {
    color: var(--new) !important;
    font-weight: 700;
}

.sep {
    color: var(--tx-4);
    margin: 0 6px;
}

/* 分类徽标：固定 40px，保证所有标题左边缘对齐 */
.ct {
    flex: 0 0 40px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .02em;
    border-radius: 3px;
    color: var(--c, var(--tx-3));
    background: var(--cbg, var(--line-2));
    margin-top: 1px;
    overflow: hidden;
}

.ct-none {
    color: var(--tx-3);
    background: var(--line-2);
}

html[data-theme="dark"] .ct,
html[data-mode="dark"]:not([data-theme]) .ct {
    filter: saturate(.9) brightness(1.06);
}

@media (prefers-color-scheme: dark) {
    html[data-mode="auto"]:not([data-theme]) .ct {
        filter: saturate(.9) brightness(1.06);
    }
}

/* 滚动条 */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--tx-4);
    border-radius: 6px;
    border: 3px solid var(--bg);
}

::-webkit-scrollbar-track {
    background: transparent;
}
