/* ==========================================================================
   TaleVant C 端主题 —— 「深夜藏书馆」
   --------------------------------------------------------------------------
   定调：暗色沉浸 + 轻奢叙事。受众是移动端海外华人玩家；产品是故事世界，
   视觉应当像一间点着蜡烛的藏书馆，而不是一个 SaaS 工具面板。
   记忆点：琥珀烛光（单一强调色）× 衬线展示字 × 暖暗底上的氛围光晕。
   所有规则限定在 #app 作用域（运营后台 admin.html 无 #app，不受影响）。
   ========================================================================== */

/* ---- 令牌：在 #app 上重定义基础变量，全部现有组件自动换肤 ---- */
#app {
  --bg: #131009;
  --panel: #1c1812;
  --panel-2: #241f17;
  --text: #f2ecdf;
  --muted: #a3988a;
  --line: rgba(242, 236, 223, .12);
  --line-2: rgba(242, 236, 223, .07);
  --accent: #d9a441;
  --accent-soft: rgba(217, 164, 65, .14);
  /* 链接色：刻意与 --accent 分开。
     这套界面的强调色是琥珀烛光，而登录窗底部的「去注册 / 忘记密码」
     是**功能入口**而不是主操作 —— 与金色的「登录」按钮同色时，
     它既不像链接、也不像按钮，正好落在两者之间的灰色地带。
     功能性链接按惯例用蓝，也让人一眼分清「这是能点的另一件事」。
     值取得偏亮（而非纯蓝 #0000ee）：底色是 #131009 的暖黑，
     中等饱和的蓝在这上面会发闷、读起来像禁用态。 */
  --link: #6da3f0;
  --link-hover: #9cc4ff;
  --danger: #e06c5a;
  --danger-soft: rgba(224, 108, 90, .13);
  --ok: #7fb98a;
  --ok-soft: rgba(127, 185, 138, .13);
  --warn: #d9a441;
  --warn-soft: rgba(217, 164, 65, .12);

  --serif: "Fraunces", "Noto Serif SC", "Songti SC", serif;
  --ease: cubic-bezier(.16, 1, .3, 1);

  color-scheme: dark;   /* 原生控件（select 弹出层、日期选择器等）跟随暗色 */
  background: var(--bg);
  color: var(--text);
  position: relative;
  font-variant-numeric: tabular-nums;
}

/* select 弹出列表：部分浏览器不吃 color-scheme，显式给底色和字色 */
#app select option,
#app select optgroup {
  background: #241f17;
  color: #f2ecdf;
}

/* ---- 氛围层：烛光光晕 + 颗粒，替代纯色平铺 ---- */
#app::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(46rem 32rem at 85% -8%, rgba(217, 164, 65, .13), transparent 62%),
    radial-gradient(40rem 30rem at -18% 12%, rgba(122, 90, 248, .10), transparent 58%),
    radial-gradient(30rem 26rem at 50% 118%, rgba(217, 164, 65, .07), transparent 60%);
}
#app::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
#app > * { position: relative; z-index: 1; }   /* 内容压在氛围层之上 */

/* 顶栏要把 sticky 抢回来：上面那行的特异性（1,0,0）高于 styles.css 的
   `.topbar`（0,1,0），会把 position 顶成 relative，顶栏于是跟着页面滚走。
   这里用「id + 类」（1,1,0）压回去，只精确命中顶栏本身，不动 #app > * ——
   那行是让所有内容浮在氛围层之上的，改它会波及每一个页面。
   层级：顶栏 20 < 账号菜单 60 < 修改密码弹窗 200 < 登录弹窗宿主 300。 */
#app > .topbar { position: sticky; top: 0; z-index: 20; }

/* ---- 字体：标题衬线化，正文保持无衬线内敛字体 ---- */
#app h1, #app h2, #app h3, #app .section-title, #app .brand,
#app .plot-title, #app .msg .who {
  font-family: var(--serif);
  letter-spacing: .01em;
}
#app .brand { font-size: 17px; font-weight: 650; }
#app .brand::first-letter { color: var(--accent); }
#app .section-title { font-size: 19px; font-weight: 620; }

