/* ============================================================================
   主题系统：白天（默认，白色极简） + 黑夜（黑夜使者 · 亚索暗黑皮肤）
   ----------------------------------------------------------------------------
   各页面 <head> 里加载（顺序：先用 theme.js 定主题，再让本文件上色）：

     <script src="/theme.js"></script>
     <link rel="stylesheet" href="/theme-nightbringer.css" />

   · 白天模式 = 不给 body/html 加任何 class，沿用 base.css / index.html 的浅色样式
   · 黑夜模式 = <html class="dark-theme"> 且 <body class="dark-theme">（由 theme.js 切换）
   · 本文件里所有暗色规则都以 body.dark-theme 开头，白天模式完全不受影响

   调底图亮度只需要改下面 4 个变量（改动最小、最容易试出效果）：
     --bg-brightness   图片亮度倍数（1 = 原图；越大越亮）
     --overlay-strong  遮罩最浅处（顶部）
     --overlay-mid     遮罩中段
     --overlay-soft    遮罩最深处（底部，内容区）
   ============================================================================ */

/* ============================================================================
   一、主题切换按钮（白天 / 黑夜都要显示）
   ============================================================================ */
.theme-toggle {
  margin-left: auto;            /* 推到导航栏最右侧 */
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  min-height: 34px;
  border-radius: 4px;
  cursor: pointer;
  /* 白天：浅灰色 */
  background: #f1f2f4;
  color: #374151;
  border: 1px solid #d8dbe0;
  box-shadow: none;
  text-shadow: none;
  transition: background .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.theme-toggle:hover {
  background: #e7e9ec;
  border-color: #c3c8cf;
}
/* 黑夜：暗金 / 亚索橙 */
body.dark-theme .theme-toggle {
  background: linear-gradient(180deg, #3b2a13 0%, #241a0c 100%);
  color: #ffb27a;
  border-color: rgba(255, 120, 60, .5);
  box-shadow: 0 0 12px rgba(255, 69, 0, .22);
}
body.dark-theme .theme-toggle:hover {
  color: #ffd9b8;
  border-color: #ff8a4c;
  box-shadow: 0 0 15px rgba(255, 69, 0, .55);
}

@media (max-width: 767px) {
  .theme-toggle {
    min-height: 40px;           /* 手指好点 */
    padding: 9px 14px;
    font-size: 14px;
  }
}

/* ============================================================================
   二、黑夜主题变量（只作用于 .dark-theme）
   ============================================================================ */
html.dark-theme,
body.dark-theme {
  /* 背景图与亮度（← 调这里就能让底图更亮/更暗） */
  --theme-bg-image: url('/images/yasuo.jpg');
  --bg-brightness: 1.28;                       /* 图片亮度滤镜 */
  --overlay-strong: rgba(6, 6, 8, .40);        /* 顶部遮罩（最浅，人物看得清） */
  --overlay-mid: rgba(6, 6, 8, .52);           /* 中段 */
  --overlay-soft: rgba(6, 6, 8, .66);          /* 底部（内容区，最实） */
  --fire-glow: rgba(255, 69, 0, .20);

  /* 主题色 */
  --bg: #121212;
  --bg-deep: #0b0b0d;
  --card: rgba(22, 22, 26, .86);               /* 卡片（提高不透明度保证可读） */
  --card-solid: #242424;
  --card-soft: rgba(40, 40, 44, .8);
  --line: #3b3b41;
  --text: #e8e8e8;
  --muted: #a8a8a8;
  --blade: #a8a8a8;

  --primary: #ff4500;
  --primary-2: #e63946;
  --primary-edge: rgba(255, 120, 60, .45);
  --danger: #ff6b6b;

  --radius: 4px;
  --glow: 0 0 15px rgba(255, 69, 0, .75);
  --glow-soft: 0 0 22px rgba(255, 69, 0, .28);

  /* 题目 / 参考 的语义色：题目=刀身钢色，参考=火焰橙 */
  --question-bg: rgba(36, 40, 46, .82);
  --question-edge: var(--blade);
  --reference-bg: rgba(48, 27, 18, .84);
  --reference-edge: var(--primary);
}

html.dark-theme {
  background-color: var(--bg-deep);
  color-scheme: dark;          /* 表单控件 / 滚动条也跟着变暗 */
}

/* ---------- 背景层：底图（加亮） + 深色遮罩（更浅） ---------- */
body.dark-theme {
  background: transparent;      /* 让下面的背景层透出来 */
  color: var(--text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .7);   /* 底图变亮后保证文字清楚 */
}

body.dark-theme::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: -2;
  background-image: var(--theme-bg-image);
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  filter: brightness(var(--bg-brightness)) saturate(1.05);  /* 让亚索更清晰 */
}

body.dark-theme::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: -1;
  background-color: var(--bg-deep);   /* 图片缺失时的兜底底色 */
  background-image:
    linear-gradient(180deg,
      var(--overlay-strong) 0%,
      var(--overlay-mid) 45%,
      var(--overlay-soft) 100%),
    radial-gradient(900px 520px at 82% -6%, var(--fire-glow), rgba(255, 69, 0, 0) 62%);
}

