:root {
  --border: #e5e7eb;
  --border-soft: #f3f4f6;
  --text: #1f2937;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #15803d;
  --accent-strong: #16a34a;
  --accent-bg: #e8f5ee;
  --accent-border: #b5dfc5;
  --sel-bg: #ecf7f0;
  --dot: #f59e0b;
  --danger: #dc2626;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  font-size: 14px;
  background: #fff;
}
button { font-family: inherit; }

#app {
  display: grid;
  grid-template-columns: 236px 384px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ---------- 侧栏 ---------- */
#sidebar { overflow-y: auto; padding: 14px 12px 30px; border-right: 1px solid var(--border); }
.sb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sb-head h1 { font-size: 20px; font-weight: 800; letter-spacing: -0.3px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
#mode-tabs { display: grid; grid-template-columns: repeat(5, 1fr); }
#mode-tabs.no-fin { grid-template-columns: repeat(4, 1fr); }
#mode-tabs .chip { padding: 3px 0; text-align: center; font-size: 12px; }
.chip {
  padding: 3px 10px; font-size: 12.5px; color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer;
  transition: background .12s;
}
.chip:hover { background: #f9fafb; }
.chip.active {
  background: var(--accent-bg); border-color: var(--accent-border);
  color: var(--accent); font-weight: 600;
}
.icon-btn {
  width: 27px; height: 27px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer;
  color: #374151;
}
.icon-btn:hover { background: #f9fafb; }
.icon-btn.spinning svg { animation: rot 1s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

.sb-label { font-size: 11.5px; color: var(--faint); margin: 14px 2px 6px; }
.all-subs {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: 13.5px; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
}
.all-subs:hover { background: #f9fafb; }
.all-subs.active { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent); font-weight: 600; }
#folder-tree { margin-top: 6px; }
.folder-row {
  display: flex; align-items: center; gap: 4px; padding: 5px 6px; border-radius: 6px;
  cursor: pointer; font-size: 13.5px; user-select: none;
}
.folder-row:hover { background: #f9fafb; }
.folder-row.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.folder-row .caret {
  width: 14px; font-size: 9px; color: var(--faint); flex: none;
  transition: transform .12s; display: inline-block; text-align: center;
}
.folder-row.open .caret { transform: rotate(90deg); }
.folder-row .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-row {
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  padding: 4px 6px 4px 26px; border-radius: 6px; cursor: pointer;
  font-size: 13px; color: #374151;
}
.feed-row:hover { background: #f9fafb; }
.feed-row.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.feed-row .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-row .warn { color: var(--danger); font-size: 11px; flex: none; }
.count { font-size: 11px; color: var(--faint); flex: none; }

/* ---------- 列表栏 ---------- */
#listpane { display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid var(--border); }
.list-head { padding: 10px 10px 0; flex: none; }
.search-row { display: flex; gap: 6px; margin-bottom: 8px; }
.search-row input {
  flex: 1; border: 1px solid var(--border); border-radius: 7px; padding: 6px 10px;
  font-size: 13px; outline: none; min-width: 0;
}
.search-row input:focus { border-color: var(--accent-border); }
.nl-btn {
  flex: none; font-size: 12px; padding: 2px 8px; line-height: 1.25;
  border: 1px solid var(--border); border-radius: 7px; background: #fff; cursor: pointer;
  color: var(--text);
}
.nl-btn:hover { background: #f9fafb; }
.status-row { display: flex; gap: 6px; padding-bottom: 9px; flex-wrap: wrap; }
.nl-banner {
  margin: 0 10px 8px; padding: 6px 10px; background: var(--accent-bg);
  border: 1px solid var(--accent-border); border-radius: 7px; font-size: 12px; color: var(--accent);
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
}
.nl-banner button { border: none; background: none; color: var(--accent); cursor: pointer; font-size: 12px; text-decoration: underline; }
.digest-banner { background: #fffbeb; border-color: #fde68a; color: #92400e; margin-top: 0; }
.digest-banner button { color: #92400e; }
.list-body { flex: 1; overflow-y: auto; border-top: 1px solid var(--border-soft); }

.card { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); cursor: pointer; }
.card:hover { background: #fafafa; }
.card.sel { background: var(--sel-bg); border-left: 3px solid var(--accent-border); padding-left: 9px; }
.card-title { font-size: 14px; font-weight: 500; line-height: 1.45; color: #111827;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card.readed .card-title { color: var(--muted); font-weight: 400; }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--dot); margin-right: 6px; vertical-align: 2px; }
.card-meta { font-size: 12px; color: var(--faint); margin: 3px 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.badge { font-size: 10.5px; padding: 0 5px; border-radius: 4px; border: 1px solid var(--accent-border); color: var(--accent); background: #fff; }
.card-snippet { font-size: 12.5px; color: var(--muted); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-reason { font-size: 12px; color: var(--accent); margin-top: 4px; }

.pane-toolbar {
  padding: 10px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; flex: none;
  border-bottom: 1px solid var(--border-soft);
}
.pane-toolbar .title { font-weight: 600; font-size: 13.5px; margin-right: auto; }
select.mini {
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; font-size: 12.5px;
  background: #fff;
}

.cluster-card { padding: 12px; border-bottom: 1px solid var(--border-soft); cursor: pointer; }
.cluster-card:hover { background: #fafafa; }
.cluster-card.sel { background: var(--sel-bg); }
.cluster-card .ct { font-size: 14px; font-weight: 600; line-height: 1.4; }
.cluster-card .cs { font-size: 12.5px; color: var(--muted); margin-top: 4px; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pill { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent); border: 1px solid var(--accent-border); margin-left: 6px; vertical-align: 1px; }
.trend { font-size: 11px; padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: 1px; }
.trend.up { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.trend.flat { background: #f0f9ff; color: #0369a1; border: 1px solid #bae6fd; }
.trend.down { background: #f9fafb; color: #6b7280; border: 1px solid #e5e7eb; }

/* ---------- 详情栏 ---------- */
#detailpane { overflow-y: auto; display: flex; flex-direction: column; }
.detail-toolbar {
  display: flex; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(4px);
  z-index: 5; flex-wrap: wrap; align-items: center;
}
.tbtn {
  padding: 4px 12px; font-size: 13px; border: 1px solid var(--border); border-radius: 7px;
  background: #fff; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  color: var(--text);
}
.tbtn:hover { background: #f9fafb; }
.tbtn.active { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent); font-weight: 600; }
.tbtn.star.active { color: #d97706; background: #fef9ec; border-color: #fbe4a5; }
.tbtn:disabled { opacity: .55; cursor: default; }

.article { max-width: 880px; margin: 0 auto; padding: 22px 34px 90px; width: 100%; }
.article-title { font-size: 22px; font-weight: 700; line-height: 1.45; }
.orig-title { font-size: 13px; color: var(--faint); margin-top: 7px; line-height: 1.5; }
.article-meta { font-size: 13px; color: var(--faint); margin: 10px 0 20px; }
.article-meta a { color: var(--faint); }
.article-content { font-size: 15px; line-height: 1.9; color: #24292f; word-break: break-word; overflow-wrap: anywhere; }
.article-content p { margin: 0 0 14px; }
.article-content img { max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border-soft); margin: 10px 0; display: block; }
.article-content a { color: #0f766e; }
.article-content h1, .article-content h2, .article-content h3, .article-content h4 { margin: 22px 0 10px; line-height: 1.5; }
.article-content pre { background: #f6f8fa; border: 1px solid var(--border-soft); border-radius: 8px; padding: 12px; overflow-x: auto; font-size: 13px; margin: 0 0 14px; }
.article-content code { background: #f6f8fa; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.article-content pre code { background: none; padding: 0; }
.article-content blockquote { border-left: 3px solid var(--accent-border); color: var(--muted); padding: 2px 0 2px 14px; margin: 0 0 14px; }
.article-content ul, .article-content ol { padding-left: 24px; margin: 0 0 14px; }
.article-content table { border-collapse: collapse; margin: 0 0 14px; max-width: 100%; display: block; overflow-x: auto; }
.article-content td, .article-content th { border: 1px solid var(--border); padding: 6px 10px; font-size: 13.5px; }
.article-content iframe, .article-content video { max-width: 100%; }

.ai-summary-box {
  background: #f0faf4; border: 1px solid var(--accent-border); border-radius: 10px;
  padding: 13px 16px; margin: 0 0 22px; font-size: 14px; line-height: 1.8;
}
.ai-summary-box .ai-label {
  color: var(--accent); font-weight: 700; font-size: 12px; margin-bottom: 6px;
  display: flex; justify-content: space-between; align-items: center;
}
.ai-summary-box .ai-label button { border: none; background: none; color: var(--accent); cursor: pointer; font-size: 12px; text-decoration: underline; }

.note-box { margin: 0 0 18px; }
.note-box textarea {
  width: 100%; min-height: 70px; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 13.5px; font-family: inherit; resize: vertical; outline: none;
}
.note-box textarea:focus { border-color: var(--accent-border); }
.note-actions { margin-top: 6px; display: flex; gap: 8px; }

.back-row { padding: 10px 16px 0; }
.mini-card { padding: 10px 16px; border-bottom: 1px solid var(--border-soft); cursor: pointer; }
.mini-card:hover { background: #fafafa; }
.mini-card .mt { font-size: 14px; font-weight: 500; line-height: 1.5; }
.mini-card.readed .mt { color: var(--muted); font-weight: 400; }
.mini-card .mm { font-size: 12px; color: var(--faint); margin-top: 2px; }
.section-head { padding: 14px 16px 6px; font-size: 13px; font-weight: 700; color: var(--muted); }

/* ---------- 通用 ---------- */
.empty { padding: 70px 24px; text-align: center; color: var(--faint); font-size: 13px; line-height: 2; }
.empty .big { font-size: 30px; display: block; margin-bottom: 6px; }
.btn {
  padding: 5px 14px; font-size: 13px; border: 1px solid var(--border); border-radius: 7px;
  background: #fff; cursor: pointer; color: var(--text);
}
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #15803d; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: default; }
.link-btn { border: none; background: none; color: var(--accent); cursor: pointer; font-size: 12.5px; text-decoration: underline; padding: 0; }

.loading { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 40px; color: var(--faint); font-size: 13px; }
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent-strong);
  border-radius: 50%; animation: rot .8s linear infinite; flex: none;
}

#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #111827; color: #fff; font-size: 13px; padding: 8px 16px; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18); max-width: 70vw; animation: fadein .18s;
}
.toast.err { background: #b91c1c; }
@keyframes fadein { from { opacity: 0; transform: translateY(-6px); } }

.modal-mask {
  position: fixed; inset: 0; background: rgba(17,24,39,.4); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: #fff; width: 780px; max-width: 94vw; max-height: 88vh; border-radius: 12px;
  display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(0,0,0,.25);
}
.modal-head { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 15px; }
.modal-head .x { border: none; background: none; font-size: 20px; color: var(--faint); cursor: pointer; line-height: 1; }
.modal-body { overflow-y: auto; padding: 6px 20px 18px; }
.modal-body h3 { font-size: 13.5px; margin: 18px 0 8px; color: var(--accent); }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.form-row { display: flex; align-items: center; gap: 10px; margin: 9px 0; flex-wrap: wrap; }
.form-row > label { width: 130px; flex: none; font-size: 13px; color: #4b5563; }
.form-row input[type=text], .form-row input[type=password], .form-row input[type=number], .form-row select {
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px; font-size: 13px; outline: none;
}
.form-row input:focus, .form-row select:focus { border-color: var(--accent-border); }
.hint { font-size: 12px; color: var(--faint); line-height: 1.7; margin: 6px 0; }
.feed-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.feed-table th { text-align: left; color: var(--faint); font-weight: 500; padding: 6px 6px; font-size: 12px; }
.feed-table td { padding: 6px 6px; border-top: 1px solid var(--border-soft); vertical-align: middle; }
.feed-table td .ftitle { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-table select { border: 1px solid var(--border); border-radius: 6px; padding: 3px 5px; font-size: 12.5px; max-width: 110px; }
.feed-table .err { color: var(--danger); font-size: 11.5px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; }
.feed-table .ok { color: var(--accent); font-size: 11.5px; }

/* ---------- 金融板块 ---------- */
.pulse-card {
  margin: 12px; padding: 12px 14px; border: 1px solid var(--accent-border);
  background: #f0faf4; border-radius: 10px; font-size: 13px; line-height: 1.7;
}
.imp {
  display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px;
  margin-left: 6px; vertical-align: 1px; border: 1px solid transparent;
}
.imp-good { background: #ecfdf3; color: #15803d; border-color: #b5dfc5; }
.imp-bad { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.imp-mixed { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.imp-neutral { background: #f9fafb; color: #6b7280; border-color: #e5e7eb; }
.tk { font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.aff-chip {
  display: inline-block; font-size: 11px; color: #374151; background: #f3f4f6;
  border-radius: 5px; padding: 1px 7px; margin: 3px 4px 0 0;
}
.sev { color: #d97706; font-size: 10.5px; letter-spacing: 1px; margin-top: 3px; }
.disclaimer {
  padding: 9px 14px; font-size: 11.5px; color: var(--faint); line-height: 1.6;
  border-top: 1px solid var(--border-soft); flex: none; background: #fff;
}

.report-item { padding: 12px; border-bottom: 1px solid var(--border-soft); cursor: pointer; }
.report-item:hover { background: #fafafa; }
.report-item.sel { background: var(--sel-bg); }
.report-item .rt { font-size: 14px; font-weight: 600; line-height: 1.4; }
.report-item .rm { font-size: 12px; color: var(--faint); margin-top: 3px; }

@media (max-width: 1100px) {
  #app { grid-template-columns: 200px 320px 1fr; }
}

/* ---------- 移动端（body.mobile 由 UA/宽度自动判定，可手动固定） ---------- */
#m-mask, #m-menu, #m-back { display: none; }
#device-switch { margin-top: 20px; font-size: 12px; color: var(--faint); cursor: pointer; padding: 4px 2px; }
#device-switch:hover { color: var(--accent); }

body.mobile #app { grid-template-columns: 1fr; }
body.mobile #sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: 80vw; max-width: 330px;
  background: #fff; z-index: 120; transform: translateX(-105%);
  transition: transform .22s ease; box-shadow: 4px 0 24px rgba(0,0,0,.14);
}
body.mobile.m-drawer #sidebar { transform: none; }
body.mobile.m-drawer #m-mask {
  display: block; position: fixed; inset: 0; background: rgba(17,24,39,.4); z-index: 115;
}
body.mobile #listpane { border-right: none; }
body.mobile #detailpane {
  position: fixed; inset: 0; background: #fff; z-index: 100;
  transform: translateX(102%); transition: transform .22s ease;
}
body.mobile.m-detail #detailpane { transform: none; }
body.mobile #m-menu {
  display: flex; align-items: center; justify-content: center;
  position: fixed; right: 14px; bottom: 22px; width: 46px; height: 46px;
  border-radius: 50%; border: 1px solid var(--border); background: #fff;
  font-size: 17px; z-index: 90; box-shadow: 0 4px 18px rgba(0,0,0,.16); cursor: pointer;
}
body.mobile.m-detail #m-menu { display: none; }
body.mobile.m-detail #m-back {
  display: flex; align-items: center; justify-content: center;
  position: fixed; left: 14px; bottom: 22px; height: 44px; padding: 0 20px;
  border-radius: 999px; border: 1px solid var(--border); background: #fff;
  font-size: 14px; font-weight: 600; z-index: 130;
  box-shadow: 0 4px 18px rgba(0,0,0,.16); cursor: pointer;
}
body.mobile .article { padding: 18px 16px 100px; max-width: none; }
body.mobile .article-title { font-size: 19px; }
body.mobile .detail-toolbar { padding: 8px 10px; gap: 6px; }
body.mobile .modal { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
body.mobile .form-row > label { width: 100%; }
body.mobile .list-body { padding-bottom: 80px; }
