/* ==========================================================================
   个人研究情报与个性化信息订阅系统 —— 全局样式
   浅色主题 / 卡片式布局 / 无外部依赖 / 颜色仅作辅助（必须同时有文字标签）
   ========================================================================== */

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-alt: #fafbfc;
  --border: #e3e8ee;
  --border-strong: #cfd6dc;
  --text: #1f2933;
  --text-soft: #5b6670;
  --text-muted: #8a939c;
  --primary: #3a6fb5;
  --primary-dark: #2f5c99;
  --primary-soft: #eaf1fa;
  --green: #6BC28B;
  --green-soft: #e9f7ee;
  --amber: #e0a020;
  --amber-soft: #fdf4e3;
  --red: #c0463a;
  --red-soft: #fbeae7;
  --purple: #7a5fb5;
  --purple-soft: #f1ecfa;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(31, 41, 51, .06), 0 4px 14px rgba(31, 41, 51, .04);
  --shadow-hover: 0 2px 6px rgba(31, 41, 51, .09), 0 10px 26px rgba(31, 41, 51, .07);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Segoe UI", system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.35; }
p { margin: 0 0 8px; }
small { font-size: 12px; }
.inline-form { display: inline; }

/* ---------------- 顶栏 ---------------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1320px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-icon { font-size: 26px; line-height: 1; }
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 15px; }
.brand-text small { color: var(--text-muted); font-size: 11px; letter-spacing: .2px; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.nav a { padding: 6px 11px; border-radius: var(--radius-sm); color: var(--text-soft); font-size: 13.5px; white-space: nowrap; }
.nav a:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 18px; padding: 2px 10px; cursor: pointer; color: var(--text); }

/* ---------------- 容器 ---------------- */
.container { max-width: 1320px; margin: 0 auto; padding: 22px 20px 60px; }
.footer { max-width: 1320px; margin: 0 auto; padding: 18px 20px 40px; color: var(--text-muted); font-size: 12px; text-align: center; }
.footer .sep { margin: 0 6px; }

