/*!
 * GT 夜间模式 v1.0
 * 设计原则：本文件【只定义暗色变量】，亮色一律走各模板自带的 :root 与 var() 回退值。
 * 因此：停用 gt-theme-mode.php 或删掉本文件，站点立即恢复原样，无任何残留样式。
 * 关键约束：偏好存 localStorage，不写 cookie —— 避免穿透 nginx 页面缓存。
 */

html[data-theme="dark"]{
  --bg:#0a0a0a;        /* 页面底：近黑 */
  --surface:#141414;   /* 卡片/导航面 */
  --text:#ffffff;      /* 主文字：纯白 */
  --border:#2a2a2a;    /* 边框翻暗 */
  --hover:#1c1c1c;     /* 悬停/次级底 */
  --field:#1c1c1c;     /* 输入框 */
  --chip:#202020;      /* 标签/分隔块 */
  --ok:#66bb6a;        /* 状态徽章的绿色（#2e7d32 在暗底上太暗） */
  color-scheme:dark;
}
/* --t2(#8b93a3) 与 --accent(#e63946) 刻意不覆盖：保持原色，对比度分别为 5.84:1 / 5.02:1，达标 */

html[data-theme="light"]{color-scheme:light}

/* 首帧兜底：html 与 body 自身也跟随，避免滚动越界时露白 */
html[data-theme="dark"],html[data-theme="dark"] body{background-color:var(--bg,#0a0a0a)}
html[data-theme="dark"] body{color:var(--text,#fff)}

/* 切换瞬间的过渡（JS 只在点击时加 .gt-theme-anim 260ms，不常驻） */
html.gt-theme-anim,html.gt-theme-anim *{
  transition:background-color .18s ease,color .18s ease,border-color .18s ease,fill .18s ease!important
}

/* ---------- 切换按钮（位于搜索图标左侧） ---------- */
.gt-theme-btn{
  display:inline-flex;align-items:center;justify-content:center;
  width:34px;height:34px;flex:0 0 auto;padding:0;line-height:0;
  border:1px solid var(--border,#e5e7eb);border-radius:8px;
  background:var(--surface,#fff);color:var(--text,#1f232b);
  cursor:pointer;-webkit-appearance:none;appearance:none;
  transition:background-color .15s,color .15s,border-color .15s
}
.gt-theme-btn:hover{background:var(--hover,#f0f0f0)}
.gt-theme-btn:focus-visible{outline:2px solid var(--accent,#e63946);outline-offset:2px}
.gt-theme-btn .gt-i-sun{display:none}
html[data-theme="dark"] .gt-theme-btn .gt-i-moon{display:none}
html[data-theme="dark"] .gt-theme-btn .gt-i-sun{display:block}

/* 关键：JS 未加载时按钮保持隐藏（模板里写死 hidden），
   所以停用 mu-plugin 后按钮自动消失，不会留下死按钮 */
.gt-theme-btn[hidden],.gt-theme-menu[hidden]{display:none!important}

@media (max-width:767px){
  .gt-theme-btn{width:30px;height:30px;border-radius:7px}
}

/* 汉堡菜单里的那一行 */
.gt-theme-menu{display:flex;align-items:center;gap:6px}

/* ---------- goodtoon-ads 广告弹窗（其样式在 body 内联输出，故用更高优先级覆盖） ---------- */
html[data-theme="dark"] .gt-popup-box{background:var(--surface,#fff)}
html[data-theme="dark"] .gt-popup-btn{background:var(--hover,#f5f5f5);color:var(--text,#555)}
html[data-theme="dark"] .gt-popup-today{border-right-color:var(--border,#e0e0e0)}
html[data-theme="dark"] .gt-popup-close{background:rgba(255,255,255,.16);color:#fff}

/* ============================================================
 * 二期/三期补充：主题 style.css（321KB，不改动）与第三方样式里写死的浅色/深色
 * 这些元素无法在模板层用变量替换，故在此用更高优先级定向覆盖
 * ============================================================ */

/* --- 漫画详情页 --- */
html[data-theme="dark"] .manga-summary-wrap{background-color:var(--surface,#fff)}
html[data-theme="dark"] li.wp-manga-chapter{background-color:var(--chip,#efeff0)}
html[data-theme="dark"] .wp-manga-chapter a,
html[data-theme="dark"] .wp-manga-chapter a:visited{color:var(--text,#000)}
html[data-theme="dark"] .btn-first-ep,
html[data-theme="dark"] .btn-last-ep{background-color:var(--hover,#f5f5f5);color:var(--text,#333)}
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] .summary-title{color:var(--text,#fff)}
html[data-theme="dark"] .meta-value{color:var(--text,#333)}

/* --- 阅读页：下拉选择框（原生控件）与侧边翻页按钮 --- */
html[data-theme="dark"] select{background-color:var(--field,#fff);color:var(--text,#333);border-color:var(--border,#ddd)}
html[data-theme="dark"] option{background-color:var(--field,#fff);color:var(--text,#333)}
html[data-theme="dark"] a.vw-side{background-color:var(--surface,rgba(255,255,255,.92));color:var(--text,#333)}

/* --- 论坛页：置顶行、等级徽章、弹窗 --- */
html[data-theme="dark"] tr.row-pinned,
html[data-theme="dark"] tr.row-pinned td{background-color:var(--chip,#fffdf0)}
html[data-theme="dark"] .lv-badge{background-color:var(--chip,#e0e0e0);color:var(--text,#fff)}
html[data-theme="dark"] .modal-box{background-color:var(--surface,#fff)}
html[data-theme="dark"] .modal-box input,
html[data-theme="dark"] .modal-box textarea,
html[data-theme="dark"] .modal-box button{background-color:var(--field,#fff);color:var(--text,#333);border-color:var(--border,#ddd)}

/* --- 会员系统（登录/注册/我的/收藏） --- */
/* 未收藏：暗底白字；已收藏：暗底浅红字（保留品牌红观感）
 * 注意用 :not(.on) —— 否则本规则会压过 gt.css 里 .gtm-fav-btn.on 的红色 */
html[data-theme="dark"] .gtm-fav-btn:not(.on){color:var(--text,#4a5568)}
html[data-theme="dark"] .gtm-fav-btn.on{
  background:var(--accent,#e63946);
  border-color:var(--accent,#e63946);
  color:#ffffff;
}
html[data-theme="dark"] .gtm-fav-btn.on:hover{background:#c82333;border-color:#c82333}
html[data-theme="dark"] .gtm-fav-btn.on .gtm-badge{background:#fff;color:var(--accent,#e63946)}
html[data-theme="dark"] .gtm-page-error{background-color:rgba(233,69,96,.15);color:#ff9db0;border-color:rgba(233,69,96,.45)}
html[data-theme="dark"] .gtm-page-error a{color:#ff9db0}

/* --- 主题 style.css 里写死的正文按钮色（优先级已高于它，无需 !important） --- */
html[data-theme="dark"] body.manga-page .chapter-readmore{color:var(--text,#333)}
html[data-theme="dark"] body.manga-page .content-readmore{color:var(--text,#333)}
/* --- 会员页：步骤高亮与错误提示（保留品牌红观感，只换底色） --- */
html[data-theme="dark"] .gtm-step.on{background:rgba(233,69,96,.18);color:#ff8fa3}
html[data-theme="dark"] .gtm-step{background:var(--hover,#f4f5f7);color:var(--t2,#8b93a3)}

/* ============================================================
 * 补充修复（升级版扫描器发现的两处）：
 *   1) 详情页 hero 区的浅色底图 bg-search.jpg（平均色 rgb(236,237,239)，面积 63 万 px²）
 *   2) 返回键 / 章节菜单键的半透明白底 rgba(255,255,255,.5)
 * ============================================================ */

/* --- 1) 详情页 hero 底图 --- */
html[data-theme="dark"] .profile-manga{
  background-image:none!important;   /* 必须 !important：底图是内联 style 属性，优先级高于选择器 */
  background-color:var(--bg,#0a0a0a)!important;
}
/* 若今后想保留纹理，可换成下面这条（用纯色渐变压暗底图）：
html[data-theme="dark"] .profile-manga{
  background-image:linear-gradient(rgba(10,10,10,.94),rgba(10,10,10,.94)),var(--gt-hero-img);
}
*/

/* --- 2) 半透明白色按钮（返回键、章节菜单键）--- */
html[data-theme="dark"] .back-btn,
html[data-theme="dark"] .chapter-menu-btn{
  background:rgba(255,255,255,.10);
  border-color:rgba(255,255,255,.14);
  color:var(--text,#1f232b);
}
html[data-theme="dark"] .back-btn:hover,
html[data-theme="dark"] .chapter-menu-btn:hover{
  background:rgba(255,255,255,.18);
}

/* --- 3) 无 class 的裸链接（如 404 页的「홈으로 가기」）---
 * 主题 style.css 里有一条通用的 a{color:#333}，会把裸链接染成深灰。
 * 用 :not([class]) 精确匹配"没有任何 class 的 <a>"，
 * 因此带 class 的链接（品牌红按钮、会员导航等）完全不受影响。 */
html[data-theme="dark"] a:not([class]){
  color:var(--text,#333);
}

/* ============================================================
 * 移动端章节列表（按站长要求）
 *   紫底白字  ->  #141414 底 + 白字
 *   且不再区分「看过 / 没看过」：底色、文字透明度、日期色全部与未读一致
 * 只作用于夜间模式；亮色模式保持原来的紫色
 * ============================================================ */
html[data-theme="dark"] .wp-manga-chapter,
html[data-theme="dark"] .wp-manga-chapter.active,
html[data-theme="dark"] .wp-manga-chapter.visited{
  background:#141414!important;
  border:none!important;
}
/* 去掉「已读」的文字变淡提示（原来 opacity:.5） */
html[data-theme="dark"] .wp-manga-chapter.visited a{
  opacity:1!important;
}
html[data-theme="dark"] .wp-manga-chapter.visited .chapter-release-date{
  color:#fff!important;
  opacity:.8!important;
}

/* ============================================================
 * PC 端章节列表底部的「白色渐隐」与标题分隔线
 *   1) ul.main.version-chap::after 是 Madara 的 show-more 提示：
 *      30px 高的 linear-gradient(透明 -> 纯白)，桌面端 opacity 会被 .active 打开
 *      → 改为渐隐到页面底色 #0a0a0a（保留提示效果，不再是白带）
 *   2) 简介区 .summary__content.show-more::after 同理
 *   3) .c-blog__heading（「전체 회차」标题）下面的 2px 近白分隔线
 * ============================================================ */
html[data-theme="dark"] .listing-chapters_wrap.show-more .version-chap:after,
html[data-theme="dark"] ul.main.version-chap:after,
html[data-theme="dark"] ul.main.version-chap.active:after,
html[data-theme="dark"] ul.main.version-chap.loaded:after{
  background:linear-gradient(to bottom, rgba(10,10,10,0), #0a0a0a)!important;
}
html[data-theme="dark"] .summary__content.show-more:after,
html[data-theme="dark"] .summary__content.show-more.active:after,
html[data-theme="dark"] .manga-excerpt.show-more:after,
html[data-theme="dark"] .manga-excerpt.show-more.active:after{
  background:linear-gradient(to bottom, rgba(10,10,10,0), #0a0a0a)!important;
}
/* 站长要求：「전체 회차」标题下的分隔线在夜间模式保持白色（不改暗） */
html[data-theme="dark"] .c-blog__heading,
html[data-theme="dark"] .c-blog__heading.style-1,
html[data-theme="dark"] .c-blog__heading.style-2,
html[data-theme="dark"] .c-blog__heading.style-3{
  border-bottom-color:#ffffff!important;
}

/* 站长要求：「전체 회차」右侧的翻转箭头（순서 변경）在夜间模式改成白色
 * 现状：图标色 rgb(0,0,0) 落在 rgb(10,10,10) 的页面上，对比度 1:1 完全看不见
 * 备注：主题原本就有 .text-ui-light ... i{color:#FFF}，本次与主题设计意图一致
 *      移动端还有一段 .btn-reverse-order{color:#999!important}，故需要 !important */
html[data-theme="dark"] .c-blog__heading .btn-reverse-order,
html[data-theme="dark"] .c-blog__heading a.btn-reverse-order i,
html[data-theme="dark"] a.btn-reverse-order i{
  color:#ffffff!important;
}
