:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e6e8ec;
  --text: #1a1d21;
  --muted: #6b7280;
  --primary: #2f6bff;
  --primary-soft: #eaf0ff;
  --accent: #ff5a36;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

h1, h2, h3 { margin: 0; font-weight: 650; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--primary); }
code { background: #f1f2f5; padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
}
@supports (padding: max(0px)) {
  .topbar {
    padding-top: max(14px, env(safe-area-inset-top));
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
  }
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, #2f6bff, #7aa2ff);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.brand h1 { font-size: 17px; }
.brand p { margin: 0; font-size: 12px; color: var(--muted); }

.date-nav { display: flex; align-items: center; gap: 8px; }
.date-nav input[type=date] {
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px; font-size: 14px; background: #fff; color: var(--text);
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.status-chip {
  font-size: 12px; color: var(--muted); background: #f4f5f7; padding: 5px 10px; border-radius: 999px;
}

.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 7px 14px; border-radius: 10px; cursor: pointer; font-size: 13px; transition: .15s;
}
.btn:hover { border-color: #c9cfd8; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #245ae0; }
.btn.ghost { background: #fff; }
.btn.danger { color: var(--danger); border-color: #f3c7c7; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-size: 16px; color: var(--muted);
}
.icon-btn:hover { border-color: #c9cfd8; color: var(--text); }

/* ---------------- Tabs ---------------- */
.tabs { display: flex; gap: 4px; padding: 12px 24px 0; background: var(--bg); flex-wrap: wrap; }
.tab {
  border: none; background: transparent; padding: 9px 16px; border-radius: 10px 10px 0 0;
  cursor: pointer; color: var(--muted); font-size: 14px;
}
.tab.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

main { padding: 18px 24px 60px; }
.view { display: none; }
.view.active { display: block; }

.summary { display: none; }
.stat { display: none; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 0; }
.chip {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 5px 12px; font-size: 12.5px; cursor: pointer; color: var(--muted);
}
.chip.active { background: var(--primary-soft); border-color: #bcd0ff; color: var(--primary); font-weight: 600; }

/* 可折叠 chips 面板（默认折叠） */
.chips-panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden;
}
.chips-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: transparent; border: none; cursor: pointer;
  font-size: 13.5px; color: var(--text); font-family: inherit; font-weight: 500;
  transition: background .15s;
}
.chips-toggle:hover { background: #f7f9fc; }
.chips-toggle .chips-toggle-label { display: flex; align-items: center; gap: 6px; }
.chips-toggle-count { color: var(--muted); font-size: 12px; font-weight: 400; }
.chips-toggle .arrow {
  display: inline-block; transition: transform .25s cubic-bezier(.4,0,.2,1);
  transform-origin: 50% 55%; font-size: 13px; color: var(--muted);
}
.chips-panel.collapsed .chips-toggle .arrow { transform: rotate(-180deg); }
.chips-panel .chips {
  padding: 4px 14px 14px;
  max-height: 320px; overflow: hidden; opacity: 1;
  transition: max-height .3s ease, opacity .2s ease, padding .25s ease;
}
.chips-panel.collapsed .chips {
  max-height: 0; padding-top: 0; padding-bottom: 0; opacity: 0; pointer-events: none;
}

.search-row { margin-bottom: 14px; }
.search-row input {
  width: 100%; max-width: 420px; padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--border); font-size: 14px; background: #fff;
}

/* ---------------- 热点看板 ---------------- */
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 14px; }

/* 看板头部：媒体数 + 全部展开/收起 */
.board-header {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 4px 0; gap: 12px;
}
.board-title { font-size: 13.5px; color: var(--text); }
.board-title b { font-weight: 700; color: var(--primary); }
.board-tools { display: flex; gap: 8px; }
.link-btn {
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  padding: 5px 12px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
  transition: .15s;
}
.link-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.card:hover { border-color: #d4dbe6; box-shadow: 0 2px 6px rgba(16,24,40,.06), 0 12px 28px rgba(16,24,40,.08); }
.card.collapsed { /* 折叠态 */ }
.card.collapsed .card-body { max-height: 0; padding-top: 0; padding-bottom: 0; opacity: 0; }
.card.collapsed .arrow { transform: rotate(-180deg); }

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #fbfcfd 0%, #f7f9fc 100%);
  cursor: pointer; user-select: none; position: sticky; top: 0; z-index: 2;
  transition: background .15s;
}
.card-head:hover { background: linear-gradient(180deg, #f1f5ff 0%, #eaf0ff 100%); }
.card-head h3 { font-size: 14.5px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-icon { font-size: 16px; line-height: 1; flex: none; filter: saturate(1.15); }
.card-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 650;
}
.card-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.card-head .badge {
  font-size: 11px; color: var(--muted); background: #fff; border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 999px; font-weight: 500;
}
.card-toggle {
  width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; cursor: pointer; font-size: 14px; color: var(--muted);
  display: grid; place-items: center; padding: 0; line-height: 1;
  transition: .15s;
}
.card-toggle:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.arrow {
  display: inline-block; transition: transform .25s cubic-bezier(.4,.0,.2,1);
  transform-origin: 50% 55%; font-size: 13px;
}

.card-body {
  padding: 4px 0 6px; max-height: 460px; overflow: auto;
  transition: max-height .3s ease, padding .25s ease, opacity .2s ease;
  opacity: 1;
}

.item {
  display: grid; grid-template-columns: 24px 1fr auto; gap: 10px;
  padding: 9px 16px; align-items: center;
  border-bottom: 1px solid transparent; transition: background .12s;
}
.item + .item { border-top: 1px solid #f3f4f6; }
.item:hover { background: #f6f9ff; }
.item .rank {
  flex: none; width: 22px; height: 22px; border-radius: 6px; background: #f1f2f5; color: var(--muted);
  font-size: 11.5px; font-weight: 600; display: grid; place-items: center;
}
.item:nth-child(1) .rank, .item:nth-child(2) .rank, .item:nth-child(3) .rank {
  background: linear-gradient(135deg, #ff7a45, #ff5a36); color: #fff;
  box-shadow: 0 1px 3px rgba(255,90,54,.35);
}
.item .title {
  font-size: 13.5px; line-height: 1.5; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  word-break: break-word;
}
.item .title:hover { color: var(--primary); }
.item .heat {
  flex: none; font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px; min-width: 0;
}
.src-tag {
  font-size: 10.5px; padding: 1px 6px; border-radius: 4px;
  background: #f1f2f5; color: var(--muted);
  white-space: nowrap; max-width: 110px; overflow: hidden; text-overflow: ellipsis;
}
.heat-num {
  font-size: 11.5px; color: var(--accent); font-weight: 600; white-space: nowrap;
}
.item .heat:empty { display: none; }

.empty { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------------- 面板 ---------------- */
.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }
.panel-head h2 { font-size: 15px; }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-cell {
  aspect-ratio: 1 / .78; border-radius: 8px; background: #f4f5f7; border: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer;
}
.cal-cell.blank { background: transparent; cursor: default; }
.cal-cell.has { background: #e8effe; }
.cal-cell.l1 { background: #d9e6ff; }
.cal-cell.l2 { background: #b3ccff; }
.cal-cell.l3 { background: #7ea8ff; color: #fff; }
.cal-cell.l4 { background: #3f74f5; color: #fff; }
.cal-cell.selected { border-color: var(--text); }
.cal-cell .d { font-size: 13px; font-weight: 600; }
.cal-cell .c { font-size: 10.5px; color: var(--muted); }
.cal-cell.l3 .c, .cal-cell.l4 .c { color: rgba(255,255,255,.85); }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.legend .l1 { background: #d9e6ff; } .legend .l2 { background: #b3ccff; }
.legend .l3 { background: #7ea8ff; } .legend .l4 { background: #3f74f5; }

/* ---------------- 词云 ---------------- */
.cloud { display: flex; flex-wrap: wrap; gap: 10px; padding: 6px 0 14px; }
.word { padding: 4px 10px; border-radius: 8px; background: #f4f6fa; cursor: pointer; transition: .15s; }
.word:hover { background: var(--primary-soft); color: var(--primary); }
.word .cnt { font-size: 11px; color: var(--muted); margin-left: 4px; }
.word-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.word-row { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--border); padding: 4px 0; font-size: 13px; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.table td.url { color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch { position: relative; width: 38px; height: 21px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #d6d9de; border-radius: 999px; cursor: pointer; transition: .2s; }
.slider::before {
  content: ""; position: absolute; width: 17px; height: 17px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(17px); }
.row-btns { display: flex; gap: 6px; }

/* ---------------- 表单 ---------------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.form-grid input, .form-grid select, .form-grid textarea {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 13.5px;
  background: #fff; color: var(--text); font-family: inherit;
}
.row-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.tips { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.tips li { margin-bottom: 6px; }

.runs { display: flex; flex-direction: column; gap: 8px; }
.run-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; }
.run-item .ok { color: var(--ok); }
.run-item .bad { color: var(--danger); }

/* ---------------- 关注热词 ---------------- */
.watch-add { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; flex-wrap: wrap; }
.watch-add input, .watch-add select {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px;
  font-size: 13.5px; background: #fff; color: var(--text); font-family: inherit;
}
.watch-scope { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.watch-scope .chips { margin-bottom: 0; }
.top-actions input[type=password] {
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px; font-size: 13px;
  background: #fff; color: var(--text);
}
.top-actions input.token-input { width: 200px; }

/* ---------------- 弹窗 & toast ---------------- */
.modal { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); display: none; z-index: 50; place-items: center; }
.modal.open { display: grid; }
.modal-card {
  background: #fff; border-radius: 16px; width: min(680px, 92vw); max-height: 88vh; overflow: auto; padding: 18px 20px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.test-result { font-size: 12.5px; color: var(--muted); margin-top: 12px; white-space: pre-wrap; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1a1d21; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 720px) {
  body { font-size: 13px; }

  /* ---- 顶栏：第一行 品牌 + 立即抓取；第二行 日期导航 ---- */
  .topbar { padding: 12px 14px; gap: 10px; align-items: center; }
  .brand { flex: 1 1 auto; min-width: 0; }
  .brand p { display: none; }
  .logo { width: 34px; height: 34px; border-radius: 10px; font-size: 16px; }
  .brand h1 { font-size: 15px; }
  .top-actions { order: 2; width: auto; gap: 8px; flex: none; }
  .top-actions .status-chip { display: none; }
  .top-actions .btn { padding: 8px 13px; }
  .date-nav { order: 3; width: 100%; justify-content: stretch; }
  .date-nav input[type=date] { flex: 1 1 auto; min-width: 0; }

  /* ---- Tabs：横向滚动 ---- */
  .tabs {
    padding: 8px 10px 0; gap: 2px; overflow-x: auto; flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 9px 14px; font-size: 13px; white-space: nowrap; flex: none; }

  main { padding: 12px 12px calc(72px + env(safe-area-inset-bottom, 0px)); }

  /* ---- 统计卡两列 ---- */
  .summary { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 12px; border-radius: 12px; }
  .stat b { font-size: 19px; }

  /* ---- 看板单列 ---- */
  .board { grid-template-columns: 1fr; gap: 10px; }
  .card { border-radius: 12px; }
  .card-body { max-height: 380px; }
  .item { padding: 8px 12px; gap: 8px; }
  .item .title { font-size: 13.5px; line-height: 1.45; }
  .item .rank { width: 20px; height: 20px; font-size: 11px; margin-top: 2px; }

  /* ---- 面板与表单 ---- */
  .panel { padding: 12px; margin-bottom: 12px; border-radius: 12px; }
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .watch-add { align-items: stretch; }
  .watch-add input, .watch-add select { flex: 1 1 auto; min-width: 0; }
  .search-row input { max-width: 100%; }

  /* ---- 触控友好 ---- */
  .btn { padding: 9px 14px; }
  .icon-btn { width: 38px; height: 38px; font-size: 18px; }

  /* ---- 日历紧凑 ---- */
  .calendar { gap: 4px; }
  .cal-cell { border-radius: 7px; }
  .cal-cell .d { font-size: 12px; }
  .cal-cell .c { font-size: 9px; }
  .month-nav { gap: 4px; }

  /* ---- 词云 / 词表 ---- */
  .cloud { gap: 8px; }
  .word { padding: 5px 11px; }
  .word-table { grid-template-columns: 1fr 1fr; }

  /* ---- 弹窗 & toast ---- */
  .modal-card { padding: 14px 14px; width: 94vw; max-height: 92vh; }
  .toast { width: 88vw; text-align: center; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 360px) {
  .brand h1 { font-size: 14px; }
  .summary { gap: 7px; }
  .stat b { font-size: 18px; }
}

/* ---------------- PWA：作为「应用」安装后的适配 ---------------- */
@media (display-mode: standalone), (display-mode: fullscreen) {
  /* 顶栏顶部留出状态栏空间 */
  body { padding-top: env(safe-area-inset-top, 0px); }
  .topbar {
    padding-top: max(14px, env(safe-area-inset-top));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  /* 底部留出 Home Indicator 空间 */
  main {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }
  /* 隐藏浏览器滚动条但保留滚动 */
  ::-webkit-scrollbar { width: 0; height: 0; display: none; }
  html { scrollbar-width: none; }
}

@media (display-mode: standalone) and (max-width: 720px) {
  /* standalone 移动端：顶栏更紧凑 */
  .topbar { padding-top: max(10px, env(safe-area-inset-top)); }
  .brand p { display: none; }
}

/* 让所有可点击元素的 hit area 足够大（移动端友好） */
.card-head { min-height: 44px; }

/* ---------------- 折叠状态加强（移动端） ---------------- */
@media (max-width: 720px) {
  .card-head { padding: 10px 12px; }
  .card-head h3 { font-size: 14px; }
  .card-icon { font-size: 15px; }
  .item { padding: 10px 12px; grid-template-columns: 22px 1fr auto; gap: 8px; }
  .item .title { font-size: 13px; -webkit-line-clamp: 2; }
  .card-body { max-height: 380px; }
  .src-tag { max-width: 80px; font-size: 10px; }
  .heat-num { font-size: 11px; }
}

/* ---------------- 离线占位页 ---------------- */
.offline-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 40px 20px;
  background: linear-gradient(180deg, #f5f6f8 0%, #eef2f7 100%);
  font-family: inherit;
}
.offline-card {
  max-width: 420px; background: #fff; border-radius: 18px; padding: 32px 24px;
  box-shadow: 0 4px 24px rgba(16, 24, 40, .08); text-align: center;
}
.offline-card h1 { font-size: 18px; margin: 12px 0 8px; }
.offline-card p { color: var(--muted); font-size: 13.5px; margin: 6px 0; line-height: 1.6; }
.offline-emoji { font-size: 48px; line-height: 1; }

/* 暗色模式跟随系统 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --card: #181c23;
    --border: #262b34;
    --text: #e6e9ef;
    --muted: #8b94a3;
    --primary: #5b8cff;
    --primary-soft: #1e2a47;
    --accent: #ff7a45;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
  body { color-scheme: dark; }
  .card-head { background: linear-gradient(180deg, #1d2229 0%, #181c23 100%); }
  .card-head:hover { background: linear-gradient(180deg, #243049 0%, #1d2a44 100%); }
  .card-head .badge { background: #11151b; }
  .card-toggle { background: #11151b; }
  .item + .item { border-top-color: #1f242c; }
  .item:hover { background: #1d232c; }
  .src-tag { background: #1f242c; }
  .word { background: #1d2229; }
  .run-item { background: #14181f; }
  .cal-cell { background: #1d2229; }
  .cal-cell.l1 { background: #1d2a44; }
  .cal-cell.l2 { background: #243562; }
  .cal-cell.l3 { background: #3d4f7f; color: #fff; }
  .cal-cell.l4 { background: #5b8cff; color: #fff; }
  .cal-cell.has { background: #1d2a44; }
  .modal-card { background: var(--card); }
  code { background: #1d2229; }
}

/* ---------------- AI 总结卡片 ---------------- */
.ai-card {
  margin: 10px 0 14px;
  border: 1px solid #c7d6fe;
  background: linear-gradient(135deg, #f5f8ff 0%, #eef2ff 100%);
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(47, 107, 255, 0.08);
  overflow: hidden;
  transition: box-shadow .2s ease;
}
.ai-card:hover { box-shadow: 0 4px 18px rgba(47, 107, 255, 0.14); }
.ai-card[data-collapsed="true"] { background: linear-gradient(135deg, #f5f8ff 0%, #f5f8ff 100%); }
.ai-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
}
.ai-head:active { background: rgba(47,107,255,0.05); }
.ai-icon {
  font-size: 18px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(47,107,255,0.15);
}
.ai-title {
  font-size: 14.5px; font-weight: 680; color: #1f3da5;
}
.ai-meta {
  flex: 1; font-size: 12px; color: #6b7ab0; margin-left: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-head .arrow {
  font-size: 14px; color: #1f3da5;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.ai-card[data-collapsed="true"] .ai-head .arrow { transform: rotate(-90deg); }
.ai-body {
  max-height: 800px;
  overflow: hidden;
  transition: max-height .35s cubic-bezier(.4,0,.2,1), opacity .25s ease, padding .25s ease;
  padding: 0 16px 14px;
  opacity: 1;
}
.ai-card[data-collapsed="true"] .ai-body {
  max-height: 0;
  padding: 0 16px;
  opacity: 0;
}
.ai-content {
  font-size: 13.5px;
  line-height: 1.7;
  color: #2a3a5a;
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  border: 1px solid #e2e8f5;
}
.ai-content h2 {
  font-size: 13.5px; font-weight: 680;
  color: #1f3da5;
  margin: 12px 0 4px;
  display: flex; align-items: center; gap: 4px;
}
.ai-content h2:first-child { margin-top: 0; }
.ai-content ul { padding-left: 18px; margin: 4px 0 8px; }
.ai-content li { margin: 2px 0; }
.ai-content strong { color: #1f3da5; }
.ai-content code {
  background: #eef2ff; padding: 1px 5px; border-radius: 4px;
  font-size: 12px; color: #1f3da5;
}
.ai-loading {
  color: #6b7ab0; font-size: 12.5px;
  display: flex; align-items: center; gap: 8px;
}
.ai-loading::before {
  content: ''; width: 12px; height: 12px;
  border: 2px solid #c7d6fe; border-top-color: #2f6bff;
  border-radius: 50%; animation: ai-spin .8s linear infinite;
}
.ai-empty { color: #6b7ab0; font-size: 12.5px; }
.ai-empty .btn { margin-left: 8px; }
.ai-actions {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed #e2e8f5;
  font-size: 11.5px; color: #6b7ab0;
}
.ai-actions .btn { font-size: 11.5px; padding: 3px 10px; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
@media (max-width: 480px) {
  .ai-head { padding: 11px 14px; }
  .ai-body { padding: 0 14px 12px; }
  .ai-card[data-collapsed="true"] .ai-body { padding: 0 14px; }
  .ai-content { padding: 10px 12px; font-size: 13px; }
}
@media (prefers-color-scheme: dark) {
  .ai-card { background: linear-gradient(135deg, #1a2238 0%, #1d2848 100%); border-color: #2a3554; }
  .ai-card[data-collapsed="true"] { background: #182238; }
  .ai-icon { background: #243154; box-shadow: 0 1px 4px rgba(0,0,0,0.4); }
  .ai-title, .ai-head .arrow { color: #9ab1ff; }
  .ai-meta, .ai-loading, .ai-empty { color: #7d8bb3; }
  .ai-content { background: #131c30; color: #d8e1f4; border-color: #2a3554; }
  .ai-content h2, .ai-content strong { color: #9ab1ff; }
  .ai-content code { background: #1d2848; color: #9ab1ff; }
  .ai-actions { border-top-color: #2a3554; }
}
@media (display-mode: standalone) {
  .ai-card { margin-top: calc(env(safe-area-inset-top, 0px) + 6px); }
}


/* ---------------- 卡片内 AI 简报 ---------------- */
.card-brief {
  margin: 6px 8px 8px;
  border: 1px solid #d9e2ff;
  border-radius: 10px;
  background: linear-gradient(135deg, #f4f7ff 0%, #eef3ff 100%);
  overflow: hidden;
}
.card-brief.empty-brief { background: #fafbfe; border-style: dashed; }
.brief-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  cursor: pointer;
  user-select: none;
}
.brief-icon { font-size: 13px; }
.brief-title { font-size: 12.5px; font-weight: 650; color: var(--primary); }
.brief-meta { font-size: 11px; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brief-meta .stale-tag, .ai-actions .stale-tag { font-weight: 650; color: #c07a00; }
.brief-gen { font-size: 11.5px; padding: 2px 8px; flex: none; }
.brief-head .arrow { font-size: 13px; color: var(--primary); transition: transform .22s cubic-bezier(.4,0,.2,1); }
.card-brief[data-collapsed="true"] .brief-head .arrow { transform: rotate(-90deg); }
.brief-body {
  max-height: 1400px;
  opacity: 1;
  overflow: hidden;
  transition: max-height .28s cubic-bezier(.4,0,.2,1), opacity .2s ease;
}
.card-brief[data-collapsed="true"] .brief-body { max-height: 0; opacity: 0; }
.brief-content {
  padding: 8px 10px 10px;
  font-size: 13px;
  line-height: 1.72;
  color: #26314a;
}
.brief-content h2 {
  font-size: 13.5px;
  font-weight: 680;
  margin: 10px 0 5px;
  color: #1b2a55;
}
.brief-content h2:first-child { margin-top: 0; }
.brief-content p { margin: 0 0 7px; }
.brief-content ul { margin: 0 0 8px; padding-left: 18px; }
.brief-content li { margin: 3px 0; }
.brief-content blockquote,
.brief-content p > em { color: var(--muted); }
.brief-content blockquote {
  margin: 6px 0 10px;
  padding: 4px 10px;
  border-left: 3px solid #c7d6ff;
  background: rgba(255,255,255,.6);
  font-size: 12px;
  color: var(--muted);
}
.brief-content a { color: var(--primary); }
.brief-content code { background: #e6ecfb; padding: 1px 4px; border-radius: 4px; }
.md-img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 8px;
  margin: 8px 0;
  background: #e9edf6;
}
.brief-shots {
  display: flex;
  gap: 6px;
  padding: 0 10px 10px;
  overflow-x: auto;
}
.brief-shot {
  flex: none;
  width: 92px;
  height: 92px;
  border-radius: 8px;
  overflow: hidden;
  background: #e9edf6;
  display: block;
}
.brief-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }

@media (prefers-color-scheme: dark) {
  .card-brief { background: linear-gradient(135deg, #18213a 0%, #1a2542 100%); border-color: #2a3554; }
  .card-brief.empty-brief { background: #141b2e; }
  .brief-title { color: #9ab1ff; }
  .brief-content { color: #d8e1f4; }
  .brief-content h2 { color: #b9c8ff; }
  .brief-content blockquote { background: rgba(255,255,255,.05); border-left-color: #3c4d7a; }
  .brief-content code { background: #1d2848; color: #9ab1ff; }
  .md-img, .brief-shot { background: #1d2848; }
}

/* ---------------- 后台简报状态 ---------------- */
.brief-status {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f6f8fc;
  border: 1px solid var(--border);
  font-size: 12.5px;
  line-height: 1.8;
}
.brief-line .muted, .brief-line.muted { color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .brief-status { background: #141b2e; border-color: #2a3554; }
}

/* ---------------- 历史归档：AI 简报 ---------------- */
.board.arch-board { grid-template-columns: 1fr; }
.arch-group-title {
  grid-column: 1 / -1;
  font-size: 12.5px; font-weight: 650; color: var(--muted);
  padding: 8px 4px 0; margin-top: 2px; border-top: 1px dashed var(--border);
}
.arch-group-title:first-of-type { border-top: 0; }
.arch-summary {
  grid-column: 1 / -1;
  border: 1px solid #c7d6fe; border-radius: 12px; overflow: hidden;
  background: linear-gradient(135deg, #f5f8ff 0%, #eef2ff 100%);
}
.arch-summary-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  border-bottom: 1px solid #dfe7ff;
}
.arch-summary-body { max-height: 620px; overflow: auto; }
.arch-summary .brief-content { padding: 10px 16px 12px; }
.arch-brief .card-body { max-height: 620px; }
.arch-brief-meta { font-size: 11px; color: var(--muted); padding: 8px 16px 0; }
.arch-brief .brief-content { padding: 6px 16px 14px; }

/* 日历：有 AI 简报的日子（简报不随条目清理，需单独可见） */
.cal-cell { position: relative; }
.cal-cell.has-brief { box-shadow: inset 0 0 0 1.5px #c9d8ff; }
.cal-brief {
  position: absolute; right: 3px; bottom: 2px;
  font-size: 9px; line-height: 1; color: var(--primary);
  background: #fff; border: 1px solid #d9e2ff; border-radius: 999px; padding: 1px 4px;
}
.legend-brief { margin-left: 10px; }

@media (prefers-color-scheme: dark) {
  .arch-summary { background: linear-gradient(135deg, #18213a 0%, #1a2542 100%); border-color: #2a3554; }
  .arch-summary-head { border-bottom-color: #2a3554; }
  .cal-cell.has-brief { box-shadow: inset 0 0 0 1.5px #2f3f6b; }
  .cal-brief { background: #11151b; border-color: #2a3554; color: #9ab1ff; }
}
