/* Layout: single-column news feed at phone width; native ad card sits in the configured slot.
   Styled as a classic newspaper (serif headlines, red accent). Follows the phone's
   light/dark theme unless the tester's link forces one (?theme=, see theme.js);
   every color below is a token, so the dark blocks only override tokens. app.js reports the active theme on each event. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --fg: #121417;
  --muted: #5d6573;
  --line: #dcdfe4;
  --accent: #a4231f;        /* restrained newspaper red: links + active section */
  --accent-fg: #ffffff;
  --thumb-a: #c9d6e3;
  --thumb-b: #d9cfe0;
  --thumb-c: #cfe0d4;
  --thumb-d: #e3d6c9;
  --font-head: "Newsreader", Georgia, "Times New Roman", serif;
  --font-ui: "Roboto Flex", Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  /* App-promo ad: fixed brand colors */
  --app-icon-bg: #121212;
  --app-icon-fg: #ffffff;
  --install-bg: #1a9d6e;
  --install-fg: #ffffff;
  --app-icon-ring: transparent; /* outline so the black icon shows on a dark page */
}
/* Dark tokens: for a dark phone unless the tester's link forces light
   (?theme=light), and whenever it forces dark (?theme=dark). theme.js sets
   data-theme on <html>. Keep the two blocks identical (a test checks). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121316;
    --surface: #121316;
    --fg: #e8e9ec;          /* 15.3:1 on bg */
    --muted: #a3a9b3;       /* 7.9:1 */
    --line: #2c2f35;
    --accent: #e5736b;      /* newspaper red, lifted for dark: 6.2:1 */
    --accent-fg: #121316;
    --thumb-a: #2b3846;
    --thumb-b: #352d3d;
    --thumb-c: #2a3a30;
    --thumb-d: #3d342a;
    --app-icon-ring: #3d4149;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121316;
  --surface: #121316;
  --fg: #e8e9ec;          /* 15.3:1 on bg */
  --muted: #a3a9b3;       /* 7.9:1 */
  --line: #2c2f35;
  --accent: #e5736b;      /* newspaper red, lifted for dark: 6.2:1 */
  --accent-fg: #121316;
  --thumb-a: #2b3846;
  --thumb-b: #352d3d;
  --thumb-c: #2a3a30;
  --thumb-d: #3d342a;
  --app-icon-ring: #3d4149;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
img { max-width: 100%; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 15px; line-height: 1.45; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
.wrap { max-width: 480px; margin: 0 auto; }
.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

header.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 2px solid var(--fg); }
header.bar .gutter { display: flex; align-items: baseline; justify-content: space-between; padding-block: 12px; gap: 12px; }
.mast { font-family: var(--font-head); font-weight: 650; font-size: 26px; letter-spacing: -0.01em; }
.date { font-size: 12px; color: var(--muted); }
nav.tabs { display: flex; gap: 18px; overflow-x: auto; padding-block: 0 10px; font-size: 13px; font-weight: 500; color: var(--muted); scrollbar-width: none; border-top: 1px solid var(--line); padding-top: 8px; }
nav.tabs span { white-space: nowrap; padding-bottom: 4px; }
nav.tabs span.on { color: var(--accent); border-bottom: 2px solid var(--accent); }

main { display: flex; flex-direction: column; gap: 1px; background: var(--line); }
.item { background: var(--surface); padding-block: 16px; }

.story { display: grid; grid-template-columns: 1fr 88px; gap: 14px; align-items: start; cursor: pointer; }
.story > div { min-width: 0; }
.kicker { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.story h2 { font-family: var(--font-head); font-weight: 500; font-size: 18px; line-height: 1.25; margin: 4px 0 6px; text-wrap: balance; }
.meta { font-size: 12px; color: var(--muted); }
.thumb { width: 88px; aspect-ratio: 1; border-radius: 6px; max-width: 100%; overflow: hidden; }
.thumb-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lead .story { grid-template-columns: 1fr; }
.lead .thumb { width: 100%; aspect-ratio: 16 / 9; order: -1; }
.lead h2 { font-size: 24px; font-weight: 650; }

/* In-feed app-promo card (ads.js). Class names avoid ad / ad-* / cta: EasyList's
   generic rules hide ad-card, ad-label, ad-title, ad-icon... classes for blocker users. */
.ehs-card { position: relative; border: 1px solid var(--line); border-radius: 12px; padding: 30px 20px 20px; text-align: center; }
.ehs-card-tag { position: absolute; top: 10px; left: 14px; font-size: 10px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.ehs-appicon { width: 64px; height: 64px; border-radius: 16px; background: var(--app-icon-bg); box-shadow: 0 0 0 1px var(--app-icon-ring); display: grid; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); gap: 7px; padding: 15px; margin: 4px auto 18px; }
.ehs-appicon i { border-radius: 4px; background: var(--app-icon-fg); display: block; }
.ehs-appicon-img { width: 64px; height: 64px; border-radius: 16px; box-shadow: 0 0 0 1px var(--app-icon-ring); margin: 4px auto 18px; display: block; object-fit: cover; }
.ehs-name { font-family: var(--font-ui); font-weight: 700; font-size: 26px; line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 6px; color: var(--fg); }
.ehs-tagline { color: var(--muted); font-size: 15px; margin: 0 0 16px; }
.ehs-store { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 500; color: var(--fg); margin: 0 0 20px; }
.gplay-logo { width: 17px; height: 19px; display: block; }
.ehs-install { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; padding: 0; border-radius: 10px; background: var(--install-bg); color: var(--install-fg); font-weight: 600; font-size: 16px; text-decoration: none; }
.ehs-install:focus-visible, .story:focus-visible, .back:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Article reader */
.reader { background: var(--surface); min-height: 100%; padding-block: 16px 40px; }
.back { background: none; border: 0; color: var(--accent); font: 500 14px var(--font-ui); padding: 4px 0; cursor: pointer; }
.reader h1 { font-family: var(--font-head); font-weight: 650; font-size: 26px; line-height: 1.2; margin: 14px 0 8px; text-wrap: balance; }
.reader p { font-family: var(--font-head); font-size: 18px; line-height: 1.55; max-width: 65ch; }
.reader-img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; margin: 12px 0 4px; }
.reader-note { color: var(--muted); }
.read-more { display: inline-block; margin-top: 4px; color: var(--accent); font: 600 15px var(--font-ui); text-decoration: none; }
.read-more:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.loading { padding: 48px 0; text-align: center; color: var(--muted); font-size: 14px; }
.end { text-align: center; color: var(--muted); font-size: 12px; padding-block: 24px; background: var(--bg); }
/* Admin preview (#preview): a small tag so nobody mistakes it for a live session */
.preview-tag { position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 20; padding: 6px 12px; border-radius: 999px; background: #1f2937; color: #fff; font: 600 12px var(--font-ui); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); pointer-events: none; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
