/* The Brief: dark editorial look (light theme too). System fonts only, no external assets. */

:root {
  --bg: #111110;
  --surface: #181817;
  --surface-2: #222220;
  --surface-hover: #262624;
  --line: #2b2a27;
  --line-strong: #4a4843;
  --text: #f1ede4;
  --text-2: #aaa59b;
  --text-3: #7d786f;
  --accent: #e8664a;
  --on-accent: #1d0d07;
  --accent-soft: rgba(232, 102, 74, .14);
  --ok: #46c36a;
  --warn: #f2a39a;
  --warn-soft: #3b1a16;
  --shadow: 0 1px 0 rgba(0, 0, 0, .35);

  /* Section dots on the settings screen. */
  --c-tech: #6ea8ff;
  --c-science: #4fc4b1;
  --c-policy: #c49af0;
  --c-politics: #f0877a;
  --c-general: #b9b4aa;
  --c-local: #7fcf8d;
  --c-entertainment: #f4ae6b;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", P052, Georgia, "Noto Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;

  --page: 1180px;
  --gutter: 16px;
  --radius: 8px;
  color-scheme: dark;
}

/* Light theme: chosen with the toggle, or the system setting when nothing was chosen. */
:root[data-theme="light"] {
  --bg: #f6f3ec;
  --surface: #fffdf8;
  --surface-2: #eeeae1;
  --surface-hover: #ebe6dc;
  --line: #e0dbd0;
  --line-strong: #b9b3a6;
  --text: #1b1a17;
  --text-2: #57534b;
  --text-3: #837e74;
  --accent: #c2452a;
  --on-accent: #ffffff;
  --accent-soft: rgba(194, 69, 42, .1);
  --ok: #2f9e52;
  --warn: #a3261b;
  --warn-soft: #f8e1dc;
  --shadow: 0 1px 0 rgba(0, 0, 0, .04);
  --c-tech: #2a62c9;
  --c-science: #13806f;
  --c-policy: #7c43b4;
  --c-politics: #c23a2a;
  --c-general: #5b5850;
  --c-local: #2f7d3e;
  --c-entertainment: #b8601a;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f3ec;
    --surface: #fffdf8;
    --surface-2: #eeeae1;
    --surface-hover: #ebe6dc;
    --line: #e0dbd0;
    --line-strong: #b9b3a6;
    --text: #1b1a17;
    --text-2: #57534b;
    --text-3: #837e74;
    --accent: #c2452a;
    --on-accent: #ffffff;
    --accent-soft: rgba(194, 69, 42, .1);
    --ok: #2f9e52;
    --warn: #a3261b;
    --warn-soft: #f8e1dc;
    --shadow: 0 1px 0 rgba(0, 0, 0, .04);
    --c-tech: #2a62c9;
    --c-science: #13806f;
    --c-policy: #7c43b4;
    --c-politics: #c23a2a;
    --c-general: #5b5850;
    --c-local: #2f7d3e;
    --c-entertainment: #b8601a;
    color-scheme: light;
  }
}