/* ---- 顶栏：暗色玻璃 ---- */
#app .topbar {
  background: rgba(19, 16, 9, .78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-2);
}
#app .topnav a { border-radius: 8px; transition: color .16s ease, background .16s ease; }
#app .topnav a.active { background: transparent; color: var(--accent); position: relative; }
#app .topnav a.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: 2px; height: 2px;
  border-radius: 2px; background: var(--accent);
}

/* ---- 卡片：书册质感（渐变描边 + 悬停烛光） ---- */
#app .card {
  background: linear-gradient(168deg, var(--panel) 0%, #191510 100%);
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(242, 236, 223, .04);
}
#app .plot-card {
  position: relative; overflow: hidden;
  transition: transform .2s var(--ease), border-color .2s ease;
}
#app .plot-card::before {                 /* 书脊装饰条 */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--accent), transparent 85%);
  opacity: .55; z-index: 2;
}
#app .plot-card:hover { transform: translateY(-3px); border-color: rgba(217, 164, 65, .45); }
#app .plot-cover {
  aspect-ratio: 3 / 4; width: calc(100% + 28px);         /* 出血到卡片边缘 */
  margin: -14px -14px 0;                                  /* 抵消卡片内边距 */
  overflow: hidden; position: relative;
}
#app .plot-cover img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .35s var(--ease), filter .35s ease;
  filter: saturate(.92) brightness(.96);
}
#app .plot-card:hover .plot-cover img { transform: scale(1.04); filter: saturate(1) brightness(1); }
/* 程序化封面（用户自建剧情无图时的兜底） */
#app .plot-cover.proc {
  display: flex; align-items: center; justify-content: center;
  background-image: radial-gradient(ellipse at 70% 20%, rgba(242,236,223,.06), transparent 55%);
}
#app .plot-cover .proc-glyph {
  font-family: var(--font-display); font-size: 64px; font-weight: 620;
  opacity: .85; text-shadow: 0 2px 18px rgba(0,0,0,.45);
}
#app .plot-cover::after {                 /* 底部渐隐压到正文 */
  content: ""; position: absolute; inset: auto 0 0 0; height: 44%;
  background: linear-gradient(180deg, transparent, rgba(16,13,10,.72)); pointer-events: none;
}
#app .plot-body { position: relative; z-index: 1; }
#app .plot-title { font-size: 15.5px; font-weight: 620; }
#app .plot-sum {
  margin-top: 4px; font-size: 12.5px; line-height: 1.55; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---- 按钮：主按钮琥珀实底，悬停微抬 ---- */
#app .btn { border-radius: 10px; transition: transform .16s var(--ease), filter .16s ease; }
#app .btn.primary { background: var(--accent); border-color: var(--accent); color: #221a0c; font-weight: 620; }
#app .btn.primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
#app .btn:hover { background: var(--panel-2); }

/* ---- 表单 ---- */
#app input, #app textarea, #app select {
  background: rgba(242, 236, 223, .05);
  border-color: var(--line);
  color: var(--text);
}
#app input:focus, #app textarea:focus, #app select:focus {
  outline: 2px solid rgba(217, 164, 65, .55); outline-offset: 1px; border-color: transparent;
}
#app input::placeholder, #app textarea::placeholder { color: var(--muted); }

/* ---- AI 配图工具条 ---- */
#app .cover-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px;
}
#app .cover-tools .btn[disabled] { opacity: .45; }
#app .cover-tools a { color: var(--accent); text-decoration: none; white-space: nowrap; }
#app .cover-tools a:hover { text-decoration: underline; }

/* ---- 对话 ---- */
#app .msg.user { background: rgba(217, 164, 65, .16); border: 1px solid rgba(217, 164, 65, .22); }
#app .msg.assistant { background: var(--panel-2); border: 1px solid var(--line-2); }
#app .composer textarea { background: rgba(242, 236, 223, .05); }

/* ---- 标签 / 提示 / 分隔 ---- */
#app .tag.gray { background: rgba(242, 236, 223, .08); color: var(--muted); }
/* 官方标：蓝色系（与暖色强调色区分，标识平台背书） */
#app .tag.official { background: rgba(133, 177, 232, .15); color: #85b1e8; }
#app .divider { background: var(--line-2); }
#app .loading, #app .empty { color: var(--muted); }

/* ---- 键盘焦点全局可见 ---- */
#app :focus-visible { outline: 2px solid rgba(217, 164, 65, .7); outline-offset: 2px; }

