:root {
  --bg: #f4f4f1;
  --panel: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e2e2dd;
  --accent: #c49b00;
  --accent-ink: #1a1a1a;
  --read: #9a9a9a;
  --en: #2a6fd6;
  --sv: #d6a200;
  --sel: #c49b0033;
  --shadow: 0 8px 28px rgba(0, 0, 0, .14);
  --bar-h: 48px;   /* the sticky bar (56 px from 1024 px) */
  --strip-h: 44px; /* the order + topics strip under it, below 1024 px */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15161a;
    --panel: #1e2026;
    --text: #ececec;
    --muted: #9b9ba3;
    --line: #2d3039;
    --accent: #e0b400;
    --read: #6e6e76;
    --en: #6fa1ff;
    --sv: #ffcc33;
    --sel: #e0b40033;
    --shadow: 0 8px 28px rgba(0, 0, 0, .55);
  }
}
/* forced dark (the Android app sets this from the system setting) */
:root[data-theme="dark"] {
  --bg: #15161a;
  --panel: #1e2026;
  --text: #ececec;
  --muted: #9b9ba3;
  --line: #2d3039;
  --accent: #e0b400;
  --read: #6e6e76;
  --en: #6fa1ff;
  --sv: #ffcc33;
  --sel: #e0b40033;
  --shadow: 0 8px 28px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
/* j/k scroll the selected headline clear of the sticky bar and strip */
html { scroll-padding-top: calc(var(--bar-h) + var(--strip-h) + 8px); }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- the bar ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  height: var(--bar-h);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.bar {
  position: relative; height: 100%;
  max-width: 1200px; margin: 0 auto;
  padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; margin-right: auto; }
.brand img { flex: none; }
.brand-text { display: grid; min-width: 0; line-height: 1.25; }
.brand h1 { font-size: 15px; margin: 0; letter-spacing: -0.01em; white-space: nowrap; }
.status { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status .st-short { display: none; }

.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none; position: relative;
  width: 40px; height: 40px; padding: 0;
  background: transparent; border: 0; border-radius: 10px; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--bg); }
#searchBtn, #searchClose { display: none; }
/* the menu button gets a dot while a filter inside it is on */
#menuBtn.dot::after {
  content: ""; position: absolute; top: 8px; right: 7px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--panel);
}
.top :focus-visible, .topics :focus-visible, .sources :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg button:focus-visible { outline-offset: -3px; }
.seg button.on:focus-visible { outline-color: var(--accent-ink); }

.search { display: flex; align-items: center; gap: 4px; flex: 1 1 160px; max-width: 320px; min-width: 0; }
#search {
  flex: 1; min-width: 0; height: 34px;
  padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 13px;
}

