/* Daily Scroll – mobile-first PWA, senior-friendly */
/* Specialist: News_Manager. Easy fonts, clear headers, safe focused environment. */
:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --text: #e8e8f0;
  --muted: #8892a0;
  --accent: #6366f1;
  --grade-a: #22c55e;
  --grade-b: #eab308;
  --grade-c: #f97316;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --touch-min: 48px;           /* 48px for seniors (WCAG 2.5.5) */
  --font-size-base: 1.25rem;   /* 20px – easy to read */
  --font-size-large: 1.375rem; /* 22px – body text */
  --font-size-headline: 1.5rem;
  --line-height: 1.6;         /* Comfortable reading */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: var(--font-size-large);
  line-height: var(--line-height);
  -webkit-text-size-adjust: 100%;
}

.masthead {
  background: var(--surface);
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.masthead h1 {
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.masthead .date { color: var(--muted); font-size: 0.9rem; margin-top: 0.25rem; }
.masthead .user-label { color: var(--muted); font-size: 0.85rem; margin-top: 0.15rem; }
.admin-selector { margin-top: 0.5rem; }
.admin-selector.hidden { display: none; }
.admin-selector label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.25rem; }
.admin-selector select {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  border-radius: 8px;
  font-size: 1rem;
}

.tabs {
  display: flex;
  gap: 0;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.tab {
  min-height: var(--touch-min);
  padding: 0.6rem 1.2rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

main { padding: 1rem 1.25rem; max-width: 640px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }

.loading, .error, .success { padding: 1rem; color: var(--muted); }
.error { color: #f87171; }
.success { color: var(--grade-a); }
.loading.hidden, .error.hidden, .success.hidden, .empty.hidden, .feed-list .hidden { display: none !important; }
.tracking-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.tracking-header h2 { margin: 0; }
.empty { padding: 1.5rem; color: var(--muted); text-align: center; }

.feed-header { margin-bottom: 1rem; }
.feed-list { display: flex; flex-direction: column; gap: 1rem; }
.story-card {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 1.25rem;
  min-height: 120px;
}
.story-card.updated { border-left: 4px solid var(--grade-b); }
.story-card h3 {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 0.5rem;
  letter-spacing: 0.01em;
}
.story-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.grade {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.75rem;
}
.grade.a { background: var(--grade-a); color: #000; }
.grade.b { background: var(--grade-b); color: #000; }
.grade.c { background: var(--grade-c); color: #000; }
.feed-hint {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 0.75rem;
  max-width: 42rem;
}
.feed-hint strong { color: var(--text); font-weight: 600; }
.story-expand {
  margin: 0.5rem 0 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  background: rgba(0, 0, 0, 0.15);
}
.story-expand summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}
.story-expand summary::-webkit-details-marker { display: none; }
.story-body {
  margin-top: 0.65rem;
  font-size: 1rem;
  color: var(--text);
  line-height: var(--line-height);
  white-space: pre-wrap;
}
.story-summary { font-size: 1.05rem; color: var(--muted); margin-bottom: 0.75rem; line-height: var(--line-height); }
.why-this {
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 0.75rem;
  cursor: help;
}
.tts-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-height: var(--touch-min);
}
.tts-bar button {
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 0.75rem;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}
.tts-bar button.secondary { background: rgba(255,255,255,0.1); color: var(--text); }
.tts-bar .speed-wrap { font-size: 0.85rem; color: var(--muted); }
.tts-feedback {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
  min-height: 1.1em;
}
.tts-feedback.err { color: #f87171; }
.tts-feedback.info { color: #94a3b8; }
.tts-feedback:empty { display: none; }
.tts-bar select {
  margin-left: 0.25rem;
  padding: 0.25rem;
  background: var(--bg);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  border-radius: 4px;
  font-size: 0.85rem;
}
.rate-bar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.rate-bar .rate-label { font-size: 0.85rem; color: var(--muted); margin-right: 0.25rem; }
.rate-bar .rate-btn {
  min-width: 36px;
  min-height: 36px;
  padding: 0.25rem 0.5rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}
.rate-bar .rate-btn:hover { background: rgba(255,255,255,0.12); color: var(--text); }
.rate-bar .rate-btn.rated { background: var(--accent); color: #fff; border-color: var(--accent); }

.tracking-badge {
  display: inline-block;
  background: rgba(234, 179, 8, 0.2);
  color: var(--grade-b);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.tracking-section { margin-top: 1.5rem; }
.tracking-section h2 { font-size: 1rem; margin-bottom: 0.75rem; color: var(--muted); }
.tracking-section.collapsible.hidden { display: none !important; }

.topics-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.topics-actions input, .topics-actions select {
  min-height: var(--touch-min);
  padding: 0.6rem 0.75rem;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}
.topics-actions .btn { min-height: var(--touch-min); padding: 0.6rem 1rem; }
.topics-list { list-style: none; }
.topic-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--touch-min);
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  border: 1px solid rgba(255,255,255,0.06);
}
.topic-item .keyword { font-weight: 600; }
.topic-item .category { font-size: 0.85rem; color: var(--muted); margin-left: 0.5rem; }
.topic-item button {
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem;
  background: rgba(248,113,113,0.2);
  border: none;
  border-radius: 8px;
  color: #f87171;
  cursor: pointer;
  font-size: 1rem;
}

.btn {
  min-height: var(--touch-min);
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }

.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.login-screen.hidden { display: none !important; }
.login-card {
  background: var(--surface);
  padding: 2rem;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  max-width: 360px;
  width: 90%;
}
.login-card h2 { font-family: var(--serif); font-size: 1.5rem; margin-bottom: 0.5rem; }
.login-card p { color: var(--muted); margin-bottom: 1rem; font-size: 0.95rem; }
.login-card input {
  width: 100%;
  min-height: var(--touch-min);
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  background: var(--bg);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  border-radius: 8px;
  font-size: 1.25rem;
  font-family: inherit;
}
.login-card .btn { width: 100%; }

@media (min-width: 600px) {
  .topics-actions { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .topics-actions input { flex: 1; min-width: 180px; }
  .topics-actions select { min-width: 140px; }
}
