/* =====================================================================
   MTC 工作小站 · 新版界面 (2026-10-02)
   - 设计令牌：浅色 / 深色两套，html[data-theme]
   - 语言：html[data-ui-lang] 控制 [data-l] 文本显隐
   - 外壳：.ui-topbar / .ui-drawer / .ui-footer
   - Bootstrap 4 组件统一换肤（只改颜色、圆角、阴影，不改布局尺寸）
   回退：cookie mtc_ui=classic 或 settings.UI_DEFAULT_SKIN='classic'
   ===================================================================== */

:root,
html[data-theme="light"] {
    --ui-bg: #f4f6f9;
    --ui-surface: #ffffff;
    --ui-surface-2: #f8f9fb;
    --ui-surface-3: #eef1f5;
    --ui-border: #e2e6ec;
    --ui-border-strong: #cdd3dc;
    --ui-text: #1b2230;
    --ui-text-2: #4a5466;
    --ui-muted: #6b7486;
    --ui-primary: #2457c5;
    --ui-primary-hover: #1d48a6;
    --ui-primary-soft: #e8eefb;
    --ui-primary-text: #ffffff;
    --ui-accent: #0f8a7e;
    --ui-danger: #c93a3a;
    --ui-danger-soft: #fbeaea;
    --ui-success: #1f8a4c;
    --ui-success-soft: #e6f4ec;
    --ui-warning: #a86400;
    --ui-warning-soft: #fdf2e0;
    --ui-info-soft: #e6f2f8;
    --ui-link: #2457c5;
    --ui-topbar: rgba(255, 255, 255, .86);
    --ui-topbar-border: #e2e6ec;
    --ui-shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --ui-shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 12px rgba(16, 24, 40, .05);
    --ui-shadow-lg: 0 12px 32px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06);
    --ui-scrim: rgba(15, 20, 30, .42);
    --ui-focus: 0 0 0 3px rgba(36, 87, 197, .28);
    --ui-code-bg: #f1f3f6;
    color-scheme: light;
}

html[data-theme="dark"] {
    --ui-bg: #0e1218;
    --ui-surface: #161b23;
    --ui-surface-2: #1b212b;
    --ui-surface-3: #232a36;
    --ui-border: #2a313d;
    --ui-border-strong: #3a4250;
    --ui-text: #e4e8ee;
    --ui-text-2: #bcc3ce;
    --ui-muted: #8d97a6;
    --ui-primary: #5b8cf0;
    --ui-primary-hover: #7aa2f5;
    --ui-primary-soft: #1c2a45;
    --ui-primary-text: #0b1220;
    --ui-accent: #3cc2b3;
    --ui-danger: #f07a7a;
    --ui-danger-soft: #3a1f22;
    --ui-success: #5fcf8f;
    --ui-success-soft: #183327;
    --ui-warning: #f0b55a;
    --ui-warning-soft: #3a2e17;
    --ui-info-soft: #17303b;
    --ui-link: #7aa2f5;
    --ui-topbar: rgba(18, 23, 30, .86);
    --ui-topbar-border: #232a35;
    --ui-shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --ui-shadow: 0 1px 3px rgba(0, 0, 0, .45), 0 4px 12px rgba(0, 0, 0, .25);
    --ui-shadow-lg: 0 16px 40px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .3);
    --ui-scrim: rgba(0, 0, 0, .58);
    --ui-focus: 0 0 0 3px rgba(91, 140, 240, .35);
    --ui-code-bg: #1d232d;
    color-scheme: dark;
}

/* ---------- 语言切换 ---------- */
html[data-ui-lang="zh"] [data-l="en"],
html:not([data-ui-lang]) [data-l="en"],
html[data-ui-lang="en"] [data-l="zh"] { display: none !important; }