/* ---- 入场序列：错峰上浮（3 组节奏，60/120/180ms） ---- */
@media (prefers-reduced-motion: no-preference) {
  #app .wrap > * {
    animation: tv-rise .5s var(--ease) both;
  }
  #app .wrap > *:nth-child(2) { animation-delay: 60ms; }
  #app .wrap > *:nth-child(3) { animation-delay: 120ms; }
  #app .wrap > *:nth-child(4) { animation-delay: 180ms; }
  #app .grid > * { animation: tv-rise .45s var(--ease) both; }
  #app .grid > *:nth-child(2) { animation-delay: 60ms; }
  #app .grid > *:nth-child(3) { animation-delay: 120ms; }
  #app .grid > *:nth-child(4) { animation-delay: 180ms; }
  #app .grid > *:nth-child(5) { animation-delay: 240ms; }
  #app .grid > *:nth-child(n+6) { animation-delay: 300ms; }
}
@keyframes tv-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  #app .wrap > *, #app .grid > * { animation: none !important; }
  #app * { transition-duration: .01ms !important; }
}

/* ---- 桌面居中栏：底色同步暗色 ---- */
@media (min-width: 640px) {
  body { background: #0a0908; }
  #app { box-shadow: 0 0 64px rgba(217, 164, 65, .06), 0 0 24px rgba(0, 0, 0, .55); }
}

/* ---- 窄屏顶栏：再压一档防重叠（衬线 brand 变宽后 390px 很紧） ---- */
@media (max-width: 420px) {
  /* padding 简写会清掉 styles.css 里给的安全区让位（padding-top），须重新声明 */
  #app .topbar { gap: 5px; padding: 0 10px; padding-top: var(--sat, 0px); }
  #app .brand { font-size: 14.5px; letter-spacing: 0; }
  #app .topnav { gap: 0; }
  #app .topnav a { padding: 6px 5px; font-size: 12px; }
  #app .topbar select { font-size: 11px; padding: 4px 3px; max-width: 72px; }
  #app .topbar .btn.sm, #app .topbar a.btn { padding: 5px 8px; font-size: 12px; }
}

/* ---- 登录 / 注册弹窗 ----------------------------------------------------
   复用 styles.css 里的 .modal-* 结构（那套是浅色底），这里在暗色主题下重新上色，
   让它和站内其他组件一样是「深夜藏书馆」的质感，而不是白底卡片。 */
#app > #authModalHost { z-index: 300; }   /* 盖过 #app > * 的默认 z-index:1 */
#app > #quotaModalHost { z-index: 300; }  /* 账户权益弹窗：同上 */
#app .modal-mask { background: rgba(8, 7, 4, .64); backdrop-filter: blur(3px); }
#app .modal-card {
  position: relative;
  background: linear-gradient(168deg, var(--panel) 0%, #191510 100%);
  border-color: var(--line);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35),
              0 30px 70px -28px rgba(0, 0, 0, .85);
}
#app .modal-title { color: var(--text); }
#app .modal-sub { color: var(--muted); }
#app .modal-card label { color: var(--muted); }
#app .modal-card input {
  background: rgba(242, 236, 223, .05);
  border-color: var(--line);
  color: var(--text);
}
#app .modal-card input::placeholder { color: rgba(163, 152, 138, .7); }
#app .modal-card input:focus {
  background: rgba(242, 236, 223, .07);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
#app .modal-close { color: var(--muted); }
#app .modal-close:hover { color: var(--text); background: var(--panel-2); }
/* 账户与安全弹窗页签：暗色主题下重新上色（styles.css 那套是浅色底） */
#app .sec-tabs { background: rgba(242, 236, 223, .06); }
#app .sec-tab { color: var(--muted); }
#app .sec-tab:hover { color: var(--text); }
#app .sec-tab.on { background: var(--accent); color: #fff; }
#app .sec-stepno { color: var(--text); }
#app .sec-panel [data-sec-step] + [data-sec-step] { border-top-color: var(--line); }
/* 登录窗底部的两个入口是**两件不同的事**（去注册 / 找回密码），不是一句
   话的两个分句。原样式里它们之间只有 HTML 折叠出来的那个空格，间距近乎为零，
   再加上同色同字号，整行会被读成「去注册找回密码？」一个标签 ——
   用户 2026-10-11 截图投诉的正是这个。
   所以拆成两条独立规则：
     · 去注册是主路径（新用户增长漏斗），保持 --link 蓝 + 550 字重；
     · 忘记密码是兜底路径，降到 --muted 暖灰 —— 色相与蓝差 179°，
       一眼可分；且这个灰在本主题里是「次要信息」语义（副标题/占位符/空态），
       不是「禁用」，不会读成灰掉不可点。
   悬停时两者都回蓝 + 下划线：色差只用来分组，可点性仍在 hover 里兑现，
   颜色不能是传达「可点」的唯一途径。
   间距用 flex gap 明确拉开，不依赖文本里那个可能被压缩掉的空格。 */
