* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --text: #17201d;
  --muted: #68736f;
  --faint: #9aa39f;
  --line: #e2e7e4;
  --line-strong: #d5ded9;
  --accent: #2b7d73;
  --accent-2: #456ed8;
  --danger: #d84b5c;
  --up: #d84b5c;
  --down: #1a9b63;
  --shadow: 0 10px 30px rgba(31, 45, 40, .08);
  --topbar-h: 56px;
  --tabbar-h: 62px;
  --app-w: 760px;
}
html, body { min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background:
    linear-gradient(180deg, #eef3f1 0%, var(--bg) 220px),
    var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }
.hidden { display: none !important; }
.screen {
  width: 100%;
  min-height: 100vh;
  max-width: var(--app-w);
  margin: 0 auto;
  background: var(--bg);
}

/* ---- 登录 ---- */
.login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    linear-gradient(150deg, #143e39 0%, #2b7d73 52%, #f0b35a 130%);
}
.login-box {
  width: 100%;
  max-width: 360px;
  padding: 30px 24px 24px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 8px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, .22);
  text-align: left;
}
.login-logo {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eaf4f1;
  color: var(--accent);
  font-size: 26px;
  margin-bottom: 18px;
}
.login-box h1 { font-size: 24px; line-height: 1.2; font-weight: 750; }
.login-sub { color: var(--muted); font-size: 13px; margin: 8px 0 22px; }
.login-box input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  font-size: 16px;
  margin-bottom: 12px;
}
.login-box input:focus {
  outline: 2px solid rgba(43, 125, 115, .18);
  border-color: var(--accent);
}
.login-box button {
  width: 100%;
  height: 46px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}
.login-box button:active { transform: translateY(1px); }
.login-err { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---- 顶部栏 ---- */
#topbar {
  position: fixed;
  top: 0;
  left: 50%;
  width: min(100%, var(--app-w));
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  transform: translateX(-50%);
  background: rgba(248, 250, 249, .92);
  border-bottom: 1px solid rgba(213, 222, 217, .82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
#title {
  max-width: calc(100% - 140px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
  font-weight: 760;
}
#backBtn {
  position: absolute;
  left: 10px;
  bottom: 8px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--accent);
  cursor: pointer;
  font-size: 34px;
  line-height: 1;
}
#topRight {
  position: absolute;
  right: 16px;
  bottom: 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

/* ---- 内容区 ---- */
#content {
  min-height: 100vh;
  padding-top: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
}

