/* =========================================================
   棠安辞量化 · 设计系统
   奶油低饱和 / 玻璃拟态 / Bento / 移动优先 / PC 侧栏
   红涨绿跌（中国市场惯例）
========================================================= */
:root {
  --bg: #f6f3ec;
  --bg-2: #efe9dd;
  --card: rgba(255, 253, 248, .78);
  --card-solid: #fffdf8;
  --border: rgba(120, 100, 60, .12);
  --border-strong: rgba(120, 100, 60, .22);
  --text: #2e2a24;
  --text-2: #6f675a;
  --muted: #9a917f;
  --accent: #b08a3e;
  --accent-2: #c9a86c;
  --accent-soft: rgba(176, 138, 62, .12);
  --up: #d5493c;
  --up-soft: rgba(213, 73, 60, .1);
  --down: #1f8a5f;
  --down-soft: rgba(31, 138, 95, .1);
  --danger: #c0453a;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 10px 40px rgba(110, 90, 50, .08);
  --shadow-sm: 0 4px 18px rgba(110, 90, 50, .07);
  --blur: blur(16px);
  --side-w: 232px;
  --tabbar-h: 62px;
  font-size: 15px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg);
  background-image: radial-gradient(1200px 600px at 85% -10%, rgba(201, 168, 108, .14), transparent 60%),
                    radial-gradient(900px 500px at -10% 110%, rgba(176, 138, 62, .08), transparent 55%);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }
::selection { background: rgba(201, 168, 108, .35); }

/* ---------------- 通用组件 ---------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  padding: 20px 22px;
  transition: box-shadow .25s ease, transform .25s ease;
}
.card:hover { box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title { font-size: 16px; font-weight: 700; letter-spacing: .3px; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-body-center { display: flex; flex-direction: column; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 12px; cursor: pointer;
  font-size: 14px; font-weight: 600; padding: 9px 18px;
  transition: all .2s ease; user-select: none; white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, #c39a4e, #a87f37); color: #fff; box-shadow: 0 6px 18px rgba(168, 127, 55, .3); }
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-ghost { background: rgba(255, 255, 255, .6); border-color: var(--border-strong); color: var(--text-2); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: #fff; }
.btn-danger { background: var(--up-soft); color: var(--up); border-color: rgba(213, 73, 60, .25); }
.btn-danger:hover { background: var(--up); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 13px; font-size: 13px; border-radius: 10px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; padding: 4px 11px; border-radius: 999px;
  background: rgba(255,255,255,.65); border: 1px solid var(--border); color: var(--text-2);
}
.chip-ok { background: var(--down-soft); color: var(--down); border-color: rgba(31,138,95,.2); }
.chip-warn { background: var(--accent-soft); color: var(--accent); border-color: rgba(176,138,62,.25); animation: pulse 2.4s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(176,138,62,.25);} 50% { box-shadow: 0 0 0 6px rgba(176,138,62,0);} }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea,
.code-row input, #init-token-input {
  width: 100%; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: rgba(255,255,255,.75);
  font-size: 14.5px; color: var(--text); outline: none; transition: border .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .code-row input:focus, #init-token-input:focus {
  border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(201, 168, 108, .18);
}
.chk { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); cursor: pointer; margin: 8px 0; }
.chk input { width: 16px; height: 16px; accent-color: var(--accent); }

.up { color: var(--up) !important; }
.down { color: var(--down) !important; }

.tip-line { font-size: 12px; color: var(--muted); line-height: 1.7; }
.kv-list { display: flex; flex-direction: column; gap: 4px; }
.kv { display: flex; justify-content: space-between; padding: 9px 4px; border-bottom: 1px dashed var(--border); font-size: 14px; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; word-break: break-all; text-align: right; }

/* hidden 属性必须压过任何 display 规则（.loading-line/.empty-hint 等 flex 布局会覆盖 UA 默认值，
   曾导致持仓页"未绑定提示/加载中/持仓内容"三者同时显示） */
[hidden] { display: none !important; }

.skeleton { position: relative; overflow: hidden; background: rgba(120, 100, 60, .08); border-radius: 8px; color: transparent !important; }
.skeleton::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { from { transform: translateX(-100%);} to { transform: translateX(100%);} }
.skeleton-block { height: 60px; border-radius: 12px; }

