:root {
  --ink: #16181d;
  --ink-2: #3d4148;
  --ink-3: #7b8088;
  --paper: #f4f2ec;
  --card: #fffefb;
  --line: #e6e1d6;
  --line-2: #d8d2c4;
  --red: #d2372c;
  --green: #1d8a4e;
  --amber: #b8862f;
  --gold: #c9a227;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --serif: "Songti SC", "SimSun", Georgia, serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 14px;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
.hidden { display: none !important; }
.dim { color: var(--ink-3); font-size: 11.5px; }

/* 顶栏 */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: #16181d; color: #f2efe7;
}
.brand { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.seal {
  width: 32px; height: 32px; border-radius: 7px; background: var(--red); color: #fff1e6;
  font-family: var(--serif); font-size: 19px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.brand b { display: block; font-size: 16px; letter-spacing: .5px; }
.brand i { display: block; font-size: 10.5px; color: #9ea3ad; font-style: normal; letter-spacing: .5px; }
.tbtn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06); color: #e8e4da; font-size: 16px; }

/* 视图与卡片 */
.view { padding: 12px 12px 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 12px; }
.card-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-h b { font-size: 13.5px; }
.card-h .dim { margin-left: auto; }
.mini { margin-left: auto; border: 1px solid var(--line-2); background: #faf8f2; border-radius: 8px; padding: 4px 9px; font-size: 11.5px; color: var(--ink-2); }
.hint { font-size: 11px; color: var(--ink-3); line-height: 1.7; margin-top: 8px; }

/* 指数条 */
.idx-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin: 0 -12px; padding-left: 12px; padding-right: 12px; }
.idx-strip::-webkit-scrollbar { display: none; }
.idx { flex: 0 0 auto; min-width: 104px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.idx b { display: block; font-size: 11.5px; color: var(--ink-2); font-weight: 500; }
.idx .v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.idx .p { font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* 自选列表 */
.wlist { display: flex; flex-direction: column; }
.wrow { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.wrow:last-child { border-bottom: 0; }
.wrow .nm { min-width: 0; }
.wrow .nm b { font-size: 14px; }
.wrow .nm span { display: block; font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.wrow .px { text-align: right; font-variant-numeric: tabular-nums; }
.wrow .px .last { font-size: 16px; font-weight: 700; }
.wrow .px .chg { font-size: 11.5px; }
.up { color: var(--red); }
.down { color: var(--green); }
.flat { color: var(--ink-2); }
.wrow .sub { grid-column: 1 / -1; display: flex; gap: 10px; font-size: 10.5px; color: var(--ink-3); flex-wrap: wrap; }

/* 今日提示 */
.brief { font-size: 12.5px; line-height: 1.9; color: var(--ink-2); }
.brief b { color: var(--ink); }
.brief .tag { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 4px; background: #f1ece1; color: var(--ink-2); margin-right: 4px; }

/* 表单 */
.sel, .field input { width: 100%; border: 1px solid var(--line-2); border-radius: 9px; padding: 9px 10px; background: #fff; color: var(--ink); }
.ta { width: 100%; border: 1px solid var(--line-2); border-radius: 9px; padding: 9px 10px; margin-top: 8px; resize: vertical; line-height: 1.7; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { border: 1px solid var(--line-2); background: #faf8f2; border-radius: 999px; padding: 5px 11px; font-size: 12px; color: var(--ink-2); }
.chip.on { background: var(--ink); color: #f4f2ec; border-color: var(--ink); }
.rowline { display: flex; align-items: flex-start; gap: 7px; margin-top: 10px; font-size: 11.5px; color: var(--ink-2); line-height: 1.6; }
.rowline input { margin-top: 2px; }
.primary { width: 100%; margin-top: 12px; border: 0; border-radius: 10px; padding: 12px; background: var(--red); color: #fff5ef; font-size: 14.5px; font-weight: 600; }
.primary:disabled { background: #c9b9b5; }
.ghost { border: 1px solid var(--line-2); background: #faf8f2; border-radius: 9px; padding: 9px 14px; font-size: 12.5px; color: var(--ink-2); }
.ghost.danger { color: var(--red); border-color: #e7c4c0; }
.ghost.wide { width: 100%; margin-top: 8px; }
.btnrow { display: flex; gap: 8px; margin-top: 8px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 5px; }
.msg { font-size: 11.5px; color: var(--ink-3); margin: 6px 0 0; line-height: 1.7; }
.msg.ok { color: var(--green); }
.msg.err { color: var(--red); }
.mi { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 12px 2px; font-size: 13.5px; color: var(--ink); }
.mi:last-child { border-bottom: 0; }
.mi em { font-style: normal; font-size: 11.5px; color: var(--ink-3); }
.mi.danger span { color: var(--red); }
.foot { text-align: center; font-size: 10.5px; color: var(--ink-3); padding: 4px 10px 14px; line-height: 1.8; }

/* 搜索 */
.searchbar { display: flex; gap: 8px; }
.searchbar input { flex: 1; border: 1px solid var(--line-2); border-radius: 10px; padding: 11px 12px; background: #fff; }
.searchbar button { border: 0; border-radius: 10px; padding: 0 18px; background: var(--ink); color: #f2efe7; font-size: 13.5px; }
.reslist { display: flex; flex-direction: column; gap: 2px; }
.res { padding: 10px 2px; border-bottom: 1px solid var(--line); }
.res:last-child { border-bottom: 0; }
.res a { color: var(--ink); text-decoration: none; font-size: 13.5px; font-weight: 600; line-height: 1.5; display: block; }
.res p { margin: 4px 0 0; font-size: 11.5px; color: var(--ink-2); line-height: 1.7; }
.res .m { font-size: 10.5px; color: var(--ink-3); margin-top: 4px; display: flex; gap: 8px; }
.res .m i { font-style: normal; color: var(--amber); }

/* B 站窗口 */
.vidwrap { position: relative; height: 470px; border-radius: 12px; overflow: hidden; background: #0e1014; }
.vidwrap iframe { width: 100%; height: 100%; border: 0; }
.vidmask { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: #cfc7b6; font-size: 12.5px; text-align: center; cursor: pointer;
  background: radial-gradient(circle at 50% 30%, #242832, #0e1014 72%); }
.vidmask small { color: #857f72; font-size: 10.5px; }

/* 抖音热榜 */
.dylist { display: flex; flex-direction: column; }
.dy { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.dy:last-child { border-bottom: 0; }
.dy .p { font-size: 11px; color: var(--ink-3); text-align: center; font-weight: 700; }
.dy .p.top { color: var(--red); }
.dy .w { line-height: 1.45; }
.dy .h { font-size: 10.5px; color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }

/* 底部 tab */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; background: #1b1e23; border-top: 1px solid #2a2e35;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { flex: 1; border: 0; background: none; padding: 8px 0 7px; color: #7d838d; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.tab i { font-style: normal; font-size: 17px; line-height: 1; }
.tab small { font-size: 10px; }
.tab.on { color: #e8e2d4; }

/* 弹层 */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(16,18,22,.42); display: flex; align-items: flex-end; }
.sheet { width: 100%; max-height: 92vh; background: var(--paper); border-radius: 16px 16px 0 0; display: flex; flex-direction: column; }
.sheet.tall { height: 92vh; }
.sheet-h { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.sheet-h b { font-size: 15px; flex: 1; }
.link { border: 0; background: none; color: var(--red); font-size: 13px; }
.pad { padding: 12px 14px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* K线 */
.kquote { display: flex; gap: 12px; align-items: baseline; margin-bottom: 8px; flex-wrap: wrap; }
.kquote b { font-size: 22px; font-variant-numeric: tabular-nums; }
.kquote span { font-size: 12.5px; }
#kCanvas { width: 100%; height: auto; border-radius: 10px; background: #fff; border: 1px solid var(--line); }
.kstats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 10px; font-size: 12px; }
.kstats div { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 4px 0; }
.kstats i { font-style: normal; color: var(--ink-3); }
.kstats b { font-variant-numeric: tabular-nums; font-weight: 600; }

/* 研究记录 */
.recs { display: flex; flex-direction: column; }
.rec { text-align: left; border: 1px solid var(--line); background: #faf8f2; border-radius: 10px; padding: 9px 10px; margin-bottom: 8px; }
.rec b { display: block; font-size: 12.5px; margin-bottom: 3px; }
.rec span { font-size: 10.5px; color: var(--ink-3); }

/* 结果排版 */
.md h2 { font-size: 15px; margin: 14px 0 6px; padding-left: 8px; border-left: 3px solid var(--red); }
.md h3 { font-size: 13.5px; margin: 12px 0 5px; color: var(--ink); }
.md p { font-size: 13px; line-height: 1.9; margin: 0 0 8px; color: var(--ink-2); }
.md ul, .md ol { padding-left: 18px; margin: 0 0 10px; }
.md li { font-size: 13px; line-height: 1.85; color: var(--ink-2); margin-bottom: 3px; }
.md strong { color: var(--ink); }
.md code { background: #efe9dc; padding: 1px 4px; border-radius: 4px; font-size: 12px; }
.md blockquote { margin: 8px 0; padding: 8px 10px; background: #f3eee2; border-left: 3px solid var(--amber); font-size: 12.5px; color: var(--ink-2); }

/* 提示与遮罩 */
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90;
  background: #23262c; color: #f2efe7; font-size: 12.5px; padding: 9px 14px; border-radius: 10px; max-width: 84vw; line-height: 1.6; }
.toast.err { background: #8c2a22; }
.veil { position: fixed; inset: 0; z-index: 95; background: rgba(14,16,20,.55); display: flex; align-items: center; justify-content: center; }
.veilbox { background: #1b1e23; color: #eee9dc; border-radius: 14px; padding: 20px 22px; max-width: 78vw; text-align: center; }
.veilbox b { font-size: 14px; }
.veilbox p { font-size: 11.5px; color: #9aa1ab; margin: 8px 0 0; line-height: 1.7; }

.wx-bar { position: sticky; top: 0; z-index: 50; background: #3b2f12; color: #f4e3b6; font-size: 11.5px; padding: 7px 12px; display: flex; gap: 10px; justify-content: space-between; line-height: 1.5; }
.wx-bar b { color: #ffe9a8; font-weight: 500; }

.formula { background: #f3eee2; border-left: 3px solid var(--amber); border-radius: 6px; padding: 7px 10px; font-size: 12.5px; color: var(--ink-2); margin: 6px 0 10px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