/* ---------- 标题：硬朗 + 火焰发光 ---------- */
body.dark-theme h1,
body.dark-theme h2 {
  color: #f7f7f7;
  font-weight: 800;
  letter-spacing: .03em;
  text-shadow: 0 0 12px rgba(255, 69, 0, .45), 0 1px 3px rgba(0, 0, 0, .85);
}
/* 想要更"海报感"的硬朗字体：把下面这条注释去掉即可 */
/* body.dark-theme h1, body.dark-theme h2 { font-family: Impact, "Arial Narrow Bold", "PingFang SC", "Microsoft YaHei", sans-serif; letter-spacing: .05em; } */

body.dark-theme .desc,
body.dark-theme .corpus-desc,
body.dark-theme .note,
body.dark-theme .status,
body.dark-theme .item-meta,
body.dark-theme .tip,
body.dark-theme .hint,
body.dark-theme .sent-meta,
body.dark-theme .box-note,
body.dark-theme .word-counts,
body.dark-theme .empty-note {
  color: var(--muted);
}
body.dark-theme .zh { color: #cfcfcf; }
body.dark-theme .sentence,
body.dark-theme .sent-text,
body.dark-theme .box-text,
body.dark-theme .prewrap,
body.dark-theme .result,
body.dark-theme .word-name { color: var(--text); }

/* ---------- 输入框：深色底 + 聚焦火焰色 ---------- */
body.dark-theme textarea,
body.dark-theme input[type="text"],
body.dark-theme select {
  background: rgba(18, 18, 20, .88);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
}
body.dark-theme textarea::placeholder,
body.dark-theme input::placeholder { color: #7c7c82; }
body.dark-theme textarea:focus,
body.dark-theme input:focus,
body.dark-theme select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), var(--glow-soft);
}