.loading-line { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13.5px; padding: 18px 4px; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(176,138,62,.25); border-top-color: var(--accent); animation: rotate .8s linear infinite; display: inline-block; }
@keyframes rotate { to { transform: rotate(360deg); } }

.empty-hint { text-align: center; padding: 30px 10px; color: var(--text-2); display: flex; flex-direction: column; gap: 14px; align-items: center; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: rgba(46, 42, 36, .92); color: #fff; padding: 10px 20px; border-radius: 12px;
  font-size: 13.5px; z-index: 999; opacity: 0; transition: all .3s ease; max-width: 88vw; text-align: center;
  backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal { position: fixed; inset: 0; background: rgba(40, 34, 24, .4); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 500; padding: 16px; animation: fadeIn .2s ease; }
.modal[hidden] { display: none; }
.modal-box { background: var(--card-solid); border-radius: 22px; box-shadow: var(--shadow); width: 100%; max-width: 520px; max-height: 88vh; display: flex; flex-direction: column; animation: slideUp .25s ease; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 0; }
.modal-close { border: none; background: none; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1; padding: 4px 8px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 22px 22px; overflow-y: auto; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------- 布局：Bento ---------------- */
.bento { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.card-span-2 { grid-column: span 2; }
.card-span-3 { grid-column: span 3; }

/* ---------------- 应用壳 ---------------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 40;
  background: rgba(250, 246, 238, .9); backdrop-filter: var(--blur);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 22px 14px;
}
.side-head { display: flex; gap: 11px; align-items: center; padding: 2px 10px 20px; }
.logo-badge {
  width: 42px; height: 42px; border-radius: 14px; flex: none;
  background: linear-gradient(135deg, #c9a86c, #a87f37); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700;
  box-shadow: 0 6px 16px rgba(168, 127, 55, .35);
}
.logo-badge-lg { width: 52px; height: 52px; font-size: 26px; border-radius: 17px; }
.side-title { font-weight: 800; font-size: 17px; letter-spacing: 1px; }
.side-sub { font-size: 11px; color: var(--muted); }
.side-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.side-link {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 13px;
  color: var(--text-2); font-size: 14.5px; font-weight: 600; transition: all .18s ease; position: relative;
}
.side-link:hover { background: rgba(255,255,255,.8); color: var(--text); }
.side-link.active { background: linear-gradient(135deg, rgba(201,168,108,.22), rgba(176,138,62,.12)); color: var(--accent); }
.side-ico { width: 20px; text-align: center; font-size: 15px; opacity: .9; }
.dot-alert { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 7px; height: 7px; border-radius: 50%; background: var(--up); animation: pulse 2s infinite; }
.side-foot { border-top: 1px dashed var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.side-user { display: flex; gap: 10px; align-items: center; padding: 6px 10px; }
.avatar { width: 36px; height: 36px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.side-user-name { font-size: 13.5px; font-weight: 700; }
.side-user-mail { font-size: 11px; color: var(--muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-logout { color: var(--muted); font-size: 13.5px; padding: 9px 14px; }
.side-logout:hover { color: var(--danger); }

.main-area { flex: 1; margin-left: var(--side-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; background: rgba(246, 243, 236, .82); backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 19px; font-weight: 800; letter-spacing: .5px; }
.page-wrap { padding: 22px 28px 40px; max-width: 1240px; width: 100%; margin: 0 auto; animation: fadeIn .3s ease; }

.tabbar { display: none; }

/* ---------------- 仪表盘 ---------------- */
.hero-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 6px 0 16px; }
.hero-label { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.hero-value { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .3px; }
.hero-list { display: flex; flex-direction: column; gap: 2px; }
.mini-list { display: flex; flex-direction: column; gap: 4px; }
.mini-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.mini-item:last-child { border-bottom: none; }
.mini-item-time { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; flex: none; }
.mini-item-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.ai-entry-card { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; position: relative; overflow: hidden; }
.ai-entry-glow {
  position: absolute; right: -14px; top: -18px; font-size: 110px; color: rgba(201, 168, 108, .16);
  line-height: 1; pointer-events: none; font-weight: 700;
}
.ai-entry-text { font-size: 13px; color: var(--text-2); }
.hot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.hot-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-radius: 14px; background: rgba(255,255,255,.55); border: 1px solid var(--border); }
.hot-name { font-size: 13px; font-weight: 600; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hot-code { font-size: 11px; color: var(--muted); }
.hot-chg { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------------- 市场 ---------------- */
.search-box { display: flex; gap: 10px; }
.search-box input {
  flex: 1; padding: 12px 16px; border-radius: 14px; border: 1px solid var(--border-strong);
  background: rgba(255,255,255,.8); font-size: 15px; outline: none; transition: all .2s;
}
.search-box input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(201,168,108,.18); }
.type-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn {
  border: 1px solid var(--border); background: rgba(255,255,255,.6); color: var(--text-2);
  padding: 5px 13px; border-radius: 999px; font-size: 12.5px; cursor: pointer; transition: all .18s;
}
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.chip-btn.active { background: linear-gradient(135deg, #c9a86c, #a87f37); color: #fff; border-color: transparent; }
.fund-list { display: flex; flex-direction: column; }
.fund-row { display: flex; align-items: center; gap: 14px; padding: 13px 6px; border-bottom: 1px dashed var(--border); transition: background .15s; border-radius: 10px; }
.fund-row:hover { background: rgba(255,255,255,.5); }
.fund-row:last-child { border-bottom: none; }
.fund-info { flex: 1; min-width: 0; cursor: pointer; }
.fund-name { font-size: 14.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fund-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.fund-quote { text-align: right; min-width: 92px; }
.fund-nav { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.fund-chg { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* 净值图（canvas 弹窗内） */
.nav-chart-box { width: 100%; height: 200px; background: rgba(255,255,255,.5); border-radius: 14px; border: 1px solid var(--border); padding: 10px; }
.nav-chart-box canvas { width: 100%; height: 100%; }
.range-chips { display: flex; gap: 6px; margin: 10px 0 6px; }

/* ---------------- 持仓 ---------------- */
.ov-wallet { margin-bottom: 18px; }
.ov-section-title { font-size: 15px; font-weight: 800; margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.ov-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.ov-stat { background: rgba(255,255,255,.55); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; }
.ov-stat .l { font-size: 12px; color: var(--muted); }
.ov-stat .v { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
table.md-table { width: 100%; border-collapse: collapse; font-size: 13px; background: rgba(255,255,255,.5); border-radius: 12px; overflow: hidden; }
table.md-table th { background: rgba(201,168,108,.13); color: var(--text-2); font-weight: 700; padding: 9px 10px; text-align: left; white-space: nowrap; font-size: 12.5px; }
table.md-table td { padding: 9px 10px; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
table.md-table td.num, table.md-table th.num { text-align: right; }

/* ---------------- 交易 ---------------- */
.trade-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.trade-filters input[type=date] { padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border-strong); background: rgba(255,255,255,.75); font-size: 13px; color: var(--text); }
.trade-item { border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; margin-bottom: 10px; background: rgba(255,255,255,.55); }
.trade-item-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.trade-type { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.trade-type.buy { background: var(--up-soft); color: var(--up); }
.trade-type.sell { background: var(--down-soft); color: var(--down); }
.trade-type.other { background: rgba(201,168,108,.14); color: var(--accent); }
.trade-status { font-size: 12.5px; font-weight: 700; }
.trade-fund { font-size: 14.5px; font-weight: 700; margin: 8px 0 2px; }
.trade-meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.trade-amount { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.trade-actions { margin-top: 10px; display: flex; gap: 8px; }
.pager { display: flex; gap: 8px; justify-content: center; padding: 10px 0; }

/* ---------------- 聊天 ---------------- */
.chat-layout { display: flex; gap: 16px; height: calc(100vh - 130px); min-height: 480px; }
.chat-main { flex: 1; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 22px; scroll-behavior: smooth; }
.chat-welcome { text-align: center; padding: 40px 16px 20px; animation: fadeIn .4s ease; }
.chat-welcome-badge {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 22px;
  background: linear-gradient(135deg, #c9a86c, #a87f37); color: #fff; font-size: 28px;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 26px rgba(168,127,55,.35);
}
.chat-welcome h2 { font-size: 21px; margin-bottom: 6px; }
.chat-welcome p { color: var(--text-2); font-size: 14px; }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; margin: 18px 0; max-width: 560px; margin-left: auto; margin-right: auto; }
.suggest-chip {
  border: 1px solid var(--border-strong); background: rgba(255,255,255,.7); color: var(--text-2);
  padding: 8px 15px; border-radius: 999px; font-size: 13px; cursor: pointer; transition: all .2s;
}
.suggest-chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.chat-bind-tip { font-size: 12.5px; color: var(--accent); background: var(--accent-soft); padding: 9px 14px; border-radius: 12px; }
.msg { display: flex; gap: 10px; margin-bottom: 18px; animation: slideUp .25s ease; }
.msg.user { flex-direction: row-reverse; }
.msg-avatar { width: 34px; height: 34px; border-radius: 12px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; }
.msg.user .msg-avatar { background: var(--accent-soft); color: var(--accent); }
.msg.ai .msg-avatar { background: linear-gradient(135deg, #c9a86c, #a87f37); color: #fff; }
.msg-body { max-width: 78%; min-width: 0; }
.msg.user .msg-body { text-align: right; }
.msg-bubble { display: inline-block; text-align: left; padding: 11px 15px; border-radius: 16px; font-size: 14px; line-height: 1.75; word-break: break-word; }
.msg.user .msg-bubble { background: linear-gradient(135deg, #c9a86c, #b08a3e); color: #fff; border-bottom-right-radius: 6px; box-shadow: 0 4px 14px rgba(168,127,55,.25); }
.msg.ai .msg-bubble { background: rgba(255,255,255,.85); border: 1px solid var(--border); border-bottom-left-radius: 6px; box-shadow: var(--shadow-sm); }

/* 思考过程 */
.think-box { margin-top: 6px; border: 1px dashed var(--border-strong); border-radius: 12px; overflow: hidden; background: rgba(255,255,255,.4); }
.think-head { display: flex; align-items: center; gap: 7px; padding: 7px 12px; font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; }
.think-head .chev { transition: transform .2s; }
.think-box.open .think-head .chev { transform: rotate(90deg); }
.think-body { display: none; padding: 4px 14px 10px; font-size: 12px; color: var(--muted); max-height: 180px; overflow-y: auto; white-space: pre-wrap; line-height: 1.7; border-top: 1px dashed var(--border); }
.think-box.open .think-body { display: block; }

/* 工具执行 chip */
.tool-chips { display: flex; flex-direction: column; gap: 5px; margin: 8px 0; }
.tool-chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px;
  background: rgba(255,255,255,.7); border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 12px; color: var(--text-2); width: fit-content;
}
.tool-chip .tico { color: var(--accent); }
.tool-chip.fail { border-color: rgba(213,73,60,.3); color: var(--up); }
.tool-chip .tsum { color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.typing-dots { display: inline-flex; gap: 4px; align-items: center; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .2s; }
.typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }

.chat-inputbar { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border); background: rgba(250, 246, 238, .8); align-items: flex-end; }
.chat-inputbar textarea {
  flex: 1; resize: none; border: 1px solid var(--border-strong); border-radius: 14px;
  padding: 11px 15px; font-size: 14.5px; font-family: inherit; outline: none;
  background: rgba(255,255,255,.85); max-height: 130px; line-height: 1.5; transition: border .2s;
}
.chat-inputbar textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(201,168,108,.15); }
.chat-side { width: 250px; flex: none; display: flex; flex-direction: column; gap: 16px; }
.skill-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.skill-tag { font-size: 12px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 4px 11px; font-weight: 600; }

/* Markdown 渲染 */
.md { font-size: 14px; }
.md h1,.md h2,.md h3 { margin: 12px 0 8px; line-height: 1.4; }
.md h1 { font-size: 17px; } .md h2 { font-size: 16px; } .md h3 { font-size: 14.5px; }
.md p { margin: 8px 0; }
.md ul,.md ol { padding-left: 20px; margin: 8px 0; }
.md li { margin: 4px 0; }
.md code { background: rgba(120,100,60,.1); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; font-family: "SF Mono", Consolas, monospace; }
.md pre { background: rgba(46,42,36,.92); color: #f0ead9; padding: 12px 14px; border-radius: 12px; overflow-x: auto; margin: 10px 0; }
.md pre code { background: none; color: inherit; padding: 0; }
.md table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 10px 0; background: rgba(255,255,255,.6); border-radius: 10px; overflow: hidden; }
.md th { background: rgba(201,168,108,.14); font-weight: 700; padding: 7px 9px; text-align: left; white-space: nowrap; }
.md td { padding: 7px 9px; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.md blockquote { border-left: 3px solid var(--accent-2); background: var(--accent-soft); padding: 8px 13px; border-radius: 0 10px 10px 0; margin: 10px 0; color: var(--text-2); }
.md a { color: var(--accent); }
.md hr { border: none; border-top: 1px dashed var(--border-strong); margin: 12px 0; }
.md strong { font-weight: 700; }
.md table-wrap { overflow-x: auto; }

/* ---------------- 绑定 ---------------- */
.bind-flow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.bind-step { background: rgba(255,255,255,.5); border: 1px solid var(--border); border-radius: 16px; padding: 18px; position: relative; }
.step-no {
  position: absolute; top: -12px; left: 16px; width: 26px; height: 26px; border-radius: 9px;
  background: linear-gradient(135deg, #c9a86c, #a87f37); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center; font-size: 13px; box-shadow: 0 4px 12px rgba(168,127,55,.3);
}
.bind-qr-wrap { text-align: center; padding-top: 8px; }
.bind-qr { width: 190px; height: 190px; border-radius: 16px; border: 1px solid var(--border); background: #fff; padding: 10px; }
.bind-qr-tip { font-size: 12.5px; color: var(--text-2); margin-top: 10px; line-height: 1.7; }
.bind-instr { padding-top: 8px; font-size: 13.5px; color: var(--text-2); }
.bind-instr p { margin-bottom: 10px; }
.bind-token-row { display: flex; gap: 8px; margin: 8px 0; }
.bind-token-row input { flex: 1; }
.bind-check-result { margin-top: 10px; font-size: 13px; }
.bind-ok { text-align: center; padding: 24px 10px; }
.bind-ok-icon { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; background: var(--down-soft); color: var(--down); font-size: 30px; display: flex; align-items: center; justify-content: center; font-weight: 800; }
.bind-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }

/* ---------------- 策略 ---------------- */
.strategy-item { border: 1px solid var(--border); background: rgba(255,255,255,.55); border-radius: 16px; padding: 16px 18px; margin-bottom: 12px; }
.strategy-item-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.strategy-name { font-size: 15.5px; font-weight: 800; }
.strategy-badge { font-size: 11.5px; padding: 3px 10px; border-radius: 999px; font-weight: 700; }
.strategy-badge.dca { background: rgba(201,168,108,.16); color: var(--accent); }
.strategy-badge.ai { background: linear-gradient(135deg, rgba(201,168,108,.25), rgba(176,138,62,.15)); color: var(--accent); }
.strategy-meta { font-size: 13px; color: var(--text-2); margin: 8px 0; display: flex; gap: 16px; flex-wrap: wrap; }
.log-list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.log-item { font-size: 13px; padding: 10px 13px; border-radius: 12px; background: rgba(255,255,255,.55); border: 1px solid var(--border); }
.log-item .lt { color: var(--muted); font-size: 11.5px; }
.log-item.ok .ls { color: var(--text-2); }
.log-item.fail .ls { color: var(--up); }
.fund-info-box { background: rgba(255,255,255,.6); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }
.pay-list { display: flex; flex-direction: column; gap: 8px; }
/* AI 策略模式选择卡（双策略） */
.strategy-mode-list { display: flex; flex-direction: column; gap: 8px; }
.strategy-mode { flex-wrap: wrap; }
.strategy-mode b { font-size: 14px; }
.strategy-mode .tip-line { white-space: normal; line-height: 1.6; }
.pay-item { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border-strong); border-radius: 12px; padding: 10px 14px; cursor: pointer; transition: all .15s; font-size: 13.5px; background: rgba(255,255,255,.6); }
.pay-item:hover { border-color: var(--accent-2); }
.pay-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.pay-item .plimit { color: var(--muted); font-size: 11.5px; margin-left: auto; }
.treaty-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.treaty-list a { font-size: 13px; }

/* ---------------- 资讯 ---------------- */
.news-body { display: flex; flex-direction: column; gap: 2px; max-height: 640px; overflow-y: auto; }
.news-item { padding: 12px 6px; border-bottom: 1px dashed var(--border); }
.news-item a { font-size: 14.5px; font-weight: 650; color: var(--text); }
.news-item a:hover { color: var(--accent); }
.news-item .nmeta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.flash-item { padding: 10px 6px; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.flash-item .ftime { color: var(--accent); font-weight: 800; margin-right: 10px; font-variant-numeric: tabular-nums; }
.flash-item .ftitle { font-weight: 650; }
.flash-item .fcontent { color: var(--text-2); font-size: 12.5px; margin-top: 3px; line-height: 1.6; }
.stock-chip { display: inline-block; margin: 3px 6px 3px 0; font-size: 12.5px; background: rgba(255,255,255,.65); border: 1px solid var(--border); padding: 4px 12px; border-radius: 999px; color: var(--text-2); }
.stock-chip b { font-weight: 700; margin-right: 6px; color: var(--text); }
.stock-chip .chip-val { font-variant-numeric: tabular-nums; font-weight: 700; }
.stock-chip .chip-val.up { color: #d5493c; }
.stock-chip .chip-val.down { color: #1f8a5f; }

/* ---------------- 登录页 ---------------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card {
  display: grid; grid-template-columns: 1fr 1fr; max-width: 880px; width: 100%;
  background: var(--card-solid); border-radius: 26px; overflow: hidden; box-shadow: var(--shadow);
  border: 1px solid var(--border); animation: slideUp .35s ease;
}
.auth-brand { background: linear-gradient(150deg, #efe4cd, #f7f1e2 55%, #efe4cd); padding: 44px 40px; display: flex; align-items: center; }
.auth-brand-inner { width: 100%; }
.auth-brand h1 { font-size: 26px; margin: 18px 0 6px; letter-spacing: 2px; }
.auth-slogan { color: var(--text-2); font-size: 14px; margin-bottom: 26px; }
.auth-feats { list-style: none; display: flex; flex-direction: column; gap: 13px; }
.auth-feats li { display: flex; gap: 10px; font-size: 13.5px; color: var(--text-2); align-items: baseline; }
.feat-ico { color: var(--accent); }
.auth-form { padding: 38px 36px; }
.auth-tabs { display: flex; gap: 4px; background: rgba(120,100,60,.07); border-radius: 13px; padding: 4px; margin-bottom: 22px; }
.auth-tab { flex: 1; display: block; text-align: center; border: none; background: none; padding: 8px 0; border-radius: 10px; font-size: 14px; font-weight: 650; color: var(--text-2); cursor: pointer; transition: all .2s; text-decoration: none; }
.auth-tab.active { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }
.auth-tab:hover { color: var(--text); }
.auth-pane { display: none; }
.auth-pane.active { display: block; animation: fadeIn .25s ease; }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; min-width: 0; }
.btn-sendcode { flex: none; min-width: 104px; }
.form-error { background: var(--up-soft); color: var(--up); font-size: 13px; padding: 10px 14px; border-radius: 12px; margin-bottom: 14px; line-height: 1.6; }
.form-ok { background: var(--down-soft); color: var(--down); font-size: 13px; padding: 10px 14px; border-radius: 12px; margin-bottom: 14px; line-height: 1.6; }
.auth-links { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin: 4px 0 16px; flex-wrap: wrap; }
.auth-links a { color: var(--text-2); }
.auth-links a:hover { color: var(--accent); }
.auth-foot { font-size: 11.5px; color: var(--muted); margin-top: 16px; text-align: center; line-height: 1.7; }

/* ---------------- 响应式：平板横屏（901-1200） ---------------- */
@media (min-width: 901px) and (max-width: 1200px) {
  :root { --side-w: 190px; }
  .side-title, .side-sub, .side-user-mail { max-width: 100px; }
  .bento { grid-template-columns: repeat(2, 1fr); }
  .card-span-3 { grid-column: span 2; }
  .page-wrap { padding: 20px 20px 36px; }
  .chat-side { display: none; }
  .chat-layout { height: calc(100vh - 140px); }
  .chat-layout { height: calc(100dvh - 140px); }
  .hero-nums { grid-template-columns: repeat(4, 1fr); }
  .hot-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* ---------------- 响应式：手机 / 平板竖屏（≤900） ---------------- */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main-area { margin-left: 0; }
  .topbar { padding: 14px 16px; background: rgba(246,243,236,.92); gap: 8px; }
  .topbar-title { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .topbar-right .chip { font-size: 11px; white-space: nowrap; }
  .page-wrap { padding: 16px 14px calc(var(--tabbar-h) + 30px); }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: rgba(250, 246, 238, .94); backdrop-filter: var(--blur);
    border-top: 1px solid var(--border); height: var(--tabbar-h);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tab-link { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); font-weight: 600; }
  .tab-link.active { color: var(--accent); }
  .tab-ico { font-size: 19px; line-height: 1; }
  .bento { grid-template-columns: 1fr; gap: 12px; }
  .card-span-2, .card-span-3 { grid-column: span 1; }
  .card { padding: 16px 15px; border-radius: 17px; }
  .hero-nums { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .hero-value { font-size: 21px; }
  .auth-card { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-form { padding: 30px 24px; }
  .bind-flow { grid-template-columns: 1fr; }
  .chat-layout { height: calc(100vh - 128px); height: calc(100dvh - 128px); }
  .chat-scroll { padding: 14px; -webkit-overflow-scrolling: touch; }
  .msg-body { max-width: 86%; }
  .chat-inputbar { padding: 10px 12px; }
  .search-box { flex-wrap: wrap; }
  .search-box input { min-width: 0; flex: 1 1 60%; }
  .trade-filters { font-size: 12px; flex-wrap: wrap; row-gap: 10px; }
  .trade-filters input[type="date"] { max-width: 42vw; }
  .toast { bottom: calc(var(--tabbar-h) + 16px); }
  /* iOS Safari：输入框字号 <16px 聚焦时会自动放大页面 */
  input[type="text"], input[type="password"], input[type="email"], input[type="number"],
  input[type="date"], input[type="search"], select, textarea { font-size: 16px; }
  /* 手机端表格更紧凑 */
  .md-table { font-size: 12px; }
  .md-table th, .md-table td { padding: 8px 8px; white-space: nowrap; }
  /* 聊天内 Markdown 表格：改块级横向滚动，避免撑破气泡 */
  .md table { display: block; overflow-x: auto; white-space: nowrap; }
  /* 触控目标加大，保证按钮可点 */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  .modal { padding: 12px; }
  .modal-box { max-height: 88dvh; margin: 0; }
  .modal-head { padding: 14px 16px 0; }
  .modal-body { padding: 12px 16px 18px; }
  /* 市场列表：按钮保留可点（不隐藏），行内自适应换行 */
  .fund-row { flex-wrap: wrap; row-gap: 8px; }
  .fund-quote { min-width: 84px; }
  .btn-ai-buy { padding: 7px 12px; font-size: 12.5px; }
  /* 热门网格双列 */
  .hot-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .hot-item { padding: 8px 10px; }
  .hot-name { max-width: none; }
  /* 交易卡片：操作按钮整行可用 */
  .trade-item { padding: 12px 13px; }
  .trade-item-top { flex-wrap: wrap; }
  .trade-actions { width: 100%; }
  .trade-actions .btn { flex: 1; }
  /* 支付方式选择：限额信息换行展示 */
  .pay-item { flex-wrap: wrap; }
  .pay-item .plimit { margin-left: 0; width: 100%; order: 3; }
  /* 工具 chip 摘要缩短 */
  .tool-chip .tsum { max-width: 170px; }
  .news-body { max-height: none; }
  .log-list { max-height: 320px; }
  .bind-qr { width: 170px; height: 170px; }
}
@media (max-width: 480px) {
  :root { font-size: 14px; }
  .hero-value { font-size: 19px; }
  .msg-body { max-width: 90%; }
  .hero-nums { grid-template-columns: repeat(2, 1fr); }
  .ov-summary { grid-template-columns: repeat(2, 1fr); }
  .kv-list .kv { font-size: 13px; }
  /* 市场行：名称占满首行，行情靠右，买入按钮整行 */
  .fund-info { flex: 1 1 100%; }
  .fund-quote { min-width: 76px; }
  .btn-ai-buy { flex: 1 1 100%; order: 3; }
  .range-chips { flex-wrap: wrap; }
  .search-box input { flex: 1 1 100%; }
  .suggest-chip { font-size: 12px; padding: 7px 12px; }
  .bind-token-row { flex-wrap: wrap; }
  .chat-welcome { padding: 24px 8px 12px; }
  .quick-links .btn { font-size: 13px; }
}

/* 滚动条美化 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(120,100,60,.2); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(120,100,60,.35); }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