/* ---- 底部 Tab ---- */
#tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  width: min(100%, var(--app-w));
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 7px 14px calc(7px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(252, 253, 252, .94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  z-index: 50;
}
.tab {
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.tab.active {
  background: #e8f3f0;
  color: var(--accent);
}
.tab-ico { font-size: 18px; line-height: 1; }

/* ---- 专题列表 ---- */
.feed-head {
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #f9fbfa 0%, #eef6f2 62%, #f8f4ef 100%);
}
.feed-head-main { min-width: 0; }
.eyebrow {
  color: var(--accent);
  font-size: 11px;
  line-height: 1;
  font-weight: 800;
  text-transform: uppercase;
}
.feed-head-title {
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.12;
  font-weight: 820;
}
.feed-head-sub {
  margin-top: 8px;
  max-width: 100%;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-stats {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stat-pill {
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid rgba(213, 222, 217, .9);
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
}
.stat-value {
  display: block;
  font-size: 18px;
  line-height: 1.1;
  font-weight: 780;
}
.stat-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}
.topic-list {
  padding: 12px 10px;
  display: grid;
  gap: 9px;
}
.topic-row {
  --topic-color: var(--accent);
  width: 100%;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .02);
  cursor: pointer;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  text-align: left;
}
.topic-row:active { background: #f7faf8; transform: translateY(1px); }
.topic-ico {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: #eef4f1;
  border: 1px solid #dfe8e4;
  color: var(--topic-color);
  background: color-mix(in srgb, var(--topic-color) 14%, #fff);
  border: 1px solid color-mix(in srgb, var(--topic-color) 22%, #fff);
  color: color-mix(in srgb, var(--topic-color) 78%, #111);
  font-size: 18px;
  font-weight: 800;
}
.topic-mid { min-width: 0; }
.topic-name-line {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
}
.topic-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  line-height: 1.2;
  font-weight: 760;
}
.topic-count {
  flex-shrink: 0;
  color: var(--faint);
  font-size: 11px;
  font-weight: 680;
}
.topic-sum {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.28;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topic-right {
  min-width: 38px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.topic-time {
  color: var(--faint);
  font-size: 12px;
  line-height: 1;
  font-weight: 650;
}
.topic-chevron {
  color: #bdc7c2;
  font-size: 22px;
  line-height: 1;
}
.badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 20px;
  text-align: center;
  font-weight: 750;
}

/* ---- 卡片流 ---- */
.cards-wrap {
  padding: 14px 10px 4px;
  display: grid;
  gap: 10px;
}
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .02);
}
.card-head {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 9px;
}
.src-tag {
  max-width: 62%;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e9f3f0;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 750;
}
.card-time {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 620;
}
.card-title {
  margin-bottom: 10px;
  font-size: 18px;
  line-height: 1.32;
  font-weight: 780;
  word-break: break-word;
}
.card-body {
  color: #26302c;
  font-size: 14.5px;
  line-height: 1.66;
  word-break: break-word;
}
.card-body strong { font-weight: 760; color: #111a17; }
.card-body a {
  color: var(--accent-2);
  text-decoration: none;
  border-bottom: 1px solid rgba(69, 110, 216, .3);
}
.card-body .md-h {
  margin: 14px 0 6px;
  line-height: 1.35;
  font-weight: 780;
}
.card-body h3.md-h { font-size: 16px; color: #111a17; }
.card-body h4.md-h { font-size: 14.5px; color: #2a3833; }
.card-body h5.md-h, .card-body h6.md-h { font-size: 13.5px; color: #43504b; }
.card-body p { margin: 7px 0; }
.card-body ul, .card-body ol { margin: 7px 0 7px 20px; }
.card-body li { margin: 4px 0; }
.card-body code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #eef2f0;
  color: #18211e;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}
.card-body blockquote {
  margin: 9px 0;
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
  background: #f3f8f6;
  color: #34423d;
}
.card-body hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 12px 0;
}
.card-body.collapsed {
  max-height: 260px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 72%, transparent);
  mask-image: linear-gradient(180deg, #000 72%, transparent);
}
.card-toggle {
  margin-top: 10px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #f8faf9;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  font-weight: 720;
}
.card-foot {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}
.card-link {
  min-width: 64px;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  background: #17201d;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 13px;
  font-weight: 720;
}

/* ---- 数据面板 ---- */
.panel-wrap { padding: 14px 10px 4px; }
.panel-upd {
  margin: 0 2px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-align: right;
}
.panel-stale { color: var(--danger); }
.section {
  padding: 2px 0 14px;
}
.section-title {
  margin: 0 2px 8px;
  color: #31403a;
  font-size: 13px;
  font-weight: 800;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}
.dcard {
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .02);
}
.dcard-label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  font-weight: 700;
}
.dcard-value {
  margin-top: 7px;
  color: #111a17;
  font-size: 20px;
  line-height: 1.18;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.dcard-chg {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 760;
}
.dcard-note {
  margin-top: 5px;
  color: var(--faint);
  font-size: 11px;
}
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }

.empty {
  padding: 46px 20px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

@media (min-width: 720px) {
  body { padding: 18px 0; }
  .screen {
    min-height: calc(100vh - 36px);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow);
    overflow: hidden;
  }
  #topbar {
    top: 18px;
    border-left: 1px solid var(--line-strong);
    border-right: 1px solid var(--line-strong);
  }
  #tabbar {
    bottom: 18px;
    border-left: 1px solid var(--line-strong);
    border-right: 1px solid var(--line-strong);
  }
  .feed-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 250px;
    align-items: end;
    gap: 18px;
    padding: 24px 22px 20px;
  }
  .feed-stats { margin-top: 0; }
  .topic-list, .cards-wrap, .panel-wrap {
    padding-left: 16px;
    padding-right: 16px;
  }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 360px) {
  .feed-head-title { font-size: 21px; }
  .stat-pill { padding: 8px; }
  .topic-row {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 9px;
    padding: 10px;
  }
  .topic-ico { width: 42px; height: 42px; }
  .card-title { font-size: 16.5px; }
  .grid { grid-template-columns: 1fr; }
}

/* 聊天页顶部「名片」：交代这位 KOL 是谁（职位·领域） */
.name-card {
  border: 1px solid var(--line);
  border-left: 3px solid var(--topic-color, var(--accent));
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--surface-soft);
}
.name-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.name-card-bio {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* ---- 头部「今日共识/分歧」横幅 + 详情 ---- */
.feed-digest {
  display: block; width: 100%; text-align: left; margin-top: 8px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); padding: 9px 11px; cursor: pointer;
}
.feed-digest:active { background: var(--surface-soft); }
.dg-line { display: flex; align-items: baseline; gap: 7px; margin: 2px 0; }
.dg-tag { flex: none; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 6px; }
.dg-cons { background: #e3f3ef; color: #1a7d6e; }
.dg-con { background: #fdeaec; color: #c23b4c; }
.dg-text { font-size: 13px; line-height: 1.4; color: var(--text); }
.dg-more { font-size: 12px; color: var(--accent); margin-top: 4px; }

.digest-section { font-size: 14px; font-weight: 600; margin: 14px 2px 8px; }
.digest-section.cons { color: #1a7d6e; }
.digest-section.con { color: #c23b4c; }
.digest-card {
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  padding: 12px 14px; margin-bottom: 10px; border-left: 3px solid var(--line-strong);
}
.digest-card.cons { border-left-color: #2fa58f; }
.digest-card.con { border-left-color: #e0566a; }
.digest-theme { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.digest-voices { font-size: 12px; color: var(--accent); margin-bottom: 6px; }
.digest-points { font-size: 14px; line-height: 1.65; color: var(--ink, var(--text)); }
.digest-foot { font-size: 12px; color: var(--muted); text-align: center; margin: 14px 0 4px; }