#app .auth-swap {
  display: flex; justify-content: center; align-items: baseline;
  gap: 18px; flex-wrap: wrap;
}
#app .auth-swap a { color: var(--link); font-weight: 550;
                    transition: color .12s ease; }
#app .auth-swap a:hover { color: var(--link-hover); text-decoration: underline; }
#app .auth-swap #auForgot { color: var(--muted); font-weight: 400; }
/* 特异度是这里唯一需要小心的点：#auForgot 选择器含 2 个 ID，压得过上面的
   a:hover（1 个 ID + 1 个伪类按同级计数）。若只写上面那条，悬停时
   「忘记密码」会停在灰色不上色 —— 看上去就是「hover 失效」。故补同等
   特异度的一条，让可点性照常兑现。 */
#app .auth-swap #auForgot:hover { color: var(--link-hover); }
/* 登录/注册只有一个主操作，占满整行比右对齐更好点 */
#app .auth-modal .modal-actions { justify-content: stretch; margin-top: 16px; }
#app .auth-modal .modal-actions .btn {
  width: 100%; min-width: 0; height: 44px; font-size: 14.5px; letter-spacing: .3px;
  box-shadow: 0 12px 28px -18px rgba(217, 164, 65, .9);
}

/* 卡片顶部一道极细的烛光描边，把弹窗从背景里「挑」出来 */
#app .auth-modal { overflow: hidden; padding: 26px 26px 20px; }
#app .auth-modal::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(217, 164, 65, .55), transparent);
}

/* ---- 弹窗头部：徽记 + 标题 + 副题，居中成组 ---- */
#app .auth-head { text-align: center; margin: 2px 0 20px; }
#app .auth-crest {
  width: 46px; height: 46px; margin: 0 auto 12px;
  display: grid; place-items: center; border-radius: 15px;
  color: var(--accent);
  background: radial-gradient(circle at 50% 28%, rgba(217, 164, 65, .22), rgba(217, 164, 65, .05) 72%);
  border: 1px solid rgba(217, 164, 65, .26);
  box-shadow: 0 10px 26px -14px rgba(217, 164, 65, .75),
              inset 0 0 18px rgba(217, 164, 65, .06);
}
#app .auth-crest svg { width: 22px; height: 22px; display: block; }
#app .auth-title { margin: 0; font-size: 21px; line-height: 1.25; }
#app .auth-sub {
  margin: 7px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--muted);
}

/* ---- 密码框内的显隐按钮 ---- */
#app .pw-wrap { position: relative; }
#app .pw-wrap input { padding-right: 44px; }
#app .pw-eye {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 32px; height: 32px; padding: 0; display: grid; place-items: center;
  border: none; border-radius: 9px; background: transparent;
  color: var(--muted); cursor: pointer;
  transition: color .15s, background .15s;
}
#app .pw-eye:hover { color: var(--text); background: rgba(242, 236, 223, .08); }
#app .pw-eye.on { color: var(--accent); }
#app .pw-eye svg { display: block; }

/* ---- 验证码行：输入框 + 图形码 / 发送按钮 并排 ---- */
#app .cap-row { display: flex; align-items: stretch; gap: 8px; }
#app .cap-row input { flex: 1 1 auto; min-width: 0; }
#app .cap-img {
  flex: 0 0 auto; width: 132px; height: 46px; border-radius: 9px;
  border: 1px solid var(--line); overflow: hidden; cursor: pointer;
  background: var(--panel-2, transparent);
  display: grid; place-items: center; user-select: none;
  transition: border-color .15s;
}
#app .cap-img:hover { border-color: var(--accent); }
#app .cap-img svg { display: block; width: 132px; height: 46px; }
#app .cap-loading, #app .cap-fail {
  font-size: 12px; color: var(--muted); text-align: center; padding: 0 8px;
}
#app .cap-fail { color: var(--danger, #c0392b); }
#app .cap-row .btn { flex: 0 0 auto; white-space: nowrap; }

