/* Reader-first: dense enough to scan a morning's news quickly, quiet
   enough to read. Sidebar ad slots (Milestone 2) go beside .articles. */
:root {
  --bg: #fbfaf8; --fg: #1a1a19; --dim: #6b6b66; --line: #e4e2dd;
  --accent: #1a5f7a; --warn: #8a6d1f; --danger: #9b2c2c; --card: #fff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a; --fg: #e8e6e1; --dim: #9a978f; --line: #2b2d31;
    --accent: #6fb3cc; --warn: #d4b25a; --danger: #e08585; --card: #1d1e22;
  }
}
* { box-sizing: border-box; }
/* Bare links had no colour, so they fell back to the browser default --
   dark blue, effectively invisible on the dark background. Every link
   that is not styled by a more specific rule lands here. */
a { color: var(--accent); }
a:hover { color: var(--fg); }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
header {
  display: flex; align-items: baseline; gap: 1.5rem;
  padding: .9rem 1.2rem; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.brand { font-weight: 700; text-decoration: none; color: var(--fg); letter-spacing: -.02em; }
nav { display: flex; gap: 1rem; }
nav a { color: var(--dim); text-decoration: none; font-size: .9rem; }
nav a.on, nav a:hover { color: var(--accent); }
main { max-width: 62rem; margin: 0 auto; padding: 1.2rem; }
/* Article column stays reading-width; the sidebar is the only thing
   that widens the page. Scarce by design: 2-3 slots, never more. */
.layout { display: grid; grid-template-columns: minmax(0,46rem) 1fr;
          gap: 2rem; align-items: start; }
.sidebar { position: sticky; top: 4.5rem; display: flex;
           flex-direction: column; gap: 1rem; }
.slot { border: 1px solid var(--line); border-radius: 6px; padding: .75rem;
        min-height: 5rem; font-size: .8rem; color: var(--dim); }
@media (max-width: 62rem) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; flex-direction: row; flex-wrap: wrap; }
  .slot { flex: 1 1 14rem; }
}
form.inline { display: inline; margin: 0; }
button.chip { font: inherit; font-size: .8rem; cursor: pointer;
              background: none; }

.bar {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; font-size: .85rem;
  color: var(--dim);
}
.blocked { color: var(--accent); }
.chip {
  display: inline-block; padding: .25rem .6rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--dim); text-decoration: none;
  font-size: .8rem;
}
.chip.on { border-color: var(--accent); color: var(--accent); }

