/* ============================================================
 * 墨线主题包 · 全站统一版（2026-11-09 r1）
 *
 * 本文件由 5 个补丁合并而来（ink-surface-r1 / ink-pages-r1~r4 / run-log-ink-r1），
 * 是墨线主题的唯一完整实现，后续改动只需维护这一个文件。
 *
 * 【开关机制】
 * 所有规则作用域收敛为 html.ink-on（配合 :not(.dark) 限定浅色）。
 * html 上的 .ink-on 类由 ink-theme.js + index.html 内联 bootstrap 控制：
 *   - 主题预设为「默认 / 经典蓝(nc-teal)」→ 墨线开（当前线上默认观感）
 *   - 在设置里切到其他主题（樱花粉/浅蓝/夜色…）→ .ink-on 自动摘除，该主题恢复本色
 *   - localStorage ink-theme='off' → 强制关闭（手动总闸）
 * 概览/活动/设置/个人页的 .ink-overview / .ink-route-page 皮肤是源码原生路由行为，
 * 不依赖 .ink-on，切换主题时它们仍保持墨线。
 *
 * 【变量反杀原理】
 * theme.ts 运行时用 el.style.setProperty 把 --theme-*/--farm-*/--color-* 写到
 * <html> 内联上（默认蓝 #2864e8 / 纯白），内联声明优先于普通 CSS 规则。
 * CSS 规范：作者样式表 !important > 内联非 important（对自定义属性同样成立），
 * 故本包用 !important 重新声明全套变量反杀。
 * ============================================================ */

/* ============================================================
 * 一、!important 变量反杀（核心）
 * ============================================================ */
