*, *::before, *::after { box-sizing: border-box; }

:root {
  --wrap: 950px;
  --bg: #ffffff;
  --panel: #ffffff;
  --ink: #555555;
  --muted: #888888;
  --line: #dcdcdc;
  --accent: #326ea1;
  --bar: #5f5f5f;
  --bar-current: #f80;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f131a;
    --panel: #171b23;
    --ink: #eef1f6;
    --muted: #a4adbb;
    --line: #262c37;
    --accent: #8fb8ff;
    --bar: #171b23;
    --bar-current: #f80;
  }
}

:root[data-theme="light"] {
  --bg:#ffffff; --panel:#ffffff; --ink:#555555; --muted:#888888;
  --line:#dcdcdc; --accent:#326ea1; --bar:#5f5f5f; --bar-current:#f80;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg:#0f131a; --panel:#171b23; --ink:#eef1f6; --muted:#a4adbb;
  --line:#262c37; --accent:#8fb8ff; --bar:#171b23; --bar-current:#f80;
  color-scheme: dark;
}

:root[data-size="1"] { font-size: 60%; }
:root[data-size="2"] { font-size: 71%; }
:root[data-size="3"] { font-size: 89%; }
:root[data-size="4"] { font-size: 112%; }

body {
  color: var(--ink);
  font-family: verdana, helvetica, arial, sans-serif;
  font-size: 100%;
  line-height: 125%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

a { color: var(--muted); text-decoration: none; }
a:hover { color: #069; }
:root[data-theme="dark"] a { color: var(--muted); }
:root[data-theme="dark"] a:hover { color: var(--accent); }

/* Shared container width for bar, grid, ads, footer */
.bar-inner, .meta, main, .ads, .foot {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding-inline: 15px;
}

/* --- Top bar --- */
.bar {
  background: var(--bar);
}
.bar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 6px 0;
}
.bar-sub { padding-top: 0; }

.brand { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; min-width: 0; }
.brand-mark { display: block; flex: 0 0 auto; width: auto; height: 30px; object-fit: contain; object-position: left center; }
.brand-stack { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 700; color: #fff; font-size: 1.2em; }
.brand-sub { color: #f2f2f2; font-size: .95em; }

.ctl-group { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctl { display: inline-flex; align-items: center; gap: 4px; }
.ctl-label { color: #fff; display: block; }

/* Bar controls behave like flat nav items on the grey strip */
select, .btn {
  font: inherit;
  color: #fff;
  background: transparent;
  display: block;
  padding: 8px 10px;
  margin-right: 10px;
  border: none;
  border-radius: 0;
}
select:hover, .btn:hover { color: var(--bar-current); }
.btn:active { color: var(--bar-current); }
:focus-visible { outline: 1px solid var(--bar-current); outline-offset: 1px; }
.bar select, .bar .btn { background: rgba(255,255,255,.14); }
.bar .hint { color: #f2f2f2; }

/* Theme toggle icon button */
.theme-btn { padding: 8px 10px; line-height: 0; }
.theme-icon { width: 20px; height: 20px; display: block; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
/* Share button: mobile-only — hidden on fine-pointer (mouse) view */
#share { display: none; }
@media (pointer: coarse) {
  #share { display: block; }
}
/* In light mode, offer the moon (switch to dark); in dark mode, offer the sun. */
:root[data-theme="light"] .theme-icon-moon { display: block; }
:root[data-theme="light"] .theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
:root:not([data-theme]) .theme-icon-moon { display: block; }
:root:not([data-theme]) .theme-icon-sun { display: none; }

.hint {
  color: #f2f2f2;
  font-size: .95em;
  padding-left: 2px;
}

/* Meta line */
.meta {
  padding: 6px 0;
  color: var(--muted);
  font-size: .95em;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 5px;
}
.meta-l1,
.meta-l2 {
  font-size: 1em;       /* both exactly the .meta size — immune to any line-box inflation */
  font-weight: 400;     /* match body default; prevents any accidental weight drift */
  line-height: inherit;
}
.meta-l2 {
  flex-basis: 100%;
  margin-left: 11px; /* align under .meta-l1 text, past the ::before dot */
}
.bar .meta { color: #f2f2f2; }
.meta::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2ecc40;  /* status: green while fresh */
  align-self: flex-start;
  margin-top: .45em;
}
.meta.stale::before {
  background: #ff9f2e;  /* status: orange when last check >10 min */
}
/* Refresh button — hidden by default, shown via JS only when stale */
.meta-refresh {
  margin-left: 6px;
  padding: 1px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}
.bar .meta-refresh { color: #f2f2f2; }
.meta-refresh svg {
  width: 15px;
  height: 15px;
  display: block;
}
.meta-refresh:hover svg { color: #2ecc40; }
.meta-refresh[hidden] { display: none; }

/* Main grid: 3 columns on the production cap; airy spacing between cards */
main {
  display: grid;
  gap: 34px 20px;
  grid-template-columns: 1fr;
  align-items: start;
  padding-top: 10px;
  margin-bottom: 0;
}

/* Mobile: tighten the nav bar — drop the sort/text word labels, hide the drag
 * hint (the cards are self-evidently draggable), and keep controls as compact
 * icon-ish select chips so nothing wraps into a mess. */
@media (max-width: 639px) {
  .bar-inner { gap: 6px 4px; padding: 5px 0; }
  .brand-sub { display: none; }
  .brand-mark { height: 26px; }
  .bar-sub { display: block; }
  .bar-sub .hint { font-size: .8em; }
  .ctl-label { display: none; }
  .ctl-group { gap: 6px; margin-left: auto; }
  .bar select, .bar .btn { padding: 6px 6px; font-size: .95em; margin-right: 0; }
  .theme-btn { padding: 6px 7px; }
  .theme-icon { width: 18px; height: 18px; }
}

@media (min-width: 640px) {
  main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 960px) {
  main { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bar-inner, .meta, main, .ads, .foot { max-width: 950px; }
}

/* Block: flat, no shadow, no radius. Grid handles spacing; no per-card gutter. */
.card {
  background: var(--panel);
  border: none;
  border-radius: 0;
  box-shadow: none;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  min-width: 0;
  transition: opacity .15s ease, outline-color .15s ease;
}

/* Ad cards mimic feed cards — same panel cell, same width, one grid column.
 * They are NOT .card (never draggable, never reordered, never persisted), and
 * .empty collapses completely so an un-filled ad can't leave a void. */
.adcard {
  background: var(--panel);
  border: none;
  border-radius: 0;
  box-shadow: none;
  width: 100%;
  margin: 0;
  padding: 4px 2px;
  min-width: 0;
  max-height: 320px; /* hard cap: never taller than the tallest feed card
                        (measured 161–286px) — keeps grid rows in bounds */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  font-size: .82em;
  color: var(--muted);
}
.adcard.empty { display: none; }
.adcard .ad-tag {
  display: block;
  margin: 0 0 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
  font-size: .72em;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.adcard ins.adsbygoogle { min-height: 60px; max-height: 280px; overflow: hidden; }
.adcard iframe { display: block; max-width: 100%; }

.card-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

/* Grip handle: always visible reorder affordance on every card. Positioned
 * absolute at the card's top-right so the card-head grid stays untouched.
 * Fully themed via CSS variables (panel/line/muted) — adapts to light & dark.
 * `touch-action: none` means starting a drag on the handle never scrolls the
 * page — scroll-vs-drag isolation on touch. */
.grip {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 2px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.grip svg { width: 14px; height: 14px; }
.grip svg circle { fill: var(--muted); }
.card { position: relative; }
.grip:hover { border-color: var(--bar-current); }
/* Mobile: modestly larger touch target than desktop — but must stay within the
 * card header band (favicon + title ~36px tall) or it visually spills into the
 * item rows below. 26px keeps it usable without overflowing. */
@media (pointer: coarse) {
  .grip {
    width: 26px;
    height: 26px;
    top: 3px;
    right: 6px;
    border-radius: 6px;
  }
  .grip svg { width: 16px; height: 16px; }
}

.num {
  color: var(--muted);
  font-size: .95em;
  padding: 0;
  background: transparent;
  border-radius: 0;
}

.fav, .favicon {
  background-color: #fff;
  display: block;
  float: none;
  width: 24px;
  height: 24px;
  object-fit: contain;
  object-position: center;
}

/* Headings match production: 1em line box, tight 5px vertical rhythm */
h1, h2, h3, h4, h5, h6 {
  line-height: 1em;
  margin: 5px 0;
  padding: 5px 0;
}

.card h2 {
  font-size: 1.4em;
  color: var(--ink);
  margin: 0;
  line-height: 1em;
  padding: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}
.card h2 a {
  color: var(--ink);
  display: block;
  text-decoration: none;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card h2 a:hover { color: #111; }
:root[data-theme="dark"] .card h2 a:hover { color: var(--accent); }

.offline-tag {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .78em;
  font-weight: 600;
  line-height: 1;
  letter-spacing: .02em;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  text-transform: lowercase;
}
.offline-tag::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e5484d; /* status-red dot: site unreachable */
  flex: 0 0 auto;
}
:root[data-theme="dark"] .offline-tag { background: rgba(255,255,255,.06); }

.chip {
  font-size: .95em;
  color: var(--muted);
  background: transparent;
  border-radius: 0;
  padding: 0;
  white-space: nowrap;
}

/* Items list: one row per link, hairline separators */
.items {
  margin: 0; padding: 0;
  list-style: none;
  min-width: 0;
}
.items li {
  display: block;
  min-width: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-top: 1px solid var(--line);
}
.items li:first-child { border-top: none; }
/* Content-box keeps prod's math: 1.5em content + 7px padding = 24px rows. */
.items a {
  box-sizing: content-box;
  color: var(--accent);
  display: block;
  height: 1.5em;
  line-height: 1.5em;
  overflow: hidden;
  padding: 4px 0 3px 0;
  width: 100%;
  text-decoration: none;
}
.items a:visited { color: var(--muted); }
.items a:hover { background-color: #fafafa; color: #333; text-decoration: none; }
:root[data-theme="dark"] .items a:hover { background-color: #1e2430; color: var(--accent); }

/* "new" badge — prod `.item_new`: italic #f60, floated right inside the link */
.tg {
  color: #f60;
  font-style: italic;
  font-weight: bold;
  float: right;
  margin-left: 4px;
  background: transparent;
  padding: 0;
  border-radius: 0;
}

/* Ads + footer */
.ads { display: grid; gap: 10px; padding-top: 10px; }
ins.adsbygoogle { display: block; min-height: 0; background: transparent; }

.foot {
  display: block;
  color: var(--muted);
  padding-top: 10px;
  padding-bottom: 24px;
}
.foot .footlinks {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  margin: 8px 0 0 0;
}
.disclosure {
  max-width: 950px;
  margin: 12px auto 0;
  padding: 0 8px;
  text-align: center;
  font-size: .95em;
  color: var(--muted);
}
.foot a {
  color: var(--accent);
  text-decoration: none;
  padding: 2px 6px;
  border: none;
  border-radius: 0;
  background: transparent;
}
.foot a:hover { color: #111; text-decoration: underline; }
.sep { color: var(--line); }

/* Static document pages (privacy policy) — clean legal-document typography */
.doc {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 16px 40px;
  color: var(--ink);
  line-height: 1.65;
  /* The shared `main` rule is a feed grid; documents must opt out. */
  display: block;
  gap: 0;
}

.doc h1 {
  color: var(--ink);
  font-size: 1.8em;
  line-height: 1.25;
  margin: 0 0 8px;
}

.doc-lede {
  color: var(--muted);
  font-size: 1.02em;
  margin: 0 0 26px;
  max-width: 62ch;
}

.doc h2 {
  color: var(--ink);
  font-size: 1.25em;
  margin: 28px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.doc h3 {
  color: var(--ink);
  font-size: 1.05em;
  margin: 18px 0 4px;
}

.doc p {
  color: var(--ink);
  margin: 8px 0;
  max-width: 70ch;
}

.doc p strong { color: var(--ink); font-weight: 600; }

.doc a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.doc a:hover { text-decoration-thickness: 2px; }

.doc-updated {
  color: var(--muted);
  font-size: .9em;
  margin: 32px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

@media (max-width: 639px) {
  .doc { padding: 22px 14px 28px; }
  .doc h1 { font-size: 1.5em; }
}

/* Public "suggest a site" form in the footer */
.suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: center;
  max-width: 950px;
  margin: 0 auto;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.suggest label { font-weight: 700; white-space: nowrap; }
.suggest input {
  flex: 1 1 160px; min-width: 0; font: inherit;
  color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 0; padding: 4px 6px;
}
.suggest input[name="note"] { flex: 2 1 220px; }
.suggest-out { color: var(--ink); white-space: nowrap; }
/* The global .btn is styled for the dark bar strip (white text on translucent
 * white). The footer form sits on a themed panel, so give its button explicit
 * themed colors or it becomes white-on-white in light mode. */
.foot .suggest .btn {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}
.foot .suggest .btn:hover { color: var(--accent); border-color: var(--accent); }
.foot .suggest .btn:disabled { color: var(--muted); }

.out {
  background: var(--panel); border: 1px solid var(--line); border-radius: 0;
  padding: 6px; overflow-x: auto;
}

/* Skeleton loaders (first paint only) */
.sk { background: var(--line); border-radius: 0; height: .8em; margin: .3em 0; }
.sk.s1 { width: 70%; } .sk.s2 { width: 90%; } .sk.s3 { width: 60%; }

@media (prefers-reduced-motion: no-preference) {
  @keyframes shimmer { 0% { opacity: .65 } 100% { opacity: 1 } }
  .sk { animation: shimmer 1.2s ease-in-out infinite alternate; }
}

/* Drag & drop states */
.card { cursor: grab; touch-action: manipulation; }
.card.is-dragging { opacity: .55; cursor: grabbing; }
.card.is-over { outline: 2px solid var(--bar-current); outline-offset: 1px; }
