/* ============ 设计变量 ============ */
:root {
  --bg: #f5f3ee;
  --surface: #fffdf9;
  --surface2: #f1eee7;
  --text: #2e2b27;
  --muted: #8b857b;
  --faint: #b8b2a7;
  --line: #e7e2d8;
  --accent: #6d8f7c;
  --accent-soft: #e4ece6;
  --accent-text: #ffffff;
  --up: #3a9670;
  --down: #c95c58;
  --up-soft: #e3f1ea;
  --down-soft: #f7e5e3;
  --warn: #b98a32;
  --warn-soft: #f6eedc;
  --roll: #d9843a;
  --roll2: #e5ad45;
  --shadow: 0 1px 2px rgba(60, 50, 30, .04), 0 6px 20px rgba(60, 50, 30, .05);
  --radius: 14px;
  --a1: #eef1ea; --a2: #dde6da; --a3: #c6d6c9; --a4: #a6bfae; --sun: #f2d8b3; --a5: #f7f2e8;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", "Cascadia Mono", Consolas, "Roboto Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17181b; --surface: #202226; --surface2: #2a2c31; --text: #e7e3db; --muted: #9a958c; --faint: #6c6861;
    --line: #34363c; --accent: #8fb5a0; --accent-soft: #283730; --accent-text: #15201a;
    --up: #5cbf93; --down: #e07b76; --up-soft: #1e3229; --down-soft: #3a2524; --warn: #d9ad5a; --warn-soft: #3a3222;
    --roll: #e89a4a; --roll2: #e8b85a; --shadow: 0 1px 2px rgba(0,0,0,.2), 0 6px 20px rgba(0,0,0,.18);
    --a1: #23272a; --a2: #2a3231; --a3: #34423d; --a4: #4a5f55; --sun: #5d523f; --a5: #1f2225;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17181b; --surface: #202226; --surface2: #2a2c31; --text: #e7e3db; --muted: #9a958c; --faint: #6c6861;
  --line: #34363c; --accent: #8fb5a0; --accent-soft: #283730; --accent-text: #15201a;
  --up: #5cbf93; --down: #e07b76; --up-soft: #1e3229; --down-soft: #3a2524; --warn: #d9ad5a; --warn-soft: #3a3222;
  --roll: #e89a4a; --roll2: #e8b85a; --shadow: 0 1px 2px rgba(0,0,0,.2), 0 6px 20px rgba(0,0,0,.18);
  --a1: #23272a; --a2: #2a3231; --a3: #34423d; --a4: #4a5f55; --sun: #5d523f; --a5: #1f2225;
  color-scheme: dark;
}

