/* ===== News for Dirk — Popsicle (light) + Popsicle Dark (CLAUDE.md §15) ===== */
:root, :root[data-theme="light"] {
  --bg: #f6f5fa;            /* page ground — cool lilac-white */
  --bg2: #efedf8;           /* secondary surface */
  --card: #ffffff;          /* card surface */
  --ink: #241f33;
  --ink-soft: #6f6885;
  --ink-faint: #9a93ad;
  --line: #e2def0;          /* hairline border */
  --accent: #e2570e;        /* mango orange */
  --accent-ink: #ffffff;    /* text on accent fills */
  --teal: #0a9d90;
  --grape: #6b4de6;
  --good: #0a9d90;          /* success / money / good */
  --danger: #d64545;
  --gold: #e0a400;
  --chip-ink: #14100c;
  /* political lean — semantic, tuned per theme */
  --left: #3b6fb0;
  --center: #7c7391;
  --right: #d64545;
  /* soft tints derive from the base hue so they adapt per theme */
  --accent-soft: color-mix(in srgb, var(--accent) 16%, var(--card));
  --good-soft: color-mix(in srgb, var(--good) 16%, var(--card));
  --danger-soft: color-mix(in srgb, var(--danger) 16%, var(--card));
  --gold-soft: color-mix(in srgb, var(--gold) 20%, var(--card));
  --glass: rgba(255, 255, 255, .82);
  --scrim: rgba(36, 31, 51, .42);
  --switch-off: #d8d2ea;
  --switch-thumb: #ffffff;
  --grad: linear-gradient(135deg, #e2570e, #6b4de6);
  --shadow: 0 10px 26px rgba(36, 31, 51, .10);
  --shadow-sm: 0 2px 8px rgba(36, 31, 51, .07);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Text", "Segoe UI",
          "Nunito", system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #191625;
  --bg2: #2e2840;           /* elevated */
  --card: #241f33;          /* surface */
  --ink: #f2eef9;
  --ink-soft: #a69dba;
  --ink-faint: #8981a0;
  --line: #3b3352;
  --accent: #ff8a3d;        /* warm coral-orange */
  --accent-ink: #2a1206;    /* near-black on accent */
  --teal: #2fd4c4;
  --grape: #ab8dff;
  --good: #2fd4c4;
  --danger: #ff6b78;
  --gold: #e0b24d;
  --chip-ink: #ffffff;
  --left: #6f9fda;
  --center: #a69dba;
  --right: #ff6b78;
  --glass: rgba(25, 22, 37, .82);
  --scrim: rgba(0, 0, 0, .55);
  --switch-off: #4a4363;
  --switch-thumb: #e9e4f5;
  --grad: linear-gradient(135deg, #ff8a3d, #ab8dff);
  --shadow: 0 10px 26px rgba(0, 0, 0, .42);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, .32);
  color-scheme: dark;
}

/* Layout width — kept in a plain :root (specificity 0,1,0) so the media-query
   breakpoints below reliably override it regardless of the data-theme attribute. */
:root {
  --maxw: 760px;   /* content width — grows with the viewport (see breakpoints) */
  --readw: 720px;  /* comfortable single-column width for list / settings views */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; min-height: 100%;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }
a { color: var(--accent); }

/* ===== Lock screen ===== */
.lock-screen {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--grad);
  padding: calc(var(--safe-top) + 20px) 20px calc(var(--safe-bottom) + 20px);
}
.lock-card { width: 100%; max-width: 360px; text-align: center; color: #fff; }
.lock-logo {
  width: 84px; height: 84px; margin: 0 auto 16px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.26);
  border-radius: 22px; display: flex; flex-direction: column; gap: 8px;
  align-items: center; justify-content: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.22);
}
.logo-rule { width: 44px; height: 5px; border-radius: 3px; background: #fff; }
.logo-bars { display: flex; gap: 6px; }
.logo-bars i { width: 12px; height: 22px; border-radius: 3px; display: block; }
.logo-bars i:nth-child(1) { background: #ffd9b0; }
.logo-bars i:nth-child(2) { background: #ffffff; }
.logo-bars i:nth-child(3) { background: #d8c8ff; }
.lock-title { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -.3px; }
.lock-hint { margin: 6px 0 20px; opacity: .9; font-size: 15px; }
/* PIN keypad (house standard 2026-10-20). Colors come from --pk-* set per app on .pin-gate. */
.pin-gate{--pk-size:clamp(64px,min(20vw,10vh),84px);display:flex;flex-direction:column;align-items:center;gap:clamp(8px,1.6vh,16px);touch-action:manipulation;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;color:var(--pk-ink)}
.pin-dots{display:flex;gap:10px}
.pin-dots span{width:14px;height:14px;border-radius:50%;border:2px solid var(--pk-ink);box-sizing:border-box}
.pin-dots span.on{background:var(--pk-ink)}
.pin-gate.busy .pin-dots span.on{animation:pkpulse .9s ease-in-out infinite}
@keyframes pkpulse{50%{opacity:.35}}
.pin-gate.bad .pin-dots{animation:pkshake .35s}
@keyframes pkshake{20%,60%{transform:translateX(-8px)}40%,80%{transform:translateX(8px)}}
.pin-msg{min-height:1.3em;font-size:16px;line-height:1.3;color:var(--pk-muted);text-align:center}
.pin-pad{display:grid;grid-template-columns:repeat(3,var(--pk-size));gap:clamp(8px,1.6vh,16px)}
.pin-pad button{height:var(--pk-size);border-radius:50%;border:1px solid var(--pk-line);background:var(--pk-surface);color:var(--pk-ink);font-family:inherit;font-weight:600;font-size:clamp(26px,4vh,32px);line-height:1;padding:0;touch-action:manipulation;-webkit-tap-highlight-color:transparent;cursor:pointer}
.pin-pad button:active{background:var(--pk-accent);color:var(--pk-accent-ink)}
.pin-pad button:disabled{opacity:.5}
.pin-pad .pin-del{border:none;background:transparent;font-size:24px}
@media (prefers-reduced-motion:reduce){.pin-gate.busy .pin-dots span.on,.pin-gate.bad .pin-dots{animation:none}}
.pin-gate { --pk-ink: #fff; --pk-muted: #fff; --pk-line: rgba(255,255,255,.4); --pk-surface: rgba(0,0,0,.2); --pk-accent: #fff; --pk-accent-ink: #16203a; }
.pin-msg { font-weight: 700; border-radius: 999px; padding: 2px 12px; background: rgba(0,0,0,.28); }
.pin-msg:empty { background: none; }
.lock-logo { width: 64px; height: 64px; margin-bottom: 8px; }
.lock-hint { margin: 4px 0 12px; }

/* ===== App shell ===== */
.app { display: flex; flex-direction: column; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  padding: calc(var(--safe-top) + 16px) 18px 12px;
  background: linear-gradient(180deg, var(--bg) 72%, transparent);
}
.topbar-inner { max-width: var(--maxw); margin: 0 auto; }
.view-title { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -.4px; }
.view-sub { color: var(--ink-soft); font-size: 13px; margin-top: 2px; font-weight: 700; }
.topbar-actions { position: absolute; top: calc(var(--safe-top) + 16px); right: 16px; display: flex; gap: 8px; align-items: center; }
.time-filter {
  height: 44px; border-radius: 13px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font-size: 13px; font-weight: 800; padding: 0 8px; max-width: 118px;
  box-shadow: var(--shadow-sm); -webkit-appearance: none; appearance: none;
}
/* L / D / A theme toggle */
.theme-toggle {
  display: flex; align-items: center; gap: 2px; height: 44px; padding: 3px;
  background: var(--card); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow-sm);
}
.theme-toggle button {
  width: 28px; height: 38px; border-radius: 10px; font-size: 12.5px; font-weight: 800;
  color: var(--ink-soft); display: flex; align-items: center; justify-content: center;
}
.theme-toggle button.active { background: var(--accent); color: var(--accent-ink); }
.theme-toggle button:active { transform: scale(.92); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; font-size: 22px; font-weight: 700; color: var(--accent);
  background: var(--card); box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.spinning { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.main { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 4px 16px calc(var(--safe-bottom) + 96px); }

/* ===== Section selector tabs (sticky under topbar) ===== */
.section-tabs {
  position: sticky; top: var(--topbar-h, 64px); z-index: 9;
  display: flex; flex-wrap: wrap; gap: 8px; overflow-x: visible; -webkit-overflow-scrolling: touch;
  padding: 8px 16px 10px; margin: 0 auto; max-width: var(--maxw); width: 100%;
  background: var(--bg); border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.section-tabs::-webkit-scrollbar { display: none; }
.section-tab {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 800;
  color: var(--ink-soft); background: var(--card); border: 1px solid var(--line); white-space: nowrap;
}
.section-tab:active { transform: scale(.96); }
.section-tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ===== Card grid: auto-fills columns to use the available width ===== */
/* As the window widens, more ~320px cards flow in per row (2 on iPad, up to 5 on a big monitor). */
.article-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; align-items: start; }
@media (max-width: 599px) {
  .article-grid { grid-template-columns: 1fr; }
  /* On phones, scroll the tabs horizontally instead of wrapping (saves vertical space) */
  .section-tabs { flex-wrap: nowrap; overflow-x: auto; }
  /* Keep the sub-line clear of the top-right control cluster (time filter / L·D·A / refresh). */
  .view-sub { margin-top: 10px; }
}

/* Larger tap targets on touch devices (iPhone/iPad) without bulking up the mouse UI. */
@media (pointer: coarse) {
  .card-star, .card-dismiss { width: 32px; height: 32px; }
  .card-dismiss { font-size: 15px; }
  .card-star { font-size: 17px; }
  .fb-btn { padding-top: 11px; padding-bottom: 11px; }
}

.show-more {
  display: block; width: 100%; max-width: 420px; margin: 12px auto 0;
  padding: 12px; border-radius: 13px; font-size: 14px; font-weight: 800;
  color: var(--accent); background: var(--card); border: 1px solid var(--line);
}
.show-more:active { transform: scale(.99); }

/* ===== Section block (Feed) ===== */
.section { margin-top: 22px; }
.section-head { display: flex; align-items: center; gap: 8px; margin: 0 2px 10px; }
.section-emoji { font-size: 20px; }
.section-name { font-size: 19px; font-weight: 800; letter-spacing: -.3px; }
.section-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.section-edit { font-size: 13px; font-weight: 800; color: var(--accent); padding: 4px 6px; }
.section-brief { font-size: 13px; font-weight: 800; color: var(--accent); padding: 4px 6px; }
.section-brief:active { transform: scale(.94); }

/* Status panel */
.log { display: flex; flex-direction: column; gap: 5px; }
.log-row { display: flex; gap: 10px; font-size: 13px; color: var(--ink-soft); align-items: center; }
.log-row span:first-child { flex: 1; }
.log-src { font-size: 10px; color: var(--ink-faint); text-transform: uppercase; font-weight: 800; letter-spacing: .4px; }
.log-add { font-weight: 800; color: var(--good); }
.api-list { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--ink-soft); }
.api-list a { color: var(--accent); text-decoration: none; font-weight: 800; }
.status-fresh { font-weight: 800; color: var(--accent); white-space: nowrap; }

/* Briefing sheet */
.brief-body { min-height: 60px; }
.brief-text { white-space: pre-wrap; font-size: 14.5px; line-height: 1.55; color: var(--ink); max-height: 62vh; overflow-y: auto; }
.brief-meta { font-size: 12px; color: var(--ink-faint); margin-top: 12px; font-weight: 700; }

/* empty section -> compact single line */
.section-empty { margin-top: 12px; }
.section-empty .section-name { color: var(--ink-faint); font-weight: 800; }
.empty-tag { font-size: 11px; font-weight: 800; color: var(--ink-faint); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; margin-left: 8px; }
.section-empty .section-edit { margin-left: auto; }
.empty-mini { color: var(--ink-faint); font-size: 13px; font-weight: 700; padding: 8px 2px 2px; }

/* balance meter — capped so it doesn't stretch across a wide multi-column feed */
.balance { margin: 0 2px 12px; max-width: 520px; }
.balance-bar { display: flex; height: 8px; border-radius: 5px; overflow: hidden; background: var(--line); }
.balance-bar span { display: block; height: 100%; }
.balance-bar .bl { background: var(--left); }
.balance-bar .bc { background: var(--center); }
.balance-bar .br { background: var(--right); }
/* Counts live in the filter buttons (the old legend row repeated them). The dot keys each
   button to its bar color. */
.lean-dot { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 5px; vertical-align: 1px; }
.lean-dot.left { background: var(--left); }
.lean-dot.center { background: var(--center); }
.lean-dot.right { background: var(--right); }
.lean-n { font-weight: 700; }

/* lean filter */
.lean-filter { display: flex; gap: 6px; margin: 0 2px 12px; max-width: 520px; background: var(--card); padding: 4px; border-radius: 14px; box-shadow: var(--shadow-sm); border: 1px solid var(--line); }
.lean-filter button { flex: 1; padding: 8px 4px; border-radius: 10px; font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.lean-filter button.active { background: var(--accent); color: var(--accent-ink); }

/* ===== Article card ===== */
.article {
  position: relative; overflow: hidden;
  background: var(--card); border-radius: 15px; padding: 14px 16px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--line);
}
.article-img {
  display: block; width: calc(100% + 32px); height: 150px; object-fit: cover;
  margin: -14px -16px 12px; background: var(--line);
}
.card-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; z-index: 2; }
.card-dismiss, .card-star {
  width: 24px; height: 24px; border-radius: 50%; line-height: 1;
  background: var(--scrim); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.card-dismiss { font-size: 13px; }
.card-star { font-size: 14px; color: rgba(255, 255, 255, .9); }
.card-star.on { background: var(--gold); color: #fff; }
.card-dismiss:active, .card-star:active { transform: scale(.9); }
/* padding-right clears the ★/✕ buttons (2 x 24px + gap, 8px in from the edge) on cards with
   no photo; 26px used to let the time sit underneath them. */
.article-top { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; flex-wrap: wrap; padding-right: 48px; }
.lean-badge { font-size: 11px; font-weight: 800; color: #fff; border-radius: 6px; padding: 2px 8px; letter-spacing: .3px; }
.lean-badge.left { background: var(--left); }
.lean-badge.center { background: var(--center); }
.lean-badge.right { background: var(--right); }
.article-source { font-size: 12px; font-weight: 800; color: var(--ink-faint); }
.article-time { font-size: 12px; color: var(--ink-faint); margin-left: auto; font-weight: 700; }
.article-title { font-size: 16px; font-weight: 700; line-height: 1.35; color: var(--ink); text-decoration: none; display: block; }
.article-title:active { opacity: .7; }
.article-summary { font-size: 13.5px; color: var(--ink-soft); line-height: 1.45; margin-top: 6px; }
.article-terms { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.term-tag { font-size: 11px; font-weight: 800; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 2px 8px; }
.article-thin { font-size: 12px; color: var(--ink-faint); font-weight: 700; margin-top: 6px; }
.related { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.related-label { font-size: 10px; font-weight: 800; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .5px; }
.related-chip { font-size: 11px; font-weight: 800; color: #fff; border-radius: 6px; padding: 2px 8px; text-decoration: none; }
.related-chip.left { background: var(--left); }
.related-chip.center { background: var(--center); }
.related-chip.right { background: var(--right); }
.related-chip:active { transform: scale(.94); }
.related-more { font-size: 11px; color: var(--ink-faint); font-weight: 800; }
.article-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.fb-btn {
  flex: 1 1 0; min-width: 64px; padding: 8px 6px; border-radius: 10px; font-size: 12.5px; font-weight: 800;
  background: var(--bg2); color: var(--ink-soft); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; gap: 5px; white-space: nowrap;
}
.fb-btn:active { transform: scale(.97); }
.fb-btn.good.on { background: var(--good-soft); color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, var(--card)); }
.fb-btn.bad.on { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--card)); }
.fb-btn.thin.on { background: var(--gold-soft); color: var(--gold); border-color: color-mix(in srgb, var(--gold) 40%, var(--card)); }

/* ===== Generic list rows (Sections / Sources) ===== */
.row {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border-radius: 15px; padding: 13px 15px; margin-bottom: 9px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--line);
}
.row:active { transform: scale(.995); }
.row-emoji { font-size: 20px; flex: 0 0 auto; }
.row-body { min-width: 0; flex: 1; }
.row-title { font-size: 15px; font-weight: 800; }
.row-sub { font-size: 12px; color: var(--ink-faint); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-chevron { color: var(--ink-faint); font-size: 18px; flex: 0 0 auto; }
.reorder { display: flex; flex-direction: column; gap: 4px; margin-right: 8px; flex: 0 0 auto; }
.reorder button { width: 40px; height: 30px; border-radius: 9px; background: var(--bg2); border: 1px solid var(--line); color: var(--accent); font-size: 16px; font-weight: 700; line-height: 1; display: flex; align-items: center; justify-content: center; touch-action: manipulation; }
.reorder button:active { transform: scale(.9); background: var(--accent); color: var(--accent-ink); }
.reorder button:disabled { opacity: .3; color: var(--ink-faint); }
.row.disabled { opacity: .5; }
.group-label { font-size: 12px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--ink-faint); margin: 22px 4px 8px; }
.mini-badge { font-size: 10px; font-weight: 800; color: #fff; border-radius: 5px; padding: 1px 6px; letter-spacing: .3px; }
.mini-badge.left { background: var(--left); }
.mini-badge.center { background: var(--center); }
.mini-badge.right { background: var(--right); }
.mini-badge.good { background: var(--good); }
.status-ok { color: var(--good); }
.status-err { color: var(--danger); }

.add-btn {
  width: 100%; padding: 14px; border-radius: 15px; font-size: 15px; font-weight: 800;
  color: #fff; background: var(--grad); box-shadow: var(--shadow); margin-top: 4px;
}
.add-btn:active { transform: scale(.99); }

/* ===== Settings ===== */
.set-card { background: var(--card); border-radius: 15px; padding: 6px 16px; margin-bottom: 14px; box-shadow: var(--shadow-sm); border: 1px solid var(--line); }
.set-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: none; }
.set-row label.set-name { flex: 1; font-size: 15px; font-weight: 700; }
.set-name small { display: block; color: var(--ink-faint); font-weight: 600; font-size: 12px; margin-top: 2px; }
.set-input { width: 150px; padding: 9px 11px; border-radius: 11px; border: 1px solid var(--line); background: var(--bg2); font-size: 14px; color: var(--ink); text-align: right; }
.set-input.wide { width: 200px; text-align: left; }
.set-btn { padding: 10px 14px; border-radius: 12px; font-size: 14px; font-weight: 800; background: var(--bg2); color: var(--accent); border: 1px solid var(--line); }
.set-btn:active { transform: scale(.97); }
.set-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.set-foot { text-align: center; color: var(--ink-faint); font-size: 12px; margin: 20px 0 8px; }

/* Sub-heading inside a merged settings card (e.g. "AI learning" / "Muted terms" sharing one card) */
.subgroup-label { font-size: 11px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase; color: var(--ink-faint); padding: 14px 0 2px; }
.subgroup-label:first-child { padding-top: 2px; }

/* Two related fields sharing one row (e.g. digest Hour + Stories-per-section) */
.set-row-pair { gap: 14px; }
.set-mini { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.set-mini .set-name-mini { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.set-mini .set-input { width: 100%; }

/* Collapsible settings card (native <details>/<summary> — Account & Security, closed by default) */
details.set-card { padding: 0; }
details.set-card > summary { list-style: none; padding: 14px 16px; cursor: pointer; display: flex; align-items: center; gap: 12px; }
details.set-card > summary::-webkit-details-marker { display: none; }
details.set-card > summary:active { opacity: .8; }
details.set-card > summary .row-chevron { transition: transform .18s; }
details.set-card[open] > summary .row-chevron { transform: rotate(90deg); }
details.set-card > summary { border-bottom: 1px solid transparent; }
details.set-card[open] > summary { border-bottom-color: var(--line); }
details.set-card > .set-collapsible-body { padding: 0 16px; }
details.set-card > .set-collapsible-body .set-row:last-child { border-bottom: none; }

.log-more { width: 100%; text-align: left; padding: 8px 2px 4px; font-size: 12.5px; font-weight: 800; color: var(--accent); }

/* Appearance mode segmented control */
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; padding: 10px 8px; border-radius: 11px; font-size: 13px; font-weight: 800; background: var(--bg2); border: 1px solid var(--line); color: var(--ink-soft); }
.seg button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ===== Empty states ===== */
.empty { text-align: center; color: var(--ink-faint); padding: 38px 24px; font-weight: 700; line-height: 1.5; }
.empty .big { font-size: 34px; display: block; margin-bottom: 8px; }

/* ===== Switch ===== */
.switch { position: relative; display: inline-block; width: 46px; height: 28px; flex: 0 0 auto; }
.switch input { display: none; }
.switch .track { position: absolute; inset: 0; background: var(--switch-off); border-radius: 999px; transition: background .2s; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; background: var(--switch-thumb); border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked ~ .thumb { transform: translateX(18px); }

/* ===== Sheets ===== */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; background: var(--bg2); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(var(--safe-bottom) + 22px); max-height: 92dvh; overflow-y: auto;
  box-shadow: 0 -10px 40px var(--scrim); animation: sheetUp .25s ease;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-grab { width: 42px; height: 5px; border-radius: 3px; background: var(--switch-off); margin: 4px auto 12px; }
.sheet-title { font-size: 19px; font-weight: 800; margin: 0 0 14px; letter-spacing: -.3px; }
.field-row { display: flex; gap: 10px; }
.edit-emoji { width: 56px; text-align: center; font-size: 22px; }
.edit-title, .edit-text, .edit-emoji {
  width: 100%; padding: 13px 14px; border-radius: 13px; border: 1px solid var(--line);
  background: var(--card); font-size: 16px; color: var(--ink); outline: none; margin-bottom: 4px;
}
.edit-title { font-weight: 700; }
.edit-title:focus, .edit-text:focus { border-color: var(--accent); }
.field-label { display: block; font-size: 13px; font-weight: 800; color: var(--ink-soft); margin: 16px 2px 8px; }
.field-hint { font-weight: 700; color: var(--ink-faint); text-transform: none; letter-spacing: 0; }
.term-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.term-chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px 7px 13px; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.term-chip button { color: var(--ink-faint); font-size: 16px; line-height: 1; }
.term-add { display: flex; gap: 8px; }
.term-input { flex: 1; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 15px; color: var(--ink); outline: none; }
.term-input:focus { border-color: var(--accent); }
.term-btn { width: 48px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-size: 22px; font-weight: 600; }
.toggle-row { display: flex; align-items: center; gap: 12px; margin: 18px 0 4px; }
.toggle-row span:first-child { flex: 1; font-size: 14px; }
.toggle-row small { display: block; color: var(--ink-faint); font-weight: 600; font-size: 12px; margin-top: 2px; }
.toggle-row b { font-weight: 800; }
.lean-pick { display: flex; gap: 7px; flex-wrap: wrap; }
.lean-pick button { padding: 9px 12px; border-radius: 11px; font-size: 13px; font-weight: 800; background: var(--card); border: 1px solid var(--line); color: var(--ink-soft); }
.lean-pick button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chips button { padding: 9px 12px; border-radius: 11px; font-size: 13px; font-weight: 800; background: var(--card); border: 1px solid var(--line); color: var(--ink-soft); }
.chips button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.sheet-actions { display: flex; gap: 10px; margin-top: 22px; }
.btn-primary { flex: 1; padding: 14px; border-radius: 13px; font-size: 15px; font-weight: 800; color: var(--accent-ink); background: var(--accent); }
.btn-primary:active { transform: scale(.99); }
.btn-danger { padding: 14px 18px; border-radius: 13px; font-size: 15px; font-weight: 800; color: var(--danger); background: var(--danger-soft); }

/* ===== Bottom nav ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 8px 8px calc(var(--safe-bottom) + 8px);
  background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.nav-btn { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px; color: var(--ink-faint); }
.nav-ico { font-size: 21px; filter: grayscale(.4); opacity: .65; transition: .15s; }
.nav-label { font-size: 11px; font-weight: 800; }
.nav-btn.active { color: var(--accent); }
.nav-btn.active .nav-ico { filter: none; opacity: 1; transform: translateY(-1px); }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 84px); transform: translateX(-50%) translateY(20px);
  background: var(--accent); color: var(--accent-ink); padding: 12px 18px; border-radius: 13px;
  font-size: 14px; font-weight: 800; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 60; max-width: 88%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* spinner row */
.loading { text-align: center; color: var(--ink-faint); padding: 40px; font-weight: 700; }

/* ===== Wider screens (iPad / desktop) ===== */
@media (min-width: 720px) {
  .view-title { font-size: 32px; }
  .article-title { font-size: 17px; }
}

/* The feed grid uses the full content width; single-column views (Sections, Sources,
   Settings) stay in a centered reading column so they don't sprawl on a big monitor. */
.row, .set-card, .group-label, .add-btn, .set-foot { max-width: var(--readw); margin-left: auto; margin-right: auto; }

/* Version badge: top-right corner, above everything including the lock screen (z 50) and
   toasts (z 60). Sits in the 16px gap above the topbar buttons and never takes a tap.
   Opaque card fill so contrast doesn't depend on what's behind it:
   ink-soft on card = 5.3:1 light / 6.2:1 dark; warn (ink on card) = 15.9:1 / 13.9:1. */
.app-version {
  position: fixed; z-index: 70; pointer-events: none;
  top: calc(var(--safe-top) + 2px); right: calc(env(safe-area-inset-right, 0px) + 6px);
  font-size: 9.5px; font-weight: 700; line-height: 1; letter-spacing: .2px;
  padding: 2px 5px; border-radius: 6px;
  background: var(--card); color: var(--ink-soft);
}
.app-version.warn { color: var(--ink); font-weight: 800; }

/* Grow the content width in steps so the feed adds columns instead of wasting side space. */
@media (min-width: 1000px) { :root { --maxw: 980px; } }
@media (min-width: 1400px) { :root { --maxw: 1320px; } }
@media (min-width: 1800px) { :root { --maxw: 1660px; } }
@media (min-width: 2200px) { :root { --maxw: 2000px; } }

/* ===== iPhone density pass (2026-09-28) =====
   Kept at the END of the file on purpose: these override base rules of equal specificity,
   and same-specificity CSS is decided by source order, so any earlier placement silently loses.
   Measured at 390x844 before: 1 story fully on the first screen, photo cards 382px tall,
   133px of section chrome before each section's first card. */
@media (max-width: 599px) {
  .view-title { font-size: 24px; }
  .topbar { padding-bottom: 8px; }
  .section-tabs { padding: 6px 12px 8px; gap: 6px; }
  .section-tab { padding: 7px 12px; font-size: 12.5px; }
  .section { margin-top: 14px; }
  .section-head { margin-bottom: 6px; }
  .section-name { font-size: 17px; }
  .balance { margin-bottom: 8px; }
  .balance-bar { height: 5px; }
  .lean-filter { margin-bottom: 10px; padding: 3px; gap: 4px; }
  .lean-filter button { padding: 6px 2px; font-size: 12px; }

  /* Photo becomes a right-hand thumbnail (news-app style) instead of a full-width banner.
     It starts below the ★/✕ buttons (8px + 32px touch size) so they never cover it. */
  .article { padding: 12px 14px; }
  .article-img { float: right; width: 88px; height: 88px; margin: 30px 0 6px 12px; border-radius: 11px; }
  .article-title { font-size: 15.5px; }
  .article-summary {
    font-size: 13px;
    display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  }
  .related, .article-actions { clear: both; }
  .article-actions { margin-top: 10px; }

  /* Slimmer tab bar (the home-indicator inset still pads the bottom). */
  .bottom-nav { padding: 5px 8px calc(var(--safe-bottom) + 5px); }
  .nav-btn { padding: 3px; gap: 1px; }
  .nav-ico { font-size: 20px; }
  .nav-label { font-size: 10.5px; }
  .main { padding-bottom: calc(var(--safe-bottom) + 76px); }
}
/* The touch-size ★/✕ pair is 70px wide, 8px in from the edge: keep the time row clear of it. */
@media (pointer: coarse) {
  .article-top { padding-right: 64px; }
}
