:root {
  --bg: #0f1420; --panel: #171e2e; --panel2: #1d2639; --line: #2a3550;
  --text: #e8ecf5; --dim: #8b96ad; --acc: #22c55e; --acc2: #3b82f6;
  --red: #ef4444; --user: #2a5480;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.65 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); display: flex; flex-direction: column; height: 100dvh; }
/* nginx 注入的 SEO 页脚：全端对用户隐藏（太占屏、挤压聊天区），HTML 仍在、蜘蛛可读 */
#seo-foot, body > div:not([id]):not([class]) { display: none !important; }
a { color: var(--acc2); }
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; outline: none; width: 100%; }
input:focus, textarea:focus { border-color: var(--acc2); }
input, textarea, select { font-size: 16px; }   /* iOS 聚焦防自动放大 */
.hidden { display: none !important; }

#topbar { display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.menu-btn { display: none; font-size: 16px; padding: 6px 10px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.quota { color: var(--dim); font-size: 13px; }
.quota b { color: var(--acc); font-weight: 600; }
.link { color: var(--acc2); text-decoration: none; font-size: 13px; white-space: nowrap; }

.btn { border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  border-radius: 8px; padding: 8px 14px; white-space: nowrap; }
.btn.primary { background: linear-gradient(135deg, #16a34a, #0d9488); border: none; color: #fff; font-weight: 600; }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.link-btn { background: none; border: none; color: var(--acc2); text-decoration: underline; padding: 0; font-size: 12px; }

#layout { flex: 1; display: flex; min-height: 0; }
#sidebar { width: 230px; flex-shrink: 0; border-right: 1px solid var(--line); background: var(--panel);
  padding: 12px; overflow-y: auto; }
#new-analysis-btn { margin-bottom: 12px; }
#drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; }
.sessions { display: flex; flex-direction: column; gap: 6px; }
.sess { padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--dim);
  border: 1px solid transparent; }
.sess:hover { background: var(--panel2); color: var(--text); }
.sess.active { background: var(--panel2); color: var(--text); border-color: var(--line); }
.sess .t { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess .d { font-size: 11px; }

#chat-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#chat { flex: 1; overflow-y: auto; padding: 22px 8%; scroll-behavior: smooth;
  overscroll-behavior: contain; font-size: 15px; }
/* 欢迎卡是 #chat 内的普通文档流块，随聊天内容滚动：
   曾是绝对定位悬浮层，矮视口/桌面会盖住输入区，2026-09-10 起废弃悬浮方案 */
#welcome { max-width: 600px; margin: 0 auto 18px; }
#welcome .w-card { width: 100%; }
.w-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px 22px; color: #a8b3c9; }
.w-card h2 { color: var(--text); font-size: 20px; margin: 0 0 10px; }
.w-card p { margin: 0 0 4px; font-size: 14px; }
.w-card b { color: var(--text); font-weight: 600; }
.price-line { display: inline-block; margin-top: 12px; padding: 6px 14px; border-radius: 999px;
  background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.35);
  color: #4ade80; font-size: 13px; font-weight: 600; }
.w-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.wtag { font-size: 12px; color: var(--dim); border: 1px solid var(--line);
  border-radius: 6px; padding: 3px 9px; }
