/* style.css — 政策雷达 design tokens & components */

:root {
  --font-display: "Noto Serif SC", "Songti SC", Georgia, serif;
  --font-body: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Editorial palette — paper, ink, vermillion */
  --bg: oklch(98.5% 0.005 80);
  --bg-elev: oklch(100% 0 0);
  --bg-sunken: oklch(96.5% 0.008 80);
  --fg: oklch(20% 0.02 250);
  --fg-muted: oklch(45% 0.015 250);
  --fg-faint: oklch(62% 0.012 250);
  --border: oklch(89% 0.008 250);
  --border-strong: oklch(80% 0.012 250);
  --accent: oklch(52% 0.18 27);          /* vermillion 朱红 */
  --accent-soft: oklch(95% 0.04 27);
  --accent-fg: #fff;
  --warn: oklch(70% 0.15 75);
  --ok: oklch(60% 0.12 155);
  --shadow-sm: 0 1px 2px oklch(20% 0.02 250 / 0.06), 0 1px 0 oklch(20% 0.02 250 / 0.03);
  --shadow-md: 0 4px 12px -2px oklch(20% 0.02 250 / 0.08);
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 14px;

  --text-xs: clamp(11px, 0.72rem, 12px);
  --text-sm: clamp(12px, 0.82rem, 13px);
  --text-base: clamp(14px, 0.95rem, 15px);
  --text-md: clamp(15px, 1rem, 16px);
  --text-lg: clamp(17px, 1.15rem, 19px);
  --text-xl: clamp(20px, 1.5rem, 26px);
  --text-2xl: clamp(24px, 2rem, 34px);
}

[data-theme="dark"] {
  --bg: oklch(16% 0.012 250);
  --bg-elev: oklch(20% 0.015 250);
  --bg-sunken: oklch(13% 0.012 250);
  --fg: oklch(95% 0.005 80);
  --fg-muted: oklch(72% 0.012 250);
  --fg-faint: oklch(55% 0.012 250);
  --border: oklch(28% 0.015 250);
  --border-strong: oklch(38% 0.018 250);
  --accent: oklch(68% 0.17 30);
  --accent-soft: oklch(28% 0.07 27);
  --shadow-sm: 0 1px 2px oklch(0% 0 0 / 0.4);
  --shadow-md: 0 6px 16px -3px oklch(0% 0 0 / 0.5);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: oklch(from var(--bg-elev) l c h / 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto;
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 36px; height: 36px; color: var(--accent); flex-shrink: 0; }
.brand-text { line-height: 1.15; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); letter-spacing: 0.5px; }
.brand-sub { font-size: var(--text-xs); color: var(--fg-faint); letter-spacing: 1.5px; text-transform: uppercase; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius); color: var(--fg-muted);
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--fg); border-color: var(--border-strong); }
.text-btn,
.primary-btn,
.secondary-btn {
  min-height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.text-btn {
  padding: 0 12px;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.text-btn:hover { background: var(--bg-sunken); color: var(--fg); border-color: var(--border-strong); }
.primary-btn {
  padding: 0 14px;
  color: var(--accent-fg);
  border: 1px solid var(--accent);
  background: var(--accent);
  box-shadow: var(--shadow-sm);
}
.primary-btn:hover { box-shadow: var(--shadow-md); }
.secondary-btn {
  padding: 0 14px;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.secondary-btn:hover { color: var(--fg); border-color: var(--border-strong); background: var(--bg-sunken); }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  font-size: var(--text-xs); color: var(--fg-muted);
  font-feature-settings: "tnum";
  white-space: nowrap;
}
@media (max-width: 480px) {
  .status-pill { display: none; }
  .brand-sub { display: none; }
  .topbar-cta, .text-btn.copy-filter-btn { display: none; }
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fg-faint); }
.status-pill.is-loading .status-dot { background: var(--warn); animation: pulse 1.4s infinite ease-in-out; }
.status-pill.is-ok .status-dot { background: var(--ok); }
.status-pill.is-error .status-dot { background: var(--accent); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: 0.35 } }

/* ---------- Layout ---------- */
.layout {
  max-width: 1440px; margin: 0 auto;
  display: grid; grid-template-columns: 280px 1fr;
  gap: 32px; padding: 28px 24px 80px;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 20px; padding: 20px 16px 60px; }
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 80px; align-self: start;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
@media (max-width: 900px) {
  .sidebar { position: static; max-height: none; }
}
.filter-block + .filter-block { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--border); }
.filter-label-row { display: flex; justify-content: space-between; align-items: baseline; }
.filter-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: 10px;
}
.link-btn { font-size: var(--text-xs); color: var(--fg-faint); }
.link-btn:hover { color: var(--accent); }

.search-wrap {
  position: relative;
  display: flex; align-items: center;
}
.search-icon { position: absolute; left: 10px; color: var(--fg-faint); pointer-events: none; }
#search-input {
  width: 100%;
  padding: 8px 10px 8px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sunken);
  font-size: var(--text-sm);
  transition: border-color .15s ease, background .15s ease;
}
#search-input:focus { border-color: var(--accent); background: var(--bg-elev); outline: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: var(--text-xs);
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--fg-muted);
  background: var(--bg-elev);
  transition: all .12s ease;
  font-feature-settings: "tnum";
}
.chip:hover { border-color: var(--border-strong); color: var(--fg); }
.chip.is-active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.chip-count { margin-left: 5px; opacity: 0.65; font-size: 10px; }
.chip.is-active .chip-count { opacity: 0.85; }

