/* 股票龙虾移动端样式：深色主题，iPhone 优先 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0d1117; --card: #161b22; --border: #30363d;
  --text: #e6edf3; --dim: #a0adba; --accent: #76ddcb;
  --up: #f85149; --down: #3fb950; /* A股惯例：红涨绿跌 */
}
html, body { height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 15px; overscroll-behavior: none; }
.hidden { display: none !important; }

.view { display: none; height: 100vh; height: 100dvh; flex-direction: column; } /* 先 vh 后 dvh：旧安卓 Chrome<108 不认 dvh 时用 vh 兜底 */
.view.active { display: flex; }

/* —— 登录页 —— */
#view-auth { align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.logo { font-size: 56px; }
.auth-card h1 { font-size: 24px; }
.slogan { color: var(--dim); margin-bottom: 16px; }
input { background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 13px 14px; color: var(--text); font-size: 16px; outline: none; }
input:focus { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: #1a0d14; border: none; border-radius: 10px;
  padding: 13px; font-size: 16px; font-weight: 600; }
.btn-ghost { background: none; border: 1px solid var(--border); border-radius: 10px;
  padding: 11px; color: var(--dim); font-size: 14px; }
.err { color: var(--up); min-height: 20px; font-size: 13px; }

/* —— 顶栏/底栏 —— */
#topbar { display: flex; align-items: center; justify-content: center; position: relative;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px; border-bottom: 1px solid var(--border); }
.topbar-title { font-size: 17px; font-weight: 600; }
.dot { position: absolute; right: 20px; top: 50%; width: 9px; height: 9px;
  background: var(--up); border-radius: 50%; }