/* ---------- 按钮：火焰渐变 + 锐利圆角 + 悬停发光 ---------- */
body.dark-theme button {
  border-radius: var(--radius);
  border: 1px solid var(--primary-edge);
  background: linear-gradient(180deg, #ff5a1f 0%, var(--primary-2) 100%);
  color: #fff;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .45);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .55);
  transition: box-shadow .18s ease, border-color .18s ease, transform .06s ease;
}
body.dark-theme button:hover:not(:disabled) {
  box-shadow: 0 0 15px var(--primary), 0 0 30px rgba(255, 69, 0, .35);
  border-color: #ff8a4c;
}
body.dark-theme button:active:not(:disabled) { transform: translateY(1px); }
body.dark-theme button:disabled { opacity: .5; }

body.dark-theme button.secondary {
  background: rgba(36, 36, 42, .92);
  color: #f0b189;
  border-color: var(--primary-edge);
  text-shadow: none;
}
body.dark-theme button.secondary:hover:not(:disabled) {
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(255, 69, 0, .45);
}
body.dark-theme button.ghost { color: #ff8a4c; }
body.dark-theme button.mini { border-radius: var(--radius); }

/* 顶部导航 */
body.dark-theme .nav a {
  color: var(--muted);
  border-color: transparent;
  border-radius: var(--radius);
}
body.dark-theme .nav a:hover { color: #ffb27a; border-color: var(--primary-edge); }
body.dark-theme .nav a.active {
  color: #fff;
  background: linear-gradient(180deg, #ff5a1f, var(--primary-2));
  border-color: #ff8a4c;
  box-shadow: var(--glow);
}
body.dark-theme .checkbox { color: var(--muted); }

/* ---------- 卡片：玻璃拟态 + 左侧剑刃发光竖条 ---------- */
body.dark-theme .card,
body.dark-theme .item,
body.dark-theme .topic-card,
body.dark-theme .word-card {
  background: var(--card);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 26px rgba(0, 0, 0, .45);
}
/* 主容器卡片：顶部刀锋线 */
body.dark-theme .card {
  border-top: 2px solid rgba(255, 69, 0, .55);
  box-shadow: 0 8px 26px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 140, 60, .18);
}
/* 列表卡片：左侧发光竖条 */
body.dark-theme .item,
body.dark-theme .topic-card,
body.dark-theme .word-card {
  position: relative;
  border-left: 3px solid var(--primary);
  box-shadow: -2px 0 14px rgba(255, 69, 0, .35), 0 8px 22px rgba(0, 0, 0, .42);
}
body.dark-theme .word-card { background: rgba(28, 28, 32, .84); }

/* ---------- 题目区 / 参考区（保留语义区分，换成暗夜配色）---------- */
body.dark-theme .question-box {
  background: var(--question-bg);
  border: 1px solid rgba(168, 168, 168, .22);
  border-left: 4px solid var(--question-edge);
  border-radius: var(--radius);
}
body.dark-theme .question-box .box-title { color: #d3d7dc; }

body.dark-theme .reference-box {
  background: var(--reference-bg);
  border: 1px solid rgba(255, 120, 60, .3);
  border-left: 4px solid var(--reference-edge);
  border-radius: var(--radius);
  box-shadow: inset 0 0 24px rgba(255, 69, 0, .12);
}
body.dark-theme .reference-box .box-title { color: #ffa367; }
body.dark-theme .box-title { letter-spacing: .04em; }
body.dark-theme .box-text { color: var(--text); }

/* ---------- 生成结果 / 高亮 / 列表 ---------- */
body.dark-theme .result {
  background: rgba(36, 28, 24, .86);
  border: 1px solid rgba(255, 120, 60, .38);
  border-radius: var(--radius);
  box-shadow: inset 0 0 20px rgba(255, 69, 0, .12);
}
body.dark-theme mark,
body.dark-theme .mark {
  background: rgba(255, 69, 0, .34);
  color: #fff;
  border-radius: 2px;
}
body.dark-theme .sent-item { border-top: 1px dashed rgba(255, 255, 255, .16); }
body.dark-theme .sent-list .sent-item:first-child { border-top: none; }
body.dark-theme .badge {
  background: rgba(255, 69, 0, .18);
  border-color: rgba(255, 120, 60, .45);
  color: #ffb27a;
}

/* ---------- 提示 / 错误 / 空状态 ---------- */
body.dark-theme .error {
  background: rgba(80, 20, 20, .6);
  border: 1px solid rgba(255, 107, 107, .45);
  color: #ffb4b4;
  border-radius: var(--radius);
}
body.dark-theme .banner {
  background: rgba(80, 55, 10, .55);
  border: 1px solid rgba(252, 211, 77, .45);
  color: #f5d489;
  border-radius: var(--radius);
}
body.dark-theme .filters select { background: rgba(18, 18, 20, .88); color: var(--text); }
body.dark-theme .link-btn { color: #ff8a4c; }
body.dark-theme .link-btn:hover { color: #ffb27a; }

/* 统一成锐利圆角（来源标签保持胶囊形，便于区分） */
body.dark-theme .item,
body.dark-theme .topic-card,
body.dark-theme .word-card,
body.dark-theme .result,
body.dark-theme .error,
body.dark-theme .banner,
body.dark-theme .link-btn { border-radius: var(--radius); }
body.dark-theme .badge { border-radius: 999px; }

/* ============================================================================
   三、移动端（< 768px）：字清楚、按钮好点、底图别太亮
   ============================================================================ */
@media (max-width: 767px) {
  body.dark-theme {
    /* 手机屏幕小、环境亮，遮罩稍微加深一点，同时降低模糊开销 */
    --overlay-strong: rgba(6, 6, 8, .46);
    --overlay-mid: rgba(6, 6, 8, .58);
    --overlay-soft: rgba(6, 6, 8, .72);
    --bg-brightness: 1.15;
  }
  body.dark-theme::before { background-position: 62% top; }
  body.dark-theme .card,
  body.dark-theme .item,
  body.dark-theme .topic-card,
  body.dark-theme .word-card {
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    background: rgba(22, 22, 26, .9);   /* 小屏提高不透明度，保证可读 */
  }
  body.dark-theme h1 { font-size: 19px; }
  body.dark-theme h2 { font-size: 16px; }
  body.dark-theme .result { font-size: 16px; }
  body.dark-theme .box-text,
  body.dark-theme .prewrap { font-size: 15px; }
  body.dark-theme button { min-height: 40px; }
}

/* 系统开启"减少动画"时不做过渡 */
@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  body.dark-theme button { transition: none; }
}