/* ---------------- Flash ---------------- */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; border-left: 3px solid var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
.flash-success { border-color: var(--green); background: var(--green-soft); color: #2f7a4d; }
.flash-warning { border-color: var(--amber); background: var(--amber-soft); color: #97670f; }
.flash-error { border-color: var(--red); background: var(--red-soft); color: #9c3428; }
.flash-info { border-color: var(--border-strong); background: var(--surface-alt); color: var(--text-soft); }

/* ---------------- 页头 ---------------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-header h1 { font-size: 21px; display: flex; align-items: center; gap: 8px; }
.ph-icon { font-size: 20px; }
.page-sub { color: var(--text-muted); font-size: 13px; margin: 4px 0 0; max-width: 780px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sub-title { font-size: 14px; margin: 12px 0 8px; color: var(--text-soft); }

/* ---------------- 卡片 ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.card-head { padding: 13px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--surface-alt); }
.card-head h2 { font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-sub { color: var(--text-muted); font-size: 12px; }
.card-body { padding: 18px; }
.card-body > :last-child { margin-bottom: 0; }
.card-flush .card-body { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(268px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-between { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* 详情页两栏 */
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 1080px) { .detail-layout { grid-template-columns: 1fr; } }

/* ---------------- 按钮 ---------------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 13.5px; cursor: pointer; font-family: inherit; line-height: 1.4; transition: all .12s ease; white-space: nowrap; }
.btn:hover { background: var(--surface-alt); border-color: var(--text-muted); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { background: #5aae7b; border-color: #5aae7b; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn-danger { color: var(--red); border-color: #eccdc7; }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-xs { padding: 2px 8px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------------- 徽章 / 标签 ---------------- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; font-weight: 500; background: #f1f3f5; color: var(--text-soft); white-space: nowrap; }
.badge-primary { background: var(--primary-soft); color: var(--primary-dark); }
.badge-green { background: var(--green-soft); color: #2f7a4d; }
.badge-amber { background: var(--amber-soft); color: #97670f; }
.badge-red { background: var(--red-soft); color: #9c3428; }
.badge-neutral { background: #f1f3f5; color: var(--text-soft); }
.badge-soft { background: #f5f7fa; color: var(--text-muted); border: 1px solid var(--border); }
.badge-region { border: 1px solid var(--border); background: #fff; color: var(--text-soft); }

.muted { color: var(--text-muted); }
.warn { color: var(--red); }
.soft { color: var(--text-soft); }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.break { word-break: break-all; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }

/* ---------------- 空状态 ---------------- */
.empty { text-align: center; padding: 26px 16px; color: var(--text-muted); }
.empty-icon { font-size: 30px; margin-bottom: 6px; }
.empty p { margin: 0; font-size: 13.5px; }
.empty-hint { font-size: 12px !important; color: var(--text-muted); margin-top: 4px !important; }

/* ---------------- 今日统计条 ---------------- */
.today-strip { background: linear-gradient(135deg, #eef4fc 0%, #f7fbf9 100%); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.today-date { font-size: 22px; font-weight: 600; }
.today-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.today-meta span { background: rgba(255,255,255,.8); border: 1px solid var(--border); border-radius: 20px; padding: 2px 11px; font-size: 12.5px; color: var(--text-soft); }
.today-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- 信息卡（第一层快速浏览）---------------- */
.tgroup .card-body { padding-top: 12px; }
.icard { border: 1px solid var(--border); border-left: 3px solid var(--border-strong); border-radius: var(--radius); padding: 13px 15px; margin-bottom: 12px; background: var(--surface); transition: box-shadow .15s ease, transform .15s ease; }
.icard:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.icard:last-child { margin-bottom: 0; }
.icard.pr-high { border-left-color: var(--red); }
.icard.pr-medium { border-left-color: var(--amber); }
.icard.pr-normal { border-left-color: var(--border-strong); }
.icard-head { display: flex; flex-direction: column; gap: 6px; }
.icard-title { font-size: 16px; line-height: 1.45; }
.icard-title a { color: var(--text); }
.icard-title a:hover { color: var(--primary); }
.icard-title .rank { display: inline-block; min-width: 22px; height: 22px; line-height: 22px; text-align: center; background: var(--primary-soft); color: var(--primary-dark); border-radius: 50%; font-size: 12.5px; margin-right: 6px; font-weight: 600; }
.icard-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.prio { font-size: 12.5px; color: var(--text-soft); }
.icard-line { margin: 9px 0 0; color: var(--text-soft); }
.icard-reason { margin: 6px 0 0; font-size: 13.5px; color: var(--primary-dark); background: var(--primary-soft); border-radius: var(--radius-sm); padding: 7px 10px; }
.icard-foot { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 9px; font-size: 12.5px; }
.score-pill { font-size: 12.5px; color: var(--primary-dark); background: var(--primary-soft); border-radius: 20px; padding: 1px 10px; }

/* ---------------- 反馈操作条 ---------------- */
.fb-bar { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.fb-bar.compact { margin-top: 8px; padding-top: 8px; }
.fb-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.fb-btn { display: inline-flex; align-items: center; padding: 3px 11px; border-radius: 20px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-soft); font-size: 12.5px; cursor: pointer; font-family: inherit; line-height: 1.6; transition: all .12s ease; }
.fb-btn:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.fb-btn.on { font-weight: 600; }
.fb-btn.vl-important.on { background: var(--green-soft); border-color: var(--green); color: #2f7a4d; }
.fb-btn.vl-general.on { background: var(--amber-soft); border-color: var(--amber); color: #97670f; }
.fb-btn.vl-unimportant.on { background: #f1f3f5; border-color: var(--text-muted); color: var(--text-soft); }
.fb-btn.link { border-color: transparent; color: var(--primary); }
#fav-on { }
form .fb-btn.on:not(.vl-important):not(.vl-general):not(.vl-unimportant) { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); }

/* ---------------- 指标网格 ---------------- */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 10px; }
.metrics.compact { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; }
.metric { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px; }
.stat .s-label { font-size: 11.5px; color: var(--text-muted); display: block; }
.stat .s-value { font-size: 17px; font-weight: 600; margin-top: 2px; display: block; }
.stat .s-value small { font-size: 11.5px; font-weight: 400; color: var(--text-muted); margin-left: 2px; }
.stat-warn { background: var(--red-soft); border-color: #eccdc7; }

/* ---------------- 值分布条 ---------------- */
.vd-row { display: grid; grid-template-columns: 140px repeat(4, auto) 1fr; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px dashed #eef1f4; font-size: 12.8px; }
.vd-row:last-child { border-bottom: none; }
.vd-topic { font-weight: 500; }
.vd-num { color: var(--text-soft); white-space: nowrap; }
.vd-important { color: #2f7a4d; }
.vd-general { color: #97670f; }
.vd-unimportant { color: var(--text-muted); }
.vd-rate { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.vd-track { display: inline-block; width: 90px; height: 8px; background: #f0f3f6; border-radius: 4px; overflow: hidden; }
.vd-track i { display: block; height: 100%; background: var(--green); }

/* ---------------- 横向条形 ---------------- */
.hchart { display: flex; flex-direction: column; gap: 7px; }
.hchart-row { display: grid; grid-template-columns: 148px 1fr 84px; gap: 10px; align-items: center; }
.hc-label { font-size: 12.5px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-track { height: 14px; background: #f0f3f6; border-radius: 7px; overflow: hidden; }
.hc-track i { display: block; height: 100%; border-radius: 7px; min-width: 2px; background: var(--primary); }
.hc-value { font-size: 12.5px; text-align: right; color: var(--text-soft); }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table th { background: var(--surface-alt); font-weight: 600; font-size: 12.5px; color: var(--text-soft); white-space: nowrap; }
.data-table tbody tr:hover { background: #fbfcfd; }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.actions { white-space: nowrap; }
.data-table form { display: inline; }

/* ---------------- 表单 ---------------- */
form .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-wide { grid-column: 1 / -1; }
.field-label { font-size: 12.5px; color: var(--text-soft); font-weight: 500; }
.field-label .req { color: var(--red); font-style: normal; margin-left: 3px; }
.field input, .field select, .field textarea, .inline-field input, .inline-field select {
  padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: inherit; background: var(--surface); color: var(--text); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(58, 111, 181, .12); }
.field-hint { font-size: 11.5px; color: var(--text-muted); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.check input { width: auto; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 14px; margin-bottom: 16px; }
.inline-field { display: inline-flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--text-soft); }
.inline-field input, .inline-field select { width: auto; min-width: 120px; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ---------------- 提示条 ---------------- */
.notice { border-radius: var(--radius-sm); padding: 11px 14px; font-size: 13px; background: var(--amber-soft); border: 1px solid #f0dcb4; color: #8a5f10; margin-bottom: 14px; }
.notice-info { background: var(--primary-soft); border-color: #cfdff2; color: var(--primary-dark); }
.notice-green { background: var(--green-soft); border-color: #cbe8d6; color: #2f7a4d; }
.notice-red { background: var(--red-soft); border-color: #eccdc7; color: #9c3428; }

/* ---------------- 列表 ---------------- */
.reason-list { list-style: none; margin: 0; padding: 0; font-size: 12.8px; }
.reason-list li { padding: 4px 0 4px 18px; position: relative; color: var(--text-soft); }
.reason-list li::before { content: '›'; position: absolute; left: 5px; color: var(--primary); font-weight: 700; }
.review-list { margin: 0; padding-left: 20px; font-size: 13.5px; }
.review-list li { margin-bottom: 7px; }
.review-list li span { display: block; font-size: 12px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 18px 0 0; }

/* ---------------- 时间线 ---------------- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.tl-item:last-child { border-bottom: none; }
.tl-date { font-size: 12.5px; color: var(--text-soft); }
.tl-body { }

/* ---------------- 评论 ---------------- */
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 13px; margin-bottom: 9px; background: var(--surface-alt); }
.comment-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; }
.comment-body { font-size: 13.5px; white-space: pre-wrap; }
.thought-day { margin-bottom: 18px; }
.thought-day > h3 { font-size: 13.5px; color: var(--primary-dark); margin-bottom: 8px; padding-bottom: 5px; border-bottom: 1px solid var(--border); }

/* ---------------- 原文 ---------------- */
.raw-content { white-space: pre-wrap; font-size: 13.5px; color: var(--text-soft); max-height: 460px; overflow-y: auto; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 13px; }
.kv { display: grid; grid-template-columns: 108px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------------- 错误页 ---------------- */
.error-page { text-align: center; padding: 60px 20px; }
.error-page .code { font-size: 56px; font-weight: 700; color: var(--primary); line-height: 1; }
.error-page h2 { margin: 12px 0 8px; font-size: 18px; }
.error-page p { color: var(--text-soft); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 900px) {
  .nav-toggle { display: block; }
  .nav { display: none; width: 100%; margin-left: 0; }
  .nav-open .nav { display: flex; }
  .topbar-inner { align-items: flex-start; }
  .container { padding: 16px 14px 50px; }
  .hchart-row { grid-template-columns: 96px 1fr 66px; }
  .tl-item { grid-template-columns: 1fr; gap: 6px; }
  .today-strip { padding: 14px 16px; }
  .today-date { font-size: 19px; }
  .vd-row { grid-template-columns: 1fr 1fr 1fr; }
  .vd-rate { grid-column: 1 / -1; justify-content: flex-start; }
}