/* ============ 基础 ============ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.65; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: .01em; }
h1 { font-size: 24px; } h2 { font-size: 19px; } h3 { font-size: 16px; } h4 { font-size: 14px; }
p { margin: 0; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.up { color: var(--up); } .down { color: var(--down); }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }
.container { max-width: 1180px; margin: 0 auto; padding: 28px 24px 80px; }
.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 28px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
@media (max-width: 860px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .container { padding: 18px 16px 64px; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
}

/* ============ 顶栏 ============ */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 0 24px; height: 58px; display: flex; align-items: center; gap: 24px; }
.brand { font-weight: 650; font-size: 16px; display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.brand-mark { width: 28px; height: 28px; flex: none; display: block; filter: drop-shadow(0 1px 2px rgba(120, 80, 40, .18)); }
.brand { letter-spacing: .08em; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 6px 12px; border-radius: 999px; color: var(--muted); white-space: nowrap; font-size: 14px; transition: background .15s, color .15s; }
.nav a:hover { color: var(--text); background: var(--surface2); }
.nav a.active { color: var(--text); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.top-actions { display: flex; gap: 6px; }
@media (max-width: 640px) {
  /* 毛玻璃会让里面的 fixed 元素相对顶栏定位，手机上改用纯色底 */
  .topbar { backdrop-filter: none; background: var(--bg); padding-top: env(safe-area-inset-top); }
  .topbar-inner { padding: 0 12px; gap: 10px; justify-content: space-between; }
  .brand { font-size: 15px; gap: 8px; }
  /* 手机上导航改成底部标签栏，像 app 一样单手可点 */
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; gap: 0; overflow: visible;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
  }
  .nav a { flex: 1; text-align: center; padding: 9px 4px; font-size: 13.5px; border-radius: 12px; }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
}

/* ============ 控件 ============ */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 7px 14px; border-radius: 10px; font: inherit; font-size: 14px; cursor: pointer; line-height: 1.4;
  display: inline-flex; align-items: center; gap: 6px; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap;
}
.btn:hover { background: var(--surface2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--down); }
.btn.danger.solid { background: var(--down); border-color: var(--down); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface2); }
.btn.sm { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted);
  display: inline-grid; place-items: center; cursor: pointer; font-size: 18px; line-height: 1;
}
.icon-btn:hover, .icon-btn.active { color: var(--text); background: var(--surface2); }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 11px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s; font-size: 14px;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="number"], input.mono { font-family: var(--mono); }
input[type="checkbox"], input[type="radio"] { width: auto; }
input[type="range"] { padding: 0; border: none; accent-color: var(--accent); box-shadow: none; background: transparent; }
.invalid, .invalid:focus { border-color: var(--down) !important; box-shadow: 0 0 0 3px var(--down-soft) !important; }
label.field { display: block; }
label.field > span, .field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
label.field > span b { color: var(--down); font-weight: 500; margin-left: 2px; }
.hint { font-size: 12px; color: var(--faint); margin-top: 4px; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 13px;
  background: var(--surface2); color: var(--text); border: 1px solid transparent; cursor: pointer; user-select: none; white-space: nowrap;
}
.chip:hover { border-color: var(--line); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip.static { cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; line-height: 1.6; }
.badge.long { background: var(--up-soft); color: var(--up); }
.badge.short { background: var(--down-soft); color: var(--down); }
.badge.neutral { background: var(--surface2); color: var(--muted); font-weight: 500; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }

.seg { display: inline-flex; background: var(--surface2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button, .seg a { border: none; background: transparent; color: var(--muted); font: inherit; font-size: 13px; padding: 4px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.seg button.on, .seg a.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--muted); user-select: none; }
.switch input { display: none; }
.switch i { width: 34px; height: 20px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(14px); }

/* ============ 卡片与布局块 ============ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card.tight { padding: 14px 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { font-size: 15px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; scrollbar-width: none; }
.subnav a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 14px; }
.subnav a.on { color: var(--text); border-color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; font-size: 14px; }
.empty .btn { margin-top: 14px; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.back { color: var(--muted); font-size: 14px; display: inline-flex; gap: 4px; align-items: center; margin-bottom: 10px; }
.back:hover { color: var(--text); }

.kpi { padding: 14px 16px; border-radius: 12px; background: var(--surface2); min-width: 0; }
.kpi .k { font-size: 12px; color: var(--muted); }
.kpi .v { font-family: var(--mono); font-size: 20px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi .s { font-size: 12px; color: var(--faint); font-family: var(--mono); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.kv dd.text { font-family: var(--font); text-align: left; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface2); }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl-wrap { overflow-x: auto; margin: 0 -6px; }

/* ============ 首页 ============ */
.motto {
  text-align: center; padding: 34px 16px 10px; font-size: 22px; letter-spacing: .12em; font-weight: 500;
}
.motto small { display: block; font-size: 12px; color: var(--faint); letter-spacing: .3em; margin-bottom: 10px; font-weight: 400; }
.quote-today { text-align: center; padding: 6px 16px 26px; color: var(--muted); }
.quote-today .q { font-size: 16px; color: var(--text); }
.quote-today .by { font-size: 13px; margin-top: 6px; }
.entry-card { display: block; padding: 22px; transition: transform .15s, border-color .15s; position: relative; overflow: hidden; }
.entry-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.entry-card h3 { font-size: 17px; margin-bottom: 4px; }
.entry-card .ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; margin-bottom: 14px; background: var(--accent-soft); color: var(--accent); }
.entry-card .meta { margin-top: 14px; font-size: 13px; color: var(--muted); font-family: var(--mono); }
.chart-box { height: 280px; position: relative; }
.chart-box.tall { height: 420px; }
@media (max-width: 640px) { .chart-box { height: 220px; } .chart-box.tall { height: 320px; } }

/* ============ 日历 ============ */
/* 日历页：左日历 6，右侧栏 4 */
.cal-wrap { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 3fr); gap: 16px; align-items: start; }
.cal-left, .cal-right { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
/* 本月记录卡片 */
.ms-row1 { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.ms-month { font-size: 20px; font-weight: 650; line-height: 1.2; }
.ms-month small { font-size: 13px; font-weight: 500; color: var(--muted); }
.ms-stat { font-size: 13.5px; color: var(--muted); }
.ms-stat b { font-size: 18px; color: var(--text); font-weight: 600; margin-right: 2px; }
/* 第二行固定一行高度：有心情统计或只有一句鼓励，卡片都一样高 */
.ms-row2 { height: 30px; margin-top: 8px; display: flex; flex-wrap: wrap; align-content: center; gap: 4px 14px; overflow: hidden; }
.ms-row2 .chip { padding: 0; background: transparent; border: none; font-size: 13.5px; gap: 5px; }
.ms-row2 .chip .mono { font-weight: 600; color: var(--text); }
@media (max-width: 860px) { .ms-row2 { height: auto; min-height: 30px; } }
.ms-empty { font-size: 14px; color: var(--muted); padding-left: 2px; }
.ms-empty::before { content: "✿ "; color: var(--accent); }
.far-next { margin-top: 14px; width: 100%; justify-content: center; }
#farBox { display: flex; flex-direction: column; transition: opacity .18s ease; }
#farBox.far-fade { opacity: 0; }
.mood-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted); }
.mood-legend .ml-k { color: var(--faint); margin-right: 2px; }
.mood-legend span { display: inline-flex; align-items: center; gap: 5px; }
.mood-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
/* 宽屏：两栏等高、底部对齐。左边比较高 → 今日远方的照片拉高；右边比较高 → 日历格子变高 */
@media (min-width: 861px) {
  .cal-wrap { align-items: stretch; }
  .cal-left > #calCol { flex: 1; display: flex; flex-direction: column; }
  .cal-left .cal-card { flex: 1; display: flex; flex-direction: column; }
  .cal-left .cal { flex: 1; grid-template-rows: auto; grid-auto-rows: minmax(44px, 1fr); }
  .cal-left .cal .d { height: auto; min-height: 44px; }
  .cal-right > #farBox { flex: 1; }
  .cal-right .far { flex: 1; display: flex; flex-direction: column; }
  .cal-right .far .far-pic { flex: 1; height: auto; min-height: 190px; }
}
@media (max-width: 860px) { .cal-wrap { grid-template-columns: minmax(0, 1fr); } }