/* ---- 「记住账户 / 记住密码」：自绘勾选框，琥珀勾 + 暖边 ---- */
#app .remember-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px 14px; margin: 2px 0 2px;
}
#app .remember {
  display: inline-flex; align-items: center; gap: 7px; margin: 0;
  font-size: 12.5px; font-weight: 500; line-height: 1; color: var(--muted);
  cursor: pointer; user-select: none; transition: color .15s;
}
#app .remember:hover { color: var(--text); }
#app .remember input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px; flex: none; margin: 0; padding: 0;
  position: relative; cursor: pointer; border-radius: 5px;
  border: 1px solid var(--line); background: rgba(242, 236, 223, .05);
  transition: background .15s, border-color .15s, box-shadow .15s;
}
#app .remember input[type="checkbox"]:checked {
  background: var(--accent); border-color: var(--accent);
}
#app .remember input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 5px; top: 1.5px;
  width: 4px; height: 9px; border: solid #221a0c;
  border-width: 0 2px 2px 0; transform: rotate(45deg);
}
/* 覆盖通用 input:focus（那条会把边框刷成透明），勾选框要留住琥珀描边 */
#app .remember input[type="checkbox"]:focus { border-color: var(--accent); }
#app .remember input[type="checkbox"]:focus-visible { outline-offset: 3px; }
/* 「记住密码」勾选时，账户框被联动锁定（密码须绑定账户才有意义）：
   视觉上压暗、禁用点击，提示这是被动开启而非可独立操作的项。 */
#app .remember input[type="checkbox"]:disabled { cursor: not-allowed; opacity: .55; }
#app .remember input[type="checkbox"]:disabled:checked { opacity: .7; }
#app .remember.locked { cursor: not-allowed; }
#app .remember.locked:hover { color: var(--muted); }
/* 「内容模式 · 成年声明」那一行：与「记住密码」同一套勾选框视觉。
   用块级 flex 而不是 inline-flex：声明文案较长，要占满卡片宽并正常换行；
   且必须显式压掉全局 input{width:100%}，否则复选框被拉成整行、
   文案被挤成一条竖条（styles.css 里有同款事故的注释，见 .share-row）。 */
#app .attest-line {
  display: flex; align-items: flex-start; gap: 9px;
  margin: 10px 0 12px; font-size: 13px; font-weight: 500;
  line-height: 1.55; color: var(--muted); cursor: pointer; user-select: none;
}
#app .attest-line:hover { color: var(--text); }
#app .attest-line input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px; flex: none; margin: 2px 0 0; padding: 0;
  position: relative; cursor: pointer; border-radius: 5px;
  border: 1px solid var(--line); background: rgba(242, 236, 223, .05);
  transition: background .15s, border-color .15s, box-shadow .15s;
}
#app .attest-line input[type="checkbox"]:checked {
  background: var(--accent); border-color: var(--accent);
}
#app .attest-line input[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 5px; top: 1.5px;
  width: 4px; height: 9px; border: solid #221a0c;
  border-width: 0 2px 2px 0; transform: rotate(45deg);
}
/* 通用 input:focus 会把边框刷成透明；声明勾选框要留住琥珀描边 */
#app .attest-line input[type="checkbox"]:focus { border-color: var(--accent); }

#app .auth-swap { padding-top: 2px; }
/* font-weight 已并入上方 .auth-swap a 那条 —— 同一属性分散在文件两处时，
   改一处忘一处正是下一次回归的入口。 */

/* 窄屏：收紧内边距与字号，避免勾选框换行后主按钮被挤出屏幕 */
@media (max-width: 420px) {
  #app .auth-modal { padding: 22px 18px 18px; }
  #app .auth-title { font-size: 19px; }
  #app .auth-crest { width: 42px; height: 42px; margin-bottom: 10px; }
  #app .auth-sub { font-size: 12px; }
}
