:root {
  --bg: #f8f7f3;
  --surface: #ffffff;
  --surface-muted: #f2efe8;
  --border: #e5e0d5;
  --ink: #1e293b;
  --ink-muted: #5b6675;
  --accent: #1f6f68;
  --accent-soft: #e6f2f0;
  --accent-ink: #144d48;
  --sand: #ede9de;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  line-height: 1.62;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.reader-shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  font-size: 1.65rem;
  line-height: 1;
}

.brand h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  font-size: 1.55rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.subtitle {
  margin: 3px 0 0;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  color: var(--ink-muted);
}

.status-pill.ok {
  background: var(--accent-soft);
  border-color: #c2deda;
  color: var(--accent-ink);
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 13px;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--ink);
}

.btn:hover {
  background: var(--surface-muted);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-ink);
}

.btn-quiet {
  background: var(--surface);
  color: var(--ink-muted);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.summary-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-label {
  font-size: 0.75rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.summary-value {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}

.controls-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.search-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.search-row input[type="search"] {
  flex: 1 1 260px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font-size: 0.9rem;
}

.search-row select,
.select-pair select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.85rem;
}

.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--ink-muted);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 0.8rem;
  cursor: pointer;
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.select-pair {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-label {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.error-banner {
  background: #f5ece9;
  border: 1px solid #dcc4bc;
  color: #5f2f24;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.88rem;
}

.story-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.story-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.story-card:hover {
  border-color: #b7c9c6;
  background: #fcfcfa;
}

.story-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  color: var(--ink-muted);
  white-space: nowrap;
}

.pill-cat {
  background: var(--accent-soft);
  border-color: #c2deda;
  color: var(--accent-ink);
  font-weight: 500;
}

.pill-calm {
  background: #eef2f5;
  border-color: #d7dee5;
  color: #3f4f61;
}

.story-date {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.story-headline {
  margin: 0 0 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.16rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.38;
}

.story-summary {
  margin: 0;
  color: #3a4554;
  font-size: 0.92rem;
}

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  color: var(--ink-muted);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 41, 59, 0.25);
  z-index: 90;
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(620px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.08);
  z-index: 100;
  overflow-y: auto;
  padding: 22px 24px 48px;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.drawer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.drawer-date {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.drawer-title {
  margin: 0 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.38rem;
  line-height: 1.32;
  color: var(--ink);
}

.drawer-lead {
  margin: 0 0 18px;
  font-size: 0.97rem;
  color: #334155;
}

.drawer-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.drawer-section h3 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.calm-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--ink);
  font-size: 0.92rem;
}

.calm-callout {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.calm-callout p {
  margin: 0;
  font-size: 0.88rem;
  color: #3a4554;
}

.raw-sources-details {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.raw-sources-details summary {
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.raw-sources-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.raw-source-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.raw-source-meta {
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.raw-source-link {
  color: var(--accent-ink);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
}

.raw-source-link:hover {
  text-decoration: underline;
}

.linked-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.linked-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-size: 0.88rem;
}

.linked-card:hover {
  background: var(--surface-muted);
}
