/* ===== 主题变量：浅色 / 暗色 ===== */
:root {
    color-scheme: light;
    --bg: #f7f8fa;
    --surface: #ffffff;
    --surface-2: #f1f3f6;
    --surface-3: #e9edf3;
    --text: #171b23;
    --muted: #6c7482;
    --faint: #9aa2ae;
    --border: #e3e7ed;
    --border-strong: #d3d9e2;
    --accent: #4a63d8;
    --accent-hover: #3b53c4;
    --accent-weak: #edf0ff;
    --accent-text: #ffffff;
    --warm: #b9704c;
    --danger: #c2453f;
    --danger-weak: #fdf0ef;
    --success: #2f855a;
    --success-weak: #ecf8f1;
    --code-bg: #f2f4f8;
    --shadow: 0 1px 2px rgba(20, 28, 45, .04), 0 10px 30px rgba(20, 28, 45, .05);
    --shadow-hover: 0 4px 12px rgba(20, 28, 45, .07), 0 18px 40px rgba(20, 28, 45, .09);
    --radius: 14px;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1218;
    --surface: #171b23;
    --surface-2: #1d222b;
    --surface-3: #242a35;
    --text: #e9ecf2;
    --muted: #98a1b0;
    --faint: #737d8c;
    --border: #2a313d;
    --border-strong: #39424f;
    --accent: #8ca4ff;
    --accent-hover: #a5b8ff;
    --accent-weak: #202a49;
    --accent-text: #10141c;
    --warm: #e0a279;
    --danger: #f07b74;
    --danger-weak: #36201f;
    --success: #6fd39b;
    --success-weak: #1b3026;
    --code-bg: #11161e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .18), 0 10px 30px rgba(0, 0, 0, .22);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, .25), 0 18px 40px rgba(0, 0, 0, .3);
}

/* ===== 基础 ===== */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    font-size: 15px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    transition: background-color .2s ease, color .2s ease;
}

a { color: var(--accent); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4 { line-height: 1.35; margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
img { max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent-weak); }

.container { width: min(1120px, calc(100% - 48px)); margin: 0 auto; }
.narrow { width: min(860px, calc(100% - 48px)); margin: 0 auto; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; }
.hidden { display: none !important; }

/* ===== 顶部导航 ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}

.nav-inner { height: 66px; display: flex; align-items: center; gap: 24px; }

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: .04em;
    white-space: nowrap;
}
.brand:hover { color: var(--text); }
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 14px;
    line-height: 1;
}

.nav-links { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-links a {
    padding: 7px 12px;
    border-radius: 9px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-links a.active { color: var(--accent); background: var(--accent-weak); }

.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--muted);
    transition: all .18s ease;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.site-main { min-height: calc(100vh - 66px - 84px); }

.site-footer { border-top: 1px solid var(--border); margin-top: 80px; padding: 26px 0; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--faint); font-size: 13px; }
.footer-admin { color: var(--faint); font-size: 13px; }
.footer-admin:hover { color: var(--accent); }

/* ===== 通用按钮 / 徽章 / 表单 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 550;
    line-height: 1.4;
    transition: all .18s ease;
    white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-weak); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-weak); color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }

.input, .textarea, .select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .textarea:focus, .select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-weak);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }

.field { display: flex; flex-direction: column; gap: 7px; }
.field > label, .field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field-hint { font-size: 12px; color: var(--faint); line-height: 1.6; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 13px;
    transition: all .18s ease;
}
.chip:hover { color: var(--accent); border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.alert { padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.alert-error { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: var(--danger-weak); color: var(--danger); }
.alert-ok { border-color: color-mix(in srgb, var(--success) 35%, var(--border)); background: var(--success-weak); color: var(--success); }

.empty {
    padding: 56px 24px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--muted);
    text-align: center;
}

/* ===== 页面标题区 ===== */
.page-head { padding: 54px 0 30px; }
.page-head h1 { font-size: clamp(28px, 4vw, 38px); }
.page-head p { color: var(--muted); margin-top: 10px; font-size: 15px; }
.section { padding: 32px 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section-head h2 { font-size: 24px; }
.section-head p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.section-more { font-size: 14px; color: var(--accent); white-space: nowrap; }

/* ===== 卡片网格（列表页 / 首页共用） ===== */
.card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.card-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
a.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); color: var(--text); }

.card-top { display: flex; align-items: center; gap: 12px; }
.card-icon {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    font-size: 20px;
    color: var(--accent);
}
.card-icon img { width: 100%; height: 100%; object-fit: cover; }
.card-title { font-size: 16px; font-weight: 650; }
.card-platform { font-size: 12px; color: var(--faint); }
.card-desc { color: var(--muted); font-size: 13.5px; line-height: 1.65; min-height: 44px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-divider { height: 1px; background: var(--border); }

/* ===== 搜索 / 筛选 / 分页 ===== */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.search-form { display: flex; gap: 8px; margin-left: auto; }
.search-form .input { width: 210px; }

.pager { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 36px; }
.pager a, .pager span {
    min-width: 36px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}
.pager a:hover { color: var(--accent); border-color: var(--accent); }
.pager .current { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.pager .disabled { opacity: .45; }

/* ===== 面包屑 ===== */
.breadcrumb { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--faint); }
.breadcrumb .current { color: var(--text); }

/* ===== Markdown 正文 ===== */
.markdown-body { color: var(--text); font-size: 15px; line-height: 1.85; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 1.4em 0 .6em; }
.markdown-body h1 { font-size: 26px; }
.markdown-body h2 { font-size: 21px; }
.markdown-body h3 { font-size: 17px; }
.markdown-body p { margin: .8em 0; }
.markdown-body ul, .markdown-body ol { padding-left: 1.6em; margin: .8em 0; }
.markdown-body a { text-decoration: underline; text-underline-offset: 3px; }
.markdown-body code { padding: 2px 6px; border-radius: 5px; background: var(--code-bg); font-size: .9em; }
.markdown-body pre { padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--code-bg); overflow-x: auto; }
.markdown-body pre code { padding: 0; background: none; }
.markdown-body blockquote { margin: 1em 0; padding: 2px 16px; border-left: 3px solid var(--accent); color: var(--muted); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.markdown-body img { border-radius: 10px; }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 1em 0; }
.markdown-body th, .markdown-body td { padding: 8px 12px; border: 1px solid var(--border); }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 1.6em 0; }

/* ===== 响应式 ===== */
@media (max-width: 1000px) {
    .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .nav-links { gap: 0; }
    .nav-links a { padding: 7px 8px; font-size: 13px; }
}
@media (max-width: 760px) {
    .container, .narrow { width: min(100% - 32px, 1120px); }
    .nav-inner { height: auto; min-height: 60px; flex-wrap: wrap; gap: 8px; padding: 10px 0; }
    .nav-links { order: 3; width: 100%; overflow-x: auto; padding-bottom: 2px; margin-left: 0; }
    .theme-toggle { margin-left: auto; }
    .card-grid, .card-grid.cols-3, .card-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .search-form { margin-left: 0; width: 100%; }
    .search-form .input { width: 100%; }
    .page-head { padding: 34px 0 20px; }
    .section-head { align-items: flex-start; flex-direction: column; gap: 6px; }
}
@media (max-width: 480px) {
    .card-grid, .card-grid.cols-3, .card-grid.cols-2 { grid-template-columns: 1fr; }
}