html.ink-on:not(.dark) {
  /* 主题层：BaseButton primary、动态 :style 取色全在这套 */
  --theme-bg: #f6eddf !important;
  --theme-text: #383c30 !important;
  --theme-primary: #6f7651 !important;
  --theme-secondary: #5b6844 !important;
  --theme-gradient: linear-gradient(125deg, #8b9467, #6f7651) !important;

  /* farm 全套：好友页/排行榜等业务页卡片、面板、sidebar-frame */
  --farm-bg: #f6eddf !important;
  --farm-bg-subtle: #f8f0e2 !important;
  --farm-surface: #fffaf0 !important;
  --farm-surface-elevated: #fffdf8 !important;
  --farm-card-bg: #fffaf0 !important;
  --farm-border: #d8cbb2 !important;
  --farm-border-subtle: #e6dcc6 !important;
  --farm-text: #383c30 !important;
  --farm-muted: #7a7364 !important;
  --farm-accent: #6f7651 !important;
  --farm-accent-hover: #5b6844 !important;
  --farm-accent-soft: rgba(111, 118, 81, .12) !important;
  --farm-input-bg: #fffaf0 !important;
  --farm-elevated-bg: #fbf4e8 !important;
  --farm-shadow: 3px 4px 0 #c0b6a34a, 0 3px 8px #52442c0d !important;
  --farm-shadow-lg: 0 10px 24px rgba(82, 68, 44, .14) !important;
  --farm-glass: rgba(255, 250, 240, .72) !important;
  --farm-glass-border: rgba(255, 250, 240, .6) !important;

  /* nc-console 中间层 */
  --color-canvas: #f6eddf !important;
  --color-bg-muted: #f8f0e2 !important;
  --color-surface: #fffaf0 !important;
  --color-border: rgba(122, 106, 80, .30) !important;
  --color-border-subtle: rgba(150, 133, 105, .24) !important;
  --color-accent: #6f7651 !important;
  --color-accent-hover: #5b6844 !important;
  --color-accent-muted: rgba(111, 118, 81, .14) !important;
  --color-text: #383c30 !important;
  --color-text-muted: #7a7364 !important;
  --color-muted-foreground: #7a7364 !important;
  --color-caption: #8d8676 !important;
  --color-list-text: #3b3f33 !important;
  --shadow-card: 3px 4px 0 #c0b6a34a, 0 3px 8px #52442c0d !important;
  --shadow-float: 0 10px 28px rgba(82, 68, 44, .12) !important;
}

/* BaseButton primary（内联 var(--theme-gradient)）→ 墨线按钮
 * 与「策略」「施肥」同款：墨绿渐变 + 描边 + 硬偏移投影 */
html.ink-on:not(.dark) [style*="theme-gradient"] {
  background: linear-gradient(125deg, #8b9467, #6f7651) !important;
  color: #fffdf8 !important;
  box-shadow: inset 0 0 0 1px #363b2e, 2px 3px 0 #beb5aa65 !important;
}

/* ============================================================
 * 二、主内容区与大块面板（ink-surface r1）
 * ============================================================ */
html.ink-on:not(.dark) .nc-app-content,
html.ink-on:not(.dark) .nc-app-content-inner {
  background: #f6eddf;
}

/* 卡片描边统一压到暖褐，圆角收到 10~12，贴近概览页 */
html.ink-on:not(.dark) .settings-content-card,
html.ink-on:not(.dark) .nc-glass-panel,
html.ink-on:not(.dark) .nc-overview-panel,
html.ink-on:not(.dark) .nc-overview-account-card,
html.ink-on:not(.dark) .nc-dash-announcement {
  border-color: rgba(150, 133, 105, .34);
  border-radius: 12px;
  box-shadow: 3px 4px 0 #c0b6a34a, 0 3px 8px #52442c0d;
}

/* 悬浮层（下拉、速切、菜单）同样换成暖纸，别在暖底上飘一块白 */
html.ink-on:not(.dark) .nc-menu-panel,
html.ink-on:not(.dark) .aqs-panel,
html.ink-on:not(.dark) .nc-appearance-panel {
  border-color: rgba(150, 133, 105, .36);
  box-shadow: 0 10px 24px rgba(82, 68, 44, .16);
}

/* ============================================================
 * 三、蓝色按钮 → 墨绿（同「策略」「施肥」）
 * ============================================================ */
html.ink-on:not(.dark) .bg-blue-600,
html.ink-on:not(.dark) .bg-blue-500,
html.ink-on:not(.dark) .bg-blue-700,
html.ink-on:not(.dark) .bg-blue-400,
html.ink-on:not(.dark) .bg-indigo-500,
html.ink-on:not(.dark) .bg-indigo-600,
html.ink-on:not(.dark) .bg-sky-600 {
  background: linear-gradient(125deg, #8b9467, #6f7651) !important;
  color: #fffdf8 !important;
  box-shadow: inset 0 0 0 1px #363b2e, 2px 3px 0 #beb5aa65 !important;
}
html.ink-on:not(.dark) .hover\:bg-blue-700:hover,
html.ink-on:not(.dark) .hover\:bg-blue-600:hover,
html.ink-on:not(.dark) .hover\:bg-blue-500:hover,
html.ink-on:not(.dark) .hover\:indigo-600:hover,
html.ink-on:not(.dark) .hover\:bg-indigo-600:hover {
  background: #5b6844 !important;
}
html.ink-on:not(.dark) .focus\:ring-blue-500:focus,
html.ink-on:not(.dark) .focus\:ring-blue-400:focus {
  --tw-ring-color: rgba(111, 118, 81, .38) !important;
}
html.ink-on:not(.dark) .focus\:border-blue-500:focus,
html.ink-on:not(.dark) .focus\:border-blue-400:focus {
  border-color: #6f7651 !important;
}

/* ---------- 浅蓝底 / 蓝字 / 蓝边 ---------- */
html.ink-on:not(.dark) .bg-blue-50  { background: #f7efe0 !important; }
html.ink-on:not(.dark) .bg-blue-100 { background: #f1e8d6 !important; }
html.ink-on:not(.dark) .bg-blue-200 { background: #e7dcc6 !important; }
html.ink-on:not(.dark) .bg-indigo-50 { background: #f7efe0 !important; }
html.ink-on:not(.dark) .hover\:bg-blue-100:hover { background: #efe5d1 !important; }
html.ink-on:not(.dark) .border-blue-600 { border-color: #363b2e !important; }
html.ink-on:not(.dark) .border-blue-500,
html.ink-on:not(.dark) .border-blue-400 { border-color: #6f7651 !important; }
html.ink-on:not(.dark) .border-blue-200,
html.ink-on:not(.dark) .border-blue-300 { border-color: #d8cbb2 !important; }
html.ink-on:not(.dark) .text-blue-400,
html.ink-on:not(.dark) .text-blue-500,
html.ink-on:not(.dark) .text-blue-600,
html.ink-on:not(.dark) .text-blue-700,
html.ink-on:not(.dark) .text-blue-800,
html.ink-on:not(.dark) .text-indigo-500,
html.ink-on:not(.dark) .text-indigo-600 {
  color: #5f6a49 !important;
}
/* 个人主题里写死的“蓝色统计数字”变量 */
html.ink-on:not(.dark) .personal-page { --personal-stat-blue: #5f6a49; }

/* ============================================================
 * 四、白卡 / 白面板 → 暖纸（含透明度修饰符变体）
 * ============================================================ */
html.ink-on:not(.dark) .bg-white { background: #fffaf0 !important; }
html.ink-on:not(.dark) .bg-white\/95 { background: rgba(255, 250, 240, .96) !important; }
html.ink-on:not(.dark) .bg-white\/90 { background: rgba(255, 250, 240, .94) !important; }
html.ink-on:not(.dark) .bg-white\/80 { background: rgba(255, 250, 240, .88) !important; }
html.ink-on:not(.dark) .bg-white\/70 { background: rgba(255, 250, 240, .82) !important; }
html.ink-on:not(.dark) .bg-white\/60 { background: rgba(255, 250, 240, .78) !important; }
html.ink-on:not(.dark) .bg-gray-50  { background: #fbf5ea !important; }
html.ink-on:not(.dark) .bg-gray-100 { background: #f3ead9 !important; }
html.ink-on:not(.dark) .hover\:bg-gray-50:hover  { background: #f6eddf !important; }
html.ink-on:not(.dark) .hover\:bg-gray-100:hover { background: #efe5d2 !important; }
html.ink-on:not(.dark) .hover\:bg-gray-200:hover { background: #e9decb !important; }

/* 半透明 hover 灰（排行榜 tab 未选中 hover、表格行 hover） */
html.ink-on:not(.dark) .hover\:bg-gray-100\/60:hover { background: rgba(239, 229, 210, .6) !important; }
html.ink-on:not(.dark) .hover\:bg-gray-50\/80:hover  { background: rgba(246, 237, 223, .8) !important; }

/* 半透明描边 / 分隔线 */
html.ink-on:not(.dark) .border-gray-200\/80 { border-color: rgba(150, 133, 105, .38) !important; }
html.ink-on:not(.dark) .border-gray-200\/60 { border-color: rgba(150, 133, 105, .30) !important; }
html.ink-on:not(.dark) .divide-gray-100 > :not([hidden]) ~ :not([hidden]) { border-color: #e6dcc6 !important; }

/* 主样式里硬编码纯白的骨架面板 */
html.ink-on:not(.dark) .nav-panel,
html.ink-on:not(.dark) .nav-scroll,
html.ink-on:not(.dark) .nav-footer,
html.ink-on:not(.dark) .nav-tile,
html.ink-on:not(.dark) .pub-auth-bg,
html.ink-on:not(.dark) .pub-landing,
html.ink-on:not(.dark) .auth-card-badge,
html.ink-on:not(.dark) .auth-card-meta-item {
  background: #fffaf0 !important;
}
html.ink-on:not(.dark) .auth-panel .base-input {
  background: #fffaf0 !important;
  border-color: rgba(140, 124, 100, .46) !important;
}
html.ink-on:not(.dark) .nc-console-tab-active .nc-console-tab-badge {
  background: #fffaf0 !important;
}

/* ---------- 页面级 scoped CSS 硬编码的白底（逐条对应） ---------- */
html.ink-on:not(.dark) .account-auto-relogin-dialog,
html.ink-on:not(.dark) .account-auto-relogin-field input,
html.ink-on:not(.dark) .account-auto-relogin-cancel,
html.ink-on:not(.dark) .account-auto-relogin-trigger,
html.ink-on:not(.dark) .account-auto-relogin-switch,
html.ink-on:not(.dark) .account-section-button,
html.ink-on:not(.dark) .announcement-panel,
html.ink-on:not(.dark) .announcement-panel .farm-btn,
html.ink-on:not(.dark) .confirm-modal,
html.ink-on:not(.dark) .dashboard-section-nav-item,
html.ink-on:not(.dark) .nc-overview-account-card .nc-dash-progress span,
html.ink-on:not(.dark) .nc-overview-account-card,
html.ink-on:not(.dark) .purchase-modal,
html.ink-on:not(.dark) .qixi-progress-card,
html.ink-on:not(.dark) .qty-icon-button,
html.ink-on:not(.dark) .qty-max-button,
html.ink-on:not(.dark) .qty-input,
html.ink-on:not(.dark) .status-tile,
html.ink-on:not(.dark) .user-menu-button,
html.ink-on:not(.dark) .user-menu-links,
html.ink-on:not(.dark) .settings-page input.peer + .base-switch:after {
  background: #fffaf0 !important;
}

/* ---------- 页面级 scoped CSS 硬编码的蓝（账号自动续登弹窗等） ---------- */
html.ink-on:not(.dark) .account-auto-relogin-save,
html.ink-on:not(.dark) .account-auto-relogin-check,
html.ink-on:not(.dark) .account-auto-relogin-trigger,
html.ink-on:not(.dark) .alipay-qr-img {
  background: linear-gradient(125deg, #8b9467, #6f7651) !important;
  color: #fffdf8 !important;
  box-shadow: inset 0 0 0 1px #363b2e, 2px 3px 0 #beb5aa65 !important;
}
html.ink-on:not(.dark) .account-auto-relogin-cancel {
  background: #fffaf0 !important;
  color: #383c30 !important;
  border-color: rgba(150, 133, 105, .46) !important;
}
html.ink-on:not(.dark) .account-auto-relogin-close,
html.ink-on:not(.dark) .account-auto-relogin-header h2,
html.ink-on:not(.dark) .account-auto-relogin-retry,
html.ink-on:not(.dark) .account-auto-relogin-status,
html.ink-on:not(.dark) .claim-modal-icon,
html.ink-on:not(.dark) .user-menu-links {
  color: #5f6a49 !important;
}
html.ink-on:not(.dark) .account-auto-relogin-dialog :focus-visible,
html.ink-on:not(.dark) .account-auto-relogin-trigger:focus-visible {
  outline-color: #6f7651 !important;
}

/* ---------- 描边与投影 ---------- */
html.ink-on:not(.dark) .border-gray-200 { border-color: rgba(150, 133, 105, .38) !important; }
html.ink-on:not(.dark) .border-gray-300 { border-color: rgba(140, 124, 100, .46) !important; }
html.ink-on:not(.dark) .shadow,
html.ink-on:not(.dark) .shadow-md,
html.ink-on:not(.dark) .shadow-lg {
  box-shadow: 3px 4px 0 #c0b6a34a, 0 3px 8px #52442c0d !important;
}

/* ============================================================
 * 五、运行日志面板 · 墨线暖纸（原 run-log-ink r1）
 * 浅色部分限定 html.ink-on，摘开关后回原蓝灰面板；
 * .dark 段为暗色兜底，不依赖开关，保留。
 * ============================================================ */
html.ink-on .nc-log-panel {
  background: linear-gradient(125deg, #fdf4e6 0%, #fdf8ee 60%, #faf3e6 100%);
  border: 1px solid #e0d4bf;
  border-radius: 14px;
  box-shadow: inset 0 0 0 2px #fffcf2, 3px 4px 0 #c0b6a34a, 0 3px 8px #52442c0d;
  overflow: hidden;
}
html.ink-on .nc-log-panel-head {
  background: color-mix(in srgb, #fffaf0 62%, transparent);
  border-bottom: 1px solid #e4d9c5;
}
html.ink-on .nc-log-panel-title {
  color: #2f332a;
  letter-spacing: .01em;
}
html.ink-on .nc-log-panel-title h3 { color: #2f332a; }
html.ink-on .nc-log-panel-title p { color: #8d8676; }

/* 滚动区：不再铺白底，让面板的暖纸渐变透上来 */
html.ink-on .nc-log-viewport {
  background: transparent;
  scrollbar-color: #c9bca5 transparent;
}
html.ink-on .nc-log-viewport::-webkit-scrollbar-thumb {
  background: #c9bca580;
  border-radius: 999px;
}
html.ink-on .nc-log-viewport::-webkit-scrollbar-thumb:hover {
  background: #b9aa8f99;
}

/* 行底色：色相统一到暖纸 / 墨绿 / 陶土，只留语义上的冷暖明度差 */
html.ink-on .nc-log-row--alt       { background: #e3d6be14; }
html.ink-on .nc-log-row--heartbeat { background: #c9a15a12; }
html.ink-on .nc-log-row--error     { background: #b4453a10; }
html.ink-on .nc-log-row--success   { background: #6f765112; }
html.ink-on .nc-log-row--error .nc-log-module,
html.ink-on .nc-log-module--error     { color: #9c4038; }
html.ink-on .nc-log-row--heartbeat .nc-log-module,
html.ink-on .nc-log-module--heartbeat { color: #8a7550; }
html.ink-on .nc-log-module--warn      { color: #92703a; }

/* 表格文字与分隔线 */
html.ink-on .nc-log-table { color: #3b4034; }
html.ink-on .nc-log-table thead th,
html.ink-on .nc-log-table tbody td { border-color: #ece1cd; }
html.ink-on .nc-log-table tbody td.nc-log-time,
html.ink-on .nc-log-time { color: #8d8676; }
html.ink-on .nc-log-msg-text,
html.ink-on .nc-log-event,
html.ink-on .nc-log-col-content { color: #3b4034; }

/* 空状态与工具按钮 */
html.ink-on .nc-log-empty { color: #8d8676; }
html.ink-on .nc-log-tools button,
html.ink-on .nc-log-filter-toggle {
  border-color: #d9cdb8;
  border-radius: 9px;
  background: #fffaf0;
  color: #5f6350;
}
html.ink-on .nc-log-tools button:hover,
html.ink-on .nc-log-filter-toggle:hover {
  background: #f6eddf;
  border-color: #c9bca5;
}
html.ink-on .nc-log-filter-toggle-active {
  border-color: #363b2e;
  background: #6f7651;
  color: #fffdf8;
}

/* 实时指示点 */
html.ink-on .nc-log-live-dot {
  background: #6f7651;
  box-shadow: 0 0 0 3px #6f765122;
}
html.ink-on .nc-log-live--off .nc-log-live-dot {
  background: #b0a892;
  box-shadow: none;
}

/* ============================================================
 * 六、深色模式兜底（不依赖墨线开关，独立生效）
 * ============================================================ */
html.dark {
  --color-surface: #2a2b24;
  --color-canvas: #1f201a;
  --color-border: rgba(200, 190, 168, .22);
  --color-border-subtle: rgba(200, 190, 168, .14);
  --shadow-card: 0 4px 14px rgba(0, 0, 0, .28);
}
.dark .nc-log-panel {
  background: linear-gradient(125deg, #2b2c25 0%, #2f3028 60%, #292a23 100%);
  border-color: #4a4b40;
  box-shadow: none;
}
.dark .nc-log-panel-head {
  background: #2f3028;
  border-bottom-color: #444538;
}
.dark .nc-log-panel-title,
.dark .nc-log-panel-title h3,
.dark .nc-log-table,
.dark .nc-log-msg-text,
.dark .nc-log-event,
.dark .nc-log-col-content {
  color: #e6e2d5;
}
.dark .nc-log-panel-title p,
.dark .nc-log-time,
.dark .nc-log-empty {
  color: #a8a292;
}
.dark .nc-log-table thead th,
.dark .nc-log-table tbody td {
  border-color: #3d3e33;
}

@media (max-width: 640px) {
  html.ink-on .nc-log-panel,
  .dark .nc-log-panel { border-radius: 12px; }
}

/* ============================================================
 * 开关（BaseSwitch）与灰底贴合主题（2026-11-09 r2）
 * 未激活态底色是 UnoCSS .bg-gray-200（冷灰蓝），此前漏覆盖；
 * 激活态在 settings-page 已是墨绿，这里兜底其他容器。
 * ============================================================ */
html.ink-on:not(.dark) .bg-gray-200 { background: #e3d8c2 !important; }
html.ink-on:not(.dark) .base-switch {
  /* 未打开 = 有机化肥卡片同款绿（点券卡渐变） */
  background: linear-gradient(110deg, #e4edcf, #e1ecd8) !important;
  border: 0 !important;
  box-shadow: inset 0 0 0 1px rgba(150, 133, 105, .35) !important;
}
html.ink-on:not(.dark) .base-switch::after {
  background: var(--ink-knob, #fffdf8) !important;
  border-color: var(--ink-knob-bd, rgba(140, 124, 100, .55)) !important;
}
html.ink-on:not(.dark) input.peer:checked + .base-switch::after,
html.ink-on:not(.dark) input.peer:checked ~ .base-switch::after {
  /* 打开态圆角块 = 爱马仕橙 #F37021 + 深墨边框（同选中按钮） */
  background: var(--ink-knob, #F37021) !important;
  border-color: var(--ink-knob-bd, #363b2e) !important;
}
html.ink-on:not(.dark) input.peer:checked + .base-switch,
html.ink-on:not(.dark) input.peer:checked ~ .base-switch {
  background: linear-gradient(110deg, #fce4bc, #fae9cc) !important;
  border: 0 !important;
  box-shadow: inset 0 0 0 1px rgba(54, 59, 46, .75) !important;
}

/* ============================================================
 * 开关贴合主题 · 多层作用域版（2026-11-09 r4）
 * 不依赖 html.ink-on（用户切换其他主题时原生墨线页面同样生效）。
 * 命中自动化卡（.ac-hub/.automation-feature-card）、设置页、
 * 原生墨线路由（.ink-route-page/.ink-overview）内的全部开关。
 * ============================================================ */
.ac-hub .base-switch,
.automation-feature-card .base-switch,
.settings-page .base-switch,
.ink-route-page .base-switch,
.ink-overview .base-switch {
  background: linear-gradient(110deg, #e4edcf, #e1ecd8) !important;
  border: 0 !important;
  box-shadow: inset 0 0 0 1px rgba(150, 133, 105, .35) !important;
}
.ac-hub .base-switch::after,
.automation-feature-card .base-switch::after,
.settings-page .base-switch::after,
.ink-route-page .base-switch::after,
.ink-overview .base-switch::after {
  background: var(--ink-knob, #fffdf8) !important;
  border-color: var(--ink-knob-bd, rgba(140, 124, 100, .55)) !important;
}
.ac-hub input:checked + .base-switch::after,
.ac-hub input:checked ~ .base-switch::after,
.automation-feature-card input:checked + .base-switch::after,
.settings-page input:checked + .base-switch::after,
.ink-route-page input:checked + .base-switch::after,
.ink-route-page input:checked ~ .base-switch::after,
.ink-overview input:checked + .base-switch::after,
.ink-overview input:checked ~ .base-switch::after {
  /* 打开态圆角块 = 爱马仕橙 #F37021 + 深墨边框（同选中按钮） */
  background: var(--ink-knob, #F37021) !important;
  border-color: var(--ink-knob-bd, #363b2e) !important;
}
.ac-hub input:checked + .base-switch,
.ac-hub input:checked ~ .base-switch,
.automation-feature-card input:checked + .base-switch,
.settings-page input:checked + .base-switch,
.ink-route-page input:checked + .base-switch,
.ink-route-page input:checked ~ .base-switch,
.ink-overview input:checked + .base-switch,
.ink-overview input:checked ~ .base-switch {
  background: linear-gradient(110deg, #fce4bc, #fae9cc) !important;
  border: 0 !important;
  box-shadow: inset 0 0 0 1px rgba(54, 59, 46, .75) !important;
}
.ac-hub .bg-gray-200,
.settings-page .bg-gray-200,
.ink-route-page .bg-gray-200,
.ink-overview .bg-gray-200 {
  background: #e3d8c2 !important;
}
