:root {
  --bg: #f7f6f2; --card: #ffffff; --ink: #1c1b18; --muted: #6b6963; --line: #e4e2db;
  --accent: #2f5d8a; --read: #2b7a4b; --maybe: #b07a1a; --skip: #8a8781; --danger: #a33a2c;
  --radius: 12px; --gap: 12px; --pad: 16px; --maxw: 720px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15161a; --card: #1e2026; --ink: #ecebe6; --muted: #9a998f; --line: #2c2f37; --accent: #7fb0e0; --read: #57b87b; --maybe: #d9a441; --skip: #7d7c78; --danger: #e0715f; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: var(--maxw); margin: 0 auto; padding: var(--pad) 16px calc(var(--pad) + env(safe-area-inset-bottom)); }
/* No overflow clipping on body or main: it disables position: sticky and clips hover labels. */
h1 { font-size: 1.4rem; margin: 0 0 8px; }
h2 { font-size: 1.05rem; line-height: 1.3; margin: 0 0 4px; }
.lede, .meta, .note, .empty { color: var(--muted); }
.meta { font-size: 0.85rem; margin: 0 0 6px; }
.top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line); max-width: var(--maxw); margin: 0 auto; }
.brand { font-weight: 700; color: var(--ink); letter-spacing: 0.02em; }
.top nav { display: flex; gap: 12px; flex: 1; }
.top nav a { color: var(--muted); padding: 4px 0; border-bottom: 2px solid transparent; }
.top nav a[aria-current="page"] { color: var(--ink); border-color: var(--accent); }
.foot { max-width: var(--maxw); margin: 24px auto; padding: 0 16px; color: var(--muted); font-size: 0.8rem; }
button, .chip, select, input, textarea { font: inherit; }
button { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 12px; cursor: pointer; }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
button.link { background: none; color: var(--muted); padding: 0; }
button:disabled { opacity: 0.5; cursor: default; }
.inline { display: inline; margin: 0; }
.flash { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--read); padding: 10px 12px; border-radius: 8px; margin: 0 0 var(--gap); }
.flash.error { border-left-color: var(--danger); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: var(--gap); }
.views { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: var(--card); font-size: 0.9rem; }
.chip.on { color: var(--ink); border-color: var(--ink); }
.chip .count { font-size: 0.75rem; color: var(--muted); }
.chip.v-read.on { border-color: var(--read); color: var(--read); }
.chip.v-maybe.on { border-color: var(--maybe); color: var(--maybe); }
.chip.v-skip.on { border-color: var(--skip); color: var(--skip); }
.feedpick select { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); max-width: 200px; }
.cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--gap); }
.card { cursor: pointer; display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; transition: opacity 0.2s, transform 0.2s; }
.card.gone { opacity: 0; transform: translateX(24px); }
.score { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-variant-numeric: tabular-nums; color: #fff; background: var(--skip); }
.v-read .score { background: var(--read); }
.v-maybe .score { background: var(--maybe); }
.v-none .score { background: var(--line); color: var(--muted); }
.card .body { min-width: 0; }
.card h2, .summary, .reasons, .reader .body p, .reader h1 { overflow-wrap: anywhere; }
.card h2 a { color: var(--ink); }
.summary { margin: 0 0 8px; color: var(--ink); opacity: 0.9; font-size: 0.95rem; }
.reasons { margin: 0 0 10px; padding-left: 18px; color: var(--muted); font-size: 0.88rem; }
.reasons li { margin: 2px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions button { background: transparent; color: var(--ink); border: 1px solid var(--line); padding: 6px 10px; font-size: 0.9rem; }
.actions button.done { border-color: var(--accent); color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: var(--gap); }
.stack.narrow { max-width: 420px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); flex: 1; }
.stack input, .stack textarea { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%; }
.stack textarea { min-height: 320px; line-height: 1.5; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.feeds { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.feeds li { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.feeds .meta { word-break: break-all; margin: 2px 0; }
.folder { color: var(--muted); font-size: 0.85rem; }
.bad { color: var(--danger); }
.profile { white-space: pre-wrap; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
@media (max-width: 480px) {
  .card { grid-template-columns: 44px 1fr; padding: 12px; }
  .score { width: 44px; height: 44px; font-size: 0.95rem; }
  .top nav { gap: 10px; font-size: 0.95rem; }
}
/* reader */
.reader { max-width: 680px; margin: 0 auto; }
.reader h1 { font-size: 1.6rem; line-height: 1.25; margin: 6px 0 12px; }
.reader .body p { font-size: 1.05rem; line-height: 1.6; margin: 0 0 1em; }
.verdict { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; align-items: start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; }
.verdict .score { width: 44px; height: 44px; font-size: 0.95rem; }
.verdict .reasons { margin: 0; }
.actions.sticky { position: sticky; top: 52px; z-index: 1; background: var(--bg); padding: 8px 0; margin-bottom: 12px; align-items: center; }
.actions .chip { margin-left: auto; }
.meta .ext { color: var(--muted); }
/* One ring for both keyboard focus and the article open in the pane. */
.card.focus, .card.active { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.kbd { font-size: 0.8rem; }
kbd { font: inherit; background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
@media (max-width: 480px) { .kbd { display: none; } }

/* undo strip + open button */
.card.collapsed .body > *:not(.undo) { display: none; }
.card.collapsed { grid-template-columns: 52px minmax(0, 1fr); align-items: center; }
.undo { display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.undo button { background: transparent; color: var(--accent); border: 1px solid var(--line); padding: 4px 10px; }
.actions .btn { display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--accent); color: var(--accent); font-size: 0.9rem; }
.saved-mark { color: var(--read); }

/* symbol buttons + note box */
.actions button, .actions .btn { min-width: 40px; justify-content: center; font-size: 1rem; line-height: 1; }
.notebox { display: flex; gap: 6px; margin-top: 8px; }
.notebox input { flex: 1; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); min-width: 0; }
.notebox button { padding: 6px 10px; font-size: 0.9rem; }
.note-text { margin: 4px 0 0; color: var(--ink); }

/* hover labels (data-tip) */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%) translateY(4px);
  background: var(--ink); color: var(--bg); font-size: 0.78rem; line-height: 1.2; padding: 6px 8px; border-radius: 6px;
  white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity 0.12s, transform 0.12s; z-index: 5;
}
[data-tip]::before {
  content: ""; position: absolute; left: 50%; bottom: calc(100% + 2px); transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--ink); border-bottom: 0; pointer-events: none; opacity: 0; transition: opacity 0.12s; z-index: 5;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after, [data-tip]:hover::before, [data-tip]:focus-visible::before { opacity: 1; transform: translateX(-50%) translateY(0); }
[data-tip]:hover::before, [data-tip]:focus-visible::before { transform: translateX(-50%); }
.actions [data-tip]:first-child::after { left: 0; transform: translateX(0) translateY(4px); }
.actions [data-tip]:first-child:hover::after, .actions [data-tip]:first-child:focus-visible::after { transform: translateX(0); }
.actions [data-tip]:first-child::before { left: 20px; }
@media (hover: none) { [data-tip]::after, [data-tip]::before { display: none; } }

/* article images */
.reader figure { margin: 0 0 1.2em; }
.reader figure img { display: block; max-width: 100%; height: auto; border-radius: 10px; background: var(--line); }
.reader figcaption { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }
.reader figure.lead { margin: 0 0 16px; }

/* two-pane desktop: compact list on the left, article on the right */
.pane { display: none; }
@media (min-width: 1000px) {
  /* Two independent scrollers, like a mail client: the page itself does
     not scroll, so the article pane can never leave the viewport. */
  html, body { height: 100%; }
  body { display: flex; flex-direction: column; overflow: hidden; }
  .top { flex: none; width: 100%; }
  main { max-width: 1400px; width: 100%; flex: 1; min-height: 0; padding-top: 12px; padding-bottom: 0; }
  .split { display: grid; grid-template-columns: minmax(360px, 460px) minmax(0, 1fr); gap: 20px; height: 100%; min-height: 0; }
  .col-list { min-height: 0; overflow-y: auto; padding: 0 6px 24px 0; scrollbar-gutter: stable; }
  .col-list .toolbar { position: sticky; top: 0; z-index: 1; background: var(--bg); padding-bottom: 8px; margin-bottom: 8px; }
  .pane { display: block; min-height: 0; overflow-y: auto; padding: 4px 8px 24px; scrollbar-gutter: stable; }
  .foot { display: none; }
  .pane .reader { max-width: 720px; }
  .pane .actions.sticky { top: 0; }
  .pane-hint { padding: 40px 0; text-align: center; }
  /* denser rows */
  .card { grid-template-columns: 40px minmax(0, 1fr); gap: 10px; padding: 10px 12px; }
  .score { width: 40px; height: 40px; font-size: 0.9rem; }
  .card h2 { font-size: 0.98rem; margin-bottom: 2px; }
  .card .summary { display: none; }
  .card .reasons { margin-bottom: 6px; font-size: 0.82rem; }
  .card .reasons li:not(:first-child) { display: none; }
  .card .actions button, .card .actions .btn { min-width: 32px; padding: 3px 7px; font-size: 0.9rem; }
  .kbd { display: block; }
}
.reader .body a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.reader .body a:hover { text-decoration-color: var(--accent); }
@media (min-width: 1000px) { .top, .foot { max-width: 1400px; } }
.card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.card .actions, .card .undo, .card .notebox { cursor: default; }

/* discovery: a side channel, styled as such */
.card.discovery { border-style: dashed; background: color-mix(in srgb, var(--card) 85%, var(--accent) 15%); }
.card.discovery .score { background: transparent; color: var(--ink); border: 2px dashed var(--accent); }
.disc-label { margin: 0 0 4px; font-size: 0.8rem; color: var(--accent); text-transform: uppercase; letter-spacing: 0.04em; }
.chip.disc { border-style: dashed; }
.reader.discovery { border-left: 3px dashed var(--accent); padding-left: 14px; }

/* toolbar chips: labels drop below so they never run under the sticky header */
.toolbar [data-tip]::after { bottom: auto; top: calc(100% + 8px); transform: translateX(-50%) translateY(-4px); }
.toolbar [data-tip]::before { bottom: auto; top: calc(100% + 2px); border-top: 0; border-bottom: 6px solid var(--ink); }
.toolbar [data-tip]:hover::after, .toolbar [data-tip]:focus-visible::after { transform: translateX(-50%) translateY(0); }
.toolbar [data-tip]:first-child::after { left: 50%; transform: translateX(-50%) translateY(-4px); }
.toolbar [data-tip]:first-child:hover::after, .toolbar [data-tip]:first-child:focus-visible::after { transform: translateX(-50%) translateY(0); }
.toolbar [data-tip]:first-child::before { left: 50%; }
/* Absolutely positioned inside a narrow chip, the label must size to its
   content or it wraps word by word. */
[data-tip]::after { width: max-content; max-width: min(320px, 80vw); white-space: normal; text-align: center; }

/* breathing room around the actions, the note box and the article body */
.reader .actions.sticky { margin-bottom: 18px; }
.reader .notebox { margin: -6px 0 18px; }
.reader .body { margin-top: 4px; }
.reader .body > :first-child { margin-top: 0; }
.card .notebox { margin: 10px 0 4px; }
.v-read-t { color: var(--read); } .v-maybe-t { color: var(--maybe); }
.flash a { margin-left: 6px; }
.offline-pill { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px; font-size: 0.75rem; color: var(--read); border: 1px solid color-mix(in srgb, var(--read) 50%, var(--line)); }
#sync-status.synced { color: var(--read); }
