:root {
  color-scheme: light;
  --bg: #f4f6f1;
  --panel: #ffffff;
  --panel-soft: #edf3ee;
  --ink: #17201b;
  --muted: #5d6962;
  --line: #d5ddd6;
  --accent: #0f766e;
  --accent-soft: #d8eee9;
  --gold: #946000;
  --gold-soft: #f8ead0;
  --danger: #b42318;
  --danger-soft: #f9dfdc;
  --shadow: 0 8px 24px rgba(23, 32, 27, 0.06);
  --focus: #0f766e;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101713;
  --panel: #17221c;
  --panel-soft: #1e2d25;
  --ink: #f1f5ee;
  --muted: #b9c6bd;
  --line: #314239;
  --accent: #64c3b4;
  --accent-soft: #173f38;
  --gold: #f1bd63;
  --gold-soft: #493613;
  --danger: #f08a80;
  --danger-soft: #4b2524;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  --focus: #83d8ca;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: 0; }
.topbar {
  min-height: 74px;
  padding: 14px clamp(18px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.eyebrow, .section-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
h1 { margin: 0; font-size: 24px; line-height: 1.15; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px 14px; color: var(--muted); font-size: 13px; }
.status-pill, .scope-label, .feed-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill { padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; }
.icon-button, .filter-trigger, .quick-filter, .chip-action, .load-more, .reset-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 750;
}
.icon-button { width: auto; padding: 6px 9px; font-size: 12px; }
.app-shell { padding: 22px clamp(18px, 4vw, 48px) 56px; }
.overview { margin-bottom: 24px; }
.section-heading, .feed-head, .filter-heading, .stats-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.section-heading { margin-bottom: 12px; }
.section-heading h2, .feed-head h2, .filter-heading h2, .stats h2 { margin: 3px 0 0; font-size: 20px; line-height: 1.2; }
.overview-content { display: grid; grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr); gap: 12px; }
.overview-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.overview-rating-panel, .overview-pulse-panel { min-height: 216px; }
.overview-panel h3 { margin: 0; font-size: 14px; }
.overview-caption { margin: 5px 0 12px; color: var(--muted); font-size: 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.metric {
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--ink);
  text-align: left;
}
.metric:hover { border-color: var(--accent); }
.metric-label { display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
.metric-value { display: block; margin-top: 5px; color: var(--accent); font-size: 22px; font-weight: 800; line-height: 1; }
.metric.S .metric-value { color: var(--danger); }
.metric.A .metric-value { color: var(--gold); }
.pulse { display: grid; grid-template-columns: repeat(24, minmax(4px, 1fr)); align-items: end; gap: 3px; height: 96px; }
.pulse-cell { position: relative; height: 100%; padding: 0; border: 0; background: transparent; }
.pulse-bar { display: block; width: 100%; min-height: 3px; border-radius: 3px 3px 1px 1px; background: var(--accent); opacity: 0.88; }
.pulse-cell:hover .pulse-bar, .pulse-cell:focus-visible .pulse-bar { background: var(--gold); opacity: 1; }
.pulse-axis { display: flex; justify-content: space-between; margin-top: 7px; color: var(--muted); font-size: 11px; }
.mobile-filter-bar { display: none; }
.workspace { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 28px; align-items: start; }
.filters {
  position: sticky;
  top: 14px;
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.close-filter { display: none; }
.quick-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-filter { width: auto; min-height: 30px; padding: 4px 8px; font-size: 12px; }
.quick-filter.is-active { border-color: var(--accent); background: var(--accent); color: #ffffff; }
.filter-form { display: grid; gap: 10px; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 750; }
input, select { width: 100%; min-height: 38px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); }
.active-filters, .mobile-active-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-token { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border: 1px solid var(--accent); border-radius: 999px; background: var(--accent-soft); color: var(--ink); font-size: 11px; font-weight: 700; }
.filter-token button { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.reset-button { padding: 7px 10px; background: var(--ink); border-color: var(--ink); color: var(--panel); }
.stats { padding-top: 14px; border-top: 1px solid var(--line); }
.stats-heading { align-items: center; margin-bottom: 8px; }
.stats h2 { font-size: 14px; }
.stat-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 5px 0; color: var(--muted); font-size: 12px; }
.stat-row strong { color: var(--ink); }
.feed { min-width: 0; }
.live-section { padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.archive-section { padding-top: 28px; }
.feed-head { margin-bottom: 14px; }
.cards { display: grid; gap: 12px; }
.card { position: relative; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); }
.live-section .card { box-shadow: none; }
.card:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.card-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.rating { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 50%; color: #ffffff; font-size: 13px; font-weight: 850; }
.rating.S { background: var(--danger); }
.rating.A { background: var(--gold); }
.rating.B { background: var(--accent); }
.title { margin: 0; font-size: 17px; line-height: 1.45; }
.card-anchor { padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); color: var(--muted); font-size: 11px; }
.metadata, .chips, .source-row { display: flex; flex-wrap: wrap; gap: 6px; }
.metadata { margin: 8px 0 0; }
.metadata span { color: var(--muted); font-size: 12px; }
.chips { margin: 10px 0 12px; }
.chip, .chip-action { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-soft); color: var(--muted); font-size: 11px; font-weight: 700; }
.chip-action:hover { border-color: var(--accent); color: var(--accent); }
.chip.score { border-color: var(--accent); color: var(--accent); }
.summary { margin: 0 0 12px; color: var(--ink); font-size: 14px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.card-insights { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin: 0 0 12px; }
.card-insights div { min-width: 0; padding: 9px 10px; border-left: 3px solid var(--accent); background: var(--panel-soft); }
.card-insights div:last-child { border-color: var(--gold); }
.card-insights dt { margin: 0 0 3px; color: var(--muted); font-size: 11px; font-weight: 800; }
.card-insights dd { margin: 0; color: var(--ink); font-size: 12px; line-height: 1.55; }
.source-row { align-items: center; color: var(--muted); font-size: 12px; }
.source-row > span { margin-right: 2px; }
.source-origin { color: var(--accent); }
.day { margin-bottom: 28px; }
.day-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.day-title h3 { margin: 0; font-size: 18px; }
.window-label { margin: 18px 0 9px; color: var(--muted); font-size: 12px; font-weight: 800; }
.load-more { display: block; width: 100%; margin-top: 8px; padding: 10px; color: var(--accent); }
.empty { padding: 24px; border: 1px dashed var(--line); border-radius: 8px; background: var(--panel); color: var(--muted); line-height: 1.6; }
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--panel-soft) 25%, var(--panel) 50%, var(--panel-soft) 75%); background-size: 200% 100%; animation: loading 1.4s ease infinite; }
.overview-skeleton { min-height: 158px; grid-column: 1 / -1; }
.card-skeleton { min-height: 180px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 40; max-width: min(320px, calc(100vw - 40px)); padding: 10px 12px; border-radius: 6px; background: var(--ink); color: var(--panel); font-size: 13px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
@keyframes loading { to { background-position: -200% 0; } }
@media (max-width: 1080px) {
  .workspace { grid-template-columns: 244px minmax(0, 1fr); gap: 20px; }
}
@media (max-width: 820px) {
  .topbar { min-height: 64px; padding-top: 12px; padding-bottom: 12px; }
  .brand { display: block; }
  .eyebrow { margin-bottom: 3px; }
  h1 { font-size: 22px; }
  .topbar-actions > a, #generatedAt { display: none; }
  .app-shell { padding-top: 16px; padding-bottom: 40px; }
  .overview { margin-bottom: 14px; }
  .overview-content { display: block; }
  .overview-panel { margin-bottom: 10px; }
  .overview-panel:nth-child(n + 2) { display: none; }
  .overview-panel:first-child { padding: 12px; }
  .metric { min-height: 62px; }
  .metric-value { font-size: 19px; }
  .mobile-filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 16px; }
  .filter-trigger { width: auto; padding: 8px 11px; border-color: var(--ink); background: var(--ink); color: var(--panel); }
  .mobile-active-filters { justify-content: flex-end; }
  .workspace { display: block; }
  .filters { position: fixed; inset: auto 0 0 0; z-index: 30; max-height: min(82vh, 720px); overflow: auto; border-radius: 10px 10px 0 0; transform: translateY(105%); transition: transform 180ms ease; }
  .filters.is-open { transform: translateY(0); }
  .filter-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(8, 14, 10, 0.46); }
  .filter-backdrop[hidden] { display: none; }
  .close-filter { display: inline-block; }
  .live-section { padding-bottom: 22px; }
  .archive-section { padding-top: 22px; }
  .feed-head { align-items: end; }
  .feed-head h2 { font-size: 19px; }
  .card { padding: 14px; }
  .card-head { grid-template-columns: auto minmax(0, 1fr); }
  .card-anchor { grid-column: 2; justify-self: start; margin-top: -2px; }
  .title { font-size: 16px; }
  .card-insights { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .skeleton, .toast, .filters { animation: none; transition: none; }
}