.articles { list-style: none; margin: 0; padding: 0; }
.articles li {
  position: relative; display: flex; gap: .9rem;
  padding: .95rem 2.2rem .95rem 0;
  border-bottom: 1px solid var(--line);
}
.articles .body { min-width: 0; }
@media (max-width: 34rem) {
  .articles li { flex-direction: column; }
}
.articles li.read h2 a { color: var(--dim); font-weight: 400; }
.meta { font-size: .78rem; color: var(--dim); display: flex; gap: .5rem; flex-wrap: wrap; }
.src { font-weight: 600; }
/* Repeated source on consecutive rows: present but recessive. */
.src.dim { font-weight: 400; opacity: .45; }
.tag { padding: 0 .35rem; border-radius: 3px; font-size: .7rem; }
.tag.unknown { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.tag.assumed { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
h2 { margin: .2rem 0 .25rem; font-size: 1.02rem; line-height: 1.35; font-weight: 600; }
h2 a { color: var(--fg); text-decoration: none; }
h2 a:hover { color: var(--accent); }
.snip { margin: 0; color: var(--dim); font-size: .88rem; }
.save {
  position: absolute; top: .9rem; right: 0; background: none; border: 0;
  color: var(--dim); font-size: 1.1rem; cursor: pointer; line-height: 1;
}
.save:hover { color: var(--warn); }
.empty { color: var(--dim); padding: 2rem 0; }

.add { display: flex; gap: .5rem; margin-bottom: .4rem; }
.add input {
  flex: 1; padding: .6rem .7rem; border: 1px solid var(--line);
  border-radius: 6px; background: var(--card); color: var(--fg); font-size: .95rem;
}
.add button {
  padding: .6rem 1rem; border: 0; border-radius: 6px;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}
.hint { font-size: .8rem; color: var(--dim); margin: 0 0 1rem; }
.flash { padding: .6rem .8rem; border-radius: 6px; font-size: .88rem; }
.flash.err { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.flash.ok { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }

.feeds { width: 100%; border-collapse: collapse; font-size: .9rem; }
.feeds tr { border-bottom: 1px solid var(--line); }
.feeds tr.muted { opacity: .5; }
.feeds td { padding: .7rem .4rem; vertical-align: top; }
.ftitle { color: var(--fg); text-decoration: none; font-weight: 600; }
.ftitle:hover { color: var(--accent); }
.furl { font-size: .75rem; color: var(--dim); word-break: break-all; }
.ferr { font-size: .75rem; color: var(--danger); margin-top: .2rem; }
.num, .when { color: var(--dim); white-space: nowrap; font-size: .8rem; }
.acts { display: flex; gap: .6rem; justify-content: flex-end; }
.acts form { margin: 0; }
button.link {
  background: none; border: 0; color: var(--dim); cursor: pointer;
  font-size: .8rem; padding: 0; text-decoration: underline;
}
button.link:hover { color: var(--accent); }
button.link.danger:hover { color: var(--danger); }

/* Discovery: sample headlines prove the feed was actually read. */
.samples { font-size: .75rem; color: var(--dim); margin-top: .25rem;
           font-style: italic; }

.missed { border-top: 1px solid var(--line); padding-top: .8rem;
         margin-top: 1.2rem; }

/* Top stories: image + text, coverage count as the importance cue. */
.stories { list-style: none; margin: 0; padding: 0; }
.stories li {
  position: relative; display: flex; gap: .9rem;
  padding: 1rem 2.2rem 1rem 0; border-bottom: 1px solid var(--line);
}
.stories li.read h2 a { color: var(--dim); font-weight: 400; }
.thumb {
  width: 132px; height: 88px; object-fit: cover; border-radius: 5px;
  flex: 0 0 auto; background: var(--line);
}
.stories .body { min-width: 0; }
.tag.coverage {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent); font-weight: 600;
}
.also { margin: .3rem 0 0; font-size: .76rem; color: var(--dim); }
.walled { margin: .15rem 0 0; font-size: .74rem; color: var(--warn); }
@media (max-width: 34rem) {
  .stories li { flex-direction: column; }
  .thumb { width: 100%; height: 150px; }
}

/* Google News style lead: one prominent story with sibling coverage
   stacked beside it, then compact rows. A page where every story is
   equally loud has no top story. */
/* Two columns only when there is real sibling coverage to fill the
   second one -- otherwise the lead runs full width rather than leaving
   a conspicuous empty gutter. */
.stories li.lead-story { display: block; padding-bottom: 1.4rem; }
.stories li.lead-story.has-siblings {
  display: grid; grid-template-columns: minmax(0,1.5fr) minmax(0,1fr);
  gap: 1.8rem; align-items: start;
}
.lead-story:not(.has-siblings) .lead-img { max-width: 30rem; }
.sib-inline { color: var(--dim); text-decoration: none; }
.sib-inline:hover { color: var(--accent); text-decoration: underline; }
.lead-img {
  width: 100%; aspect-ratio: 16/10; object-fit: cover;
  border-radius: 6px; background: var(--line); margin-bottom: .6rem;
}
.lead-story h2 { font-size: 1.32rem; line-height: 1.28; margin: .25rem 0 .35rem; }
.siblings { list-style: none; margin: 0; padding: 0; }
.siblings li {
  /* Block layout, not flex: the meta line sits ABOVE the headline as a
     caption. Side by side, a long feed title squeezes the headline into
     a five-words-per-line column. */
  display: block; padding: .55rem 0;
  border-bottom: 1px solid var(--line);
}
.siblings li:last-child { border-bottom: 0; }
.siblings .meta {
  display: block; margin-bottom: .1rem;
  font-size: .71rem; color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.siblings .src { font-weight: 600; }
.siblings .when::before { content: "· "; }
.sib-title {
  color: var(--fg); text-decoration: none; font-size: .88rem;
  line-height: 1.35; display: block;
}
.sib-title:hover { color: var(--accent); }
.walled-note { font-size: .74rem; color: var(--warn); padding-top: .5rem; }
details.more { margin-top: .45rem; }
details.more summary {
  cursor: pointer; font-size: .78rem; color: var(--accent);
  list-style: none;
}
details.more summary::-webkit-details-marker { display: none; }
details.more summary:hover { text-decoration: underline; }
.siblings.inline { margin-top: .5rem; padding-left: .85rem;
                   border-left: 2px solid var(--line); }
.siblings.inline li { padding: .45rem 0; }
@media (max-width: 46rem) {
  .stories li.lead-story { grid-template-columns: 1fr; gap: .8rem; }
}

/* Video: a play badge over the publisher's own poster frame, linking
   out. We never embed a player -- that would reproduce their content
   and cost them the view. */
.thumbwrap {
  position: relative; flex: 0 0 auto; line-height: 0;
  /* inline-block, and align-self so the wrapper does NOT stretch to the
     flex row's height. As a stretched block it was taller than the
     132x88 image inside it, so the centred play badge floated in empty
     space below the picture. */
  display: inline-block; align-self: flex-start;
}
.lead-wrap { display: block; width: 100%; }
.playbadge {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(0,0,0,.62); color: #fff; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  padding-left: 2px; pointer-events: none;
}
.playbadge.big { width: 52px; height: 52px; font-size: 20px; }

a.thumbwrap { cursor: pointer; }
a.thumbwrap:hover .thumb, a.thumbwrap:hover .lead-img { opacity: .88; }
.thumb, .lead-img { transition: opacity .12s ease; }

.more-note { font-size: .74rem; color: var(--dim); padding-top: .35rem; }

/* Discovery takes a list of topics, so the input is a textarea. */
.add textarea {
  flex: 1; padding: .6rem .7rem; border: 1px solid var(--line);
  border-radius: 6px; background: var(--card); color: var(--fg);
  font: inherit; font-size: .95rem; resize: vertical; min-height: 2.6rem;
}
.add { align-items: flex-start; }

/* Search + saved topics */
.topiclist { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.chip .count {
  display: inline-block; margin-left: .3rem; padding: 0 .3rem;
  border-radius: 999px; background: var(--accent); color: #fff;
  font-size: .68rem;
}
.savetopic { display: inline-flex; gap: .35rem; align-items: center; }
.savetopic input {
  padding: .2rem .45rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--fg); font: inherit; font-size: .8rem;
  width: 11rem;
}

/* Saved topics as nav sections, the way Google News shows its tabs. */
nav.sections {
  display: flex; gap: .9rem; margin-left: auto; flex-wrap: wrap;
  padding-left: 1rem; border-left: 1px solid var(--line);
}
nav.sections a { color: var(--dim); text-decoration: none; font-size: .85rem; }
nav.sections a.on, nav.sections a:hover { color: var(--accent); }
nav.sections .count {
  display: inline-block; padding: 0 .28rem; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: .66rem;
}
.topicedit { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.topicedit input {
  padding: .25rem .5rem; border: 1px solid var(--line); border-radius: 5px;
  background: var(--card); color: var(--fg); font: inherit; font-size: .82rem;
}

.searchopt {
  display: flex; align-items: center; gap: .35rem; white-space: nowrap;
  font-size: .82rem; color: var(--dim); padding-top: .6rem;
}
.searchopt input { margin: 0; }

/* Progress for long operations (discovery fetches every candidate).
   [hidden] must win: the HTML attribute is only display:none from the
   UA stylesheet, so any author `display` rule overrides it and the
   spinner shows on every page load. */
[hidden] { display: none !important; }

.busy {
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem .85rem; margin: .2rem 0 1rem;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--dim); font-size: .86rem;
}
.spinner {
  width: 15px; height: 15px; flex: 0 0 auto; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: nfmspin .8s linear infinite;
}
@keyframes nfmspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}
button:disabled { opacity: .6; cursor: progress; }

/* Discovery adds happen in place: a run takes ~35s, so navigating away
   after one add throws the rest of the results out. */
.addstate { font-size: .8rem; }
.addstate.ok { color: var(--accent); }
.addstate.err { color: var(--danger); }
.addall { margin: .2rem 0 .8rem; }
[aria-busy="true"], .htmx-request { opacity: .55; cursor: progress; }

/* Sign in / register */
.authbox { max-width: 22rem; margin: 3rem auto; }
.authbox h1 { font-size: 1.3rem; margin: 0 0 1rem; }
.authbox label { display: block; margin-bottom: .9rem; font-size: .85rem;
                 color: var(--dim); }
.authbox input {
  display: block; width: 100%; margin-top: .25rem; padding: .55rem .65rem;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--fg); font: inherit;
}
.authbox button[type=submit] {
  width: 100%; padding: .6rem; border: 0; border-radius: 6px;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}
/* Sign out reads as a control, not a footnote: it was a small grey
   underlined string that looked like body text. */
.signout { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.who { font-size: .78rem; color: var(--dim); }
.signout button.link {
  text-decoration: none; font-size: .78rem;
  padding: .22rem .6rem; border: 1px solid var(--line); border-radius: 999px;
  color: var(--dim);
}
.signout button.link:hover { color: var(--accent); border-color: var(--accent); }

/* Settings */
.settings { max-width: 34rem; margin: 2rem auto; }
.settings h1 { font-size: 1.3rem; margin: 0 0 1rem; }
.settings h2 { font-size: .95rem; margin: 1.6rem 0 .4rem; }
.settings label { display: block; margin-bottom: .8rem; font-size: .85rem;
                  color: var(--dim); }
.settings input {
  display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--fg); font: inherit; font-size: .9rem;
}
.settings button[type=submit] {
  margin-top: .6rem; padding: .55rem 1.1rem; border: 0; border-radius: 6px;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}
.testmail { margin-top: 1.4rem; padding-top: 1rem;
            border-top: 1px solid var(--line); }

/* Signed-out explainer. Quiet: informative, not a sales pitch. */
.pitch {
  max-width: 26rem; margin: 1.5rem auto 0; text-align: center;
  font-size: .84rem; line-height: 1.5; color: var(--dim);
}

/* Operator status table */
table.status { width: 100%; border-collapse: collapse; font-size: .85rem;
               margin-bottom: 1rem; }
table.status td { padding: .35rem .2rem; border-bottom: 1px solid var(--line); }
table.status td:first-child { color: var(--dim); width: 55%; }
table.status .warn { color: var(--warn); }
table.status tr.warn-row td { color: var(--warn); }