/* Outlet colours (badges and coverage dots), picked per outlet by colorIndex() in lib.js. */
.c0 { --oc: #c8372d; }
.c1 { --oc: #2f6fb3; }
.c2 { --oc: #18867b; }
.c3 { --oc: #7a4cb0; }
.c4 { --oc: #c02c6c; }
.c5 { --oc: #c9662a; }
.c6 { --oc: #3c8640; }
.c7 { --oc: #4f5f75; }
.c8 { --oc: #283f8f; }
.c9 { --oc: #957514; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; overscroll-behavior-y: contain; }
body {
  overscroll-behavior-y: contain; /* our own pull-to-refresh; no browser reload or glow at the top */
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
svg { width: 24px; height: 24px; fill: currentColor; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.noscript { padding: 24px; text-align: center; }

.kicker {
  margin: 0;
  font: 700 11px/1.2 var(--mono);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ---- buttons & fields -------------------------------------------------- */

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  flex: none;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn:disabled { opacity: .38; cursor: default; background: transparent; }

.btn-filled {
  height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 650;
  letter-spacing: .01em;
  cursor: pointer;
}
.btn-filled:hover { filter: brightness(1.06); }
.btn-filled:disabled { opacity: .6; cursor: default; }
.btn-text {
  justify-self: start;
  height: 36px;
  padding: 0 12px;
  margin-left: -12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}
.btn-text:hover { background: var(--accent-soft); }

.field { display: grid; gap: 6px; min-width: 0; }
.field > span, .field > label > span { font: 600 11px/1.2 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); }
.field input, .field select {
  height: 44px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--bg);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.switch {
  appearance: none;
  position: relative;
  width: 44px;
  height: 26px;
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: var(--surface-2);
  cursor: pointer;
  flex: none;
  transition: background .15s, border-color .15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-3);
  transition: transform .15s, background .15s;
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(18px); background: var(--on-accent); }
.switch:disabled { opacity: .5; }

/* ---- masthead (feed, login) ---------------------------------------------- */

.masthead {
  display: block;
  padding: 2px 0 14px;
  text-align: center;
  text-decoration: none;
}
.mast-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 14px; }
.mast-rule { height: 2px; background: var(--line-strong); opacity: .75; }
.mast-name {
  font: 700 30px/1.05 var(--serif);
  letter-spacing: .14em;
  margin-right: -.14em; /* letter-spacing trails the last letter; keep the word optically centred */
  color: var(--text);
}
.mast-tag {
  display: block;
  margin: 6px 0 0;
  font: 500 9.5px/1.2 var(--mono);
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ---- login -------------------------------------------------------------- */

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login-inner { width: min(100%, 560px); display: grid; gap: 28px; }
.masthead-login .mast-name { font-size: 30px; }
.login-card {
  justify-self: center;
  width: min(100%, 420px);
  display: grid;
  gap: 16px;
  padding: 28px 24px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.login-card h1 { margin: -6px 0 4px; font: 700 26px/1.2 var(--serif); }
.login-card .btn-filled { width: 100%; margin-top: 4px; }
.login-error:empty { display: none; }
.login-error { margin: 0; color: var(--warn); font-size: 14px; }

/* ---- top chrome: utility bar, masthead, tabs ------------------------------ */

/* Narrow screens: only the tab bar sticks; the chrome box steps aside so the tabs can. */
.chrome { display: contents; }
.topbar { padding-top: env(safe-area-inset-top); }
.utility, .masthead, .tabs, .feed { max-width: var(--page); margin-left: auto; margin-right: auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.utility {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding-top: 10px;
  padding-bottom: 10px;
}
.dateline {
  flex: 1 1 100%;
  min-width: 0;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font: 500 10.5px/1.2 var(--mono);
  letter-spacing: .12em;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
}
#dateline { overflow: hidden; text-overflow: ellipsis; }
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
  flex: none;
}

.search {
  order: 2;
  flex: 1 1 0;
  min-width: 0;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 2px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.search-icon { width: 18px; height: 18px; color: var(--text-3); }
.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 4px 0 8px;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 15px;
}
.search input::-webkit-search-cancel-button { display: none; }
.search input::placeholder { color: var(--text-3); }
.search .mic { width: 34px; height: 34px; color: var(--text-2); }
.search .mic svg { width: 19px; height: 19px; }
.search .mic.listening { background: var(--accent-soft); color: var(--accent); }

.actions { order: 3; display: flex; align-items: center; gap: 2px; flex: none; }
.tool-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  min-width: 36px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.tool-btn svg { width: 19px; height: 19px; }
.tool-btn:hover { background: var(--surface-hover); color: var(--text); }
.tool-btn[aria-pressed="true"] { color: var(--accent); }
.tool-btn.round { width: 36px; padding: 0; justify-content: center; border: 1px solid var(--line-strong); border-radius: 50%; margin-left: 4px; }
.tool-label { display: none; }
.count-badge {
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
  font: 600 10.5px/1.2 var(--mono);
  text-align: center;
}
/* Icon-only buttons: the source count sits on the gear as a small badge. */
.tool-btn .count-badge { position: absolute; top: 1px; right: -3px; min-width: 16px; padding: 1px 4px; font-size: 9px; background: var(--accent); color: var(--on-accent); }
#theme .i-moon { display: none; }
#theme[data-mode="light"] .i-sun { display: none; }
#theme[data-mode="light"] .i-moon { display: block; }

.tabs-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.tabs {
  height: 46px;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 0 11px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); font-weight: 600; }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 11px;
  right: 11px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}
.tab-saved { margin-left: auto; }
.tab-saved svg { width: 17px; height: 17px; }

/* ---- shared story pieces ------------------------------------------------- */

.feed { padding-top: 20px; padding-bottom: 48px; }

.src-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 13px;
  line-height: 20px;
}
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 3px;
  border-radius: 4px;
  background: var(--oc);
  color: #fff;
  font: 700 8.5px/1 var(--mono);
  letter-spacing: .02em;
  flex: none;
}
.src-name { font-weight: 550; color: var(--text); opacity: .88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.src-sep { color: var(--text-3); }
.ago { margin-left: auto; padding-left: 8px; font: 500 11px/1 var(--mono); color: var(--text-3); white-space: nowrap; flex: none; }
.src-line.inline .ago { margin-left: 0; padding-left: 0; }

.media { display: block; overflow: hidden; background: var(--surface-2); }
.media img { display: block; width: 100%; height: 100%; object-fit: cover; }

h2 a, h3 a { text-decoration: none; }
h2 a:hover, h3 a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .18em; }

.dek {
  margin: 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-foot { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.spacer { flex: 1; }
.bookmark { width: 32px; height: 32px; color: var(--text-3); border-radius: 6px; }
.bookmark svg { width: 18px; height: 18px; }
.bookmark[aria-pressed="true"] { color: var(--accent); }

.coverage {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  max-width: 100%;
  padding: 0 8px 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.coverage:hover { border-color: var(--text-3); }
.coverage[aria-expanded="true"] { border-color: var(--accent); }
.coverage-text { overflow: hidden; text-overflow: ellipsis; }
.dots { display: inline-flex; }
.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--oc);
  box-shadow: 0 0 0 2px var(--surface-2);
}
.dot + .dot { margin-left: -3px; }
.chev { width: 16px; height: 16px; color: var(--text-3); transition: transform .15s; }
.coverage[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* Other outlets of a story group. */
.persp-list { list-style: none; margin: 10px 0 0; padding: 0; }
.persp {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 6px;
  padding: 8px 0 6px;
  border-top: 1px solid var(--line);
}
.persp-src {
  grid-column: 1 / -1;
  font: 600 10px/1.3 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
}
.persp-text { min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.persp-title { font-size: 14px; line-height: 1.4; text-decoration: none; color: var(--text); overflow-wrap: anywhere; }
a.persp-title:hover { text-decoration: underline; text-underline-offset: .18em; }
a.persp-title:visited { color: var(--text-2); }
.persp-ago { font: 500 10.5px/1 var(--mono); color: var(--text-3); white-space: nowrap; }
.persp .bookmark { width: 30px; height: 30px; }

/* ---- Home front: lead story + "In focus" rail ---------------------------- */

.front { display: grid; gap: 28px; margin-bottom: 8px; }
.lead-story { min-width: 0; }
.lead-story .media { aspect-ratio: 16 / 9; border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: 16px; }
.lead-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.lead-meta .src-line { flex: 0 1 auto; }
.lead-meta .bookmark { margin-left: auto; }
.lead-title {
  margin: 0 0 12px;
  font: 700 30px/1.12 var(--serif);
  letter-spacing: -.005em;
  overflow-wrap: anywhere;
}
.lead-dek { margin: 0; max-width: 66ch; color: var(--text-2); font-size: 16px; line-height: 1.6; }
.perspectives {
  margin-top: 20px;
  padding: 14px 16px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.perspectives .persp-list { margin-top: 10px; }

.rail { min-width: 0; padding-top: 22px; border-top: 1px solid var(--line); }
.rail-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 2px solid var(--line-strong); }
.rail-title { margin: 4px 0 0; font: 700 21px/1.2 var(--serif); }
.rail-count { font: 500 11px/1.2 var(--mono); color: var(--text-3); padding-bottom: 3px; }
.rail-item { padding: 16px 0 12px; border-bottom: 1px solid var(--line); }
.rail-item:last-child { border-bottom: 0; }
.rail-headline { margin: 8px 0 6px; font: 700 19px/1.27 var(--serif); overflow-wrap: anywhere; }
.rail-dek { -webkit-line-clamp: 2; line-clamp: 2; margin-bottom: 8px; }
.front.no-rail .rail { display: none; }

/* ---- breaking: tab dot, strip on Home, covered line -------------------------- */

.tab-dot, .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.tab-dot { margin-right: -1px; }
.pulse { animation: pulse 1.6s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  70%, 100% { box-shadow: 0 0 0 7px transparent; }
}

.breaking {
  margin: 0 0 24px;
  padding: 12px 14px 4px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--accent-soft), transparent 55%), var(--surface);
}
.breaking-kicker {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 2px;
  font: 700 11px/1.2 var(--mono);
  letter-spacing: .16em;
  color: var(--accent);
}
.breaking-item { padding: 10px 0 8px; border-top: 1px solid var(--line); }
.breaking-item:first-child { border-top: 0; }
.breaking-title { margin: 0 0 4px; font: 700 20px/1.25 var(--serif); overflow-wrap: anywhere; }
.breaking-title a:visited { color: var(--text-2); }
.covered { margin: 0 0 6px; font: 500 11px/1.4 var(--mono); letter-spacing: .04em; color: var(--text-2); }
.breaking-item .story-foot { margin-top: 2px; }
.breaking .persp-list { margin-bottom: 4px; }
.card-body > .covered { margin: 0 0 8px; }

/* Settings: a compact select on a switch row. */
.select-small {
  flex: none;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: 600 13px/1 var(--mono);
}
.select-small:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }


/* ---- weather widget -------------------------------------------------------- */

.weather { order: 1; flex: 1 1 100%; position: relative; min-width: 0; }
.weather[hidden] { display: none; }
.weather-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  height: 34px;
  padding: 0 10px 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: 600 13.5px/1 var(--sans);
  cursor: pointer;
}
.weather-btn:hover, .weather-btn[aria-expanded="true"] { border-color: var(--line-strong); background: var(--surface-hover); }
.weather-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.weather-temp { font: 700 14px/1 var(--mono); letter-spacing: -.01em; }
.weather-city { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-weight: 500; }
.wx { width: 24px; height: 24px; flex: none; fill: none; stroke: var(--text-2); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.wx .sun { fill: #f2b84b; stroke: #f2b84b; }
.wx .ray { stroke: #f2b84b; }
.wx .moon { fill: #cdd5ea; stroke: #cdd5ea; stroke-width: 1; }
.wx .cloud { fill: var(--surface-2); stroke: var(--text-2); }
.wx .line { stroke: var(--text-3); }
.wx .drop { stroke: var(--c-tech); }
.wx .flake { fill: var(--text); stroke: none; }
.wx .bolt { fill: #f2b84b; stroke: #f2b84b; stroke-width: .8; }
.wx-big { width: 52px; height: 52px; }
.wx-sm { width: 26px; height: 26px; }

.weather-pop {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  left: 0;
  width: min(340px, calc(100vw - 2 * var(--gutter)));
  max-height: min(80vh, 640px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .6);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.weather-pop[hidden] { display: none; }
.weather-pop p { margin: 0; }
.wx-place { font: 700 11px/1.2 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); }
.wx-head { display: flex; align-items: center; gap: 14px; }
.wx-temp { font: 700 40px/1 var(--serif); }
.wx-label { margin-top: 4px; color: var(--text-2); font-size: 14px; }
.wx-facts { display: grid; gap: 0; border-top: 1px solid var(--line); }
.wx-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.wx-key { color: var(--text-2); }
.wx-val { font-family: var(--mono); font-weight: 600; }
.wx-days { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.wx-day { display: grid; justify-items: center; gap: 6px; padding: 10px 4px; border: 1px solid var(--line); border-radius: 6px; }
.wx-dayname { font: 600 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }
.wx-hilo { font: 600 12.5px/1 var(--mono); color: var(--text-2); white-space: nowrap; }
.wx-note { font-size: 13px; color: var(--text-3); }
.wx-cities { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.wx-city { display: flex; align-items: center; gap: 4px; }
.wx-cpick, .wx-rpick {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.wx-cpick:hover, .wx-rpick:hover, .wx-crm:hover { background: var(--surface-hover); }
.wx-cpick.on { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.wx-crm { width: 40px; height: 40px; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); font-size: 20px; line-height: 1; cursor: pointer; }
.wx-add { display: flex; gap: 8px; }
.wx-add input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--bg);
  font-size: 15px;
}
.wx-add input:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.wx-go { height: 40px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 6px; background: transparent; color: var(--text); font-weight: 600; cursor: pointer; }
.wx-go:hover { background: var(--surface-hover); }
.wx-results { list-style: none; margin: -6px 0 0; padding: 0; display: grid; border-top: 1px solid var(--line); }
.wx-none { padding: 10px; color: var(--text-3); font-size: 14px; }

/* Settings: notifications card. */
.panel-note { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.5; }
.inline-row { display: flex; gap: 8px; align-items: stretch; }
.inline-row input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--bg); font-size: 15px; }
.inline-row input:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.inline-row input[readonly] { font-family: var(--mono); font-size: 13px; color: var(--text-2); }
.btn-outline { flex: none; height: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 6px; background: transparent; color: var(--text); font-weight: 600; cursor: pointer; }
.btn-outline:hover { background: var(--surface-hover); }
.two-col { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 12px; }
.field label { display: block; }
.advanced summary { cursor: pointer; padding: 8px 0; color: var(--text-2); font-weight: 600; font-size: 14px; }
.advanced[open] summary { margin-bottom: 6px; }

/* ---- list header + card grid --------------------------------------------- */

.list-head { margin: 36px 0 20px; padding-bottom: 12px; border-bottom: 1px solid var(--line-strong); }
body[data-view="section"] .list-head, body[data-view="saved"] .list-head { margin-top: 8px; }
.list-title { margin: 4px 0 0; font: 700 28px/1.15 var(--serif); }

/* Cards keep their own height: an opened story group must not stretch its row neighbours. */
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; align-items: start; }

.card {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 16px 0 10px;
  border-bottom: 1px solid var(--line);
}
.card-body { min-width: 0; display: flex; flex-direction: column; }
.card-title { margin: 8px 0 6px; font: 700 18px/1.28 var(--serif); overflow-wrap: anywhere; }
.card-title a:visited, .rail-headline a:visited, .lead-title a:visited { color: var(--text-2); }
.card-dek { -webkit-line-clamp: 2; line-clamp: 2; }
.also {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.also strong { color: var(--text); font-weight: 650; }
.card .story-foot { margin-top: 8px; }

/* Phones: compact list rows with a small square picture on the right. */
.card.has-img { grid-template-columns: minmax(0, 1fr) 88px; column-gap: 14px; }
.card.has-img .media { grid-column: 2; grid-row: 1; align-self: start; width: 88px; height: 88px; margin-top: 28px; border-radius: 6px; }
.card.has-img .card-body { grid-column: 1; grid-row: 1; }
.card .also { display: none; }

.sentinel { height: 1px; }
.feed-status {
  margin: 28px 0 8px;
  text-align: center;
  color: var(--text-3);
  font: 500 11px/1.4 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  min-height: 1.4em;
}
.feed-status.done::before {
  content: "";
  display: block;
  width: 40px;
  height: 2px;
  margin: 0 auto 14px;
  background: var(--accent);
}
.retry { display: block; margin: 0 auto; }
/* Start-up failure: grey "live" dot, the message set as a headline above Retry. */
body.offline .live-dot { background: var(--text-3); box-shadow: none; }
body.offline .feed-status { margin: 64px 0 20px; font: 700 26px/1.25 var(--serif); letter-spacing: 0; text-transform: none; color: var(--text); }
body.offline .feed-status::after { content: "Check your connection, then try again."; display: block; margin-top: 8px; font: 400 15px/1.5 var(--sans); color: var(--text-2); }

/* ---- sources screen ----------------------------------------------------- */

.subbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 56px;
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  padding: env(safe-area-inset-top) 8px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.subbar-brand { justify-self: center; font: 700 17px/1 var(--serif); letter-spacing: .16em; margin-right: -.16em; }
.sources-body { max-width: 760px; margin: 0 auto; padding: 24px 16px 56px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.sources-intro { padding-bottom: 14px; margin-bottom: 4px; border-bottom: 1px solid var(--line-strong); }
.sources-intro h1 { margin: 6px 0 0; font: 700 30px/1.15 var(--serif); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 12px; }
.panel h2 { margin: 0; font: 700 19px/1.25 var(--serif); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; cursor: pointer; }
.switch-hint { display: block; margin-top: 2px; font-size: 12.5px; color: var(--text-3); }
.add-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.add-msg { margin: 0; font-size: 14px; color: var(--text-2); }
.add-msg:empty { display: none; }
.add-msg.error { color: var(--warn); }
.hint { margin: 10px 2px 0; color: var(--text-3); font-size: 13px; line-height: 1.5; }

.section-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.sec-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px 6px 4px; }
.sec-card.dragging { opacity: .5; }
.sec-card.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.sec-card.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.sec-card.is-hidden .sec-name, .sec-card.is-hidden .src-list { opacity: .5; }
.sec-head { display: flex; align-items: center; gap: 2px; min-height: 48px; }
.drag-handle { cursor: grab; }
.drag-handle:active { cursor: grabbing; }
.sec-name { flex: 1; min-width: 0; margin: 0; display: flex; align-items: center; gap: 10px; padding-left: 4px; font: 700 18px/1.2 var(--serif); }
.sec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--chip, var(--c-general)); flex: none; }
[data-section="tech"] { --chip: var(--c-tech); }
[data-section="science"] { --chip: var(--c-science); }
[data-section="policy"] { --chip: var(--c-policy); }
[data-section="politics"] { --chip: var(--c-politics); }
[data-section="general"] { --chip: var(--c-general); }
[data-section="local"] { --chip: var(--c-local); }
[data-section="entertainment"] { --chip: var(--c-entertainment); }
.sec-head .switch { margin: 0 8px 0 6px; }
.src-list { list-style: none; margin: 4px 0 0; padding: 0 0 0 42px; }
.src {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 4px 8px 4px 0;
  border-top: 1px solid var(--line);
}
.src-text { flex: 1; min-width: 0; }
.src-name { display: block; }
.src .src-name { opacity: 1; font-weight: 500; }
.src-host { display: block; font: 500 11px/1.4 var(--mono); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-warn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 6px;
  border-radius: 4px;
  background: var(--warn-soft);
  color: var(--warn);
  font: 600 10.5px/1.4 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  flex: none;
}
.badge-warn svg { width: 14px; height: 14px; }
.btn-remove {
  flex: none;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.btn-remove:hover { background: var(--surface-hover); }
.btn-remove.confirm { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.src-empty { padding: 12px 0; color: var(--text-3); font-size: 14px; border-top: 1px solid var(--line); }

/* ---- refresh strip and pull indicator ----------------------------------- */

.refresh-strip {
  position: relative;
  display: flex;
  align-items: center;
  height: 28px;
  padding: 0 var(--gutter);
  border-top: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--text-2);
  font-size: 13px;
  overflow: hidden;
}
.refresh-strip-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 35%;
  background: var(--accent);
  animation: refresh-slide 1.3s ease-in-out infinite;
}
@keyframes refresh-slide {
  from { transform: translateX(-100%); }
  to { transform: translateX(290%); }
}
.refresh-strip-text { position: relative; }

.pull {
  position: fixed;
  left: 50%;
  top: 0;
  z-index: 9; /* under the tab bar, so the circle slides out from behind it */
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
  color: var(--text-2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 0);
}
.pull.settling { transition: transform .2s ease-out, opacity .2s; }
.pull svg { width: 22px; height: 22px; transition: transform .15s; }
.pull.ready { color: var(--accent); border-color: var(--accent); }
.pull.ready svg { transform: rotate(180deg); }

/* ---- snackbar ----------------------------------------------------------- */

.snackbar {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 20;
  max-width: min(560px, calc(100% - 32px));
  padding: 13px 18px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  transform: translate(-50%, 24px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, transform .15s;
}
.snackbar.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- 600–1099: unfolded Fold. Lead full width, rail below, 2-column cards --- */

@media (min-width: 600px) {
  :root { --gutter: 24px; }
  .utility { flex-wrap: nowrap; padding-top: 12px; padding-bottom: 8px; }
  .dateline { flex: 1 1 auto; }
  .search { order: 0; flex: 0 1 240px; height: 34px; }
  .weather { order: 0; flex: none; }
  .weather-city { max-width: 120px; }
  .actions { order: 0; }
  .lead-story .media { aspect-ratio: 21 / 9; }
  .perspectives .persp { grid-template-columns: 128px minmax(0, 1fr) auto; column-gap: 12px; }
  .perspectives .persp-src { grid-column: auto; }
  .search input { font-size: 14px; }
  .masthead { padding-bottom: 16px; }
  .mast-row { gap: 28px; }
  .mast-name { font-size: 40px; }
  .masthead-login .mast-name { font-size: 38px; }
  .mast-tag { font-size: 10px; }

  .lead-title { font-size: 38px; }
  .lead-dek { font-size: 17px; }
  .breaking-title { font-size: 23px; }
  .rail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
  .rail-item:last-child { border-bottom: 1px solid var(--line); }
  .rail-list > .rail-item:nth-last-child(-n + 2):nth-child(odd),
  .rail-list > .rail-item:last-child { border-bottom: 0; }

  .list-title { font-size: 32px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
  .card,
  .card.has-img {
    display: flex;
    flex-direction: column;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
  }
  .card.has-img .media { width: auto; height: auto; margin: 0; border-radius: 0; aspect-ratio: 16 / 9; }
  .card-body { padding: 16px 16px 10px; }
  .card-title { font-size: 20px; margin: 10px 0 8px; }
  .card-dek { -webkit-line-clamp: 3; line-clamp: 3; }
  .card .also { display: -webkit-box; }
  .card .story-foot { margin-top: 12px; padding-top: 4px; }
}

/* ---- >=1100: desktop. Lead + rail side by side, 3-column cards ------------- */

@media (min-width: 1100px) {
  /* The whole chrome (utility bar, masthead, tabs) stays on top, as on a newspaper site. */
  .chrome { display: block; position: sticky; top: 0; z-index: 10; background: var(--bg); }
  .tabs-bar { position: static; }
  .chrome.scrolled { box-shadow: 0 10px 24px -18px rgba(0, 0, 0, .7); }
  .tool-label { display: inline; }
  .tool-btn { padding: 0 10px; }
  .tool-btn .count-badge { position: static; min-width: 20px; padding: 2px 6px; font-size: 10.5px; background: var(--surface-2); color: var(--text-2); }
  .search { flex-basis: 260px; margin-right: 6px; }
  .mast-name { font-size: 46px; }

  .feed { padding-top: 26px; }
  .front { grid-template-columns: minmax(0, 58fr) minmax(0, 42fr); gap: 0; align-items: start; }
  .lead-story .media { aspect-ratio: 16 / 9; }
  .lead-story { padding-right: 28px; }
  .lead-title { font-size: 42px; }
  .rail { padding: 0 0 0 28px; border-top: 0; border-left: 1px solid var(--line); align-self: stretch; }
  .rail-list { display: block; }
  .rail-item, .rail-list > .rail-item:nth-last-child(-n + 2):nth-child(odd) { border-bottom: 1px solid var(--line); }
  .rail-list > .rail-item:last-child { border-bottom: 0; }

  .breaking { padding: 16px 22px 6px 22px; margin-bottom: 30px; }
  .breaking-kicker { margin-bottom: 4px; }
  .breaking-title { font-size: 26px; }
  .breaking-item { padding: 14px 0 12px; }

  .list-head { margin-top: 44px; }
  .list-title { font-size: 34px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
  .card-title { font-size: 21px; }
}

/* ---- Add a source: website / search / browse ---- */
.add-source { gap: 14px; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg); }
.seg-btn { height: 38px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); font: 600 14px/1 var(--sans); cursor: pointer; }
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-selected="true"] { background: var(--accent); color: var(--on-accent); }
.seg-btn:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.find-pane { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; }
.find-status { margin: 0; font-size: 14px; color: var(--text-2); }
.find-status:empty { display: none; }
.find-status.error { color: var(--warn); }
.find-status.busy::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: find-spin .8s linear infinite; }
@keyframes find-spin { to { transform: rotate(360deg); } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 34px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 17px; background: transparent; color: var(--text-2); font: 600 13px/1 var(--sans); cursor: pointer; }
.chip:hover { background: var(--surface-hover); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.find-results { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.find-row { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 10px; padding: 14px 0; border-top: 1px solid var(--line); }
.find-row:first-child { border-top: 0; padding-top: 2px; }
.find-main { min-width: 0; display: grid; gap: 3px; }
.find-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 8px; }
.find-title { margin: 0; font: 700 17px/1.25 var(--serif); overflow-wrap: anywhere; }
.find-meta { margin: 0; font: 500 12px/1.4 var(--mono); color: var(--text-3); overflow-wrap: anywhere; }
.find-sample { margin: 0; font-size: 14px; line-height: 1.4; color: var(--text-2); overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; }
.find-err { margin: 0; font-size: 13px; color: var(--warn); }
.find-err:empty { display: none; }
.find-actions { display: flex; gap: 8px; align-items: center; }
.find-actions .select-small { flex: 1 1 auto; min-width: 0; max-width: 200px; }
.btn-add { flex: none; height: 38px; min-width: 96px; padding: 0 16px; }
.find-row.is-added .btn-add { background: transparent; color: var(--ok); border: 1px solid var(--line-strong); opacity: 1; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 10px; font: 600 11px/1.5 var(--sans); letter-spacing: .02em; white-space: nowrap; }
.pill svg { width: 12px; height: 12px; fill: currentColor; }
.pill-ok { background: var(--accent-soft); color: var(--ok); }
.pill-lean { border: 1px solid var(--line-strong); color: var(--text-2); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.manual-add summary { padding: 4px 0; }
.manual-add .add-feed { display: grid; gap: 12px; padding-top: 4px; }
@media (min-width: 600px) {
  .find-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 16px; }
  .find-actions .select-small { flex: none; width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .pulse { animation: none; }
  .refresh-strip-bar { animation: none; width: 100%; opacity: .5; }
  .pull svg { transition: none; }
  .find-status.busy::before { animation: none; }
}