.w-ex-label { margin-top: 16px; font-size: 13px; color: var(--dim); }
.w-ex { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.w-ex .ex { border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  border-radius: 999px; padding: 8px 16px; font-size: 14px; }
.w-ex .ex:hover, .w-ex .ex:active { border-color: var(--acc2); color: var(--acc2); }
.dim { color: var(--dim); } .small { font-size: 12px; }

.msg { margin: 14px 0; }
.msg .who { font-size: 12px; color: #94a5c2; margin-bottom: 4px; }
.bubble { border-radius: 12px; padding: 12px 16px; overflow-wrap: break-word; }
.user { display: flex; flex-direction: column; align-items: flex-end; }
.user .bubble { background: var(--user); max-width: 88%; }
.ai .bubble { background: #1a2337; border: 1px solid #33415e; }
.ai.failed .bubble { border-color: var(--red); }

.progress { color: var(--dim); font-size: 12.5px; padding: 4px 16px; }
details.think { margin: 6px 16px 10px; border: 1px dashed var(--line); border-radius: 8px;
  padding: 6px 10px; color: var(--dim); font-size: 13px; }
details.think summary { cursor: pointer; }
details.think .think-body { white-space: pre-wrap; max-height: 300px; overflow-y: auto; }
.report { min-width: 0; line-height: 1.75; }
.report h1, .report h2, .report h3, .report h4, .report b { color: #fff; }
.report table { border-collapse: collapse; margin: 0; font-size: 13px; }
/* 表格横向滚动容器（手机上报告表格常超宽）：圆角边框 + 两侧渐变边缘
   + "↔ 左右滑动查看"角标，JS initTblBoxes 按滚动位置点亮/熄灭 */
.tbl-box { position: relative; margin: 10px 0; }
.tbl-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: #33415e transparent; }
.tbl-scroll::-webkit-scrollbar { height: 6px; }
.tbl-scroll::-webkit-scrollbar-track { background: transparent; }
.tbl-scroll::-webkit-scrollbar-thumb { background: #33415e; border-radius: 3px; }
.report .tbl-scroll table { display: table; width: max-content; min-width: 100%;
  max-width: none; margin: 0; }
.tbl-box .fade-l, .tbl-box .fade-r { position: absolute; top: 1px; bottom: 1px;
  width: 30px; pointer-events: none; opacity: 0; transition: opacity .2s; z-index: 2; }
.tbl-box .fade-l { left: 1px; border-radius: 8px 0 0 8px;
  background: linear-gradient(to right, var(--panel), transparent); }
.tbl-box .fade-r { right: 1px; border-radius: 0 8px 8px 0;
  background: linear-gradient(to left, var(--panel), transparent); }
.tbl-box.scroll-l .fade-l, .tbl-box.scroll-r .fade-r { opacity: 1; }
.tbl-hint { position: absolute; right: 10px; bottom: 8px; font-size: 11px; color: var(--dim);
  background: rgba(23,30,46,.92); border: 1px solid var(--line); border-radius: 999px;
  padding: 2px 10px; pointer-events: none; opacity: 0; transition: opacity .25s; z-index: 3; }
.tbl-box.scroll-r .tbl-hint { opacity: 1; }
.tbl-box.no-scroll .fade-l, .tbl-box.no-scroll .fade-r, .tbl-box.no-scroll .tbl-hint {
  display: none; }
.report th, .report td { border: 1px solid var(--line); padding: 5px 10px; text-align: right; white-space: nowrap; }
.report th:first-child, .report td:first-child { text-align: left; }
.report th { background: var(--panel2); }
.report pre { background: #0b0f18; padding: 10px; border-radius: 8px; overflow-x: auto; }
.report code { background: #0b0f18; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.report h1, .report h2, .report h3 { margin: 16px 0 8px; }
.report blockquote { border-left: 3px solid var(--acc2); margin: 8px 0; padding: 2px 12px; color: #a9b6cd; }
.cost-tag { font-size: 12.5px; color: var(--dim); margin-top: 6px; }

#composer { border-top: 1px solid var(--line); background: var(--panel); padding: 12px 8%;
  position: sticky; bottom: 0; z-index: 20; box-shadow: 0 -10px 24px rgba(0,0,0,.42); }
#chips-row { display: flex; align-items: center; margin-bottom: 8px; }
.field-label { flex-shrink: 0; font-size: 13px; color: var(--dim); margin-right: 10px; }
.stock-field { position: relative; flex: 1; min-width: 0; }
#stock-input { height: 46px; border-radius: 10px; font-size: 16px; }
#stock-input::placeholder { color: #5b6780; }
.suggest { position: absolute; bottom: calc(100% + 4px); left: 0; right: 0; z-index: 45;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 -10px 30px rgba(0,0,0,.45); max-height: 264px; overflow-y: auto;
  -webkit-overflow-scrolling: touch; display: none; }
.suggest.show { display: block; }
.suggest div { display: flex; align-items: center; gap: 10px; padding: 11px 13px; cursor: pointer; }
.suggest div + div { border-top: 1px solid rgba(42,53,80,.5); }
.suggest div:hover, .suggest div:active { background: var(--line); }
.suggest b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.suggest .scode { color: var(--dim); font-size: 12px; flex-shrink: 0; }
.suggest .mkt { margin-left: auto; flex-shrink: 0; }
.mkt { font-size: 11px; line-height: 1.4; border-radius: 5px; padding: 1px 7px; white-space: nowrap; }
.m-A { background: rgba(34,197,94,.14); color: #4ade80; }
.m-HK { background: rgba(245,158,11,.14); color: #fbbf24; }
.m-US { background: rgba(59,130,246,.14); color: #60a5fa; }
.picked { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 7px 12px;
  background: rgba(34,197,94,.07); border: 1px solid rgba(34,197,94,.3); border-radius: 10px;
  font-size: 13px; }
.picked .pk-name { color: var(--text); font-weight: 600; }
.picked .pk-code { color: var(--dim); }
.picked .pk-warn { color: #fbbf24; font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chip { border: 1px solid var(--line); background: var(--panel2); color: var(--dim);
  border-radius: 16px; padding: 6px 14px; font-size: 13px; }
.chip.on { color: #fff; background: var(--acc2); border-color: var(--acc2); }
/* 快捷短语入口 chip（用户话术，区别于官方模板的琥珀色虚线） */
.chip.chip-qs { border-style: dashed; border-color: rgba(245,158,11,.55);
  color: #fbbf24; background: rgba(245,158,11,.06); flex-shrink: 0; }
.input-row { display: flex; gap: 10px; }
#question { flex: 1; resize: none; min-height: 44px; border-radius: 10px; }
.composer-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px;
  color: var(--dim); font-size: 12px; }
#mode-hint.warn { color: #fbbf24; font-weight: 600; }
.meta-actions { display: flex; gap: 12px; white-space: nowrap; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex;
  align-items: center; justify-content: center; z-index: 50; }
.modal.hidden { display: none; }
.modal-card { width: 380px; max-width: 92vw; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
#auth-form { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.modal-card.wide { width: 620px; max-height: 80vh; display: flex; flex-direction: column; }
.tabs { display: flex; gap: 4px; padding: 10px 14px; border-bottom: 1px solid var(--line);
  align-items: center; justify-content: space-between; }
.tab { background: none; border: none; color: var(--dim); font-size: 15px; padding: 4px 10px; }
.tab.active { color: var(--text); font-weight: 600; border-bottom: 2px solid var(--acc); }
.modal-close { background: none; border: none; color: var(--dim); font-size: 20px; padding: 4px 10px; }
.tab-body { padding: 16px; display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto; min-height: 0; }
.msg-line { color: var(--red); font-size: 13px; min-height: 16px; }
.msg-line.ok { color: var(--acc); }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; min-width: 0; letter-spacing: 3px; }
.code-btn { flex-shrink: 0; white-space: nowrap; padding: 9px 14px; }
.share-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.share-body .code-row input { letter-spacing: normal; font-size: 13px; }

.history-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; }
.hitem { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.hitem:hover { background: var(--panel2); }
.hitem .s { color: var(--dim); font-size: 12px; }

.toast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  background: #26324b; border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 10px; z-index: 60; max-width: 84vw; }
.toast.hidden { display: none; }

/* ================= 快捷短语抽屉（v1.2.0） ================= */
.prompt-sheet { width: 560px; max-height: 88vh; display: flex; flex-direction: column; }
.pm-body { flex: 1; overflow-y: auto; min-height: 240px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px; -webkit-overflow-scrolling: touch; }
.pm-list { display: flex; flex-direction: column; gap: 8px; }
.pm-empty { text-align: center; padding: 22px 0; }
.pm-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  cursor: pointer; display: flex; gap: 10px; align-items: flex-start; }
.pm-row .cb { flex: 0 0 20px; width: 20px; height: 20px; border: 1.5px solid var(--dim);
  border-radius: 6px; margin-top: 1px; position: relative; }
.pm-row.on .cb { background: var(--acc2); border-color: var(--acc2); }
.pm-row.on .cb::after { content: '✓'; position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center; color: #fff; font-size: 13px; }
.pm-row.on { border-color: var(--acc2); background: rgba(59,130,246,.08); }
.pm-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pm-main .t { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-main .t .s { color: var(--dim); font-weight: 400; font-size: 11px; }
.pm-main .c { color: var(--dim); font-size: 12.5px; line-height: 1.5; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pm-main .c.old { opacity: .55; text-decoration: line-through; }
.pm-row.dup .t { color: #fbbf24; }
.pm-row.manage { cursor: default; align-items: center; }
.pm-row.manage .cb { display: none; }
.pm-acts { display: flex; gap: 4px; flex-shrink: 0; }
.pm-act { background: none; border: 1px solid var(--line); color: var(--dim);
  border-radius: 7px; font-size: 12px; padding: 6px 9px; }
.pm-act:active { border-color: var(--acc2); color: var(--acc2); }
.pm-act.danger { color: #f87171; border-color: rgba(239,68,68,.4); }
.pm-actions-row { display: flex; gap: 8px; }
.pm-actions-row .btn { flex: 1; padding: 11px 6px; font-size: 13px; }
.pm-back-row { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.pm-back-row .link-btn { font-size: 14px; }
.pm-counter { text-align: right; color: var(--dim); font-size: 12px; margin-top: -4px; }
.pm-edit-btns { display: flex; gap: 8px; }
.pm-edit-btns .btn { flex: 1; }
#pm-content { min-height: 200px; }
.pm-sec { color: var(--dim); font-size: 12px; margin-top: 6px; }
.pm-prev { border: 1px dashed var(--acc); border-radius: 10px; padding: 10px 12px;
  background: rgba(34,197,94,.06); }
.pm-prev .t { color: #4ade80; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.pm-prev .txt { white-space: pre-wrap; font-size: 13px; max-height: 220px; overflow-y: auto; }
.pm-prev .row { display: flex; gap: 8px; margin-top: 8px; }
.pm-prev .row .btn { flex: 1; font-size: 12px; padding: 8px 4px; }
.pm-foot { border-top: 1px solid var(--line); padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; }
.pm-selinfo { flex: 1; color: var(--dim); font-size: 12.5px; }

/* ================= 移动端 ================= */
@media (max-width: 760px) {
  /* 应用式三段布局（body 100dvh + 内滚聊天 + composer 钉底 + SEO 页脚隐藏）已全端生效，
     这里只做小屏紧凑化 */
  #topbar { padding: 8px 8px; gap: 6px; }
  .brand { font-size: 14.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .menu-btn { display: inline-block; padding: 7px 9px; flex-shrink: 0; }
  .top-right { gap: 5px; flex-shrink: 0; }
  .quota { display: none; }              /* 小屏藏配额详情，输入区提示里会显示 */
  .top-right .btn { padding: 8px 9px; font-size: 13px; }  /* nowrap 防止"笔记"竖排断字 */
  .top-right .link { font-size: 12.5px; }

  #sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: 78vw; max-width: 300px;
    transform: translateX(-105%); transition: transform .22s ease; border-right: 1px solid var(--line);
    padding-top: 14px; }
  #sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.5); }

  #chat { padding: 14px 12px 18px; }
  .msg { margin: 16px 0; }
  .bubble { padding: 12px 14px; }
  .user .bubble { max-width: 92%; }
  .w-card { padding: 16px 16px; border-radius: 12px; }
  .w-card h2 { font-size: 18px; }
  .w-card p { font-size: 13.5px; }
  .w-ex .ex { padding: 9px 16px; }       /* 触控友好 */

  #composer { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .composer-meta .link-btn { font-size: 13px; padding: 5px 0; }
  .field-label { font-size: 12px; margin-right: 8px; }
  #stock-input { height: 48px; }
  .suggest { max-height: min(320px, 44vh); }
  .suggest div { padding: 13px 13px; }   /* 大触控行 */
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex-shrink: 0; padding: 8px 15px; }
  .input-row { align-items: flex-end; gap: 8px; }
  #question { min-height: 46px; }
  #send-btn { padding: 13px 18px; font-size: 15px; flex-shrink: 0; }
  .composer-meta { flex-wrap: wrap; }

  .modal { align-items: flex-end; }     /* 弹层变底部抽屉 */
  .modal-card { width: 100%; max-width: 100%; border-radius: 16px 16px 0 0;
    max-height: 86vh; overflow-y: auto; }
  .modal-card.wide { max-height: 86vh; }
  .prompt-sheet { width: 100%; max-height: 92vh; overflow: hidden; }
  .pm-body { padding-bottom: calc(18px + env(safe-area-inset-bottom)); } /* 无底栏时动作不贴手势条 */
  .pm-row { padding: 12px; }            /* 大触控行 */
  .pm-act { padding: 10px 12px; min-height: 40px; }  /* 触控热区接近 44px */
  .pm-row.manage { align-items: flex-start; }
  details.think .think-body { max-height: 40vh; }
  .report table { font-size: 12.5px; }
}

/* 超窄屏（≤400px）：顶栏再压一档，品牌名超宽时省略号兜底 */
@media (max-width: 400px) {
  .brand { font-size: 13px; }
  .top-right { gap: 4px; }
  .top-right .btn { padding: 8px 7px; font-size: 12.5px; }
  .top-right .link { font-size: 12px; }
}

/* 沙箱图表（AI 分析配图，report 与 share 页共用） */
.md-img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line);
  margin: 6px 0; display: block; background: #fff; }

/* ---------- 股票笔记（v1.3.0：报告自动入库 + 追问手动存入，按股票归档） ---------- */
.nm-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nm-head b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nm-body { overflow-y: auto; flex: 1; min-height: 220px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.nm-list { display: flex; flex-direction: column; gap: 8px; }
.nm-folder, .nm-item { border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; cursor: pointer; background: var(--panel); }
.nm-folder:hover, .nm-item:hover { background: var(--panel2); }
.nm-folder { display: flex; align-items: center; gap: 10px; }
.nm-folder .ic { font-size: 20px; }
.nm-row { display: flex; align-items: flex-start; gap: 8px; }
.nm-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.nm-main .t { font-weight: 600; font-size: 14px; }
.nm-main .t .scode { font-weight: 400; color: var(--dim); font-size: 12px; }
.nm-main .c { color: var(--dim); font-size: 12px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.nm-main .c.s { -webkit-line-clamp: 1; }
.nm-kind { flex: 0 0 auto; font-size: 11px; border-radius: 6px; padding: 2px 7px; margin-top: 2px;
  background: var(--panel2); color: var(--dim); border: 1px solid var(--line); }
.nm-kind.k-analysis { color: var(--acc2); border-color: rgba(59,130,246,.4); }
.nm-acts { flex: 0 0 auto; display: flex; gap: 6px; }
.nm-full { border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 10px;
  font-size: 13px; cursor: default; }
.nm-full.hidden { display: none; }
.nm-empty { text-align: center; padding: 30px 10px; line-height: 2; }
.ans-acts { margin-top: 4px; }
.ans-acts .link-btn { font-size: 12px; }
.ans-acts .link-btn:disabled { color: var(--dim); text-decoration: none; cursor: default; }