/* ---------- 基础 ---------- */
body.ui-modern {
    background: var(--ui-bg);
    color: var(--ui-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
                 "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
/* 链接色：只与 Bootstrap 的 a{} 同级，页面自定义的链接色优先 */
:where(body.ui-modern) a { color: var(--ui-link); }
:where(body.ui-modern) a:hover { color: var(--ui-primary-hover); }
body.ui-modern ::selection { background: var(--ui-primary-soft); }
body.ui-modern :focus-visible { outline: none; box-shadow: var(--ui-focus); border-radius: 6px; }

.ui-skip {
    position: absolute; left: 12px; top: -40px; z-index: 100001;
    background: var(--ui-primary); color: var(--ui-primary-text) !important;
    padding: 8px 12px; border-radius: 8px; transition: top .15s;
}
.ui-skip:focus { top: 8px; }
.ui-topbar button:focus:not(:focus-visible), .ui-drawer button:focus:not(:focus-visible),
.ui-footer button:focus:not(:focus-visible), .ui-drawer summary:focus:not(:focus-visible) { outline: none; }

/* ---------- 顶栏 ---------- */
.ui-topbar {
    position: sticky; top: 0; z-index: 1030;
    background: var(--ui-topbar);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid var(--ui-topbar-border);
}
.ui-topbar__inner {
    position: relative;
    display: flex; align-items: center; gap: 8px;
    height: 60px; padding: 0 20px;
    max-width: 1680px; margin: 0 auto;
}
.ui-brand {
    display: inline-flex; align-items: center; gap: 10px;
    color: var(--ui-text) !important; text-decoration: none !important;
    font-weight: 650; font-size: 16px; letter-spacing: .01em; white-space: nowrap;
    margin-right: 12px;
}
.ui-brand__mark {
    width: 32px; height: 32px; border-radius: 9px; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--ui-primary), #3b7be8);
    color: #fff; box-shadow: 0 2px 6px rgba(36, 87, 197, .3);
}
html[data-theme="dark"] .ui-brand__mark { background: linear-gradient(135deg, #3d6fd6, #5b8cf0); color: #fff; }

.ui-nav { display: flex; align-items: center; gap: 2px; flex: 1 1 auto; min-width: 0; }
.ui-nav__link {
    display: inline-flex; align-items: center; gap: 6px;
    height: 36px; padding: 0 11px; border-radius: 8px;
    font-size: 14px; font-weight: 500; line-height: 1;
    color: var(--ui-text-2) !important; text-decoration: none !important;
    background: transparent; border: 0; cursor: pointer; white-space: nowrap;
    transition: background-color .15s, color .15s;
}
.ui-nav__link:hover { background: var(--ui-surface-3); color: var(--ui-text) !important; }
.ui-nav__link.is-active { color: var(--ui-primary) !important; background: var(--ui-primary-soft); }
.ui-caret { font-size: 10px; opacity: .6; transition: transform .2s; }
[aria-expanded="true"] > .ui-caret, details[open] > summary .ui-caret { transform: rotate(180deg); }

.ui-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.ui-iconbtn {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px; flex: none;
    border: 0; background: transparent; cursor: pointer;
    color: var(--ui-text-2) !important; font-size: 16px; text-decoration: none !important;
    transition: background-color .15s, color .15s;
}
.ui-iconbtn:hover { background: var(--ui-surface-3); color: var(--ui-text) !important; }
.ui-langbtn { font-size: 13px; font-weight: 700; letter-spacing: .02em; }
html[data-theme="dark"] .ui-show-light, html:not([data-theme="dark"]) .ui-show-dark { display: none; }
.ui-badge {
    position: absolute; top: 3px; right: 2px;
    min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
    background: var(--ui-danger); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center;
    box-shadow: 0 0 0 2px var(--ui-surface);
}
html[data-theme="dark"] .ui-badge { background: #e5484d; }

.ui-user {
    display: inline-flex; align-items: center; gap: 8px;
    height: 38px; padding: 0 8px 0 4px; border-radius: 19px;
    border: 1px solid var(--ui-border); background: var(--ui-surface);
    color: var(--ui-text) !important; cursor: pointer; font-size: 14px; font-weight: 500;
    margin-left: 4px;
}
.ui-user:hover { border-color: var(--ui-border-strong); }
.ui-user__name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-avatar {
    width: 30px; height: 30px; border-radius: 50%; flex: none; object-fit: cover;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--ui-primary-soft); color: var(--ui-primary); font-weight: 700; font-size: 13px;
}
.ui-avatar--lg { width: 44px; height: 44px; font-size: 18px; }

.ui-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
    font-size: 14px; font-weight: 600; text-decoration: none !important; cursor: pointer; white-space: nowrap;
}
.ui-btn--sm { height: 34px; padding: 0 14px; }
.ui-btn--primary { background: var(--ui-primary); color: var(--ui-primary-text) !important; }
.ui-btn--primary:hover { background: var(--ui-primary-hover); }
.ui-btn--ghost { background: var(--ui-surface); border-color: var(--ui-border); color: var(--ui-text) !important; }
.ui-btn--ghost:hover { border-color: var(--ui-border-strong); background: var(--ui-surface-2); }

/* ---------- 下拉 / 超级菜单 ---------- */
.ui-dd { position: relative; }
.ui-dd--mega { position: static; }
.ui-dd__panel {
    position: absolute; top: calc(100% + 8px); left: 0; z-index: 1040;
    min-width: 236px; padding: 6px;
    background: var(--ui-surface); color: var(--ui-text);
    border: 1px solid var(--ui-border); border-radius: 12px; box-shadow: var(--ui-shadow-lg);
    opacity: 0; visibility: hidden; transform: translateY(-4px);
    transition: opacity .15s, transform .15s, visibility 0s linear .15s;
}
.ui-dd.is-open > .ui-dd__panel { opacity: 1; visibility: visible; transform: none; transition: opacity .15s, transform .15s; }
.ui-dd--right > .ui-dd__panel { left: auto; right: 0; }
.ui-dd__panel--mega {
    left: 50%; top: calc(100% - 2px);
    transform: translate(-50%, -4px);
    width: min(1120px, calc(100vw - 40px));
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 12px;
    padding: 14px;
}
.ui-dd.is-open > .ui-dd__panel--mega { transform: translate(-50%, 0); }
.ui-dd__panel--menu { width: 264px; }
.ui-dd__group + .ui-dd__group { margin-top: 2px; }
.ui-dd__panel--mega .ui-dd__group + .ui-dd__group { margin-top: 0; }
.ui-dd__title {
    padding: 8px 10px 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: var(--ui-muted);
}
.ui-dd__item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border-radius: 8px; border: 0; background: transparent; text-align: left;
    color: var(--ui-text) !important; text-decoration: none !important; font-size: 14px; line-height: 1.35; cursor: pointer;
}
.ui-dd__item:hover, .ui-dd__item:focus-visible { background: var(--ui-surface-3); }
.ui-dd__item--danger, .ui-dd__item--danger .ui-dd__ic { color: var(--ui-danger) !important; }
.ui-dd__ic { width: 18px; text-align: center; color: var(--ui-muted); font-size: 14px; flex: none; }
.ui-dd__item:hover .ui-dd__ic { color: var(--ui-primary); }
.ui-dd__label { flex: 1 1 auto; min-width: 0; }
.ui-ext { font-size: 10px; color: var(--ui-muted); opacity: .7; }
.ui-tag {
    flex: none; font-size: 10px; font-weight: 700; letter-spacing: .04em;
    padding: 2px 6px; border-radius: 5px; background: var(--ui-surface-3); color: var(--ui-muted);
}
.ui-tag--danger { background: var(--ui-danger-soft); color: var(--ui-danger); }
.ui-dd__sep { height: 1px; background: var(--ui-border); margin: 6px 4px; }
.ui-dd__head { padding: 10px 10px 8px; border-bottom: 1px solid var(--ui-border); margin-bottom: 6px; }
.ui-dd__head-name { font-weight: 650; }
.ui-dd__head-sub { font-size: 12.5px; color: var(--ui-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 抽屉（平板 / 手机） ---------- */
.ui-scrim {
    position: fixed; inset: 0; z-index: 1050; background: var(--ui-scrim);
    opacity: 0; transition: opacity .2s;
}
.ui-scrim.is-open { opacity: 1; }
.ui-drawer {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 1060;
    width: min(360px, 88vw); display: flex; flex-direction: column;
    background: var(--ui-surface); color: var(--ui-text);
    border-right: 1px solid var(--ui-border); box-shadow: var(--ui-shadow-lg);
    transform: translateX(-102%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
    visibility: hidden;
}
.ui-drawer.is-open { transform: none; visibility: visible; }
.ui-drawer__head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 14px 12px 12px 16px; border-bottom: 1px solid var(--ui-border);
}
.ui-drawer__user { display: flex; align-items: center; gap: 12px; color: var(--ui-text) !important; text-decoration: none !important; min-width: 0; }
.ui-drawer__user > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.ui-drawer__name { font-weight: 650; font-size: 16px; }
.ui-drawer__sub { font-size: 12.5px; color: var(--ui-muted); }
.ui-drawer__body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 8px 10px 12px; }
.ui-drawer__section { padding-bottom: 6px; margin-bottom: 6px; border-bottom: 1px solid var(--ui-border); }
.ui-drawer__link {
    display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 10px; border-radius: 10px;
    color: var(--ui-text) !important; text-decoration: none !important; font-size: 15px; font-weight: 500; cursor: pointer;
}
.ui-drawer__link:hover { background: var(--ui-surface-3); }
.ui-drawer__link.is-active { background: var(--ui-primary-soft); color: var(--ui-primary) !important; }
.ui-drawer__link.is-active .ui-dd__ic { color: var(--ui-primary); }
.ui-acc > summary { list-style: none; }
.ui-acc > summary::-webkit-details-marker { display: none; }
.ui-acc__sum .ui-caret { margin-left: auto; }
.ui-acc__sum .ui-tag { margin-left: auto; }
.ui-acc__sum .ui-tag + .ui-caret { margin-left: 8px; }
.ui-acc__body { padding: 2px 0 8px 8px; }
.ui-drawer__grid { display: grid; grid-template-columns: 1fr; gap: 2px; }
.ui-drawer__item {
    display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 10px; border-radius: 8px;
    color: var(--ui-text-2) !important; text-decoration: none !important; font-size: 14px;
}
.ui-drawer__item:hover { background: var(--ui-surface-3); color: var(--ui-text) !important; }
.ui-drawer__foot { border-top: 1px solid var(--ui-border); padding: 12px 14px; display: grid; gap: 10px; }
.ui-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; border-radius: 10px; background: var(--ui-surface-3); }
.ui-seg button {
    height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--ui-text-2);
    font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.ui-seg button.is-on { background: var(--ui-surface); color: var(--ui-text); box-shadow: var(--ui-shadow-sm); }
.ui-drawer__row { display: flex; justify-content: space-between; align-items: center; }
.ui-linkbtn {
    border: 0; background: none; padding: 4px 0; cursor: pointer; font-size: 13.5px;
    color: var(--ui-muted) !important; text-decoration: none !important;
}
.ui-linkbtn:hover { color: var(--ui-primary) !important; }
.ui-linkbtn--danger:hover { color: var(--ui-danger) !important; }
body.ui-drawer-open { overflow: hidden; }

/* 平板：抽屉内条目两列 */
@media (min-width: 640px) and (max-width: 1279.98px) {
    .ui-drawer { width: 420px; }
    .ui-drawer__grid { grid-template-columns: 1fr 1fr; }
}

/* 断点：≥1280 桌面导航；<1280 汉堡 + 抽屉 */
@media (min-width: 1280px) {
    .ui-only-compact { display: none !important; }
    .ui-drawer, .ui-scrim { display: none !important; }
}
@media (max-width: 1279.98px) {
    .ui-only-wide, .ui-only-wide-flex { display: none !important; }
    .ui-topbar__inner { padding: 0 10px; gap: 4px; }
    .ui-brand { margin-right: 0; }
}
@media (max-width: 1439.98px) and (min-width: 1280px) {
    .ui-nav__link { padding: 0 8px; font-size: 13.5px; }
    .ui-user__name { display: none; }
}
@media (max-width: 380px) {
    .ui-brand__text { font-size: 15px; }
    .ui-iconbtn { width: 36px; }
}

/* ---------- 页脚 ---------- */
.ui-footer {
    margin-top: 40px; border-top: 1px solid var(--ui-border); background: var(--ui-surface);
    color: var(--ui-muted); font-size: 13px;
}
.ui-footer__inner {
    max-width: 1680px; margin: 0 auto; padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
    display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: space-between; align-items: center;
}
.ui-footer__links { display: flex; align-items: center; gap: 8px; }
.ui-footer a, .ui-footer .ui-linkbtn { color: var(--ui-muted) !important; font-size: 13px; }
@media (max-width: 767.98px) {
    .ui-footer__inner { flex-direction: column; text-align: center; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* 业务页兼容：这些页面在手机/平板为旧版右上角悬浮按钮预留了顶部空白，新版顶栏下收回 */
@media (max-width: 991.98px) {
    body.ui-modern .lv-page { padding-top: 8px; }
}
.ui-drawer:focus { outline: none; }
/* SCI 学习总库（templates/sci_hub/list.html，自带 --sh-* 令牌）：深色下重定义令牌，适配器跳过该页 */
html[data-theme="dark"] .sh-page {
    --sh-paper: #0e1218; --sh-card: #161b23; --sh-ink: #e4e8ee; --sh-ink-2: #bcc3ce; --sh-muted: #8d97a6;
    --sh-line: #2a313d; --sh-line-strong: #3a4250; --sh-accent: #7aa2f5; --sh-accent-ink: #9dbaf7; --sh-accent-soft: #1c2a45;
    --sh-sage: #7fd1a0; --sh-sage-soft: #183327; --sh-danger: #f07a7a; --sh-danger-soft: #3a1f22;
}
html[data-theme="dark"] .sh-page .sh-hero {
    background: radial-gradient(1200px 320px at 8% -40%, rgba(91, 140, 240, .14), transparent 70%), linear-gradient(180deg, #121821 0%, #0e1218 100%);
}
html[data-theme="dark"] .sh-page .sh-stats { background: rgba(22, 27, 35, .8); }
html[data-theme="dark"] .sh-page .sh-search select { background-color: #1b212b; }
html[data-theme="dark"] .sh-page .sh-search button,
html[data-theme="dark"] .sh-page .sh-op.sh-op-read,
html[data-theme="dark"] .sh-page .sh-pg.sh-on { background: #5b8cf0; border-color: #5b8cf0; color: #0b1220; }
html[data-theme="dark"] .sh-page .sh-search button:hover,
html[data-theme="dark"] .sh-page .sh-op.sh-op-read:hover { background: #7aa2f5; border-color: #7aa2f5; color: #0b1220; }
html[data-theme="dark"] .sh-page .sh-op.sh-op-read i { color: #0b1220; }
html[data-theme="dark"] .sh-page .sh-btn-primary { background: #3d6fd6; border-color: #3d6fd6; color: #fff; }
html[data-theme="dark"] .sh-page .sh-btn-primary:hover { background: #4c7fe6; border-color: #4c7fe6; color: #fff; }
html[data-theme="dark"] .sh-page .sh-scope code { background: rgba(255, 255, 255, .06); }
html[data-theme="dark"] .sh-page .sh-table-head { background: #1b212b; }
html[data-theme="dark"] .sh-page .sh-table th { background: #161b23; }
html[data-theme="dark"] .sh-page .sh-table tbody tr:hover { background: #1b212b; }
html[data-theme="dark"] .sh-page .sh-op { background: #1b212b; }
html[data-theme="dark"] .sh-page .sh-op:hover { border-color: #2a3e66; }
html[data-theme="dark"] .sh-page .sh-avatar { background: linear-gradient(145deg, #23304a, #1c2a45); }
html[data-theme="dark"] .sh-page a.sh-journal:hover { background: #1f4430; color: #a6e3bf; }


/* 回到顶部按钮跟随主题 */
body.ui-modern .toTop-arrow { background: var(--ui-text) !important; opacity: .55; border-radius: 12px !important; }
body.ui-modern .toTop-arrow:hover { opacity: .8; }
html[data-theme="dark"] body.ui-modern .toTop-arrow::before,
html[data-theme="dark"] body.ui-modern .toTop-arrow::after { border-color: var(--ui-bg) !important; background: var(--ui-bg) !important; }

/* =====================================================================
   Bootstrap 4 组件换肤（两套主题共用变量）
   ===================================================================== */
:where(body.ui-modern) h1, :where(body.ui-modern) h2, :where(body.ui-modern) h3,
:where(body.ui-modern) h4, :where(body.ui-modern) h5, :where(body.ui-modern) h6 { color: inherit; }
:where(body.ui-modern) hr { border-top-color: var(--ui-border); }
:where(body.ui-modern) .text-muted { color: var(--ui-muted) !important; }
:where(body.ui-modern) .text-dark { color: var(--ui-text) !important; }
:where(body.ui-modern) .border, :where(body.ui-modern) .border-top, :where(body.ui-modern) .border-bottom,
:where(body.ui-modern) .border-left, :where(body.ui-modern) .border-right { border-color: var(--ui-border) !important; }

/* 按钮 */
:where(body.ui-modern) .btn { border-radius: 8px; font-weight: 500; }
:where(body.ui-modern) .btn-primary { background-color: var(--ui-primary); border-color: var(--ui-primary); color: var(--ui-primary-text); }
:where(body.ui-modern) .btn-primary:hover, :where(body.ui-modern) .btn-primary:focus { background-color: var(--ui-primary-hover); border-color: var(--ui-primary-hover); color: var(--ui-primary-text); }
:where(body.ui-modern) .btn-outline-primary { color: var(--ui-primary); border-color: var(--ui-primary); }
:where(body.ui-modern) .btn-outline-primary:hover { background: var(--ui-primary); color: var(--ui-primary-text); }
:where(body.ui-modern) .btn-light, :where(body.ui-modern) .btn-outline-secondary {
    background: var(--ui-surface); border-color: var(--ui-border-strong); color: var(--ui-text);
}
:where(body.ui-modern) .btn-light:hover, :where(body.ui-modern) .btn-outline-secondary:hover { background: var(--ui-surface-3); color: var(--ui-text); }
:where(body.ui-modern) .btn-link { color: var(--ui-link); }
:where(body.ui-modern) .btn:focus, :where(body.ui-modern) .btn.focus { box-shadow: var(--ui-focus); }

/* 表单 */
:where(body.ui-modern) .form-control, :where(body.ui-modern) .custom-select {
    border-radius: 8px; border-color: var(--ui-border-strong);
    background-color: var(--ui-surface); color: var(--ui-text);
}
:where(body.ui-modern) .form-control::placeholder { color: var(--ui-muted); opacity: 1; }
:where(body.ui-modern) .form-control:focus, :where(body.ui-modern) .custom-select:focus {
    border-color: var(--ui-primary); box-shadow: var(--ui-focus); background-color: var(--ui-surface); color: var(--ui-text);
}
:where(body.ui-modern) .form-control:disabled, :where(body.ui-modern) .form-control[readonly] { background-color: var(--ui-surface-3); }
:where(body.ui-modern) .input-group-text { background: var(--ui-surface-3); border-color: var(--ui-border-strong); color: var(--ui-text-2); }

/* 卡片 / 列表 / 巨幕 */
:where(body.ui-modern) .card { background-color: var(--ui-surface); border-color: var(--ui-border); border-radius: 12px; }
:where(body.ui-modern) .card-header, :where(body.ui-modern) .card-footer { background-color: var(--ui-surface-2); border-color: var(--ui-border); }
:where(body.ui-modern) .list-group-item { background-color: var(--ui-surface); border-color: var(--ui-border); color: var(--ui-text); }
:where(body.ui-modern) .list-group-item-action:hover { background-color: var(--ui-surface-3); color: var(--ui-text); }
:where(body.ui-modern) .list-group-item.active { background-color: var(--ui-primary); border-color: var(--ui-primary); color: var(--ui-primary-text); }
:where(body.ui-modern) .jumbotron { background-color: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: 14px; }

/* 表格 */
:where(body.ui-modern) .table { color: var(--ui-text); }
:where(body.ui-modern) .table th, :where(body.ui-modern) .table td, :where(body.ui-modern) .table thead th { border-color: var(--ui-border); }
:where(body.ui-modern) .table thead th { color: var(--ui-text-2); }
:where(body.ui-modern) .table-bordered, :where(body.ui-modern) .table-bordered th, :where(body.ui-modern) .table-bordered td { border-color: var(--ui-border); }
:where(body.ui-modern) .table-striped tbody tr:nth-of-type(odd) { background-color: var(--ui-surface-2); }
:where(body.ui-modern) .table-hover tbody tr:hover { background-color: var(--ui-surface-3); color: var(--ui-text); }
:where(body.ui-modern) .thead-light th, :where(body.ui-modern) .table-light, :where(body.ui-modern) .table-light > td, :where(body.ui-modern) .table-light > th {
    background-color: var(--ui-surface-3); color: var(--ui-text); border-color: var(--ui-border);
}

/* 分页 / 面包屑 / 标签页 */
:where(body.ui-modern) .page-link { background-color: var(--ui-surface); border-color: var(--ui-border); color: var(--ui-link); }
:where(body.ui-modern) .page-link:hover { background-color: var(--ui-surface-3); border-color: var(--ui-border); }
:where(body.ui-modern) .page-item.active .page-link { background-color: var(--ui-primary); border-color: var(--ui-primary); color: var(--ui-primary-text); }
:where(body.ui-modern) .page-item.disabled .page-link { background-color: var(--ui-surface-2); color: var(--ui-muted); border-color: var(--ui-border); }
:where(body.ui-modern) .breadcrumb { background-color: var(--ui-surface-3); border-radius: 10px; }
:where(body.ui-modern) .breadcrumb-item.active, :where(body.ui-modern) .breadcrumb-item + .breadcrumb-item::before { color: var(--ui-muted); }
:where(body.ui-modern) .nav-tabs { border-bottom-color: var(--ui-border); }
:where(body.ui-modern) .nav-tabs .nav-link.active, :where(body.ui-modern) .nav-tabs .nav-item.show .nav-link {
    background-color: var(--ui-surface); color: var(--ui-text); border-color: var(--ui-border) var(--ui-border) var(--ui-surface);
}
:where(body.ui-modern) .nav-tabs .nav-link:hover { border-color: var(--ui-border); }
:where(body.ui-modern) .nav-pills .nav-link.active { background-color: var(--ui-primary); color: var(--ui-primary-text); }

/* 弹层 */
:where(body.ui-modern) .dropdown-menu {
    background-color: var(--ui-surface); border-color: var(--ui-border); border-radius: 10px; box-shadow: var(--ui-shadow-lg); color: var(--ui-text);
}
:where(body.ui-modern) .dropdown-item { color: var(--ui-text); }
:where(body.ui-modern) .dropdown-item:hover, :where(body.ui-modern) .dropdown-item:focus { background-color: var(--ui-surface-3); color: var(--ui-text); }
:where(body.ui-modern) .dropdown-divider { border-top-color: var(--ui-border); }
:where(body.ui-modern) .modal-content { background-color: var(--ui-surface); color: var(--ui-text); border-color: var(--ui-border); border-radius: 14px; }
:where(body.ui-modern) .modal-header, :where(body.ui-modern) .modal-footer { border-color: var(--ui-border); }
:where(body.ui-modern) .close { color: var(--ui-text); text-shadow: none; }
:where(body.ui-modern) .popover { background-color: var(--ui-surface); border-color: var(--ui-border); }
:where(body.ui-modern) .popover-body { color: var(--ui-text); }

/* 提示 / 徽章 */
:where(body.ui-modern) .alert { border-radius: 10px; }
:where(body.ui-modern) .badge { font-weight: 600; border-radius: 6px; }
:where(body.ui-modern) .badge-primary { background-color: var(--ui-primary); color: var(--ui-primary-text); }

/* 代码 */
:where(body.ui-modern) code { color: #c7254e; }
:where(html[data-theme="dark"] body.ui-modern) code { color: #f29bb4; }

/* ---------- 深色主题：仅深色下需要的补丁 ---------- */
:where(html[data-theme="dark"] body.ui-modern) .bg-white,
:where(html[data-theme="dark"] body.ui-modern) .bg-light { background-color: var(--ui-surface) !important; }
:where(html[data-theme="dark"] body.ui-modern) .text-black-50 { color: var(--ui-muted) !important; }
:where(html[data-theme="dark"] body.ui-modern) .text-body { color: var(--ui-text) !important; }
:where(html[data-theme="dark"] body.ui-modern) .table-dark { background-color: var(--ui-surface-3); }
:where(html[data-theme="dark"] body.ui-modern) .alert-primary { background: var(--ui-primary-soft); border-color: #2a3e66; color: #b9cdf7; }
:where(html[data-theme="dark"] body.ui-modern) .alert-info { background: var(--ui-info-soft); border-color: #24495a; color: #a9d8ea; }
:where(html[data-theme="dark"] body.ui-modern) .alert-success { background: var(--ui-success-soft); border-color: #22533a; color: #a6e3bf; }
:where(html[data-theme="dark"] body.ui-modern) .alert-warning { background: var(--ui-warning-soft); border-color: #5a4720; color: #f3d39b; }
:where(html[data-theme="dark"] body.ui-modern) .alert-danger { background: var(--ui-danger-soft); border-color: #5a2a2e; color: #f5b5b5; }
:where(html[data-theme="dark"] body.ui-modern) .alert-secondary, :where(html[data-theme="dark"] body.ui-modern) .alert-light {
    background: var(--ui-surface-3); border-color: var(--ui-border); color: var(--ui-text);
}
:where(html[data-theme="dark"] body.ui-modern) .badge-light, :where(html[data-theme="dark"] body.ui-modern) .badge-secondary {
    background: var(--ui-surface-3); color: var(--ui-text);
}
:where(html[data-theme="dark"] body.ui-modern) .table-primary, :where(html[data-theme="dark"] body.ui-modern) .table-primary > td { background-color: #1c2a45; }
:where(html[data-theme="dark"] body.ui-modern) .table-success, :where(html[data-theme="dark"] body.ui-modern) .table-success > td { background-color: #183327; }
:where(html[data-theme="dark"] body.ui-modern) .table-warning, :where(html[data-theme="dark"] body.ui-modern) .table-warning > td { background-color: #3a2e17; }
:where(html[data-theme="dark"] body.ui-modern) .table-danger, :where(html[data-theme="dark"] body.ui-modern) .table-danger > td { background-color: #3a1f22; }
:where(html[data-theme="dark"] body.ui-modern) .table-info, :where(html[data-theme="dark"] body.ui-modern) .table-info > td { background-color: #17303b; }
:where(html[data-theme="dark"] body.ui-modern) .table-secondary, :where(html[data-theme="dark"] body.ui-modern) .table-active,
:where(html[data-theme="dark"] body.ui-modern) .table-secondary > td { background-color: var(--ui-surface-3); }
:where(html[data-theme="dark"] body.ui-modern) .btn-dark { background: #e4e8ee; border-color: #e4e8ee; color: #0e1218; }
:where(html[data-theme="dark"] body.ui-modern) .btn-outline-dark { color: var(--ui-text); border-color: var(--ui-border-strong); }
:where(html[data-theme="dark"] body.ui-modern) .btn-outline-dark:hover { background: var(--ui-surface-3); }
:where(html[data-theme="dark"] body.ui-modern) select option { background: var(--ui-surface); color: var(--ui-text); }
:where(html[data-theme="dark"] body.ui-modern) img:not([src$=".svg"]) { filter: brightness(.94); }
:where(html[data-theme="dark"] body.ui-modern) .layui-layer { background-color: var(--ui-surface); color: var(--ui-text); }
:where(html[data-theme="dark"] body.ui-modern) .layui-layer-title { background-color: var(--ui-surface-2); color: var(--ui-text); border-bottom-color: var(--ui-border); }
:where(html[data-theme="dark"] body.ui-modern) ::-webkit-scrollbar { width: 10px; height: 10px; }
:where(html[data-theme="dark"] body.ui-modern) ::-webkit-scrollbar-thumb { background: #333b48; border-radius: 6px; }
:where(html[data-theme="dark"] body.ui-modern) ::-webkit-scrollbar-track { background: transparent; }

/* mtc-ui.js 的「深色适配器」标记：旧页面里写死的白底容器 → 深色表面 */
html[data-theme="dark"] .ui-auto-surface { background-color: var(--ui-surface) !important; border-color: var(--ui-border) !important; }
html[data-theme="dark"] .ui-auto-surface-2 { background-color: var(--ui-surface-2) !important; border-color: var(--ui-border) !important; }

@media (prefers-reduced-motion: reduce) {
    .ui-drawer, .ui-scrim, .ui-dd__panel, .ui-caret { transition: none !important; }
}
@media print {
    .ui-topbar, .ui-drawer, .ui-scrim, .ui-footer, .ui-skip { display: none !important; }
    :where(body.ui-modern) { background: #fff; color: #000; }
}