.seg { display: inline-flex; flex: none; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  background: transparent; border: 0; color: var(--text); white-space: nowrap;
  padding: 0 11px; min-height: 32px; cursor: pointer; font: inherit; font-size: 13px;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chk { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex: none; white-space: nowrap; cursor: pointer; }
.btn {
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.busy { opacity: .6; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  #refresh.busy .i { animation: spin 1s linear infinite; }
}
@keyframes spin { to { transform: rotate(360deg); } }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; padding: 0; }
.link:hover { text-decoration: underline; }

#savedBtn { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 34px; padding: 0 10px; }
#savedBtn .i { width: 16px; height: 16px; }
#savedBtn.on .i { fill: currentColor; }
#savedBtn .n { font-size: 11px; font-weight: 700; line-height: 16px; padding: 0 6px; border-radius: 999px; background: var(--line); }
#savedBtn.on .n { background: rgba(0, 0, 0, .12); }
#savedBtn .n:empty { display: none; }
.q {
  display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px;
  border: 2px solid currentColor; border-radius: 50%; font-size: 11px; font-weight: 800; line-height: 1;
}

/* ---------- order + topics ---------- */
.cats button {
  background: transparent; color: var(--text); cursor: pointer;
  font: inherit; font-size: 13px; white-space: nowrap;
}
.cats button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.cats button[data-count]::after {
  content: attr(data-count); margin-left: 5px; font-size: 10.5px; font-weight: 500;
  color: var(--muted); vertical-align: 1px;
}
.cats button.on[data-count]::after { color: var(--accent-ink); opacity: .7; }
.cats button[data-count="0"] { opacity: .45; }

main { display: flex; gap: 16px; padding: 16px; max-width: 1200px; margin: 0 auto; }

/* Below 1024 px: language, Hide read, Refresh, Sources and ? drop down from the menu
   button; order + topics are one strip under the bar that scrolls sideways; the bar
   slides away while scrolling down and comes back on the way up. */
@media (max-width: 1023.98px) {
  .menu {
    display: none; position: absolute; z-index: 3;
    top: calc(100% + 4px); right: max(8px, env(safe-area-inset-right));
    width: min(300px, calc(100vw - 16px));
    flex-direction: column; align-items: stretch; gap: 4px;
    padding: 12px; background: var(--panel);
    border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  }
  .menu.open { display: flex; }
  .menu .seg { display: flex; margin-bottom: 6px; }
  .menu .seg button { flex: 1; min-height: 38px; font-size: 14px; }
  .menu .chk { font-size: 14px; color: var(--text); padding: 8px; }
  .menu .chk input { width: 18px; height: 18px; margin: 0; }
  .menu .act {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px;
    padding: 0 8px; background: transparent; border: 0; border-radius: 8px; font-size: 14px; text-align: left;
  }
  .menu .act:hover { background: var(--bg); }

  main { flex-direction: column; }
  .topics {
    position: sticky; top: var(--bar-h); z-index: 4;
    height: var(--strip-h);
    margin: -16px -16px 0; /* edge to edge, over main's padding */
    background: var(--panel); border-bottom: 1px solid var(--line);
  }
  .strip {
    height: 100%;
    display: flex; align-items: center; gap: 8px;
    padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain;
    scroll-snap-type: x proximity; scroll-padding-inline: 28px; /* chips stop just past the fade */
    /* fade the edge where more chips are hidden (reader.js sets fade-l / fade-r) */
    --fade-l: 0px; --fade-r: 0px;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
    mask-image: linear-gradient(to right, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
  }
  .strip::-webkit-scrollbar { display: none; }
  .strip.fade-l { --fade-l: 28px; }
  .strip.fade-r { --fade-r: 28px; }
  #sortSeg { scroll-snap-align: start; }
  .cats { display: flex; gap: 6px; flex: none; padding-left: 10px; border-left: 1px solid var(--line); }
  .cats button { flex: none; height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; scroll-snap-align: start; }
  .cats button:hover { border-color: var(--accent); }
  .cats button.on { border-color: var(--accent); }

  .top, .topics { transition: transform .2s ease; }
  .bar-hidden .top { transform: translateY(-100%); }
  .bar-hidden .topics { transform: translateY(calc(-1 * var(--bar-h))); }
}
@media (max-width: 1023.98px) and (prefers-reduced-motion: reduce) {
  .top, .topics { transition: none; }
}

/* Phones: the search hides behind an icon and opens over the bar; short status. */
@media (max-width: 699.98px) {
  .search { display: none; }
  .top.searching .search {
    display: flex; position: absolute; inset: 0; z-index: 4; max-width: none; gap: 6px;
    padding: 0 max(4px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
    background: var(--panel);
  }
  .top.searching #search { height: 38px; font-size: 16px; }
  #search::-webkit-search-cancel-button { display: none; } /* the ✕ next to it clears and closes */
  #searchBtn, #searchClose { display: inline-flex; }
  .status .st-short { display: inline; }
  .status .st-full, #savedBtn .lbl {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  #savedBtn { height: 40px; padding: 0 9px; gap: 4px; background: transparent; border: 0; border-radius: 10px; }
  #savedBtn:hover { background: var(--bg); }
  #savedBtn.on { background: var(--accent); }
  #savedBtn .i { width: 18px; height: 18px; }
  #savedBtn .n { padding: 0; background: none; font-size: 13px; }
  #savedBtn.on .n { background: none; }
}

/* From 1024 px: one bar with everything, topics in a column left of the headlines. */
@media (min-width: 1024px) {
  :root { --bar-h: 56px; }
  html { scroll-padding-top: calc(var(--bar-h) + 8px); }
  .bar { gap: 8px; padding: 0 16px; }
  .brand h1 { font-size: 17px; }
  .brand-text { max-width: 250px; }
  #menuBtn { display: none; }
  .menu { display: contents; }
  .menu .act { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 34px; height: 34px; padding: 0; }
  .menu .act .lbl {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
  }
  #settingsBtn[aria-expanded="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  #langSeg { margin-left: 4px; }

  main { align-items: flex-start; gap: 20px; }
  .topics {
    position: sticky; top: calc(var(--bar-h) + 16px);
    flex: 0 0 200px; max-height: calc(100vh - var(--bar-h) - 32px); overflow-y: auto;
  }
  .strip { display: flex; flex-direction: column; gap: 12px; }
  #sortSeg { display: flex; }
  #sortSeg button { flex: 1; padding: 0 6px; }
  .cats { display: flex; flex-direction: column; gap: 2px; }
  .cats button { display: flex; align-items: center; width: 100%; height: 34px; padding: 0 10px; border: 0; border-radius: 8px; font-size: 14px; text-align: left; }
  .cats button:hover { background: var(--panel); }
  .cats button.on:hover { background: var(--accent); }
  .cats button[data-count]::after { margin-left: auto; padding-left: 8px; font-size: 12px; }
}

/* ---------- Sources: a panel on the right, under the bar ---------- */
.sources {
  position: fixed; z-index: 6; top: var(--bar-h); right: 0; bottom: 0;
  width: min(380px, 100%);
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  overflow: auto; overscroll-behavior: contain;
}
.src-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.src-head strong { font-size: 15px; }
.src-head span { margin-left: auto; }
.src-head .icon-btn { width: 36px; height: 36px; margin-right: -8px; }
.src-row.topic { cursor: grab; user-select: none; }
.src-row.topic.dragging { opacity: .4; }
.src-row.topic.over { box-shadow: 0 -2px 0 var(--accent); }
.src-row.topic label { flex: 1; cursor: pointer; }
.src-row .grip { color: var(--muted); font-size: 11px; letter-spacing: -2px; }
.src-row .arrow { font-size: 11px; color: var(--muted); padding: 0 3px; }
.src-row .arrow:hover { color: var(--accent); }
.src-row .arrow:disabled { opacity: .3; cursor: default; text-decoration: none; }
.src-group { margin-top: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.src-row { display: flex; align-items: center; gap: 8px; padding: 4px 2px; font-size: 14px; }
.src-row input { margin: 0; }
.src-row small { margin-left: 2px; }
.src-row .cnt { margin-left: auto; color: var(--muted); font-size: 12px; }
.src-row .err { margin-left: auto; color: #c0392b; font-size: 12px; }
.src-row .warn { margin-left: auto; color: #d98b00; font-size: 12px; }
.src-row .cat { color: var(--muted); }
.hint { margin: 2px 0 6px; font-size: 12px; color: var(--muted); }
#mute { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-size: 13px; }
.src-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); display: grid; gap: 8px; font-size: 13px; color: var(--muted); }
.src-foot select { font: inherit; font-size: 13px; }

/* ---------- headlines ---------- */
.srcs {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px;
  padding: 0 8px; font: inherit; font-size: 10.5px; font-weight: 700; line-height: 16px; cursor: pointer;
}
.srcs:hover { filter: brightness(1.08); }
.members { margin: 8px 0 0; padding: 8px 0 0 0; list-style: none; border-top: 1px dashed var(--line); display: grid; gap: 5px; }
.members[hidden] { display: none; } /* display: grid above would otherwise beat the hidden attribute */
.members li { font-size: 13.5px; display: flex; gap: 8px; align-items: baseline; }
.members a { color: var(--text); text-decoration: none; }
.members a:hover { color: var(--accent); }
.members .msrc { color: var(--muted); font-size: 12px; white-space: nowrap; }
.badges { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.badge { background: var(--bg); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 0 7px; font: inherit; font-size: 10.5px; line-height: 16px; cursor: pointer; }
.badge:hover { border-color: var(--accent); color: var(--accent); }
.item:focus { outline: none; }
.item:focus-visible { border-color: var(--accent); }

.list { flex: 1; min-width: 0; display: grid; gap: 8px; align-content: start; }
.day { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 2px; }
.item {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px;
}
.item.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--sel); }
.item .row { display: flex; gap: 10px; align-items: flex-start; }
.item .title { color: var(--text); text-decoration: none; font-weight: 600; font-size: 16px; display: block; flex: 1; min-width: 0; }
.item .title:hover { color: var(--accent); }
.item.read .title { color: var(--read); font-weight: 500; }
.star {
  flex: none; background: none; border: 0; cursor: pointer; color: var(--muted);
  font-size: 18px; line-height: 1; padding: 0 2px; margin-top: 1px;
}
.star::before { content: "☆"; }
.star:hover { color: var(--accent); }
.item.saved .star { color: var(--accent); }
.item.saved .star::before { content: "★"; }
.meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.src { font-weight: 600; }
.src::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--muted); vertical-align: middle; }
.item[data-lang="en"] .src::before { background: var(--en); }
.item[data-lang="sv"] .src::before { background: var(--sv); }
.ico { width: 14px; height: 14px; border-radius: 3px; object-fit: contain; }
.item.has-ico .src::before { display: none; }
.item.has-ico .meta { gap: 5px; }
.desc { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item.read .desc { display: none; }
.empty { color: var(--muted); padding: 40px; text-align: center; }

.help { position: fixed; inset: 0; z-index: 20; background: #0008; display: flex; align-items: center; justify-content: center; padding: 16px; }
.help[hidden] { display: none; }
.help-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; max-width: 420px; width: 100%; font-size: 14px; }
.help-head { display: flex; justify-content: space-between; margin-bottom: 8px; }
.help dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.help dt { font-family: ui-monospace, Consolas, monospace; color: var(--accent); font-weight: 600; }
.help dd { margin: 0; color: var(--muted); }

.foot { max-width: 1200px; margin: 24px auto 32px; padding: 0 16px; color: var(--muted); font-size: 12.5px; text-align: center; }

@media (max-width: 820px) {
  .star { font-size: 22px; }
}