.source-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.source-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--radius-sm);
  font-size: var(--text-sm); color: var(--fg-muted);
  cursor: pointer; user-select: none;
}
.source-item:hover { background: var(--bg-sunken); color: var(--fg); }
.source-item input { accent-color: var(--accent); }
.source-item .src-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-item .src-kind {
  max-width: 52px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-faint);
  font-size: 10px;
}
.source-item.is-failed { color: var(--fg-faint); opacity: 0.6; }
.source-item.is-failed .src-count { color: var(--accent); }
.source-item .src-count {
  margin-left: auto; font-family: var(--font-mono); font-size: 11px;
  color: var(--fg-faint); font-feature-settings: "tnum";
}

.segmented {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--bg-sunken);
  padding: 3px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.segmented.source-mode { grid-template-columns: 1fr 1fr 1.3fr; }
.segmented button {
  font-size: var(--text-xs); padding: 6px 4px;
  border-radius: calc(var(--radius) - 3px);
  color: var(--fg-muted);
  transition: background .12s ease, color .12s ease;
}
.segmented button:hover { color: var(--fg); }
.segmented button.is-active { background: var(--bg-elev); color: var(--fg); box-shadow: var(--shadow-sm); }

.sidebar-meta { font-size: var(--text-xs); color: var(--fg-faint); }
.meta-row { display: flex; justify-content: space-between; padding: 3px 0; font-feature-settings: "tnum"; }
.meta-row strong { color: var(--fg); font-weight: 600; }
.sidebar-note p {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  line-height: 1.55;
}
.sidebar-link {
  display: inline-flex;
  margin-top: 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
}

/* ---------- Content ---------- */
.content { min-width: 0; }
.content-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.page-sub { color: var(--fg-muted); font-size: var(--text-sm); margin-top: 4px; }

.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; gap: 2px; background: var(--bg-elev); }
.view-toggle button { padding: 6px 14px; font-size: var(--text-xs); border-radius: calc(var(--radius) - 3px); color: var(--fg-muted); }
.view-toggle button.is-active { background: var(--bg-sunken); color: var(--fg); }

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--border);
  margin-bottom: 16px;
}
.metric-strip div {
  padding: 14px 16px;
  background: var(--bg-elev);
}
.metric-strip strong {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  line-height: 1.1;
}
.metric-strip span {
  display: block;
  margin-top: 3px;
  font-size: var(--text-xs);
  color: var(--fg-faint);
}

.conversion-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
  margin-bottom: 18px;
  border: 1px solid oklch(from var(--accent) l c h / 0.28);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent-soft), var(--bg-elev) 62%);
}
.conversion-panel h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  line-height: 1.3;
}
.conversion-panel p {
  margin-top: 4px;
  color: var(--fg-muted);
  font-size: var(--text-sm);
  line-height: 1.55;
}
.conversion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
}
@media (max-width: 760px) {
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .conversion-panel { align-items: stretch; flex-direction: column; }
  .conversion-actions { justify-content: flex-start; }
}

.topic-summary {
  margin-bottom: 16px;
  font-size: var(--text-sm);
  color: var(--fg-muted);
  min-height: 22px;
}
.topic-summary .pill {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  margin: 0 4px;
}

/* ---------- Feed ---------- */
.feed { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-elev); }
.feed.view-cards { background: transparent; border: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

.item {
  display: block;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  transition: background .12s ease;
}
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--bg-sunken); }

.feed.view-cards .item {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: var(--bg-elev);
}
.feed.view-cards .item:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.item-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.source-tag {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  letter-spacing: 0.3px;
}
.item-time {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  font-feature-settings: "tnum";
  font-family: var(--font-mono);
}
.item-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 8px;
}
.item-title a:hover { color: var(--accent); }
.item-desc {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  line-height: 1.6;
  max-width: 75ch;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-foot {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-top: 12px; flex-wrap: wrap;
}
.topic-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.topic-tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--fg-faint);
  background: var(--bg-sunken);
}
.item-link {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  font-weight: 500;
}
.item-link:hover { color: var(--accent); }

/* ---------- Skeleton / empty ---------- */
.skeleton .sk { background: linear-gradient(90deg, var(--bg-sunken) 0%, var(--border) 50%, var(--bg-sunken) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; border-radius: var(--radius-sm); }
.skeleton .sk-tag { width: 60px; height: 16px; margin-bottom: 12px; }
.skeleton .sk-title { width: 70%; height: 20px; margin-bottom: 10px; }
.skeleton .sk-line { width: 100%; height: 12px; margin-bottom: 6px; }
.skeleton .sk-line.short { width: 40%; }
@keyframes shimmer { 0% { background-position: 200% 0 } 100% { background-position: -200% 0 } }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--fg-faint);
}
.empty-state h3 { font-family: var(--font-display); font-size: var(--text-lg); color: var(--fg-muted); margin-bottom: 6px; }
.empty-state p { font-size: var(--text-sm); }

.error-banner {
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-sm);
  border: 1px solid oklch(from var(--accent) l c h / 0.3);
}

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  margin-top: 32px;
}
.footer-inner {
  max-width: 1440px; margin: 0 auto;
  padding: 18px 24px;
  display: flex; justify-content: space-between; gap: 12px;
  font-size: var(--text-xs); color: var(--fg-faint);
  flex-wrap: wrap;
}
