/* =====================================================================
   Voyager · DarkStar — 页面框架 + AI 对话(仿 DeepSeek 网页版)+ 手机端适配
   站主要求:
     ① 三条杠 + 我的 固定右上角(见 nav.css);
     ② 入口页全屏、可展开可收缩(见 entry.css);
     ③ AI 对话仿 DeepSeek:窄列居中、回答无边框、输入区悬浮圆角、消息留白;
     ④ 论坛全屏(占满视口、内部滚动);
     ⑤ 卡牌浏览的筛选条常驻顶部(sticky top:0);
     ⑥ 手机版 UI 重做:单列、输入吸底、字号下调。
   本文件最后加载,只覆盖视觉与布局,不动任何后端逻辑。
   ===================================================================== */

:root {
  --ds-col: 780px;                 /* DeepSeek 式居中窄列 */
  --ds-bg: #141110;
  --ds-panel: #211d19;
  --ds-user: #2c2824;
  --ds-line: rgba(255, 255, 255, .08);
}

/* ---------- 1. 页面框架 ---------- */
/* 顶栏收成一条细带:品牌在左,右侧留给固定的「三条杠 + 我的」 */
body .topbar {
  position: relative; top: auto; z-index: 30;
  background: rgba(8, 6, 5, .72);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
body .topbar .tabs { display: none !important; }
body .topbar .topbar-right { display: none !important; }
body .topbar-inner { padding: 9px clamp(12px, 3vw, 22px); flex-wrap: nowrap; overflow: hidden; }
/* 品牌区:图标 + Voyager + DarkStar 胶囊 + 副标题,强制一行,不重叠、不裁字 */
body .topbar .brand {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: nowrap; white-space: nowrap;
  min-width: 0; overflow: hidden; line-height: 1.2;
}
body .topbar .brand-mark { width: 26px; height: 26px; flex: none; }
body .topbar .brand-name { flex: none; font-size: 18px; line-height: 1.2; }
body .topbar .brand-sub {
  flex: none; white-space: nowrap; font-size: 10.5px; line-height: 1.2;
  padding: 1px 8px; border-radius: 999px;
}

/* 主内容区:撑满一屏(100dvh - 顶栏高度),不再在底部留一条空黑 */
.views {
  padding: 14px clamp(12px, 3vw, 22px) 70px;
  min-height: calc(100dvh - var(--topbar-h, 56px));
  display: flex; flex-direction: column;
}
.view.active { flex: 1 1 auto; min-height: 0; }
body:has(#view-chat.active) .views { padding: 0; min-height: 100dvh; }

/* 回到顶部按钮:对话页不需要,别压住输入区 */
body:has(#view-chat.active) .to-top { display: none !important; }
/* 对话页整屏:页脚先收起来,否则会多出一条可滚动的空白 */
body:has(#view-chat.active) .foot { display: none !important; }
/* 公告横幅在对话页改成浮层,不占高度、不把输入框挤出屏幕 */
body:has(#view-chat.active) .notice-bar {
  position: fixed; top: 66px; left: 50%; transform: translateX(-50%);
  width: min(var(--ds-col), calc(100vw - 24px)); z-index: 65; margin: 0;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
}

/* 筛选条统一贴顶(顶栏不再是 sticky,滚下去之后筛选条真正常驻) */
.browse-head { top: 0; }

/* ---------- 2. 卡牌浏览:筛选条常驻顶部 ---------- */
#view-cards .browse-head {
  position: sticky; top: 0; z-index: 45;
  margin: 0 -4px 14px; padding: 10px 4px 12px;
  background: rgba(9, 7, 6, .94);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .45);
}
#view-cards .browse-head .browse-tools { padding-right: 104px; }
#view-cards .selbar, #view-cards .selbar.build { top: 0; z-index: 46; }

/* ---------- 3. AI 对话:仿 DeepSeek ---------- */
body:has(#view-chat.active) .topbar { display: none !important; }
#view-chat { height: 100dvh; }
.chat-wrap {
  height: 100dvh; max-width: none; margin: 0; min-height: 0;
  border: none; border-radius: 0; box-shadow: none;
  background: rgba(9, 7, 6, .72);
  /* 不用 backdrop-filter:它会给 position:fixed 的子元素(如 AI 用量全屏弹窗)
     造一个包含块,导致弹窗只盖住聊天区。这里用略带不透明的底色即可。 */
  backdrop-filter: none;
  display: flex; flex-direction: column;
}
.chat-head {
  flex: none; height: 58px; padding: 0 clamp(12px, 2.4vw, 20px);
  padding-right: 108px;                 /* 给右上角固定控件让位 */
  gap: 10px; border-bottom: 1px solid rgba(255, 255, 255, .05);
  background: rgba(10, 8, 7, .55); backdrop-filter: blur(10px);
  flex-wrap: nowrap; min-width: 0;
}
.chat-head .ai-avatar {
  width: 28px; height: 28px; padding: 0; border-radius: 9px;
  background: none; box-shadow: none; overflow: hidden; flex: none;
}
.chat-head .ai-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 9px; display: block; }
.chat-head-txt { min-width: 0; overflow: hidden; }
.chat-ai-name { font-size: 14.5px; font-weight: 700; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-ai-name em { display: none; }
.chat-ai-sub { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .mode-switch { flex: none; margin-left: 6px; border: none; background: rgba(255, 255, 255, .05); padding: 3px; }
.chat-head .mode-btn { font-size: 12px; padding: 5px 12px; }
.chat-head-tools { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.chat-tool {
  border: none; background: transparent; color: var(--ink-3); cursor: pointer;
  font-size: 12px; padding: 6px 9px; border-radius: 8px; white-space: nowrap;
}
.chat-tool:hover { color: var(--ink); background: rgba(255, 255, 255, .06); }

/* 消息区:大留白 + 居中窄列 */
.chat-body { padding: 26px clamp(14px, 3vw, 28px) 6px; }
.chat-log, .chat-hello, .typing { width: 100%; max-width: var(--ds-col); margin-left: auto; margin-right: auto; }
.chat-log { gap: 28px; }
.typing { padding: 6px 2px; }

/* 气泡:回答无边框、无底色;只有用户消息用底色区分 */
.msg { max-width: 100%; gap: 10px; align-items: flex-start; }
.msg.assistant { align-self: stretch; }
.msg.user { align-self: stretch; justify-content: flex-end; flex-direction: row; }
.msg .msg-av { width: 28px; height: 28px; flex: none; border-radius: 8px; margin-top: 2px; object-fit: cover; }
.msg .msg-main { min-width: 0; max-width: 100%; }
.msg.assistant .msg-main { flex: 1; }
.msg .bubble {
  background: none; border: none; border-radius: 0; box-shadow: none; padding: 0;
  font-size: 15.5px; line-height: 1.85; color: #ece7df; white-space: pre-wrap;
  word-break: break-word;
}
.msg.assistant .bubble { color: #ece7df; }
.msg .bubble b { color: #fff7ec; }
.msg .bubble a { color: var(--brand-3); }
.msg.user .msg-main { max-width: 78%; }
.msg.user .bubble {
  background: var(--ds-user); color: #f4eee6;
  border-radius: 18px; padding: 10px 16px; font-size: 15px; line-height: 1.75;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
}
.msg .bubble .curs { background: var(--brand-3); }
.msg-system {
  align-self: center; max-width: 86%; text-align: center;
  background: none; border: none; padding: 2px 10px;
  font-size: 12px; color: var(--ink-3);
}
.banner-banned { max-width: var(--ds-col); margin: 0 auto 14px; }
.msg-warn { max-width: var(--ds-col); margin: 4px auto; border-radius: 12px; }

/* 图片消息(一次最多 3 张) */
.msg-imgs { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 8px; }
.msg-img {
  padding: 0; border: 1px solid rgba(255, 255, 255, .1); background: #0e0c0a;
  border-radius: 12px; overflow: hidden; cursor: zoom-in; line-height: 0;
}
.msg-img img { display: block; width: 132px; height: 132px; object-fit: cover; }
.msg-img:hover { border-color: var(--brand); }

/* 思考过程:可折叠,DeepSeek 那种灰底小卡片 */
.think {
  margin: 0 0 12px; max-width: 100%; border: none; border-radius: 12px;
  background: rgba(255, 255, 255, .045); overflow: hidden;
  font-size: 13px; color: var(--ink-2);
}
.think > summary {
  display: flex; align-items: center; gap: 7px; cursor: pointer; user-select: none;
  padding: 9px 13px; background: none; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.think > summary::-webkit-details-marker { display: none; }
.think > summary::before {
  content: ''; width: 6px; height: 6px; flex: none; border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .16s ease;
}
.think[open] > summary::before { transform: rotate(45deg); }
.think-body { padding: 0 14px 10px 26px; display: flex; flex-direction: column; gap: 5px; color: var(--ink-3); }
.think-line { line-height: 1.65; }

/* 回答里附带的卡图 */
.bubble-cards { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.card-snippet {
  display: flex; gap: 12px; align-items: center; max-width: 440px; cursor: pointer;
  background: rgba(255, 255, 255, .04); border-radius: 14px; padding: 12px 14px;
}
.msg .bubble.card-snippet {
  border: none; padding: 12px 14px; background: rgba(255, 255, 255, .04); border-radius: 14px;
}
.card-snippet:hover { background: rgba(255, 255, 255, .07); }
.snippet-art { width: 74px; border-radius: 8px; display: block; }
.snippet-name { font-weight: 800; font-size: 15px; color: var(--ink); }
.snippet-en { font-size: 12px; color: var(--ink-3); }
.snippet-tip { font-size: 12px; margin-top: 4px; color: var(--ink-2); }

/* 开场白 */
.chat-hello { padding: clamp(28px, 9vh, 90px) 16px 8px; gap: 8px; }
.chat-hello-avatar {
  width: 66px; height: 66px; padding: 0; border-radius: 20px;
  background: none; border: none; box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  overflow: hidden;
}
.chat-hello-avatar img { border-radius: 20px !important; }
.chat-hello-name { margin-top: 14px; font-size: 21px; }
.chat-hello-ask { font-size: 14.5px; color: var(--ink-2); }
.chat-hello-tips { margin-top: 20px; gap: 9px; max-width: 620px; }
.chat-hello-tip {
  background: rgba(255, 255, 255, .055); border: none; border-radius: 999px;
  padding: 9px 16px; font-size: 12.8px; color: var(--ink-2);
}
.chat-hello-tip:hover { background: rgba(255, 255, 255, .1); color: var(--ink); }

/* 输入区:悬浮圆角、无外框 */
.composer {
  position: sticky; bottom: 0; z-index: 6; flex: none;
  border-top: none;
  background: linear-gradient(to top, rgba(7, 5, 4, .94) 46%, rgba(7, 5, 4, 0));
  padding: 6px clamp(10px, 2.4vw, 20px) 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
.ds-composer {
  width: 100%; max-width: var(--ds-col); margin: 0 auto;
  background: var(--ds-panel); border: none; border-radius: 18px;
  padding: 10px 12px 8px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .05) inset;
  transition: box-shadow .18s ease;
}
.ds-composer:focus-within { box-shadow: 0 16px 46px rgba(0, 0, 0, .58), 0 0 0 1px rgba(239, 231, 220, .2) inset; }
#chatInput {
  display: block; width: 100%; border: none; outline: none; resize: none;
  background: transparent; color: var(--ink); font-size: 15px; line-height: 1.6;
  min-height: 26px; max-height: 150px; padding: 4px 4px 6px;
}
#chatInput::placeholder { color: var(--ink-3); }
.ds-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px 8px; flex-wrap: wrap; margin-top: 2px;
}
.ds-switches { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.ds-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
/* 胶囊开关(role=switch) */
.ds-switch {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 12px;
  border: none; border-radius: 999px; cursor: pointer; white-space: nowrap;
  background: rgba(255, 255, 255, .06); color: var(--ink-2);
  font-size: 12.5px; font-weight: 600; transition: all .15s ease;
}
.ds-switch svg { opacity: .78; flex: none; }
.ds-switch:hover { color: var(--ink); background: rgba(255, 255, 255, .1); }
.ds-switch.on {
  background: rgba(201, 133, 90, .2); color: #ffd9b8;
  box-shadow: 0 0 0 1px rgba(201, 133, 90, .45) inset;
}
.ds-switch.on svg { opacity: 1; }
.ds-switch.on::after { content: ''; width: 5px; height: 5px; border-radius: 50%; background: #7ddc9a; flex: none; }
.ds-chip {
  height: 28px; padding: 0 10px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  background: transparent; border: 1px solid var(--line); color: var(--ink-3);
  font-size: 11.5px; line-height: 1;
}
.ds-chip:hover { color: var(--ink-2); border-color: var(--brand-line); }
.ds-icon-btn {
  width: 32px; height: 32px; flex: none; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-3);
}
.ds-icon-btn:hover { background: rgba(255, 255, 255, .07); color: var(--ink); }
.ds-icon-btn.busy { opacity: .5; pointer-events: none; }
.send-btn {
  width: 34px; height: 34px; flex: none; padding: 0; border: none; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  background: linear-gradient(135deg, #f7f1e8, #d9cbb9); color: #17120e;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35); transition: filter .15s ease, opacity .15s ease;
}
.send-btn:hover { filter: brightness(1.05); }
.send-btn:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
/* 附件缩略图 */
.ds-attach { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 2px 8px; }
.ds-thumb {
  position: relative; width: 62px; height: 62px; border-radius: 10px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .14); background: #0e0c0a;
}
.ds-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ds-thumb-x {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; padding: 0;
  border: none; border-radius: 50%; cursor: pointer; line-height: 1;
  background: rgba(0, 0, 0, .68); color: #fff; font-size: 10px;
}
.composer-note { max-width: var(--ds-col); margin: 7px auto 0; text-align: center; font-size: 11px; color: var(--ink-3); }

/* 快捷条 / 猜卡面板在窄列里居中 */
.quick-actions { max-width: var(--ds-col); margin: 0 auto 7px; }
.quick-actions .btn {
  background: rgba(255, 255, 255, .055); border: none; border-radius: 999px;
  padding: 6px 14px; font-size: 12.5px; color: var(--ink-2);
}
.quick-actions .btn:hover { background: rgba(255, 255, 255, .1); color: var(--ink); }
.quick-hint { font-size: 11px; color: var(--ink-3); }
.guess-panel { max-width: var(--ds-col); margin: 0 auto 7px; }
.guess-panel .btn { border-radius: 999px; }

/* 猜卡模式:关掉图片与两个开关 */
body.mode-guess .ds-switch,
body.mode-guess .ds-switches,
body.mode-guess #attachBtn,
body.mode-guess #uploadBtn,
body.mode-guess #identifyModeBtn { display: none !important; }
/* 猜卡模式下只留发送按钮,靠右 */
body.mode-guess .ds-actions { margin-left: auto; }

/* ---------- 4. 论坛:全屏、内部滚动 ---------- */
/* 论坛整页固定后,细顶栏要让位(否则会压住论坛标题) */
body:has(#view-forum.active) .topbar { display: none !important; }
body:has(#view-forum.active) .foot { display: none !important; }
#view-forum.active {
  position: fixed; inset: 0; z-index: 55;
  display: block; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: #090706;
  padding: 0 0 60px;
}
#view-forum .browse-head {
  position: sticky; top: 0; z-index: 40;
  margin: 0 0 14px; padding: 12px clamp(12px, 3vw, 24px) 12px;
  background: rgba(9, 7, 6, .96); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .45);
}
#view-forum .browse-head h1 { font-size: 19px; margin-bottom: 8px; }
#view-forum .browse-head .browse-tools { padding-right: 104px; }
#view-forum .forum-list { padding: 0 clamp(12px, 3vw, 24px); max-width: 1100px; margin: 0 auto; }
#view-forum .forum-nations { padding: 0 clamp(12px, 3vw, 24px); max-width: 1100px; margin: 0 auto 14px; }
#view-forum #forumMoreWrap { padding-bottom: 20px; }

/* 论坛帖子详情:整页沉浸(全屏 + 内部滚动) */
#postModal .modal.wide-modal { padding-bottom: 80px; }
#postModal > .modal { min-height: 100dvh; }

/* ---------- 5. 手机版:单列 / 输入吸底 / 字号下调 ---------- */
@media (max-width: 719.98px) {
  :root { --ds-col: 100%; }

  /* 手机不再显示细顶栏,内容直接铺满,固定控件浮在右上角 */
  body .topbar { display: none !important; }
  /* 顶部留出固定控件的高度,任何页面都不会被「三条杠 + 我的」压住 */
  .views { padding: 54px 10px 64px; min-height: 100dvh; }
  body:has(#view-chat.active) .views { padding: 0; min-height: 100dvh; }

  /* 卡牌浏览:标题让出固定控件的位置,搜索/筛选整行可用 */
  #view-cards .browse-head { margin: 0 0 10px; padding: 8px 0 10px; }
  #view-cards .browse-head h1 { font-size: 17px; padding-right: 94px; margin-bottom: 12px; }
  #view-cards .browse-head .browse-tools { padding-right: 0; gap: 8px; }
  #view-cards .searchbox { flex: 1 1 100%; }
  #view-cards .browse-tools .btn { flex: 1 1 auto; }
  #view-cards .result-note { width: 100%; margin-left: 0; }
  #view-cards .card-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }

  /* 对话页:整屏 + 输入吸底 + 安全区 */
  body:has(#view-chat.active) .chat-wrap { height: 100dvh; }
  .chat-head {
    height: 50px; padding: 6px 10px; padding-right: 96px; gap: 8px;
    background: rgba(9, 7, 6, .82);
  }
  .chat-head .ai-avatar { display: none; }
  .chat-ai-name { font-size: 13.5px; }
  .chat-ai-sub { display: none; }
  .chat-head .mode-switch { margin-left: 0; padding: 2px; }
  .chat-head .mode-btn { font-size: 11.5px; padding: 4px 9px; }
  .chat-head-tools { display: none; }
  .chat-body { padding: 14px 12px 4px; }
  .chat-log { gap: 22px; }
  .msg .bubble { font-size: 15px; line-height: 1.8; }
  .msg .msg-av { width: 24px; height: 24px; border-radius: 7px; }
  .msg.user .msg-main { max-width: 86%; }
  .msg.user .bubble { font-size: 14.5px; padding: 9px 14px; border-radius: 16px; }
  .msg-img img { width: 104px; height: 104px; }
  .chat-hello { padding: 22px 8px 4px; }
  .chat-hello-avatar { width: 56px; height: 56px; border-radius: 17px; }
  .chat-hello-name { font-size: 18px; }
  .chat-hello-ask { font-size: 13.5px; }
  .chat-hello-tips { margin-top: 14px; gap: 7px; }
  .chat-hello-tip { font-size: 12px; padding: 7px 12px; }
  .composer { padding: 4px 8px 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .ds-composer { border-radius: 20px; padding: 8px 10px 7px; }
  #chatInput { font-size: 16px; max-height: 120px; }   /* 16px 防 iOS 自动放大 */
  .ds-switch { height: 30px; padding: 0 10px; font-size: 12px; }
  .ds-switch span { font-size: 12px; }
  .ds-bar { row-gap: 6px; }
  .ds-icon-btn { width: 30px; height: 30px; }
  .send-btn { width: 32px; height: 32px; border-radius: 11px; }
  .composer-note { font-size: 10px; }
  .quick-actions { gap: 6px; }
  .quick-hint { display: none; }
  .guess-bar { gap: 8px; padding: 8px 10px; }
  .guess-hint { font-size: 12px; min-width: 0; flex: 1 1 100%; }
  .think { font-size: 12.5px; }
  .think-body { padding-left: 20px; }

  /* 论坛:标题与工具行压缩,帖子单列 */
  #view-forum .browse-head { padding: 10px 12px; }
  #view-forum .browse-head h1 { font-size: 16.5px; padding-right: 94px; margin-bottom: 12px; }
  #view-forum .browse-head .browse-tools { padding-right: 0; gap: 6px; }
  #view-forum .browse-head .result-note { display: none; }
  #view-forum .forum-list, #view-forum .forum-nations { padding-left: 10px; padding-right: 10px; }
  #view-forum .post-card { padding: 11px; }

  /* 其它页:标题、弹窗、卡片网格字号下调 */
  .browse-head h1, .deck-head h1, .res-head h2, .mk-head h2 { font-size: 17px; }
  .browse-head h1 { padding-right: 94px; white-space: nowrap; }
  /* 长说明副标题在手机上另起一行会挤坏标题,直接收起来 */
  .browse-head h1 .sub { display: none; }
  #view-cards .browse-head h1 .count-total { display: inline-block; }
  .deck-head .sub, .mk-sub { font-size: 12px; }
  .modal-mask.fullpage > .modal { padding: 16px 12px 44px; }
  .res-wrap { padding: 0 0 30px; }
  .notice-bar { margin-bottom: 10px; }
  .to-top { right: 12px; bottom: 16px; width: 40px; height: 40px; }
}

/* 更窄(≤420):进一步收紧 */
@media (max-width: 420px) {
  .ds-switch { padding: 0 8px; }
  .ds-switch span { font-size: 11.5px; }
  .ds-switch svg { width: 13px; height: 13px; }
  .msg-img img { width: 92px; height: 92px; }
}

/* ---------- 6. 「猜猜卡牌」独立页也按全屏处理(它本身是 100dvh 布局) ----------
   只在它 active 时生效,不影响别的页面。 */
body:has(#view-guess.active) .views { padding: 0; }
body:has(#view-guess.active) .topbar { display: none !important; }
body:has(#view-guess.active) .foot { display: none !important; }
/* 顶部右侧给固定的「三条杠 + 我的」让位,别压住猜卡自己的计分块 */
body:has(#view-guess.active) .guess-head { padding-right: 108px; }
@media (max-width: 719.98px) {
  body:has(#view-guess.active) .guess-head { padding-right: 96px; }
}

/* 站主:高窗口下底部黑带 —— 让视图区真正铺满视口 */
body { min-height: 100dvh; }
main.views { min-height: calc(100dvh - 56px); }
body.view-fill .view.active { min-height: calc(100dvh - 56px); }
