/* ============================================================
   栈道 · 暗色模式增强
   仅在手动暗色或系统暗色解析生效时应用（html.app-dark-effective）。
   目标：可读性、层级、代码高亮、原生控件一致。
   ============================================================ */

html:is(.mdui-theme-dark, .app-dark-effective) {
    color-scheme: dark;
}

html.mdui-theme-light,
html.mdui-theme-light body {
    color-scheme: light;
}

/* ---------- 排行榜整行：显式铺底，避免 WebView/系统强制暗色把透明行刷成灰条 ---------- */
html:is(.mdui-theme-dark, .app-dark-effective) body.page-rank .card,
html:is(.mdui-theme-dark, .app-dark-effective) body.page-rank .card-body,
html:is(.mdui-theme-dark, .app-dark-effective) body.page-rank .rank-list,
html:is(.mdui-theme-dark, .app-dark-effective) body.page-rank .rank-item {
    background-color: rgb(var(--mdui-color-surface-container-low)) !important;
    -webkit-tap-highlight-color: transparent;
}

html:is(.mdui-theme-dark, .app-dark-effective) body.page-rank .rank-item:hover {
    background-color: rgba(var(--mdui-color-primary), .08) !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) body.page-rank .rank-item.me {
    background-color: rgba(var(--mdui-color-primary), .11) !important;
}

/* ---------- 主视觉：给暗色一点蓝色空气感，别糊成一团 ---------- */
html:is(.mdui-theme-dark, .app-dark-effective) .app-home-intro {
    background:
        radial-gradient(120% 90% at 100% 0%, rgba(var(--mdui-color-primary), .13), transparent 58%),
        linear-gradient(135deg, rgba(var(--mdui-color-primary-container), .34), rgb(var(--mdui-color-surface-container-low)) 72%) !important;
    border-radius: 26px !important;
    box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 18px 40px -32px #000;
}

html:is(.mdui-theme-dark, .app-dark-effective) .app-stat-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, .035), transparent 58%), rgb(var(--mdui-color-surface-container-low)) !important;
    box-shadow: 0 0 0 1px rgba(var(--mdui-color-on-surface), .07) inset;
}

