:root {
  color-scheme: light;
  --paper: #f7f5f0;
  --surface: #fbfaf7;
  --ink: #25282d;
  --muted: #747a82;
  --line: #dcd9d2;
  --blue: #315f91;
  --blue-soft: #e8eef5;
  --sage: #4f8277;
  --sage-soft: #e7f0ed;
  --amber: #ad7c2d;
  --risk: #a94b43;
  --risk-soft: #f7eae7;
  --nav-height: 74px;
}

* { box-sizing: border-box; }

html { background: #ebe8e1; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 15px/1.65 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a { font: inherit; }

.app-shell {
  width: min(100%, 720px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
}

.app-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 60px;
  padding: max(12px, env(safe-area-inset-top)) 20px 12px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(14px);
}

.brand {
  color: var(--ink);
  font: 700 23px/1.1 Georgia, "Times New Roman", serif;
  text-decoration: none;
  letter-spacing: -.02em;
}

.freshness {
  padding-left: 16px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.app-main { padding: 30px 20px calc(var(--nav-height) + 34px); }
.view { display: none; }
.view.active { display: block; }

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 18px; font-size: clamp(30px, 8vw, 42px); line-height: 1.18; letter-spacing: -.035em; }
h2 { margin-bottom: 0; font-size: 20px; line-height: 1.3; }
h3 { margin-bottom: 8px; font-size: 17px; line-height: 1.35; }

.daily-summary {
  margin-bottom: 25px;
  max-width: 620px;
  color: #35393f;
  font-size: 17px;
  line-height: 1.85;
}

.page-description, .section-intro {
  color: var(--muted);
  font-size: 13px;
}

.page-description { margin: -8px 0 0; }
.section-intro { margin: -7px 0 16px; }
.cluster-action {
  display: inline-flex;
  margin-top: 14px;
  color: var(--blue);
  font-size: 13px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 38px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metrics div { padding: 0 16px; text-align: center; }
.metrics div + div { border-left: 1px solid var(--line); }
.metrics span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.metrics strong { color: var(--blue); font-size: 30px; font-weight: 500; line-height: 1.2; }
.metrics div:nth-child(2) strong { color: var(--amber); }

.content-section { margin-top: 34px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading span { color: var(--muted); font-size: 11px; }
.cluster-list, .risk-list, .event-stream { display: grid; gap: 14px; }

.cluster-card, .risk-card, .stream-card, .placeholder-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.cluster-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 18px;
  padding: 20px;
  color: inherit;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}

.cluster-index { margin-right: 10px; color: var(--blue); font-size: 18px; font-weight: 500; }
.cluster-count { color: var(--blue); font-size: 25px; font-weight: 500; line-height: 1.2; }
.cluster-count small { color: var(--muted); font-size: 12px; font-weight: 400; }
.cluster-summary { grid-column: 1 / -1; margin: 0; color: #555b62; }
.cluster-meta { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cluster-action { grid-column: 1 / -1; justify-self: start; margin-top: 0; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 3px 9px; border-radius: 6px; background: var(--blue-soft); color: var(--blue); font-size: 11px; }
.updated { flex: none; color: var(--muted); font-size: 11px; }

.risk-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 12px;
  padding: 17px 18px;
  border-left: 3px solid var(--risk);
  cursor: pointer;
}

.risk-card h3 { margin: 0; }
.risk-card p { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 13px; }
.badge { align-self: start; padding: 2px 8px; border: 1px solid currentColor; border-radius: 6px; color: var(--risk); font-size: 11px; }

.stream-heading { margin-bottom: 22px; }
.stream-controls { display: flex; gap: 8px; margin: -4px -20px 20px; padding: 4px 20px 8px; overflow-x: auto; scrollbar-width: none; }
.stream-controls::-webkit-scrollbar { display: none; }
.filter-button { flex: none; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: transparent; cursor: pointer; }
.filter-button.active { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }

.stream-card { padding: 18px; cursor: pointer; }
.stream-card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.stream-card time { color: var(--muted); font-size: 11px; }
.stream-card p { margin-bottom: 12px; color: #565c63; font-size: 13px; }
.stream-card .chips { margin-top: 8px; }
.stream-more { display: block; width: 100%; margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--blue); background: var(--surface); cursor: pointer; }
.stream-more[hidden] { display: none; }
.stream-more:disabled { color: var(--muted); cursor: wait; }
.event-source { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 8px; margin: 0 0 12px; padding: 10px 11px; border-left: 3px solid var(--blue); border-radius: 8px; background: var(--blue-soft); font-size: 12px; }
.source-kicker { color: var(--muted); font-size: 11px; }
.primary-source { color: var(--ink); font-size: 13px; font-weight: 650; line-height: 1.4; }
.source-text { color: var(--blue); overflow-wrap: anywhere; }
.source-count, .source-status { color: var(--muted); }
.source-status { flex: none; padding: 2px 7px; border-radius: 5px; background: var(--surface); font-size: 10px; }
.risk-card .event-source { grid-column: 1 / -1; margin: 6px 0 2px; }

.placeholder-view { padding-top: 4px; }
.placeholder-card { margin-top: 34px; padding: 34px 24px; text-align: center; }
.placeholder-card p { margin: 0 auto; max-width: 420px; color: var(--muted); }
.placeholder-mark { display: block; margin-bottom: 14px; color: var(--blue); font-size: 30px; }

.empty-state { padding: 42px 18px; color: var(--muted); text-align: center; }
.error-state { color: var(--risk); }

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 720px);
  min-height: var(--nav-height);
  margin: 0 auto;
  padding: 9px 8px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(18px);
}

.bottom-nav a { display: grid; place-items: center; align-content: center; gap: 3px; color: var(--muted); font-size: 11px; text-decoration: none; }
.bottom-nav svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav a.active { color: var(--blue); }
.bottom-nav a.active:first-child svg path:first-child { fill: var(--blue); stroke: var(--blue); }

.event-dialog {
  width: 100%;
  max-width: 760px;
  height: 100dvh;
  max-height: none;
  margin: 0 auto;
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  background: var(--surface);
}
.event-dialog::backdrop { background: rgba(30, 34, 39, .32); backdrop-filter: blur(3px); }
.detail-toolbar { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: max(10px, env(safe-area-inset-top)) 20px 10px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(14px); }
.detail-toolbar span { color: var(--muted); font-size: 13px; }
.dialog-close { width: 36px; height: 36px; border: 0; border-radius: 50%; color: var(--muted); background: var(--paper); cursor: pointer; font-size: 24px; line-height: 1; }
.event-detail { padding: 28px 20px calc(44px + env(safe-area-inset-bottom)); }
.event-detail > h2 { margin-right: 22px; font-size: 25px; line-height: 1.35; }
.event-summary { color: #454b52; font-size: 15px; line-height: 1.8; }
.cluster-detail > h2 { margin-bottom: 10px; font-size: 28px; }
.cluster-detail-list { display: grid; gap: 12px; margin-top: 22px; }
.cluster-detail-event { position: relative; padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.cluster-detail-event h3 { margin-right: 34px; }
.cluster-detail-event > p { margin-bottom: 10px; color: #565c63; font-size: 13px; }
.cluster-detail-event .event-source { margin-top: 12px; }
.importance-rank { position: absolute; top: 17px; right: 17px; color: var(--blue); font-size: 14px; font-weight: 600; }
.cluster-event-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.cluster-toolbar { justify-content: flex-start; }
.cluster-close { font-size: 19px; }
.detail-meta, .detail-meta-row { color: var(--muted); font-size: 11px; }
.detail-meta { margin: 3px 0 0; }
.detail-meta-row { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 18px; }
.detail-section { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.detail-section > h3 { margin-bottom: 14px; }
.source-timeline { display: grid; gap: 10px; }
.source-entry { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.source-entry.active { border-color: color-mix(in srgb, var(--blue) 60%, var(--line)); box-shadow: inset 3px 0 0 var(--blue); }
.source-entry-header, .fact-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.source-title { margin: 8px 0 4px; font-size: 13px; line-height: 1.55; }
.read-body-button { margin-top: 10px; padding: 6px 10px; border: 1px solid var(--blue); border-radius: 7px; color: var(--blue); background: transparent; cursor: pointer; font-size: 12px; }
.body-section { scroll-margin-top: 64px; }
.body-pane { min-height: 160px; }
.body-heading { display: grid; gap: 5px; margin-bottom: 14px; }
.body-heading h4 { margin: 0; font-size: 17px; line-height: 1.45; }
.body-tabs { display: flex; gap: 8px; margin: 18px 0 12px; }
.body-tab { padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: transparent; cursor: pointer; }
.body-tab.active { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.document-copy { white-space: pre-wrap; color: #343940; font-size: 15px; line-height: 1.9; }
.translation-note, .body-unavailable { margin-top: 16px; color: var(--muted); font-size: 12px; }
.fact, .transmission-step, .interpretation-item { margin: 10px 0; padding: 13px 14px; border-left: 2px solid var(--blue); background: var(--paper); }
.fact p, .interpretation-item p { margin: 8px 0; }
.evidence-list { display: grid; gap: 8px; margin-top: 12px; }
.evidence-row { padding-top: 9px; border-top: 1px solid var(--line); }
.evidence-row blockquote { margin: 6px 0; color: #555b62; font-size: 12px; }
.unresolved-questions { margin-top: 18px; padding: 14px; border-radius: 10px; background: var(--risk-soft); }
.unresolved-questions h4, .unresolved-questions p { margin-bottom: 6px; }
.evidence-assessment { padding: 12px 14px; border-radius: 9px; background: var(--sage-soft); color: #365e55; font-size: 13px; }
.transmission-step { border-left-color: var(--sage); }

@media (min-width: 760px) {
  .app-shell { border-right: 1px solid var(--line); border-left: 1px solid var(--line); }
  .app-main { padding-right: 44px; padding-left: 44px; }
  .stream-controls { margin-right: -44px; margin-left: -44px; padding-right: 44px; padding-left: 44px; }
  .event-dialog { height: min(92dvh, 960px); margin: auto; border: 1px solid var(--line); border-radius: 18px; }
  .event-detail { padding-right: 38px; padding-left: 38px; }
}

@media (prefers-reduced-motion: no-preference) {
  .view.active { animation: reveal .18s ease-out; }
  @keyframes reveal { from { opacity: .4; transform: translateY(3px); } }
}