.cal-card { padding: 10px 18px 32px; position: relative; }
button.cal-title { border: none; background: transparent; font: inherit; color: var(--text); cursor: pointer; padding: 4px 8px; margin: -4px -8px; border-radius: 10px; }
button.cal-title:hover, button.cal-title[aria-expanded="true"] { background: var(--surface2); }
.cal-title .caret { font-size: 10px; color: var(--faint); margin-left: 2px; }
/* 年月日选择面板 */
.picker { position: absolute; left: 12px; top: 54px; z-index: 5; width: min(320px, calc(100% - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 36px rgba(0,0,0,.14); padding: 12px; animation: pop .15s; }
.pk-year { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.pk-year span { font-weight: 600; }
.pk-year button { width: 30px; height: 28px; border: none; background: var(--surface2); border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 16px; }
.pk-year button:hover { color: var(--text); }
.pk-months { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.pk-months button { border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 7px 0; font: inherit; font-size: 13.5px; color: var(--text); cursor: pointer; }
.pk-months button:hover { background: var(--surface2); }
.pk-months button.now { color: var(--accent); font-weight: 600; }
.pk-months button.on { background: var(--accent); color: var(--accent-text); }
.pk-day { display: flex; align-items: center; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.pk-day input { width: auto; flex: 1; min-width: 130px; padding: 5px 8px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; min-height: 32px; }
.cal-title { display: flex; align-items: baseline; gap: 8px; }
.cal-m { font-size: 24px; font-weight: 650; line-height: 1; letter-spacing: -.02em; }
.cal-m small { font-size: 14px; font-weight: 500; margin-left: 2px; color: var(--muted); }
.cal-y { font-size: 14px; color: var(--text); font-weight: 600; }
.cal-nav { display: inline-flex; background: var(--surface2); border-radius: 999px; padding: 2px; }
.cal-nav button { width: 30px; height: 26px; border: none; background: transparent; border-radius: 999px; color: var(--muted); font-size: 17px; line-height: 1; cursor: pointer; }
.cal-nav button:hover { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.cal .wd { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 2px 0 6px; letter-spacing: .1em; }
.cal .wd.we { color: color-mix(in srgb, var(--accent) 80%, var(--muted)); }
.cal .d {
  height: 44px; border-radius: 9px; border: 1px solid transparent; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  cursor: pointer; transition: background .15s, border-color .15s; outline: none;
}
.cal .d.out { visibility: hidden; }
/* 日期数字用常规无衬线字体（等宽数字），比等宽字体更饱满 */
.cal .d .n { font-family: -apple-system, "Segoe UI", "Helvetica Neue", Arial, var(--font); font-variant-numeric: tabular-nums; font-size: 16px; font-weight: 500; line-height: 1; color: var(--text); }
.cal .d.we .n { color: color-mix(in srgb, var(--accent) 65%, var(--text)); }
.cal .d.has .n { font-weight: 650; }
.cal .d .dots { display: flex; gap: 2px; height: 5px; }
.cal .d .dots i { width: 5px; height: 5px; border-radius: 50%; display: block; }
.cal .d:not(.future):hover { background: var(--surface2); }
.cal .d:focus-visible { border-color: var(--accent); }
/* 今天：只用主色文字和细边框标出，不用圆圈 */
.cal .d.today { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: color-mix(in srgb, var(--accent) 7%, transparent); }
.cal .d.today .n { color: var(--accent); font-weight: 750; }
.cal .d.future { cursor: default; }
.cal .d.future .n { color: var(--faint); opacity: .65; }
@media (max-width: 640px) {
  .cal-card { padding: 9px 10px 26px; }
  .cal .d { height: 42px; border-radius: 8px; }
  .cal .d .n { font-size: 15px; }
}

/* 今日远方的收藏 */
.star-btn { border: none; background: transparent; cursor: pointer; font-size: 19px; line-height: 1; color: var(--faint); padding: 2px 4px; border-radius: 6px; transition: color .15s, transform .15s; }
.star-btn:hover { color: var(--warn); transform: scale(1.12); }
.star-btn.on { color: #e7b23e; }
button.fav-lib { display: flex; align-items: center; gap: 12px; width: 100%; font: inherit; color: var(--text); cursor: pointer; text-align: left; transition: border-color .15s, transform .15s; }
button.fav-lib:hover { border-color: #e7b23e; transform: translateY(-1px); }
.fav-lib .fav-star { font-size: 22px; color: #e7b23e; line-height: 1; }
.fav-lib[data-empty] .fav-star { color: var(--faint); }
.fav-lib b { display: block; font-weight: 550; font-size: 14.5px; }
.fav-lib small { display: block; font-size: 12px; color: var(--faint); }
.fav-lib .fav-count { font-size: 22px; font-weight: 650; }
.fav-lib .chev { color: var(--faint); }
.fav-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
@media (max-width: 560px) { .fav-grid { grid-template-columns: minmax(0, 1fr); } }
.fav-list { display: flex; flex-direction: column; gap: 6px; }
.fav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; border: 1px solid transparent; border-radius: 10px; background: transparent; font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.fav-item:hover { background: var(--surface2); border-color: var(--line); }
.fav-thumb { position: relative; width: 56px; height: 40px; border-radius: 7px; overflow: hidden; flex: none; background: var(--a5); }
.fav-thumb svg, .fav-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.fav-thumb img { opacity: 0; transition: opacity .4s; }
.fav-thumb.loaded img { opacity: 1; }
.fav-thumb.failed img { display: none; }
.fav-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fav-txt b { font-weight: 550; font-size: 14px; }
.fav-txt small { font-size: 12px; color: var(--faint); }
.fav-item .chev { color: var(--faint); }
.far-modal .far { box-shadow: none; }
.mood-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface2); }
.mood-bar span { height: 100%; }

.entry-row { display: flex; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: flex-start; }
.entry-row:hover { background: var(--surface2); }
.entry-row .date { font-family: var(--mono); font-size: 13px; color: var(--muted); width: 92px; flex: none; padding-top: 2px; }
.entry-row .t { font-weight: 550; }
.entry-row .b { color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.data-foot { margin-top: 36px; padding-top: 16px; border-top: 1px dashed var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }

/* 今日远方 */
.far { padding: 0; overflow: hidden; }
.far .far-pic { position: relative; height: 190px; background: var(--a5); border-bottom: 1px solid var(--line); overflow: hidden; }
.far .far-pic svg.art { position: absolute; inset: 0; width: 100%; height: 100%; }
.far .far-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .6s ease; }
.far .far-pic.loaded img { opacity: 1; }
.far .far-pic.failed img { display: none; }
.far .far-pic .cap { position: absolute; right: 8px; bottom: 6px; font-size: 11px; color: var(--muted); background: color-mix(in srgb, var(--surface) 78%, transparent); padding: 1px 7px; border-radius: 6px; max-width: calc(100% - 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.far .far-pic .cap.credit { display: none; color: #fff; background: rgba(0, 0, 0, .38); }
.far .far-pic.loaded .cap.credit { display: block; }
.far .far-pic .cap.fallback { display: none; }
.far .far-pic.failed .cap.fallback { display: block; }
.far .far-pic.loaded::after { content: ""; position: absolute; inset: auto 0 0 0; height: 40%; background: linear-gradient(transparent, rgba(0, 0, 0, .18)); pointer-events: none; }
.far .far-pic .cap { z-index: 1; }
.far .far-v.pic { font-size: 14px; line-height: 1.8; color: var(--text); font-style: normal; }
.far .far-body { padding: 14px 16px 16px; }
.far .far-k { font-size: 12px; color: var(--muted); margin-top: 10px; }
.far .far-v { font-size: 13.5px; }

/* ============ 书架：分类栏 + 上中下三段方块 ============ */
.cat-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.cat-bar .caret { font-size: 10px; opacity: .7; }
.cat-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 18px; box-shadow: var(--shadow); }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.cat-opt { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 12px; cursor: pointer; font: inherit; color: var(--text); display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.cat-opt:hover { border-color: var(--cat, var(--accent)); }
.cat-opt.on { border-color: var(--cat, var(--accent)); background: color-mix(in srgb, var(--cat, var(--accent)) 10%, var(--surface)); }
.cat-opt b { font-weight: 550; font-size: 14px; display: flex; align-items: center; gap: 7px; }
.cat-opt b i { width: 8px; height: 8px; border-radius: 50%; background: var(--cat); }
.cat-opt .mono { font-size: 12px; color: var(--muted); }
.cat-opt small { grid-column: 1 / -1; font-size: 12px; color: var(--faint); }
.cat-tag { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 6px; color: var(--cat); background: color-mix(in srgb, var(--cat) 14%, transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.shelf-sec { margin-top: 26px; }
.sec-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.sec-head h2 { font-size: 18px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
@media (max-width: 640px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.tiles-empty { grid-column: 1 / -1; color: var(--faint); font-size: 14px; padding: 18px 4px; }
.tile {
  aspect-ratio: 4 / 5; position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 0; display: flex; flex-direction: column; cursor: pointer; overflow: hidden; user-select: none;
  box-shadow: var(--shadow); transition: transform .15s, border-color .15s, box-shadow .15s;
}
.tile-cover { position: relative; height: 50%; flex: none; border-bottom: 3px solid var(--cat); overflow: hidden; }
.tile-cover svg, .book-cover svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tile-cover .tile-top { position: absolute; left: 0; right: 0; top: 0; padding: 7px 7px 0 8px; }
.tile-cover .cat-tag { background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(4px); }
.tile-cover .tile-more, .tile-cover .handle { background: color-mix(in srgb, var(--surface) 72%, transparent); border-radius: 6px; color: var(--muted); }
.tile-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 8px 12px 10px; }
.tile-body .tile-title { margin-top: 0; -webkit-line-clamp: 2; font-size: 15px; }
.book-cover { position: relative; width: 150px; aspect-ratio: 5 / 4; flex: none; border-radius: 12px; overflow: hidden; border-bottom: 3px solid var(--cat); }
.cover-roll { position: absolute; right: 6px; bottom: 6px; width: 26px; height: 26px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted); background: color-mix(in srgb, var(--surface) 78%, transparent); opacity: 0; transition: opacity .15s; }
.book-cover:hover .cover-roll, .cover-roll:focus-visible { opacity: 1; }
@media (hover: none) { .cover-roll { opacity: 1; } }
@media (max-width: 640px) { .book-cover { width: 110px; } }
:root[data-theme="dark"] .cover-svg { filter: brightness(.88) saturate(.92); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cover-svg { filter: brightness(.88) saturate(.92); } }
.tile:hover, .tile:focus-visible { border-color: var(--cat); transform: translateY(-2px); outline: none; }
.tile.dragging { opacity: .9; transform: scale(1.04); box-shadow: 0 12px 30px rgba(0,0,0,.18); border-color: var(--cat); z-index: 2; cursor: grabbing; }
[data-tiles="want"] .tile { cursor: grab; }
.tile-top { display: flex; justify-content: space-between; align-items: center; gap: 4px; min-height: 24px; }
.tile-title { font-weight: 650; font-size: 15.5px; line-height: 1.45; margin-top: 10px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tile-author { font-size: 12.5px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 11.5px; color: var(--faint); font-family: var(--mono); }
.tile-more { border: none; background: transparent; color: var(--faint); font-size: 16px; line-height: 1; width: 26px; height: 24px; border-radius: 6px; cursor: pointer; }
.tile-more:hover { background: var(--surface2); color: var(--text); }
.handle { color: var(--faint); font-size: 15px; padding: 2px 4px; cursor: grab; touch-action: none; }
.rate-hint { color: var(--accent); font-family: var(--font); }
.tier { display: inline-block; font-family: var(--font); font-size: 12px; font-weight: 650; padding: 1px 9px; border-radius: 6px; color: #fff; background: var(--tier); white-space: nowrap; }
.tier.big { font-size: 14px; padding: 3px 12px; }
.tier-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tier-pick button { border: 1.5px solid color-mix(in srgb, var(--tier) 45%, transparent); background: color-mix(in srgb, var(--tier) 8%, var(--surface)); color: var(--tier); font: inherit; font-weight: 700; font-size: 16px; padding: 12px 6px; border-radius: 12px; cursor: pointer; transition: transform .1s; }
.tier-pick button:hover { transform: translateY(-1px); }
.tier-pick button.on { background: var(--tier); color: #fff; border-color: var(--tier); box-shadow: 0 4px 14px color-mix(in srgb, var(--tier) 40%, transparent); }
.book-head .row.top { flex-wrap: nowrap; }
@media (max-width: 640px) { .book-head .row.top { flex-wrap: wrap; } }
.note-unit .nt { font-size: 16px; }
.note-unit .src { margin-top: 10px; font-size: 14.5px; line-height: 1.8; padding: 10px 14px; background: var(--surface2); border-radius: 10px; }
.note-unit::before { display: none; }

/* ============ 笔记：富文本编辑、列表行、阅读视图 ============ */
.rte { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.rte:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rte-bar { display: flex; align-items: center; gap: 4px; padding: 5px 6px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.rte-bar button { width: 32px; height: 28px; border: 1px solid transparent; background: transparent; border-radius: 7px; cursor: pointer; color: var(--text); font-size: 15px; font-family: Georgia, serif; }
.rte-bar button:hover { background: var(--surface2); }
.rte-bar button.on { background: var(--accent-soft); border-color: var(--accent); }
.rte-bar .tiny { margin-left: 6px; }
.rte-body { min-height: 160px; max-height: 50vh; overflow-y: auto; padding: 10px 12px; outline: none; font-size: 14.5px; line-height: 1.8; white-space: pre-wrap; word-break: break-word; }
.rte-body:empty::before { content: attr(data-ph); color: var(--faint); }
.rte-body u, .note-src u, .quote-card u { text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.note-list { padding: 4px 6px; }
.note-row { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; border: none; background: transparent; font: inherit; color: var(--text); padding: 12px 10px; border-radius: 10px; cursor: pointer; }
.note-row + .note-row { border-top: 1px solid var(--line); border-radius: 0; }
.note-row:hover { background: var(--surface2); border-radius: 10px; }
.note-row:hover + .note-row { border-top-color: transparent; }
.note-row .when { font-family: var(--mono); font-size: 12.5px; color: var(--faint); flex: none; width: 118px; }
.note-row .nt { flex: 1; min-width: 0; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-row .nb { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30%; }
.note-row .nc { font-size: 11.5px; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 6px; flex: none; }
.note-row .chev { color: var(--faint); flex: none; }
@media (max-width: 640px) { .note-row { flex-wrap: wrap; gap: 2px 10px; } .note-row .when { width: auto; order: 2; } .note-row .nt { flex-basis: 100%; white-space: normal; } .note-row .nb { order: 3; max-width: none; } .note-row .chev { display: none; } }
.note-src { font-size: 15px; line-height: 1.9; padding: 14px 16px; background: var(--surface2); border-radius: 12px; border-left: 3px solid var(--accent); word-break: break-word; }
.note-mine { font-size: 14.5px; line-height: 1.8; padding: 2px 2px; }

/* ============ 阅读统计 ============ */
.read-stats .kpi .v small { font-size: 13px; font-weight: 400; color: var(--muted); }
.read-stats .grid.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 520px) { .read-stats .grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .read-stats .kpi { padding: 10px 11px; } .read-stats .kpi .v { font-size: 17px; } }
.mq { margin-top: 18px; padding: 18px 22px 14px 26px; border-radius: 12px; position: relative; background: linear-gradient(135deg, var(--accent-soft), color-mix(in srgb, var(--warn-soft) 70%, var(--accent-soft))); }
.mq::before { content: "“"; position: absolute; left: 8px; top: -2px; font-size: 40px; line-height: 1; color: var(--accent); opacity: .45; font-family: Georgia, serif; }
.mq-text { font-size: 16.5px; line-height: 1.7; }
.mq-by { font-size: 13px; color: var(--muted); }
.lib-cats .cat-opt { padding: 12px 14px; }
.lib-cats .cat-opt[data-empty] { opacity: .55; }

/* 评分星星 */
.stars { display: inline-flex; gap: 2px; color: var(--warn); letter-spacing: 0; }
.stars .off { color: var(--line); }
.star-input { display: inline-flex; gap: 4px; }
.star-input button { border: none; background: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--line); padding: 0 1px; }
.star-input button.on { color: var(--warn); }

/* 记录单元的背景插画 */
.hero { position: relative; border-radius: var(--radius); overflow: hidden; min-height: 210px; background: var(--a5); border: 1px solid var(--line); }
.hero svg.art { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero .hero-q { position: relative; padding: 30px 32px; max-width: 620px; }
.hero .hero-q .cat { font-size: 12px; letter-spacing: .25em; color: var(--muted); }
.hero .hero-q .q { font-size: 19px; margin-top: 8px; line-height: 1.7; text-shadow: 0 1px 0 color-mix(in srgb, var(--a5) 70%, transparent); }
.hero .hero-q .by { font-size: 13px; color: var(--muted); margin-top: 6px; }
.hero .shuffle { position: absolute; right: 12px; top: 12px; }
@media (max-width: 640px) { .hero .hero-q { padding: 22px 18px; } .hero .hero-q .q { font-size: 16.5px; } }
/* 记录页的紧凑句子条 */
.hero.compact { min-height: 0; }
.hero.compact .hero-q { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px 56px 16px 22px; max-width: none; transition: opacity .16s ease, transform .16s ease; }
.hero.compact .hero-q.fade { opacity: 0; transform: translateY(3px); }
.hero.compact .hero-q .cat {
  font-size: 12px; letter-spacing: .08em; color: var(--text); white-space: nowrap; padding: 2px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--mc, var(--accent)) 22%, color-mix(in srgb, var(--surface) 70%, transparent));
}
.hero.compact .hero-q .q { font-size: 16px; margin-top: 0; line-height: 1.6; }
.hero.compact .shuffle { top: 50%; transform: translateY(-50%); right: 10px; background: color-mix(in srgb, var(--surface) 60%, transparent); }
@media (max-width: 640px) { .hero.compact .hero-q { padding: 12px 48px 12px 14px; gap: 6px 10px; } .hero.compact .hero-q .q { font-size: 15px; } }

.intensity { display: flex; gap: 6px; }
.intensity button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-family: var(--mono); cursor: pointer; }
.intensity button.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.remind { border-radius: 12px; padding: 14px 16px; background: var(--surface2); border-left: 3px solid var(--accent); font-size: 14px; }
.remind.pos { background: var(--warn-soft); border-color: var(--warn); }
.remind.neg { background: var(--accent-soft); border-color: var(--accent); }
.remind h4 { font-size: 13px; margin-bottom: 6px; color: var(--muted); font-weight: 500; }
.remind ul { margin: 0; padding-left: 18px; }
.remind .foot { font-size: 12px; color: var(--faint); margin-top: 8px; }

/* ============ 读书 ============ */
.shelf { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 860px) { .shelf { grid-template-columns: minmax(0, 1fr); } }
.shelf-col { background: var(--surface2); border-radius: var(--radius); padding: 14px; min-height: 120px; }
.shelf-col > h3 { font-size: 14px; color: var(--muted); font-weight: 500; margin: 2px 4px 12px; display: flex; justify-content: space-between; }
.book { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 15px; cursor: pointer; display: block; transition: border-color .15s; }
.book + .book { margin-top: 10px; }
.book:hover { border-color: var(--accent); }
.book .bt { font-weight: 600; }
.book .ba { font-size: 13px; color: var(--muted); }
.book .one { font-size: 13.5px; margin-top: 8px; color: var(--text); }
.progress { height: 5px; background: var(--surface2); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.excerpt { position: relative; padding: 18px 20px 16px 24px; }
.excerpt::before { content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px; border-radius: 3px; background: var(--accent); opacity: .6; }
.excerpt .src { font-size: 15px; line-height: 1.8; }
.excerpt .page { font-family: var(--mono); font-size: 12px; color: var(--faint); margin-top: 6px; }
.excerpt .mine { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 14px; color: var(--muted); }
.excerpt .mine b { color: var(--text); font-weight: 500; }
.cited { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.cited a { padding: 1px 8px; border-radius: 6px; background: var(--surface2); font-family: var(--mono); }
.cited a:hover { color: var(--accent); }
.note-card h4 { font-size: 15px; margin-bottom: 10px; }
.note-card ol { margin: 4px 0 0; padding-left: 20px; }
.note-card .lab { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* ============ 仓位 ============ */
.pos-card { display: block; padding: 18px 20px; transition: border-color .15s; }
.pos-card:hover { border-color: var(--accent); }
.pos-card .sym { font-size: 17px; font-weight: 650; font-family: var(--mono); }
.price-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1000px) { .price-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 520px) { .price-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.op-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.roll-btn {
  appearance: none; border: none; cursor: pointer; font: inherit; font-weight: 650; font-size: 14px; color: #fff;
  padding: 9px 18px 9px 14px; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--roll), var(--roll2)); box-shadow: 0 3px 12px color-mix(in srgb, var(--roll) 35%, transparent);
  transition: transform .1s, box-shadow .2s;
}
.roll-btn .knob { width: 30px; height: 18px; border-radius: 999px; background: rgba(255,255,255,.35); position: relative; }
.roll-btn .knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s; }
.roll-btn.on .knob::after { transform: translateX(12px); }
.roll-btn.on { box-shadow: 0 0 0 3px color-mix(in srgb, var(--roll) 30%, transparent), 0 3px 12px color-mix(in srgb, var(--roll) 35%, transparent); }
.roll-btn:active { transform: translateY(1px); }
.roll-panel { border: 1.5px dashed var(--roll); background: color-mix(in srgb, var(--roll) 6%, var(--surface)); }
.roll-panel .card-head h3 { color: var(--roll); }
/* 标的名称旁的编辑 / 删除 */
.head-ops { display: inline-flex; gap: 6px; margin-left: 6px; }
.head-op { font-weight: 700; padding: 4px 12px; }
/* 可滚动、可放大的记录卡片 */
.scroll-card { cursor: zoom-in; transition: border-color .15s; display: flex; flex-direction: column; }
.scroll-card:hover { border-color: var(--accent); }
.scroll-card form, .scroll-card form * { cursor: auto; }
.scroll-card .scroll-body { max-height: 280px; overflow-y: auto; padding-right: 6px; margin-right: -6px; overscroll-behavior: contain; scrollbar-width: thin; }
.scroll-card .scroll-body .timeline { padding-top: 2px; }
.expand-btn { width: 30px; height: 30px; font-size: 16px; }
.expand-body { max-height: 70vh; overflow-y: auto; padding-right: 6px; }
/* 资金曲线（仿交易所首页：大数字 + 盈亏 + 平滑曲线 + 底部时间范围） */
.fund-card { padding: 20px 22px 14px; }
.fund-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.fund-title { font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.fund-lab { font-size: 14px; color: var(--text); }
.fund-big { font-size: 38px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; margin-top: 2px; }
.fund-pnl { font-size: 14px; color: var(--text); margin-top: 6px; }
.fund-pnl .mono { margin-left: 6px; }
.fund-side { text-align: right; line-height: 1.9; padding-top: 2px; font-weight: 700; color: var(--text); }
.fund-side .mono { color: var(--text); margin-left: 4px; font-weight: 700; }
.fund-side .mono.up { color: var(--up); }
.fund-side .mono.down { color: var(--down); }
.fund-chart { position: relative; margin-top: 6px; }
.fund-chart .chart-box { height: 240px; }
.fund-mark { position: absolute; z-index: 2; font-family: var(--mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; pointer-events: none; }
.fund-hover { position: absolute; left: 4px; top: 0; z-index: 2; font-size: 12px; color: var(--muted); background: color-mix(in srgb, var(--surface) 85%, transparent); padding: 1px 6px; border-radius: 6px; pointer-events: none; }
.fund-hover b { color: var(--text); margin-left: 4px; }
.fund-ranges { display: flex; justify-content: space-between; gap: 6px; margin-top: 10px; }
.fund-ranges button { flex: 1; max-width: 88px; border: none; background: transparent; color: var(--muted); font: inherit; font-size: 14px; padding: 6px 0; border-radius: 10px; cursor: pointer; }
.fund-ranges button:hover { color: var(--text); }
.fund-ranges button.on { background: var(--surface2); color: var(--text); font-weight: 600; }
.fund-hint { margin-top: 10px; }
@media (max-width: 640px) { .fund-big { font-size: 32px; } .fund-side { text-align: left; padding-top: 0; } .fund-chart .chart-box { height: 200px; } }

/* 交易逻辑模板 */
.tpl-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 6px; }
.tpl-lab { font-size: 11.5px; color: var(--faint); margin-right: 2px; }
.tpl-chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 12px; padding: 2px 9px; border-radius: 999px; cursor: pointer; transition: border-color .15s, background .15s; }
.tpl-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.tpl-chip.used { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tpl-chip.mine { border-style: dashed; border-color: var(--accent); }
.tpl-chip.mine i { font-style: normal; color: var(--faint); margin-left: 2px; padding: 0 2px; border-radius: 4px; }
.tpl-chip.mine i:hover { color: var(--down); background: var(--down-soft); }
.tpl-save { border: none; background: transparent; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; padding: 2px 4px; }
.tpl-save:hover { text-decoration: underline; }

/* K 线画图工具 */
.draw-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 8px; }
.draw-bar .seg button { font-size: 12.5px; padding: 4px 10px; }
.vol-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.draw-hint { margin-left: 4px; }
.draw-style { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface2); font-size: 12.5px; }
.draw-style .ds-name { font-weight: 650; }
.draw-style .ds-item { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.draw-style input[type="color"] { width: 28px; height: 22px; padding: 0 1px; border-radius: 6px; cursor: pointer; }
.draw-style input[type="range"] { width: 72px; }
.draw-style select { width: auto; padding: 2px 6px; font-size: 12.5px; }
.draw-style .mono { min-width: 32px; color: var(--text); }
.draw-layer { position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.draw-layer.drawing { pointer-events: all; cursor: crosshair; }
.draw-layer .dw-hit, .draw-layer .dw-handle { pointer-events: all; cursor: move; }
.draw-layer .dw-body { pointer-events: visiblePainted; cursor: move; }
.draw-layer.drawing .dw-hit, .draw-layer.drawing .dw-body { pointer-events: none; }
.draw-layer .dw-handle { fill: var(--surface); stroke-width: 2; cursor: grab; }
.draw-layer .dw.sel line:not(.dw-hit), .draw-layer .dw.sel rect, .draw-layer .dw.sel polygon { filter: drop-shadow(0 0 1.5px rgba(0,0,0,.25)); }

/* 复盘面板：上下排列、紧凑 */
.review-card { padding: 16px 20px 18px; }
.review-card .card-head { margin-bottom: 8px; }
.rv-sec + .rv-sec { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.rv-lab { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.rv-lab .faint { font-weight: 400; font-size: 12px; }
.rv-lab .btn { margin-left: auto; }
.review-card textarea { min-height: 0; resize: vertical; padding: 8px 11px; line-height: 1.65; overflow-y: auto; }
.review-card .chips { gap: 6px; }
.review-card .chip { padding: 3px 10px; font-size: 12.5px; }
.quote-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 760px) { .quote-grid { grid-template-columns: minmax(0, 1fr); } }
.quote-grid .quote-card { margin: 0; padding: 10px 12px 8px 16px; font-size: 13.5px; }
.quote-grid .quote-card::before { font-size: 24px; left: 4px; top: -3px; }
.quote-card.q-mood::before { color: var(--qc); }
.quote-card .q-title { font-weight: 600; margin-bottom: 2px; }
.quote-card .q-body { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.quote-card .from { font-size: 12px; align-items: center; }
.quote-card .from .btn { padding: 2px 8px; }
.psy-px { font-family: var(--mono); font-size: 11.5px; color: var(--muted); background: var(--surface2); padding: 0 6px; border-radius: 5px; margin-left: 4px; }
.op-sep { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }
.iv-bar { display: flex; gap: 2px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 14px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 5px; }
.legend i.dash { border-top-style: dashed; }
.chart-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; text-align: center; padding: 20px; pointer-events: none; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live .dot { width: 7px; height: 7px; background: var(--faint); }
.live.on .dot { background: var(--up); box-shadow: 0 0 0 3px var(--up-soft); }
.live.poll .dot { background: var(--warn); }

.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item::before { content: ""; position: absolute; left: -17px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--tl, var(--accent)); box-shadow: 0 0 0 3px var(--surface); }
.tl-item .when { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.tl-item .what { font-size: 14px; }
.tl-item .x { float: right; opacity: 0; transition: opacity .15s; }
.tl-item:hover .x { opacity: 1; }
@media (hover: none) { .tl-item .x { opacity: 1; } }
.logic-block + .logic-block { margin-top: 14px; }
.logic-block .lab { font-size: 12px; color: var(--muted); margin-bottom: 3px; display: flex; justify-content: space-between; }
.logic-block .txt { font-size: 14px; white-space: pre-wrap; }
.discipline { background: var(--warn-soft); border-radius: 12px; padding: 12px 16px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.discipline b { color: var(--warn); }
.counter { font-family: var(--mono); font-size: 11px; color: var(--faint); float: right; }
.counter.ok { color: var(--up); }

.quote-card { border-radius: 12px; background: var(--surface2); padding: 14px 16px 12px 18px; position: relative; font-size: 14px; }
.quote-card::before { content: "“"; position: absolute; left: 6px; top: -4px; font-size: 30px; color: var(--accent); opacity: .5; font-family: Georgia, serif; }
.quote-card .from { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; justify-content: space-between; gap: 8px; }
.quote-card + .quote-card { margin-top: 10px; }
.pick-list { max-height: 50vh; overflow: auto; margin-top: 12px; }
.pick-item { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 14px; }
.pick-item + .pick-item { margin-top: 8px; }
.pick-item:hover { border-color: var(--accent); }
.pick-item.on { border-color: var(--accent); background: var(--accent-soft); }

.bars .bar-row { display: grid; grid-template-columns: 96px 1fr 36px; align-items: center; gap: 10px; font-size: 13px; }
.bars .bar-row + .bar-row { margin-top: 9px; }
.bars .track { height: 8px; border-radius: 999px; background: var(--surface2); overflow: hidden; }
.bars .track span { display: block; height: 100%; background: var(--down); opacity: .75; border-radius: 999px; }
.bars .c { font-family: var(--mono); text-align: right; color: var(--muted); }

/* ============ 弹窗 / 提示 ============ */
.modal-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(20, 18, 15, .38); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 520px; box-shadow: 0 20px 60px rgba(0,0,0,.25); border: 1px solid var(--line); animation: pop .18s; }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 0 22px; }
.modal-body { padding: 14px 22px 22px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } }
#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 60; pointer-events: none; }
@media (max-width: 640px) { #toast { bottom: calc(78px + env(safe-area-inset-bottom)); } }
#toast .t { background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 14px; margin-top: 8px; animation: pop .2s; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.calc-out { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 640px) { .calc-out { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.calc-out .kpi .v { font-size: 16px; }
.warn-text { color: var(--warn); font-size: 13px; }
.err-text { color: var(--down); font-size: 13px; }
