:root {
  --bg: #0e1116;
  --panel: #161b22;
  --border: #262c36;
  --rule: #30363d;
  --text: #e6edf3;
  --dim: #7d8590;
  --head: #4f9ba6;

  /* Each radar's colours. NewsRadar is the default. */
  --bar-bg: var(--panel);
  --bar-top: transparent;
  --bar-line: var(--border);
  --brand: #58d0e0;
  --title: var(--text);
  --bar-h: 45px;

  /* time | score | source | story */
  --cols: 92px 64px 170px 1fr;
  --gap: 18px;
}

body[data-radar="animal"] {
  --bar-bg: #1f1a10;
  --bar-top: #f0a347;
  --bar-line: #5c4520;
  --brand: #f0a347;
  --title: #79c0ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
}

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--bar-h);
  padding: 0 20px;
  background: var(--bar-bg);
  border-top: 3px solid var(--bar-top);
  border-bottom: 1px solid var(--bar-line);
}

.bar h1 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand);
}

.status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--dim);
}

.status.live { color: #3fb950; border-color: #3fb950; }
.status.down { color: #d29922; border-color: #d29922; }

.count {
  margin-left: auto;
  font-size: 13px;
  color: var(--dim);
}

.toggle {
  font: inherit;
  font-size: 13px;
  padding: 4px 12px;
  color: var(--dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.toggle.on { color: #3fb950; border-color: #3fb950; }

main { padding: 0 20px 40px; }

.head,
.story {
  display: grid;
  grid-template-columns: var(--cols);
  gap: var(--gap);
}

.head {
  position: sticky;
  top: var(--bar-h);
  z-index: 10;
  padding: 14px 0 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  color: var(--head);
  font-family: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.feed {
  list-style: none;
  margin: 0;
  padding: 0;
}

.empty {
  padding-top: 24px;
  text-align: center;
  color: var(--dim);
}

.story {
  position: relative;
  align-items: start;
  padding: 10px 30px 10px 0;
  border-bottom: 1px solid #1c222b;
}

.delete-btn {
  position: absolute;
  top: 8px;
  right: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.story:hover .delete-btn,
.delete-btn:focus-visible {
  opacity: 1;
}

.delete-btn:hover {
  color: #f85149;
  background: rgba(248, 81, 73, 0.12);
}

.story.deleting {
  opacity: 0.35;
  pointer-events: none;
}

.story.new { animation: flash 5s ease-out; }

@keyframes flash {
  0%   { background: rgba(63, 185, 80, 0.16); }
  100% { background: transparent; }
}

.time .day {
  display: block;
  font-size: 11px;
  opacity: 0.75;
}

.time,
.score,
.source {
  font-family: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--dim);
  padding-top: 2px;
}

.score {
  position: relative;
  text-align: right;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: default;
}

/* 20 is the base score - neutral */
.score.base { color: #6e7681; }

/* above 20: brighter green the higher it goes */
.score.g1 { color: #9ae0a7; }
.score.g2 { color: #3fb950; }
.score.g3 { color: #15af27; }
.score.g4 { color: #33b33d; }
.score.g5 { color: #05d428; }

/* below 20: brighter red the lower it goes */
/* below 20: recedes rather than shouts - nothing here is worth your eye */
.score.r1 { color: #5c646e; }
.score.r2 { color: #4e555e; }
.score.r3 { color: #434951; }
.score.r4 { color: #3a3f47; }

.tooltip {
  display: none;
  position: absolute;
  top: -8px;
  left: calc(100% + 12px);
  z-index: 30;
  min-width: 150px;
  padding: 8px 11px;
  background: #0b0e13;
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
}

.tooltip span { display: block; }
.tooltip span + span { margin-top: 3px; }

.score:hover .tooltip { display: block; }

.title {
  display: block;
  color: var(--title);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}

.title:hover { text-decoration: underline; }

.summary {
  margin: 3px 0 0;
  color: #9aa4b0;
  font-size: 14px;
}

@media (max-width: 760px) {
  :root { --cols: 70px 48px 1fr; --gap: 12px; }

  .head span:nth-child(3),
  .source { display: none; }

  .tooltip { left: 0; top: 100%; }
}

.countdown {
  font-family: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--dim);
}

.panel {
  margin: 14px 0 6px;
  padding: 10px 14px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}

.sources-head,
.source-row {
  display: grid;
  grid-template-columns: 36px 1fr 240px 60px 90px 60px;
  gap: 12px;
  align-items: baseline;
}

.sources-head {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
  color: var(--head);
}

.source-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.source-row {
  padding: 4px 0;
  color: var(--dim);
}

.source-row.ok .src-state        { color: #3fb950; }
.source-row.unchanged .src-state { color: #6e7681; }
.source-row.waiting .src-state   { color: #d29922; }
.source-row.error .src-state     { color: #f85149; }

.source-row.error { color: #b1bac4; }

.src-state {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.src-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---- Keywords panel: every scoring word and its points. */
.keywords-intro,
.keywords-gate,
.panel-intro {
  margin: 0 0 10px;
  color: var(--dim);
  font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.5;
}

.keywords-gate {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
}

.keyword-groups {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 28px;
}

.keyword-head {
  margin: 0 0 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
  font-size: 12px;
  font-weight: 400;
}

.keyword-head.good { color: #7ee787; }
.keyword-head.bad  { color: #ff9492; }

.keyword-list {
  list-style: none;
  margin: 0;
  padding: 0;
  column-width: 200px;
  column-gap: 24px;
  max-height: 340px;
  overflow-y: auto;
}

.keyword-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  color: var(--text);
  break-inside: avoid;
}

.keyword-list .phrase {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Shared look for every box you can type in. */
.panel input {
  font: inherit;
  font-size: 12px;
  padding: 2px 6px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.panel input:focus {
  outline: none;
  border-color: var(--head);
}

.keyword-list .points {
  width: 58px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.keyword-list.good-list .points { color: #7ee787; }
.keyword-list.bad-list  .points { color: #ff9492; }

.keyword-list .remove {
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--dim);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.keyword-list .remove:hover {
  color: #f85149;
  background: rgba(248, 81, 73, 0.12);
}

.keywords-bar,
.panel-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 12px;
}

.feed-add,
.keyword-add {
  display: flex;
  gap: 6px;
}

.keyword-add #keyword-phrase { width: 190px; }
.feed-add #feed-url { width: 320px; max-width: 60vw; }

/* The show / remove column in the Sources panel. */
.source-row input[type="checkbox"] {
  margin: 0;
  accent-color: #3fb950;
  cursor: pointer;
}

.source-row.off { opacity: 0.45; }

.source-row .yours {
  margin-left: 6px;
  font-size: 11px;
  color: var(--head);
}

.source-row .remove {
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--dim);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.source-row .remove:hover {
  color: #f85149;
  background: rgba(248, 81, 73, 0.12);
}
.keyword-add #keyword-points { width: 80px; }

.keywords-which {
  color: var(--dim);
}

.keywords-message,
.panel-message {
  margin: -4px 0 12px;
  color: #d29922;
  font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
}

/* ---- Admin page (/admin): the sources everyone sees. */
.admin-page main { padding-top: 14px; }

.plain-link {
  color: var(--head);
  text-decoration: none;
}

.plain-link:hover { text-decoration: underline; }

.panel-message.bad { color: #ff9492; }

.admin-head,
.admin-row {
  grid-template-columns: 1fr 1.4fr 110px 70px 150px 110px;
  align-items: center;
}

.admin-row { padding: 6px 0; }

.admin-row.off { opacity: 1; }
.admin-row.off > span { opacity: 0.45; }

.admin-row .src-link {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dim);
  text-decoration: none;
}

.admin-row .src-link:hover { color: var(--text); }

.admin-row .toggle {
  justify-self: start;
  font-size: 12px;
  padding: 3px 10px;
}

.admin-page .panel input[type="url"] { width: 300px; max-width: 55vw; }
.admin-page .panel input[type="text"] { width: 150px; }
.admin-page .panel input[type="number"] { width: 80px; }
.admin-page .panel input[type="password"] { width: 220px; }

mark.hit {
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 700;
  background: transparent;
}

mark.hit.good {
  color: #8ff0a4;
  background: rgba(63, 185, 80, 0.16);
}

mark.hit.bad {
  color: #8b949e;
  background: transparent;
  font-weight: 400;
  border-bottom: 1px dotted #6e7681;
}

.tooltip .good { color: #7ee787; }
.tooltip .bad  { color: #ff9492; }

@media (max-width: 760px) {
  /* The header has more than fits on a phone - let it scroll sideways
     rather than squash or push the buttons off screen. */
  .bar { overflow-x: auto; }
  .bar > * { flex-shrink: 0; }
  .count { margin-left: 0; }

  .keyword-groups { grid-template-columns: 1fr; }

  .sources-head:not(.admin-head),
  .source-row:not(.admin-row) { grid-template-columns: 30px 1fr 70px 60px; }

  .admin-head,
  .admin-row { grid-template-columns: 1fr 110px 100px; }

  .admin-head span:nth-child(2),
  .admin-head span:nth-child(3),
  .admin-head span:nth-child(4),
  .admin-row > :nth-child(2),
  .admin-row > :nth-child(3),
  .admin-row > :nth-child(4) { display: none; }

  .sources-head:not(.admin-head) span:nth-child(5),
  .sources-head:not(.admin-head) span:nth-child(6),
  .source-row:not(.admin-row) > :nth-child(5),
  .source-row:not(.admin-row) > :nth-child(6) { display: none; }
}



/* ---- attention should track interest ---------------------------- */
/* The whole row fades as the score drops, so low scorers become
   background texture instead of competing for the eye. */
.story.t-base { opacity: 0.78; }
.story.t-r1   { opacity: 0.58; }
.story.t-r2   { opacity: 0.48; }
.story.t-r3   { opacity: 0.40; }
.story.t-r4   { opacity: 0.32; }

/* Readable on demand, without having to go hunting. Must come after
   the tier rules above - same specificity, so source order decides. */
.story:hover { opacity: 1; }

/* .story sets display:grid, which overrides the browser default for
   [hidden]. Without this line the min-score filter would do nothing. */
.story[hidden] { display: none; }

/* 20 and under: summary clamped to a single line, so a dull story
   takes one row instead of three. Swap for display:none to lose it. */
.story.t-base .summary,
.story.t-r1 .summary,
.story.t-r2 .summary,
.story.t-r3 .summary,
.story.t-r4 .summary {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- visited: rows whose title you've clicked fade back, like a
   read link, so your eye can tell new from already-seen at a glance. */
.story.visited .title { color: var(--dim); }
.story.visited .title:hover { color: var(--text); }

.filter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--dim);
}

.filter select {
  font: inherit;
  font-size: 12px;
  padding: 3px 6px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
