:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #1f232d;
  --border: #2a2f3a;
  --text: #e8eaf0;
  --muted: #9aa3b2;
  --accent: #ff5a1f;
  --hot: #ff3b3b;
  --warm: #ffb020;
  --cool: #5b6472;
  --green: #38c172;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
h1, h2 { margin: 0; }
button { font: inherit; cursor: pointer; }

/* topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { font-size: 17px; }
.topbar-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.health-summary { color: var(--muted); font-size: 13px; }
.logout { color: var(--muted); font-size: 13px; text-decoration: none; }
.logout:hover { color: var(--text); }
.scan-msg { color: var(--green); font-size: 13px; }

.banner-error {
  background: #3a1414; border: 1px solid #713131; color: #ffb4b4;
  padding: 10px 20px; font-size: 14px;
}

/* filters */
.filters {
  display: flex; gap: 8px; padding: 14px 20px; flex-wrap: wrap; align-items: center;
}
.filters input[type="search"] {
  flex: 1; min-width: 200px;
}
.filters input, .filters select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font: inherit;
}

/* story list */
.story-list { display: flex; flex-direction: column; gap: 14px; padding: 0 20px 40px; max-width: 1100px; margin: 0 auto; }
.empty { color: var(--muted); text-align: center; padding: 60px 0; }
.result-bar { display: flex; align-items: baseline; gap: 8px; padding: 2px 2px 4px; }
.result-bar .count { color: var(--text); font-size: 13px; font-weight: 600; }
.result-bar .count-sub { color: var(--muted); font-size: 13px; }

.card {
  display: flex; gap: 16px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px; transition: opacity .2s;
}
.card.status-dismissed { opacity: .45; }
.card.status-posted { border-color: #2b4d38; }
.card-media { flex: 0 0 180px; position: relative; width: 180px; height: 130px; border-radius: 10px; overflow: hidden; }
.card-media img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  display: block; z-index: 1;
}
.media-placeholder {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 46px; z-index: 0;
}
.media-placeholder span { filter: grayscale(.2) drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
/* Five deterministic gradient backdrops so image-less cards still look intentional. */
.ph-0 { background: linear-gradient(135deg, #1f2a3a, #2c1f3a); }
.ph-1 { background: linear-gradient(135deg, #2a1f24, #3a2c1f); }
.ph-2 { background: linear-gradient(135deg, #1f3a2e, #1f2a3a); }
.ph-3 { background: linear-gradient(135deg, #331f24, #1f2436); }
.ph-4 { background: linear-gradient(135deg, #2c2c1f, #1f3336); }
.media-tag {
  position: absolute; bottom: 6px; left: 6px; background: rgba(0,0,0,.75);
  font-size: 11px; padding: 2px 7px; border-radius: 5px; z-index: 2;
}
.card-body { flex: 1; min-width: 0; }
.card-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }

.score {
  font-weight: 800; font-size: 18px; padding: 2px 10px; border-radius: 8px; color: #fff;
}
.score-hot { background: var(--hot); }
.score-warm { background: var(--warm); color: #201500; }
.score-cool { background: var(--cool); }

.chip {
  font-size: 12px; color: var(--muted); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px;
  white-space: nowrap;
}
.chip.sport { color: var(--accent); border-color: #55341f; }
.chip.velocity { color: var(--warm); }
.chip.covered { color: var(--green); border-color: #2b4d38; text-decoration: none; }

.headline { font-size: 17px; line-height: 1.35; margin: 2px 0 4px; }
.summary { color: var(--muted); margin: 0 0 6px; font-size: 14px; }
.reasoning { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.reasoning summary { cursor: pointer; color: #7d8795; }

.sources { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.chip.src { text-decoration: none; }
.chip.src:hover { color: var(--text); border-color: var(--muted); }
.chip.src-x { border-color: #274054; }
.chip.src-reddit { border-color: #5a3222; }
.chip.src-err { color: #ff8b8b; border-color: #713131; }

.titles { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.titles li {
  display: flex; gap: 8px; align-items: baseline; background: var(--panel-2);
  border-radius: 8px; padding: 6px 10px; font-size: 14px;
}
.copy {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; padding: 0 6px; font-size: 13px; flex-shrink: 0;
  transition: color .15s, border-color .15s, background .15s;
}
.copy:hover { color: var(--text); border-color: var(--muted); }
.copy.copied { color: var(--green); border-color: var(--green); background: rgba(56,193,114,.12); }
.title-text { flex: 1; }

.card-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.btn {
  background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 8px 14px;
  font-weight: 600;
}
.btn:hover { filter: brightness(1.1); }
.btn.small { padding: 4px 10px; font-size: 13px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); font-weight: 500; }
.btn.small:hover { border-color: var(--muted); }
.btn.ghost { background: none; }
.status-label { color: var(--muted); font-size: 12px; margin-left: auto; text-transform: uppercase; letter-spacing: .06em; }

.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
/* Dim the feed while a filter/search request is in flight. */
#story-list.htmx-request { opacity: .45; transition: opacity .12s; }

/* health */
.health-panel { max-width: 1100px; margin: 0 auto 60px; padding: 0 20px; color: var(--muted); }
.health-panel summary { cursor: pointer; padding: 8px 0; }
.health-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.health-table th, .health-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.health-table .st-ok { color: var(--green); }
.health-table .st-partial { color: var(--warm); }
.health-table .st-error { color: var(--hot); }
.src-cell { display: flex; gap: 4px; flex-wrap: wrap; }

/* login */
.login-wrap { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 36px; width: 340px; display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { font-size: 20px; }
.login-card .sub { color: var(--muted); margin: 0; font-size: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.login-card input {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 10px; font: inherit;
}
.login-card button {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 11px; font-weight: 700;
}
.login-card .error { color: #ff8b8b; margin: 0; font-size: 14px; }

@media (max-width: 640px) {
  .card { flex-direction: column; }
  .card-media { width: 100%; height: 180px; flex-basis: auto; }
}