/* ---------- 弱化文字统一提亮：暗色下 .3~.48 的透明度基本等于看不见 ---------- */
html:is(.mdui-theme-dark, .app-dark-effective) .rail-explore > span,
html:is(.mdui-theme-dark, .app-dark-effective) .rail-kicker {
    color: rgba(var(--mdui-color-on-surface), .58) !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .rail-brand small,
html:is(.mdui-theme-dark, .app-dark-effective) .rail-user small {
    color: rgba(var(--mdui-color-on-surface), .62) !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .rail-search input::placeholder,
html:is(.mdui-theme-dark, .app-dark-effective) .app-search-input::placeholder {
    color: rgba(var(--mdui-color-on-surface), .50) !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .app-section-head span,
html:is(.mdui-theme-dark, .app-dark-effective) .app-page-title-sub,
html:is(.mdui-theme-dark, .app-dark-effective) .app-post-meta,
html:is(.mdui-theme-dark, .app-dark-effective) .meta-stat,
html:is(.mdui-theme-dark, .app-dark-effective) .app-cat-body small,
html:is(.mdui-theme-dark, .app-dark-effective) .app-checkin-text span,
html:is(.mdui-theme-dark, .app-dark-effective) .app-hot-main small,
html:is(.mdui-theme-dark, .app-dark-effective) .app-tag-chip span,
html:is(.mdui-theme-dark, .app-dark-effective) .app-detail-author-main .sub,
html:is(.mdui-theme-dark, .app-dark-effective) .app-detail-views,
html:is(.mdui-theme-dark, .app-dark-effective) .app-feed-more {
    color: rgba(var(--mdui-color-on-surface), .62) !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .app-pill.soft,
html:is(.mdui-theme-dark, .app-dark-effective) .app-comment-who span,
html:is(.mdui-theme-dark, .app-dark-effective) .app-comment-actions button,
html:is(.mdui-theme-dark, .app-dark-effective) .app-comment-actions a,
html:is(.mdui-theme-dark, .app-dark-effective) .empty-state,
html:is(.mdui-theme-dark, .app-dark-effective) .no-data {
    color: rgba(var(--mdui-color-on-surface), .58) !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .app-group .chev,
html:is(.mdui-theme-dark, .app-dark-effective) .app-public-room-chev {
    color: rgba(var(--mdui-color-on-surface), .46) !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .app-profile .app-stat-label,
html:is(.mdui-theme-dark, .app-dark-effective) .app-profile .app-stat-label small,
html:is(.mdui-theme-dark, .app-dark-effective) .points-log-item small,
html:is(.mdui-theme-dark, .app-dark-effective) .points-rule-desc,
html:is(.mdui-theme-dark, .app-dark-effective) .post-meta {
    color: rgba(var(--mdui-color-on-surface), .60) !important;
}

/* 论坛侧栏 */
html:is(.mdui-theme-dark, .app-dark-effective) .forum-card-head a,
html:is(.mdui-theme-dark, .app-dark-effective) .forum-live-dot,
html:is(.mdui-theme-dark, .app-dark-effective) .forum-rail-stats span,
html:is(.mdui-theme-dark, .app-dark-effective) .forum-hot-body small {
    color: rgba(var(--mdui-color-on-surface), .58) !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .forum-hot-rank,
html:is(.mdui-theme-dark, .app-dark-effective) .forum-hot-heat {
    color: rgba(var(--mdui-color-on-surface), .54) !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .forum-person strong {
    color: rgba(var(--mdui-color-on-surface), .82) !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .forum-person small,
html:is(.mdui-theme-dark, .app-dark-effective) .forum-rail-note {
    color: rgba(var(--mdui-color-on-surface), .58) !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .forum-rail-note b {
    color: rgba(var(--mdui-color-on-surface), .76) !important;
}

/* 私信 */
html:is(.mdui-theme-dark, .app-dark-effective) .cv-time,
html:is(.mdui-theme-dark, .app-dark-effective) .chat-status,
html:is(.mdui-theme-dark, .app-dark-effective) .chat-day,
html:is(.mdui-theme-dark, .app-dark-effective) .page-messages .meta,
html:is(.mdui-theme-dark, .app-dark-effective) .page-messages .grp.other .bub .meta {
    color: rgba(var(--mdui-color-on-surface), .58) !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .cv-last,
html:is(.mdui-theme-dark, .app-dark-effective) .app-public-room-body small {
    color: rgba(var(--mdui-color-on-surface), .66) !important;
}

/* 后台/表单里的小字 */
html:is(.mdui-theme-dark, .app-dark-effective) .adm-row-id,
html:is(.mdui-theme-dark, .app-dark-effective) .adm-kv .k {
    color: rgba(var(--mdui-color-on-surface), .56) !important;
}

/* ---------- 排行榜徽章：亮色主题的“透明描边”到暗色就废了 ---------- */
html:is(.mdui-theme-dark, .app-dark-effective) .legacy-ui .rank-badges :is(.role-badge, .owner-badge, .admin-badge, .vip-badge, .custom-title-badge, .title-badge, .level-badge, .pinned-badge) {
    opacity: 1 !important;
    text-shadow: none !important;
    background-image: none !important;
    background-color: rgba(var(--mdui-color-primary), .15) !important;
    border: 1px solid rgba(var(--mdui-color-primary), .34) !important;
    color: rgb(var(--mdui-color-primary)) !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .legacy-ui .rank-badges .owner-badge {
    background-color: rgba(255, 180, 171, .15) !important;
    border-color: rgba(255, 180, 171, .36) !important;
    color: #ffb4ab !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .legacy-ui .rank-badges .admin-badge {
    background-color: rgba(173, 198, 255, .15) !important;
    border-color: rgba(173, 198, 255, .36) !important;
    color: #adc6ff !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .legacy-ui .rank-badges .vip-badge {
    background-color: rgba(255, 213, 138, .15) !important;
    border-color: rgba(255, 213, 138, .36) !important;
    color: #ffd98a !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .legacy-ui .rank-badges :is(.custom-title-badge, .title-badge) {
    background-color: rgba(213, 188, 255, .15) !important;
    border-color: rgba(213, 188, 255, .34) !important;
    color: #e9ddff !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .legacy-ui .rank-badges .level-badge {
    background-color: rgba(196, 198, 208, .12) !important;
    border-color: rgba(196, 198, 208, .30) !important;
    color: #e2e2e9 !important;
}

/* ---------- 代码高亮：原来加载的是 GitHub 浅色主题 ---------- */
html:is(.mdui-theme-dark, .app-dark-effective) body.page-post .markdown-body pre {
    background: #121924 !important;
    border-color: rgba(var(--mdui-color-on-surface), .12) !important;
    box-shadow: 0 0 0 1px rgba(var(--mdui-color-primary), .05) inset;
}

html:is(.mdui-theme-dark, .app-dark-effective) .markdown-body .hljs {
    color: #c9d1d9 !important;
    background: transparent !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .markdown-body :is(.hljs-comment, .hljs-code, .hljs-formula) {
    color: #8b949e !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .markdown-body :is(.hljs-doctag, .hljs-keyword, .hljs-meta .hljs-keyword, .hljs-template-tag, .hljs-template-variable, .hljs-type, .hljs-variable.language_, .hljs-deletion) {
    color: #ff7b72 !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .markdown-body :is(.hljs-title, .hljs-title.class_, .hljs-title.class_.inherited__, .hljs-title.function_) {
    color: #d2a8ff !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .markdown-body :is(.hljs-attr, .hljs-attribute, .hljs-literal, .hljs-meta, .hljs-number, .hljs-operator, .hljs-selector-attr, .hljs-selector-class, .hljs-selector-id, .hljs-variable) {
    color: #79c0ff !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .markdown-body :is(.hljs-meta .hljs-string, .hljs-regexp, .hljs-string) {
    color: #a5d6ff !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .markdown-body :is(.hljs-built_in, .hljs-symbol, .hljs-bullet, .hljs-link, .hljs-section, .hljs-selector-tag, .hljs-name, .hljs-quote, .hljs-tag, .hljs-char.escape_, .hljs-subst) {
    color: #ffa657 !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .markdown-body :is(.hljs-emphasis) {
    color: #c9d1d9 !important;
    font-style: italic;
}

html:is(.mdui-theme-dark, .app-dark-effective) .markdown-body :is(.hljs-strong) {
    color: #c9d1d9 !important;
    font-weight: 700;
}

html:is(.mdui-theme-dark, .app-dark-effective) .markdown-body :is(.hljs-addition) {
    color: #aff5b4 !important;
    background-color: rgba(46, 160, 67, .15) !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .markdown-body :is(.hljs-deletion) {
    color: #ffdcd7 !important;
    background-color: rgba(248, 81, 73, .15) !important;
}

html:is(.mdui-theme-dark, .app-dark-effective) .markdown-body code:not(pre code) {
    background: rgba(var(--mdui-color-on-surface), .10) !important;
    color: #e6edf3 !important;
}

/* ---------- 原生控件、滚动条、选区 ---------- */
html:is(.mdui-theme-dark, .app-dark-effective) input,
html:is(.mdui-theme-dark, .app-dark-effective) textarea,
html:is(.mdui-theme-dark, .app-dark-effective) select {
    color: rgb(var(--mdui-color-on-surface));
    caret-color: rgb(var(--mdui-color-primary));
}

html:is(.mdui-theme-dark, .app-dark-effective) input::placeholder,
html:is(.mdui-theme-dark, .app-dark-effective) textarea::placeholder {
    color: rgba(var(--mdui-color-on-surface), .50);
}

html:is(.mdui-theme-dark, .app-dark-effective) select option {
    background: rgb(var(--mdui-color-surface-container));
    color: rgb(var(--mdui-color-on-surface));
}

html:is(.mdui-theme-dark, .app-dark-effective) ::selection {
    background: rgba(var(--mdui-color-primary), .30);
    color: rgb(var(--mdui-color-on-surface));
}

html:is(.mdui-theme-dark, .app-dark-effective) ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

html:is(.mdui-theme-dark, .app-dark-effective) ::-webkit-scrollbar-track {
    background: rgba(var(--mdui-color-on-surface), .03);
}

html:is(.mdui-theme-dark, .app-dark-effective) ::-webkit-scrollbar-thumb {
    background: rgba(var(--mdui-color-on-surface), .24);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

html:is(.mdui-theme-dark, .app-dark-effective) ::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--mdui-color-on-surface), .38);
    border: 2px solid transparent;
    background-clip: padding-box;
}

/* 2026-11-27：自己那一行不能再用半透明 primary，否则系统强制暗色仍会把它刷成灰条。
   改成与其它行同一实底，用左侧主色条保留“我”的标识。 */
html:is(.mdui-theme-dark, .app-dark-effective) body.page-rank .rank-item.me {
    background-color: rgb(var(--mdui-color-surface-container-low)) !important;
    box-shadow: inset 3px 0 0 rgb(var(--mdui-color-primary));
}

/* 2026-11-27：legacy 的卡片 hover 仍是白色半透明（.56 !important），
   暗色/强制暗色下会整块发灰。把所有 legacy 卡片/列表项在暗色下压成实底。 */
html:is(.mdui-theme-dark, .app-dark-effective) .legacy-ui .card,
html:is(.mdui-theme-dark, .app-dark-effective) .legacy-ui .card:hover,
html:is(.mdui-theme-dark, .app-dark-effective) .legacy-ui .sidebar-card,
html:is(.mdui-theme-dark, .app-dark-effective) .legacy-ui .sidebar-card:hover,
html:is(.mdui-theme-dark, .app-dark-effective) .legacy-ui .post-card,
html:is(.mdui-theme-dark, .app-dark-effective) .legacy-ui .post-card:hover,
html:is(.mdui-theme-dark, .app-dark-effective) .legacy-ui .post-item,
html:is(.mdui-theme-dark, .app-dark-effective) .legacy-ui .post-item:hover,
html:is(.mdui-theme-dark, .app-dark-effective) .legacy-ui .list-item,
html:is(.mdui-theme-dark, .app-dark-effective) .legacy-ui .list-item:hover,
html:is(.mdui-theme-dark, .app-dark-effective) body.page-badges .card,
html:is(.mdui-theme-dark, .app-dark-effective) body.page-badges .card:hover {
    background-color: rgb(var(--mdui-color-surface-container-low)) !important;
    background-image: none !important;
    border-color: rgba(var(--mdui-color-outline-variant), .45) !important;
}