#tabbar { display: flex; border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); background: var(--card); }
.tab-btn { flex: 1; background: none; border: none; color: var(--dim); font-size: 18px;
  padding: 8px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tab-btn span { font-size: 11px; }
.tab-btn.active { color: var(--accent); }

.tabpage { display: none; flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 14px; }
.tabpage.active { display: block; }

/* —— 行情 —— */
.add-row { display: flex; gap: 8px; margin-bottom: 12px; }
.add-row input { flex: 1; }
.add-row button { background: var(--accent); color: #1a0d14; border: none;
  border-radius: 10px; padding: 0 16px; font-weight: 600; }
.empty { color: var(--dim); text-align: center; padding: 48px 0; font-size: 14px; }
.stock-list { list-style: none; }
.stock-item { display: flex; align-items: center; background: var(--card);
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.stock-item .info { flex: 1; }
.stock-item .name { font-weight: 600; }
.stock-item .code { color: var(--dim); font-size: 12px; }
.stock-item .price { text-align: right; min-width: 90px; }
.stock-item .p { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stock-item .pct { font-size: 13px; font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--dim); }
.stock-item .del { background: none; border: none; color: var(--dim); font-size: 16px; padding: 4px 8px; }

#kline-box { position: fixed; inset: auto 0 0 0; background: var(--card);
  border-top: 1px solid var(--border); border-radius: 16px 16px 0 0; padding: 12px;
  padding-bottom: calc(env(safe-area-inset-bottom) + 12px); }
.kline-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.kline-head button { background: none; border: none; color: var(--dim); font-size: 18px; }
#kline-canvas { width: 100%; height: 220px; }

/* —— 资讯 —— */
.post-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; margin-bottom: 10px; }
.post-card h3 { font-size: 16px; margin-bottom: 6px; }
.post-card .time { color: var(--dim); font-size: 12px; margin-bottom: 8px; }
.post-card .body { color: var(--text); font-size: 14px; line-height: 1.7; white-space: pre-wrap; }
.post-card .tags { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.post-card .tag { font-size: 11px; color: var(--accent); border: 1px solid var(--accent);
  border-radius: 20px; padding: 2px 8px; }


/* —— 聊天 —— */
#tab-chat { display: none; flex-direction: column; }
#tab-chat.active { display: flex; }
#chat-msgs { flex: 1; overflow-y: auto; padding-bottom: 8px; }
.msg { max-width: 85%; padding: 10px 13px; border-radius: 14px; margin-bottom: 10px;
  font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.msg.user { margin-left: auto; background: var(--accent); color: #1a0d14; border-bottom-right-radius: 4px; }
.msg.ai { background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.ai.streaming::after { content: '▍'; color: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }
.chat-input-row { display: flex; gap: 8px; padding: 8px 0 calc(env(safe-area-inset-bottom) + 4px); }
.chat-input-row input { flex: 1; }
.chat-input-row button { background: var(--accent); color: #1a0d14; border: none;
  border-radius: 10px; padding: 0 18px; font-weight: 600; }
.chat-input-row button:disabled { opacity: 0.4; }

/* —— 我的 —— */
.me-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.me-email { font-weight: 600; margin-bottom: 12px; }
.me-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; }
.me-row input[type=number] { width: 64px; text-align: center; padding: 6px; }
.me-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.me-sub { margin: 18px 0 8px; font-size: 14px; color: var(--dim); }
.notif-list { list-style: none; margin-bottom: 16px; }
.notif-item { background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 6px; }
.notif-item .t { font-weight: 600; font-size: 14px; }
.notif-item .b { color: var(--dim); font-size: 13px; margin-top: 4px; line-height: 1.5; }
.notif-item .time { color: var(--dim); font-size: 11px; margin-top: 4px; }
.notif-item.unread { border-color: var(--accent); }


/* 研究工作台保留深色底，在手机上按单列阅读，宽屏增加留白。 */
button { cursor: pointer; font-family: inherit; min-height: 44px; }
button:disabled { opacity: .5; cursor: wait; }
button:focus-visible, a:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input, textarea { min-width: 0; font-family: inherit; }
textarea { width: 100%; resize: vertical; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 12px; font-size: 16px; line-height: 1.6; }
a { color: var(--accent); text-decoration: none; overflow-wrap: anywhere; }
a:hover { text-decoration: underline; }
h2 { font-size: 17px; } h3 { font-size: 15px; }
.muted { color: var(--dim); font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.eyebrow { color: var(--accent); font-size: 12px; letter-spacing: 1px; margin-bottom: 8px; }
#app { max-width: 1080px; margin: auto; }
#view-main { min-height: 0; }
#topbar { background: var(--bg); flex: none; }
#tabbar { flex: none; }
.tabpage { min-height: 0; padding: 18px 16px 24px; }
.market-hero { padding: 22px; background: linear-gradient(135deg, #203936, #171f2b 75%); border: 1px solid #35504c; border-radius: 20px; margin-bottom: 20px; }
.market-hero h1 { font-size: 24px; line-height: 1.45; margin-bottom: 10px; }
.market-hero .btn-ghost { margin-top: 12px; }
.market-hero textarea { margin: 10px 0; }
.market-hero label { display: block; margin-top: 16px; font-size: 13px; }
.breadth { display: flex; gap: 24px; margin: 16px 0; }
.breadth strong { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 22px 0 12px; }
.section-heading span { color: var(--dim); font-size: 11px; }
.sector-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sector-card { background: #18232d; border: 1px solid var(--border); border-radius: 13px; padding: 13px; text-align: left; color: var(--text); }
.sector-card strong { display: block; margin-bottom: 5px; }
.candidate-list { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 12px 0; }
.candidate { display: flex; gap: 12px; justify-content: space-between; align-items: center; text-align: left; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.candidate small { display: block; margin-top: 4px; color: var(--dim); }
.stock-item .info { cursor: pointer; min-width: 0; }
.stock-item .del { min-width: 44px; }
.post-card { border-radius: 16px; padding: 18px; }
.post-card h3 { line-height: 1.5; }
.post-card .body, .task-result { line-height: 1.85; overflow-wrap: anywhere; white-space: pre-wrap; }
.post-card .tag { cursor: pointer; background: none; padding: 5px 12px; }
.task-presets { display: flex; gap: 8px; flex-wrap: wrap; }
.task-status { font-size: 12px; color: var(--accent); }
.task-result { font-size: 14px; margin-top: 12px; }
.task-result summary { cursor: pointer; color: var(--accent); padding: 8px 0; }
#kline-box { z-index: 10; max-height: 90vh; max-height: 90dvh; overflow-y: auto; max-width: 760px; margin: auto; padding: 20px; box-shadow: 0 -20px 90px #000a; }
.kline-head { position: sticky; top: -20px; padding: 12px 0; background: var(--card); z-index: 1; }
.kline-head button { min-width: 44px; }
.detail-price { font-size: 30px; margin: 12px 0; font-variant-numeric: tabular-nums; }
.metrics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.metric { padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.metric strong { display: block; margin: 6px 0; font-size: 19px; }
.metric summary { color: var(--dim); font-size: 12px; cursor: pointer; }
.metric p { font-size: 12px; line-height: 1.6; margin-top: 8px; }
.detail-actions { display: flex; gap: 10px; margin: 14px 0 20px; }
.detail-actions button { flex: 1; }
.source-item { display: block; padding: 12px 0; border-bottom: 1px solid var(--border); line-height: 1.6; font-size: 14px; }
.source-item small { display: block; color: var(--dim); }
.warning { color: #e6b66d; font-size: 12px; line-height: 1.7; white-space: pre-wrap; }
.notif-item { cursor: pointer; overflow-wrap: anywhere; }
#service-status { white-space: pre-line; }
#chat-msgs { min-height: 0; }
.chat-input-row { flex: none; }
@media (min-width: 700px) {
  .tabpage { padding: 24px 36px; }
  .sector-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .candidate-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .auth-card { max-width: 380px; }
}
@media (prefers-reduced-motion: reduce) { .msg.ai.streaming::after { animation: none; } }
.category-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; }
.category-tabs button { flex: none; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; color: var(--dim); background: var(--card); }
.category-tabs button.active { color: var(--bg); background: var(--accent); border-color: var(--accent); }
#notification-category { width: 100%; margin: 8px 0 12px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); font-size: 16px; }
.report-dialog { position: fixed; inset: auto 0 0; z-index: 12; max-width: 760px; max-height: 90dvh; margin: auto; padding: 20px; overflow-y: auto; background: var(--card); border: 1px solid var(--border); border-radius: 18px 18px 0 0; box-shadow: 0 -20px 90px #000a; padding-bottom: calc(env(safe-area-inset-bottom) + 20px); }
.report-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.85; margin: 16px 0; }
.signal-check { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; line-height: 1.7; }
.signal-check strong { color: var(--accent); }
#market-status, .notif-item .b { white-space: pre-line; }

/* —— 长辈模式：html.elder 由 JS 按 localStorage 挂载，全局放大 + 提亮次要文字 —— */
.elder-toggle { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--dim); font-size: 15px; }
.elder-toggle input { width: 20px; height: 20px; accent-color: var(--accent); }
.hero-actions { display: flex; gap: 10px; }
.hero-actions button { flex: 1; }
html.elder, html.elder body { font-size: 18px; }
html.elder .muted, html.elder .post-card .time, html.elder .ai-mark, html.elder .code { color: #c4cdd8; font-size: 14px; }
html.elder button { min-height: 52px; }
html.elder .btn-primary, html.elder .btn-ghost { font-size: 18px; padding: 14px; }
html.elder input, html.elder textarea, html.elder select { font-size: 19px; padding: 15px 14px; }
html.elder .tab-btn { font-size: 22px; padding: 10px 0 8px; }
html.elder .tab-btn span { font-size: 14px; }
html.elder .topbar-title { font-size: 21px; }
html.elder h2 { font-size: 21px; } html.elder h3 { font-size: 18px; }
html.elder .market-hero h1 { font-size: 28px; }
html.elder .stock-item .p { font-size: 22px; }
html.elder .stock-item .pct { font-size: 16px; }
html.elder .post-card .body, html.elder .msg, html.elder .task-result, html.elder .report-text { font-size: 17px; line-height: 1.9; }
html.elder .detail-price { font-size: 36px; }
html.elder .breadth strong { font-size: 28px; }
html.elder .metric strong { font-size: 23px; }
html.elder .elder-toggle { color: var(--text); font-size: 16px; }

/* —— 思考气泡（AI 思考流，回答完成后收起可回看） —— */
.think { margin: 0 0 10px; max-width: 85%; border-left: 3px solid var(--border); padding: 6px 10px; font-size: 13px; color: var(--dim); background: rgba(255,255,255,.03); border-radius: 8px; }
.think summary { cursor: pointer; color: var(--accent); font-size: 12px; }
.think-body { white-space: pre-wrap; line-height: 1.6; max-height: 40vh; overflow-y: auto; margin-top: 6px; }
html.elder .think { font-size: 15px; }

/* —— Markdown 渲染（报告/聊天/任务结果：标题/表格/列表/引用/行内码） —— */
.md-h1, .md-h2, .md-h3, .md-h4 { font-weight: 600; margin: 12px 0 6px; line-height: 1.4; }
.md-h1 { font-size: 17px; } .md-h2 { font-size: 16px; } .md-h3 { font-size: 15px; } .md-h4 { font-size: 14px; }
th, td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }
table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 13px; }
th { background: rgba(255,255,255,.05); }
blockquote { border-left: 3px solid var(--accent); margin: 8px 0; padding: 4px 10px; color: var(--dim); }
code { background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 5px; font-size: .92em; }
html.elder th, html.elder td { font-size: 15px; padding: 8px 10px; }
