:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1a1d21;
  --muted: #6b7280;
  --border: #e2e5ea;
  --accent: #2563eb;
  --bullish-bg: #e6f7ec;
  --bullish-text: #157347;
  --bearish-bg: #fdecec;
  --bearish-text: #b3261e;
  --neutral-bg: #eef0f2;
  --neutral-text: #52575d;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1e2126;
    --text: #e7e9ec;
    --muted: #9aa1ac;
    --border: #2c3038;
    --accent: #5b8def;
    --bullish-bg: #113321;
    --bullish-text: #6fd39a;
    --bearish-bg: #3a1616;
    --bearish-text: #f29e98;
    --neutral-bg: #2a2d33;
    --neutral-text: #c2c7cd;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- Password gate ---------- */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.gate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.gate-card h1 { font-size: 1.25rem; margin: 0 0 8px; }
.gate-card p { color: var(--muted); font-size: 0.9rem; margin: 0 0 16px; }
.gate-card input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 12px;
}
.gate-card button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  cursor: pointer;
}
.gate-error { color: var(--bearish-text); }

/* .gate sets display:flex for centering, which otherwise beats the browser's
   default [hidden]{display:none} rule since author styles win over UA styles. */
.gate[hidden] { display: none; }

/* ---------- App shell ---------- */
.app { max-width: 900px; margin: 0 auto; padding: 16px 16px 48px; }

.header { margin-bottom: 12px; }
.header h1 { font-size: 1.4rem; margin: 0 0 4px; }
.updated { color: var(--muted); font-size: 0.85rem; margin: 0 0 6px; }
.notice { color: var(--muted); font-size: 0.8rem; margin: 0; }

/* ---------- Controls ---------- */
.controls {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.filters-toggle {
  display: none;
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  min-height: 44px;
}
.controls-panel { display: flex; flex-direction: column; gap: 10px; }
#search {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  min-height: 44px;
}
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  min-height: 40px;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: white; }
.sort-group { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); }
.sort-group select {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  min-height: 40px;
}

@media (max-width: 640px) {
  .filters-toggle { display: block; }
  .controls-panel { display: none; }
  .controls-panel.open { display: flex; }
}

/* ---------- Sections ---------- */
.section { margin-bottom: 28px; }
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  margin: 0 0 12px;
}
.section-count {
  font-size: 0.75rem;
  background: var(--neutral-bg);
  color: var(--neutral-text);
  padding: 2px 8px;
  border-radius: 999px;
}
.empty-state { color: var(--muted); font-size: 0.9rem; padding: 12px 0; }

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 900px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.card-headline {
  display: block;
  font-weight: 600;
  color: var(--text);
  text-decoration: underline;
  font-size: 0.98rem;
  margin-bottom: 6px;
}
.card-meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 8px;
}
.card-dot { margin: 0 4px; }
.card-row2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.card-sentiment {
  font-size: 0.78rem;
  padding: 3px 9px;
  border-radius: 999px;
}
.card-sentiment.bullish { background: var(--bullish-bg); color: var(--bullish-text); }
.card-sentiment.bearish { background: var(--bearish-bg); color: var(--bearish-text); }
.card-sentiment.neutral { background: var(--neutral-bg); color: var(--neutral-text); }
.card-timestamp { color: var(--muted); font-size: 0.78rem; }
.card-details summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--accent);
  min-height: 32px;
  display: flex;
  align-items: center;
}
.card-ai-summary { font-size: 0.88rem; margin: 8px 0 6px; }
.card-snippet { font-size: 0.8rem; color: var(--muted); margin: 0; }

.footer {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
  margin-top: 24px;
}
