:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-2: #d1d5db;
  --text: #111827;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --accent: #111827;
  --up: #dc2626;
  --down: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(17, 24, 39, .06), 0 8px 24px rgba(17, 24, 39, .06);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
#app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 210px; flex: 0 0 210px; min-width: 210px; max-width: 210px;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; border-bottom: 1px solid var(--border); }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--accent); color: #fff; font-family: Georgia, "Times New Roman", serif; font-weight: 700; font-size: 17px; display: flex; align-items: center; justify-content: center; letter-spacing: -1px; }
.brand-name { font-weight: 600; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--text-3); }
#nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.nav-group { margin-bottom: 8px; }
.nav-group-title {
  font-size: 11px; color: var(--text-3); padding: 6px 10px 4px; letter-spacing: .5px;
  display: flex; align-items: center; gap: 4px;
}

/* Collapsible nav groups — title styled exactly like nav-item */
.nav-group.collapsible .nav-group-title {
  font-size: 14px; color: var(--text-2); padding: 10px 12px; border-radius: 10px;
  cursor: pointer; user-select: none; transition: background .15s;
  display: flex; align-items: center; gap: 9px;
  letter-spacing: normal;
}
.nav-group.collapsible { margin-bottom: 8px; }
.nav-group.collapsible .nav-group-title:hover { background: #f3f4f6; color: var(--text); }
.nav-group-title > svg, .nav-group-icon svg { flex-shrink: 0; }
.nav-group-arrow {
  display: inline-flex; align-items: center; color: var(--text-3);
  transition: transform .2s; flex-shrink: 0; margin-left: -5px;
}
.nav-group.collapsible.collapsed .nav-group-arrow { transform: rotate(-90deg); }
/* 分组标题右侧「+」新建按钮 */
.nav-add-btn {
  margin-left: auto; width: 22px; height: 22px; border-radius: 50%;
  border: none; background: transparent; color: var(--text-3);
  font-size: 16px; line-height: 1; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation; transition: background .15s, color .15s;
}
.nav-add-btn:hover { background: #f3f4f6; color: var(--text); }
.nav-group.collapsible .nav-group-items {
  overflow: hidden; max-height: 400px;
  transition: max-height .25s ease;
}
.nav-group.collapsible.collapsed .nav-group-items {
  max-height: 0;
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text-2); cursor: pointer; font-size: 14px;
  margin-bottom: 4px; -webkit-user-select: none; user-select: none;
  touch-action: manipulation; position: relative;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: #f3f4f6; color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item .badge { margin-left: auto; font-size: 11px; background: rgba(0,0,0,.08); color: var(--text-2); padding: 1px 7px; border-radius: 99px; }
.nav-item.active .badge { background: rgba(255,255,255,.2); color: #fff; }

/* Unread bubble（微信式：红色小徽标，>99 显示 99+） */
.nav-item .unread-bubble {
  margin-left: auto; font-size: 10px; font-weight: 600;
  min-width: 16px; height: 16px; line-height: 16px; text-align: center;
  background: #ef4444; color: #fff; padding: 0 4px; border-radius: 8px;
  display: inline-block; flex-shrink: 0;
}
.nav-item.active .unread-bubble { background: #ef4444; color: #fff; }

.side-foot { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-3); line-height: 1.6; }
#drawer-mask { display: none; }

/* ---------- Main ---------- */
#main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; position: relative; z-index: 10; background: var(--bg); }
/* 右滑返回预览层 */
.swipe-preview {
  position: fixed; inset: 0; z-index: 5;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .18s ease-out;
}
.swipe-preview-inner { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 14px; }
body.swiping { overflow: hidden; }
body.swiping #main { box-shadow: -10px 0 34px rgba(0,0,0,.16); }
#menu-btn { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
#sidebar { transition: width .2s ease, flex-basis .2s ease; }
#app.sidebar-hidden #sidebar { width: 0; flex: 0 0 0; min-width: 0; max-width: 0; border-right: none; overflow: hidden; }
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 25;
  min-height: 60px;
}
#page-title { font-size: 18px; font-weight: 600; }
.page-sub { font-size: 12px; color: var(--text-3); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: #f59e0b; display: inline-block; }
.conn-dot.ok { background: var(--down); }
.conn-dot.bad { background: var(--up); }
#content { padding: 20px 22px 40px; max-width: 1080px; width: 100%; margin: 0 auto; }
#drawer-mask { display: none; }

/* 页面切换过渡动画（iPhone 无震动 API 的视觉替代反馈） */
#content.page-switch { animation: pageSwitch .18s ease; }
@keyframes pageSwitch { from { opacity: .45; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #content.page-switch { animation: none; } }

/* ---------- Components ---------- */
.btn { border: none; border-radius: 8px; padding: 8px 14px; font-size: 13.5px; cursor: pointer; font-family: var(--font); touch-action: manipulation; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn.ghost:hover { color: var(--text); border-color: var(--text-3); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-2); padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: #f3f4f6; color: var(--text); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card-title .hint { font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: auto; }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--text-3); }
.stat .v { font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--text-3); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.mono { font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--text-2); }
.chg { font-weight: 600; }
.sym { font-size: 12px; color: var(--text-3); }
.name-cell { font-weight: 500; }
/* 每日看板持仓表 */
.pf-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -6px; padding: 0 6px; }
.pf-foot { font-size: 11px; color: var(--text-3); padding-top: 10px; text-align: right; }
/* 新建 Portfolio 名称输入 */
.pf-name-row { margin-bottom: 12px; }
.pf-name-label { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.pf-table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.pf-table thead th {
  background: #f3f4f6; color: var(--text-2); font-size: 12px; font-weight: 600;
  padding: 7px 4px; white-space: nowrap; border-bottom: 1px solid var(--border-2); text-align: center;
}
.pf-table th { text-align: center; }
.pf-table th:first-child { width: 16%; }
.pf-table td { text-align: center; padding: 8px 4px; font-size: 14px; }
.pf-table td:first-child { text-align: center; }
.pf-name { min-width: 0; }
.pf-nm { font-size: 13.5px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-sym { font-size: 10.5px; color: var(--text-3); margin-top: 1px; }
.pf-table .pf-num { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: center; white-space: nowrap; }
.err-cell { color: var(--text-3); font-size: 12.5px; }
.spark { display: block; }
.spark.up polyline { stroke: var(--up); }
.spark.down polyline { stroke: var(--down); }

.placeholder { text-align: center; padding: 48px 20px; }
.placeholder .ph-icon { font-size: 30px; opacity: .4; margin-bottom: 10px; }
.placeholder h3 { font-size: 16px; margin-bottom: 6px; }
.placeholder p { color: var(--text-2); font-size: 13px; max-width: 420px; margin: 0 auto 8px; }
.placeholder .ph-status { display: inline-block; margin-top: 6px; font-size: 12px; padding: 3px 12px; border-radius: 99px; background: #f3f4f6; color: var(--text-2); }

/* 首页（Dennis的工作台） */
.home-hero { margin: 8px 0 20px; }
.home-title {
  font-size: 26px; font-weight: 700; letter-spacing: .5px;
  background: linear-gradient(90deg, var(--text), #6b7280);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.home-date { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }
/* 名言区：杂志风极简（左侧细竖线强调，大字名言，小字作者，无背景无装饰） */
.quote-block {
  margin: 26px 0 4px; padding: 2px 0 2px 18px;
  border-left: 3px solid var(--accent);
}
.quote-block .quote-text {
  font-size: 18px; line-height: 1.65; font-weight: 500; color: var(--text);
  letter-spacing: .2px; word-break: break-word;
}
.quote-block .quote-author {
  margin-top: 10px; font-size: 13px; color: var(--text-3); font-weight: 400;
}

/* Todo（iOS 提醒事项风格） */
.todo-card .card-title .hint { margin-left: 0; margin-right: auto; }
.todo-add-row { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; }
.todo-add-row input {
  flex: 1; min-width: 0; min-height: 38px; padding: 0 16px;
  border: none; background: var(--bg); border-radius: 19px;
  font-size: 16px; font-family: var(--font); color: var(--text);
}
.todo-add-row input:focus { outline: none; background: var(--bg); }
.todo-push { width: 32px; height: 32px; border-radius: 50%; border: none; flex-shrink: 0;
  background: var(--accent); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation; transition: transform .15s, opacity .15s;
}
.todo-push:active { transform: scale(.9); }
.todo-push:disabled { opacity: .4; }
/* 提示文字视觉缩小；输入文字保持 16px（iOS 聚焦自动放大规则：<16px 必放大） */
.todo-add-row input::placeholder { font-size: 13px; color: var(--text-3); }
.todo-swipe {
  position: relative;
  border-bottom: 1px solid var(--border);
  touch-action: pan-y;
  overflow: hidden;
  transition: max-height .26s ease, opacity .26s ease, border-color .26s ease;
}
.todo-swipe:last-child { border-bottom: none; }
/* 完成后淡出收缩消失（iOS 提醒事项效果） */
.todo-swipe.removing { max-height: 0 !important; opacity: 0; border-bottom-color: transparent; }
.todo-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 4px; min-height: 44px; background: var(--surface);
  position: relative; z-index: 2;
}
/* iOS 提醒事项式圆点：细描边，完成时填充并带弹跳动画 */
.todo-check {
  width: 17px; height: 17px; border-radius: 50%;
  border: 1.5px solid #c7c7cc; cursor: pointer; flex-shrink: 0; margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  color: transparent; font-size: 10px; touch-action: manipulation;
  background: var(--surface);
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.todo-check.done {
  background: var(--accent); border-color: var(--accent); color: #fff;
  animation: check-pop .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes check-pop {
  0% { transform: scale(.5); }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.todo-main { flex: 1; min-width: 0; }
.todo-text { font-size: 14.5px; line-height: 1.45; word-break: break-word; flex: 1; min-width: 0; transition: color .2s ease; }
/* iOS 完成态：文字变灰（无删除线，跟随系统提醒事项） */
.todo-text.done { color: #8e8e93; }
/* 编辑状态：待办文字变成内联输入框 */
.todo-edit-input {
  flex: 1; min-width: 0; min-height: 30px; padding: 0 10px;
  border: 1px solid var(--border-2); border-radius: 8px;
  font-size: 16px; font-family: var(--font); color: var(--text); background: var(--surface);
}
.todo-edit-input:focus { outline: none; border-color: var(--accent); }
/* iOS 滑动删除按钮：行左滑露出（absolute 右缘，行高一致，系统红） */
.todo-del {
  position: absolute; top: 0; right: 0; bottom: 0; width: 76px;
  background: #ff3b30; color: #fff; border: none;
  font-size: 15px; font-weight: 500; letter-spacing: .5px;
  display: none; align-items: center; justify-content: center;
  cursor: pointer; touch-action: manipulation;
}
.todo-swipe.swiped .todo-del { display: flex; }
.todo-empty { padding: 22px 0; text-align: center; color: var(--text-3); font-size: 13px; }
.todo-tip { font-size: 11.5px; color: var(--text-3); padding-top: 12px; text-align: center; }

/* Podcast */
.pod-add { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.pod-add input { flex: 1; min-width: 180px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px; font-family: var(--font); min-height: 40px; }
.pod-item { padding: 12px 2px; border-bottom: 1px solid var(--border); }
.pod-item:last-child { border-bottom: none; }
.pod-item a { color: var(--text); text-decoration: none; font-weight: 500; }
.pod-item a:hover { text-decoration: underline; }
.pod-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.pod-desc { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }
.pod-title-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.src-badge { font-size: 11px; font-weight: 500; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.src-semianalysis { background: #EEEDFE; color: #3C3489; border: 1px solid #AFA9EC; }
.src-marks { background: #E6F1FB; color: #0C447C; border: 1px solid #85B7EB; }
.src-focused { background: #E1F5EE; color: #085041; border: 1px solid #5DCAA5; }
.src-simonwillison { background: #FEF3C7; color: #92400E; border: 1px solid #F59E0B; }

/* ---------- Archive (PDF list) ---------- */
.archive-section { margin-bottom: 16px; }
.archive-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.archive-title .hint { font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: auto; }
.archive-toggle { cursor: pointer; -webkit-user-select: none; user-select: none; }
.archive-toggle:hover { color: var(--accent); }
.archive-caret { font-size: 12px; color: var(--text-3); flex-shrink: 0; transition: transform .15s; }
.archive-body { padding-top: 2px; }
.archive-item { padding: 9px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.archive-item:last-child { border-bottom: none; }
.archive-item a { color: var(--text); text-decoration: none; font-weight: 500; font-size: 13px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.archive-item a:hover { text-decoration: underline; }
.archive-item a.archive-size { flex: none; font-size: 11px; color: var(--accent); }
.archive-item .archive-meta { font-size: 11.5px; color: var(--text-3); flex-shrink: 0; }
.archive-empty { color: var(--text-3); font-size: 13px; padding: 12px 0; }

/* Podcast tabs (RSS / ILTB) — kept for backward compat, now unused by default */
.pod-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.pod-tab { padding: 7px 14px; border-radius: 99px; font-size: 13px; cursor: pointer; color: var(--text-2); border: 1px solid var(--border); background: var(--surface); touch-action: manipulation; }
.pod-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pod-tab .cnt { opacity: .7; font-size: 11.5px; margin-left: 4px; }

/* Chat */
#chat-fab { position: fixed; right: 20px; bottom: 24px; z-index: 60; background: var(--accent); color: #fff; border: none; border-radius: 99px; padding: 12px 20px; font-size: 14px; cursor: pointer; box-shadow: var(--shadow); font-family: var(--font); min-height: 44px; touch-action: manipulation; }
#chat-panel { position: fixed; right: 20px; bottom: 84px; width: 380px; max-width: calc(100vw - 32px); height: 62vh; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); z-index: 70; display: flex; flex-direction: column; overflow: hidden; }
#chat-panel.hidden { display: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
#chat-msgs { flex: 1; overflow-y: auto; padding: 14px 16px; }
.msg { margin-bottom: 12px; max-width: 88%; }
.msg.user { margin-left: auto; }
.msg .bubble { padding: 9px 13px; border-radius: 12px; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.msg.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant .bubble { background: #f3f4f6; border-bottom-left-radius: 4px; }
.msg .meta { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.action-chip { font-size: 12px; background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; border-radius: 6px; padding: 2px 8px; margin-top: 4px; display: inline-block; }
.action-chip.fail { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.chat-input-row { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); align-items: center; }
.chat-input-row input { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 16px; font-family: var(--font); min-height: 40px; }
.chat-input-row input:focus { outline: none; border-color: var(--text-3); }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: var(--accent); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px; z-index: 90; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }

/* Settings */
.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-2); }
.kv .v { font-weight: 500; text-align: right; }
.kv .v.bad { color: #b45309; }
.token-row { display: flex; align-items: center; gap: 8px; }
.token-row input { flex: 1; font-family: var(--font-mono, monospace); font-size: 12px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: #f8f9fa; color: var(--text-2); }

/* Token modal */
#token-modal.hidden { display: none; }
.modal-mask { position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 95; }
.modal { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); width: min(400px, calc(100vw - 24px)); background: var(--surface); border-radius: 16px; padding: 22px; z-index: 96; box-shadow: var(--shadow); }
.modal h3 { font-size: 16px; margin-bottom: 8px; }
.modal p { font-size: 13px; color: var(--text-2); margin-bottom: 14px; line-height: 1.6; }
.modal code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.modal input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 16px; font-family: var(--font); }
.modal textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 16px; font-family: var(--font); resize: vertical; }
.modal textarea:focus { outline: none; border-color: var(--text-3); }
.modal input:focus { outline: none; border-color: var(--text-3); }
.modal-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- 更新 Portfolio 弹窗 ---------- */
#pf-modal .modal { width: min(560px, calc(100vw - 24px)); }
.pf-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-size: 16px; font-weight: 600; }
.pf-modal-sub { font-size: 12.5px; color: var(--text-2); margin-bottom: 10px; line-height: 1.6; }
#pf-input {
  width: 100%; min-height: 150px; padding: 10px 12px; resize: vertical;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 16px; font-family: var(--font); line-height: 1.6; color: var(--text);
}
#pf-input:focus { outline: none; border-color: var(--text-3); }
.pf-modal-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
#pf-status { font-size: 12.5px; margin: 10px 0 2px; min-height: 16px; }
#pf-results { max-height: 300px; overflow-y: auto; margin-top: 6px; border-top: 1px solid var(--border); }
.pf-row { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.pf-row:last-child { border-bottom: none; }
.pf-idx {
  width: 20px; height: 20px; border-radius: 50%; background: #f3f4f6;
  color: var(--text-2); font-size: 11.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.pf-row-main { flex: 1; min-width: 0; }
.pf-row-name { font-size: 13.5px; font-weight: 500; }
.pf-row-sym { font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: 6px; }
.pf-mkt {
  font-size: 10.5px; color: #fff; background: #9ca3af; border-radius: 4px;
  padding: 1px 5px; margin-left: 6px; vertical-align: 1px;
}
.pf-row-in { font-size: 11.5px; color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* ✎ 修改按钮 */
.pf-fix {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 7px;
  border: 1px solid var(--border); background: #fff; color: var(--text-2);
  font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.pf-fix:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
/* 编辑区 */
.pf-edit { margin-top: 8px; padding: 9px 10px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; }
.pf-edit-bar { display: flex; gap: 6px; align-items: center; }
.pf-edit-input {
  flex: 1; min-width: 0; padding: 6px 9px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 16px; font-family: var(--font); color: var(--text);
}
.pf-edit-input:focus { outline: none; border-color: var(--text-3); }
.pf-edit-cands { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pf-cand-btn {
  display: flex; align-items: center; gap: 5px; padding: 5px 9px;
  border: 1px solid var(--border); border-radius: 7px; background: #fff;
  font-size: 12.5px; font-family: var(--font); color: var(--text); cursor: pointer;
  transition: all .15s; max-width: 100%;
}
.pf-cand-btn:hover { border-color: var(--accent); color: var(--accent); background: #f0f7ff; }
.pf-cand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px; }
.pf-edit-msg { font-size: 12px; margin-top: 6px; min-height: 0; }
.btn.small { padding: 5px 10px; font-size: 12px; white-space: nowrap; }

/* ============================================================
   Mobile（≤820px）—— 抽屉式侧栏 + 优化触控/排版
   ============================================================ */
@media (max-width: 820px) {
  /* 侧栏改为固定抽屉，默认隐藏 */
  #sidebar {
    position: fixed !important; top: 0; left: 0; bottom: 0;
    width: 280px !important; flex: none !important; min-width: 0 !important; max-width: none !important;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 50;
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto; overflow-x: hidden;
    padding-top: env(safe-area-inset-top, 0px);
  }
  #sidebar.open { transform: translateX(0); }
  #app.sidebar-hidden #sidebar { width: 280px !important; }
  #drawer-mask {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35);
    z-index: 45; transition: opacity .2s;
  }
  #drawer-mask.show { display: block; }
  .brand { gap: 10px; padding: 18px 16px 14px; border-bottom: 1px solid var(--border); }
  .brand-mark { width: 38px; height: 38px; font-size: 17px; border-radius: 10px; }
  .brand-text { display: flex; flex-direction: column; }
  #nav { padding: 8px 6px; }
  .nav-group { margin-bottom: 10px; }
  .nav-item .badge { display: none; }
  .nav-item.active { background: var(--accent); color: #fff; }
  .nav-item.active:hover { background: var(--accent); }
  .side-foot { display: none; }

  /* topbar - 安全区 + 一定高于 sidebar */
  #topbar {
    padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 8px !important;
    gap: 8px !important;
    min-height: calc(env(safe-area-inset-top, 0px) + 44px);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
  }
  #page-title { font-size: 15px !important; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .page-sub { display: none; }
  #page-title-wrap { flex: 1; min-width: 0; }
  .top-actions { gap: 8px; flex-shrink: 0; }
  #refresh-btn { padding: 7px 12px; font-size: 12.5px; min-height: 36px; }
  .conn-dot { width: 8px; height: 8px; }

  /* 内容 */
  #content { padding: 14px 12px calc(100px + env(safe-area-inset-bottom, 0px)); max-width: 100%; }
  .card { padding: 14px; border-radius: 10px; margin-bottom: 12px; }
  .card-title { font-size: 14px; margin-bottom: 10px; }
  .card-title .hint { font-size: 11px; }
  .stats-row { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .stat { padding: 12px 14px; }
  .stat .k { font-size: 11px; }
  .stat .v { font-size: 18px; }
  .placeholder { padding: 36px 14px; }
  .placeholder p { font-size: 12.5px; }

  /* 每日看板表格：移动端全部列压缩在屏内，不横向滚动 */
  .pf-wrap { margin: 0 -10px; padding: 0 10px; }
  .pf-table { width: 100%; table-layout: fixed; }
  .pf-table thead th { font-size: 10.5px; padding: 6px 3px; }
  .pf-table th:first-child { width: 20%; }
  .pf-table td { padding: 8px 3px; }
  .pf-table .pf-num { font-size: 11px; }
  .pf-table .pf-nm { font-size: 12.5px; }
  .pf-table .pf-sym { font-size: 9.5px; }
  .spark svg { width: 60px; height: 24px; }

  /* 待办（iOS 风格） */
  .todo-row { padding: 12px 0; gap: 9px; }
  .todo-text { font-size: 14.5px; }

  /* 首页 */
  .home-hero { margin: 4px 0 16px; }
  .home-title { font-size: 23px; }
  .quote-block .quote-text { font-size: 16px; }

  /* 投资人动态 / SemiAnalysis 列表 */
  .pod-add { flex-direction: column; }
  .pod-add input { width: 100%; }
  .pod-item { padding: 12px 0; }
  .pod-item a { font-size: 14px; }
  .pod-title-row { gap: 6px; }
  .src-badge { font-size: 10.5px; padding: 2px 7px; }

  /* 设置 */
  .kv { font-size: 13px; }

  /* Chat */
  #chat-panel { width: 100vw; max-width: 100vw; right: 0; bottom: 0; height: 78vh; border-radius: 16px 16px 0 0; }
  #chat-fab { right: 14px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); padding: 10px 16px; font-size: 13px; }
  #chat-input { font-size: 16px; min-height: 44px; }
  #chat-send { min-height: 44px; }

  /* Token modal */
  .modal { top: 30%; width: calc(100vw - 24px); padding: 20px 18px; }
  .modal h3 { font-size: 15px; }
  .modal p { font-size: 12.5px; }
  /* Portfolio modal：顶部对齐、内容可滚动 */
  #pf-modal .modal { top: 3vh; transform: translate(-50%, 0); max-height: 92vh; display: flex; flex-direction: column; }
  #pf-input { min-height: 110px; }
  #pf-results { max-height: 32vh; }
}
@media (min-width: 821px) { #chat-fab { bottom: 28px; } }

/* ---------- ILTB YouTube 卡片网格 ---------- */
.iltb-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 12.5px; color: var(--text-3); }
.iltb-head .btn { margin-left: auto; }
.iltb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.iltb-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: transform .12s, box-shadow .12s; }
.iltb-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.iltb-thumb { position: relative; display: block; aspect-ratio: 16/9; background: #e8eaed; overflow: hidden; }
.iltb-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.iltb-thumb .dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.78); color: #fff; font-size: 11px; padding: 1px 5px; border-radius: 4px; }
.iltb-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.iltb-title { font-size: 13.5px; font-weight: 500; color: var(--text); text-decoration: none; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.iltb-title:hover { color: var(--accent); text-decoration: underline; }
.iltb-meta { font-size: 11.5px; color: var(--text-3); margin-top: auto; }
.iltb-trans { margin-top: 2px; align-self: flex-start; }
.iltb-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.iltb-actions .btn { margin-top: 0; }
.iltb-view.muted { opacity: .45; }

/* ---------- Transcript 模态框 ---------- */
#trans-modal.hidden { display: none; }
#pf-modal.hidden { display: none; }
#trans-modal .modal { width: min(760px, calc(100vw - 24px)); top: 4vh; transform: translate(-50%, 0); max-height: 92vh; display: flex; flex-direction: column; }
#trans-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
#trans-title { font-size: 14.5px; font-weight: 600; line-height: 1.4; flex: 1; }
#trans-status { font-size: 12.5px; color: var(--text-2); min-height: 20px; margin-bottom: 10px; }
#trans-body { flex: 1; overflow-y: auto; font-size: 13.5px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--bg); max-height: 70vh; }
#trans-body p { margin: 0 0 8px; }
#trans-body .trans-h { font-size: 13.5px; font-weight: 600; margin: 14px 0 8px; padding-top: 10px; border-top: 1px solid var(--border); }
#trans-body .trans-h:first-child { margin-top: 0; padding-top: 0; border-top: none; }
#trans-body .trans-ts { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-3); font-size: 12px; margin-right: 6px; }
#trans-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.spinner { display: inline-block; width: 13px; height: 13px; border: 2px solid var(--text-3); border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
