/* BriefMe. Original design inspired by Apple's interface principles. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(0.28, 0.11, 0.32, 1);
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --radius-l: 28px;
  --radius-m: 18px;
  --radius-s: 12px;
  --nav-h: 52px;
  --tab-h: 58px;
  --maxw: 1120px;
  --read-font: var(--font);
  --read-size: 19px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-3: #3a3a3c;
  --hairline: rgba(255, 255, 255, 0.1);
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #6e6e73;
  --accent: #2997ff;
  --accent-press: #0077ed;
  --glass: rgba(22, 22, 23, 0.72);
  --shadow: none;
  --backdrop: rgba(0, 0, 0, 0.55);
  --green: #30d158;
  --amber: #ffb340;
  --red: #ff453a;
  --blue: #2997ff;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #fff;
  --surface-2: #f0f0f3;
  --surface-3: #e3e3e8;
  --hairline: rgba(0, 0, 0, 0.1);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --accent: #0071e3;
  --accent-press: #0062c4;
  --glass: rgba(251, 251, 253, 0.8);
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.06);
  --backdrop: rgba(0, 0, 0, 0.3);
  --green: #1f9d47;
  --amber: #c27a00;
  --red: #d70015;
  --blue: #0071e3;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + 16px); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.47 var(--font); letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}
button { font: inherit; color: inherit; letter-spacing: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; top: 8px; }
.skip:focus { left: 12px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 10px; }
.muted { color: var(--text-2); }

/* ---------- Navigation ---------- */
.nav {
  position: sticky; top: 0; z-index: 40; padding-top: env(safe-area-inset-top);
  background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent; transition: border-color 0.3s;
}
.nav.is-scrolled { border-bottom-color: var(--hairline); }
.nav-inner { height: var(--nav-h); max-width: var(--maxw); margin: 0 auto; padding: 0 22px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-weight: 600; font-size: 19px; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 7px; }
.nav-links { display: flex; gap: 28px; margin-left: 12px; }
.nav-links a { color: var(--text-2); font-size: 13px; letter-spacing: -0.01em; transition: color 0.2s; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: var(--text-2); transition: background 0.2s, color 0.2s; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 19px; height: 19px; }

/* ---------- Buttons ---------- */
.update-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; border-radius: 980px; font-weight: 600; letter-spacing: 0.02em;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease), opacity 0.2s;
  touch-action: manipulation; user-select: none; text-align: center;
}
.update-btn:hover { background: var(--accent-press); }
.update-btn:active { transform: scale(0.97); }
.update-btn--compact { height: 32px; padding: 0 15px; font-size: 12px; margin-left: 6px; }
.update-btn--hero { height: 54px; padding: 0 32px; font-size: 17px; min-width: 200px; box-shadow: 0 8px 30px rgba(41, 151, 255, 0.28); }
.update-btn .spinner { display: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff; animation: spin 0.8s linear infinite; }
.update-btn[data-state="loading"] { cursor: progress; }
.update-btn[data-state="loading"] .spinner { display: block; }
.update-btn[data-state="success"] { background: var(--green); box-shadow: none; }
.update-btn[data-state="error"] { background: var(--red); box-shadow: none; }
.update-btn:disabled { opacity: 0.85; }
@keyframes spin { to { transform: rotate(360deg); } }

.ghost-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 54px; padding: 0 26px;
  border-radius: 980px; background: var(--surface); color: var(--text); font-size: 17px; font-weight: 600;
  transition: background 0.2s, transform 0.15s var(--ease);
}
.ghost-btn:hover { background: var(--surface-2); }
.ghost-btn:active { transform: scale(0.97); }
.ghost-btn svg { width: 18px; height: 18px; color: var(--accent); }
.text-btn { flex: none; color: var(--accent); font-size: 15px; padding: 6px 2px; white-space: nowrap; }
.text-btn--strong { font-weight: 600; }
.pill-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: #fff; border-radius: 980px; padding: 7px 16px; font-size: 14px; font-weight: 600; }
.pill-btn:hover { text-decoration: none; background: var(--accent-press); }
.pill-btn--soft { background: var(--surface-2); color: var(--text); }
.pill-btn--soft:hover { background: var(--surface-3); }
.pill-btn svg { width: 15px; height: 15px; }

/* ---------- Tags ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.tag--critical { background: var(--red); color: #fff; }
.tag--high { background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber); }
.tag--developing { background: color-mix(in srgb, var(--blue) 16%, transparent); color: var(--blue); }
.tag--verified { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.tag--disputed { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.tag--unverified { background: var(--surface-2); color: var(--text-2); }
.tag--new { background: var(--accent); color: #fff; }
.tag--focus { background: none; padding: 0; color: var(--c, var(--text-2)); }
.tag--critical::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; margin-right: 5px; animation: pulse 1.6s var(--ease) infinite; }

/* ---------- Layout and banners ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; transition: transform 0.5s var(--spring), filter 0.5s var(--spring); }
.banner { margin: 16px 0 0; padding: 12px 16px; border-radius: var(--radius-s); background: var(--surface); color: var(--text-2); font-size: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.banner strong { color: var(--amber); font-weight: 600; }
#demo-banner { display: block; }
.banner--install span { flex: 1 1 220px; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 68px 0 44px; }
.eyebrow { margin: 0 0 10px; color: var(--text-2); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.hero h1 {
  margin: 0; font-size: clamp(44px, 7vw, 80px); line-height: 1.05; font-weight: 700; letter-spacing: -0.035em;
  background: linear-gradient(180deg, var(--text) 30%, color-mix(in srgb, var(--text) 60%, transparent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  will-change: transform, opacity;
}
.meta { margin-top: 20px; display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--text-2); font-size: 14px; letter-spacing: -0.01em; }
.dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--text-3); }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 980px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500; }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.chip[data-tone="green"] i { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent); }
.chip[data-tone="amber"] i { background: var(--amber); }
.chip[data-tone="red"] i { background: var(--red); }
.chip[data-tone="blue"] i { background: var(--accent); animation: pulse 1.2s var(--ease) infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.hero-actions { margin-top: 30px; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.update-status { min-height: 22px; margin: 14px auto 0; max-width: 480px; color: var(--text-2); font-size: 14px; }

/* ---------- Top 3 ---------- */
.label-row { display: flex; align-items: baseline; gap: 12px; margin: 0 0 14px 4px; }
.label { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.025em; }
.label-note { color: var(--text-2); font-size: 15px; }
.top3 { list-style: none; margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; counter-reset: t; }
.top3 li { counter-increment: t; min-width: 0; }
.top3-card {
  position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; gap: 10px;
  padding: 26px; border-radius: var(--radius-l); background: var(--surface); box-shadow: var(--shadow);
  transition: transform 0.4s var(--spring), background 0.2s;
}
.top3-card:hover { transform: translateY(-3px); }
.top3-card:active { transform: scale(0.985); }
.top3-card::before {
  content: counter(t); font-size: 56px; line-height: 0.9; font-weight: 700; letter-spacing: -0.05em;
  background: linear-gradient(160deg, var(--c, var(--accent)), color-mix(in srgb, var(--c, var(--accent)) 35%, transparent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.top3-title { font-size: 21px; font-weight: 700; line-height: 1.22; letter-spacing: -0.022em; }
.top3-sum { color: var(--text-2); font-size: 15px; line-height: 1.42; }
.src { margin-top: auto; padding-top: 6px; color: var(--text-3); font-size: 12px; font-weight: 500; letter-spacing: 0; }
.src b { color: var(--text-2); font-weight: 600; }

/* ---------- Snapshot cards ---------- */
.card { background: var(--surface); border-radius: var(--radius-l); padding: 28px; box-shadow: var(--shadow); min-width: 0; }
.card-kicker { margin: 0 0 12px; color: var(--text-2); font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.card-kicker--sm { margin: 22px 0 6px; font-size: 13px; }
.snapshot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card--lead { grid-column: 1 / -1; padding: 34px; }
.lead-summary { margin: 0; font-size: 22px; line-height: 1.36; font-weight: 600; letter-spacing: -0.02em; max-width: 880px; }
.also { list-style: none; margin: 0; padding: 0; }
.also li { border-top: 1px solid var(--hairline); }
.also button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 13px 0; font-size: 16px; font-weight: 500; }
.also button span { flex: 1; }
.also svg { width: 16px; height: 16px; color: var(--text-3); }
.risk-list, .watch-list { list-style: none; margin: 0; padding: 0; }
.risk-list li { padding: 13px 0; border-top: 1px solid var(--hairline); }
.risk-list li:first-child { border-top: 0; padding-top: 2px; }
.risk-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.risk-area { font-weight: 600; font-size: 16px; }
.level { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.level[data-level="severe"], .level[data-level="high"] { color: var(--red); }
.level[data-level="elevated"] { color: var(--amber); }
.level[data-level="guarded"] { color: var(--accent); }
.level[data-level="low"] { color: var(--green); }
.risk-basis { margin: 4px 0 0; color: var(--text-2); font-size: 14px; line-height: 1.43; }
.risk-basis a { white-space: nowrap; font-size: 12px; }
.watch-list { counter-reset: w; }
.watch-list li { counter-increment: w; display: flex; gap: 14px; padding: 13px 0; border-top: 1px solid var(--hairline); font-size: 16px; line-height: 1.38; }
.watch-list li:first-child { border-top: 0; padding-top: 2px; }
.watch-list li::before { content: counter(w); flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); font-size: 13px; font-weight: 600; }

/* ---------- Sections ---------- */
.section-head { padding: 88px 0 22px; text-align: center; }
.section-head h2 { margin: 0; font-size: clamp(32px, 4.4vw, 48px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.08; }
.section-head p { margin: 8px 0 0; color: var(--text-2); font-size: 19px; letter-spacing: -0.015em; }
.section-head--sm { padding-top: 72px; }
.section-head--sm h2 { font-size: clamp(26px, 3.2vw, 34px); }

/* ---------- Topic tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 14px; width: 100%; min-width: 0;
  padding: 24px; border-radius: var(--radius-l); background: var(--surface); box-shadow: var(--shadow); overflow: hidden;
  transition: transform 0.45s var(--spring);
}
.tile::after { content: ""; position: absolute; inset: 0 0 auto; height: 120px; background: radial-gradient(120% 100% at 0% 0%, color-mix(in srgb, var(--c) 16%, transparent), transparent 70%); pointer-events: none; }
.tile:hover { transform: translateY(-3px); }
.tile:active { transform: scale(0.98); }
.tile-top { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.app-icon {
  width: 44px; height: 44px; border-radius: 11px; flex: none; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--c), color-mix(in srgb, var(--c) 55%, #000)); color: #fff;
  font-size: 15px; font-weight: 700; letter-spacing: 0; box-shadow: 0 4px 14px color-mix(in srgb, var(--c) 30%, transparent);
}
.app-icon--lg { width: 64px; height: 64px; border-radius: 15px; font-size: 21px; }
.tile-name { flex: 1; min-width: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.tile-count { color: var(--text-2); font-size: 13px; font-weight: 600; white-space: nowrap; }
.tile-heads { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; position: relative; z-index: 1; }
.tile-heads li { display: grid; gap: 5px; }
.tile-heads .h { font-size: 15px; font-weight: 600; line-height: 1.32; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-heads .empty { color: var(--text-3); font-size: 15px; }
.tile-more { margin-top: auto; display: flex; align-items: center; gap: 4px; color: var(--accent); font-size: 14px; font-weight: 500; position: relative; z-index: 1; }
.tile-more svg { width: 14px; height: 14px; }

/* ---------- Additional reading ---------- */
.reading { list-style: none; margin: 0; padding: 6px 28px; background: var(--surface); border-radius: var(--radius-l); box-shadow: var(--shadow); }
.reading li { padding: 18px 0; border-top: 1px solid var(--hairline); }
.reading li:first-child { border-top: 0; }
.reading a.r-title { color: var(--text); font-size: 17px; font-weight: 600; line-height: 1.3; }
.reading p { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }
.reading .src { padding-top: 6px; }

.foot { padding: 64px 0 calc(48px + env(safe-area-inset-bottom)); text-align: center; color: var(--text-3); font-size: 12px; }
.foot p { margin: 4px 0; }

/* ---------- Scroll reveal ---------- */
[data-reveal] { opacity: 0; transform: translateY(28px) scale(0.985); transition: opacity 0.8s var(--ease), transform 0.9s var(--spring); transition-delay: var(--d, 0s); }
[data-reveal].is-in { opacity: 1; transform: none; }

/* ---------- Pushed pages (app-style navigation) ---------- */
.stack { position: fixed; inset: 0; z-index: 55; pointer-events: none; }
.stack.has-pages { pointer-events: auto; }
.stack-backdrop { position: absolute; inset: 0; background: var(--backdrop); opacity: 0; transition: opacity 0.45s var(--ease); }
.stack.has-pages .stack-backdrop { opacity: 1; }
.stack-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(760px, 100%); overflow: hidden; }
.page {
  position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg);
  transform: translateX(100%); transition: transform 0.55s var(--spring), filter 0.55s var(--spring);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.35); will-change: transform;
}
.page.is-in { transform: none; }
.page.is-under { transform: translateX(-22%); filter: brightness(0.7); }
.page.is-dragging { transition: none; }
.page-bar {
  position: relative; z-index: 2; flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  height: calc(var(--nav-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0;
  background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent; transition: border-color 0.3s;
}
.page.is-scrolled .page-bar { border-bottom-color: var(--hairline); }
.back { justify-self: start; display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-size: 17px; padding: 6px 4px; max-width: 100%; }
.back svg { width: 22px; height: 22px; stroke-width: 2.2; }
.back span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-bar-title { font-size: 17px; font-weight: 600; opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.3s var(--spring); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.page.is-scrolled .page-bar-title { opacity: 1; transform: none; }
.page-actions { justify-self: end; display: flex; gap: 4px; }
.page-actions .icon-btn { color: var(--accent); }
.page-actions .aa { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.page-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 8px 28px calc(110px + env(safe-area-inset-bottom)); }
.page-head { display: flex; align-items: center; gap: 16px; margin: 10px 0 8px; }
.page-title { margin: 0; font-size: 36px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.page-sub { margin: 4px 0 0; color: var(--text-2); font-size: 15px; }
.focus-head { display: flex; align-items: baseline; gap: 10px; margin: 30px 0 10px; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.focus-head .n { color: var(--text-3); font-size: 15px; font-weight: 600; }
.focus-head i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); align-self: center; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.story-card { width: 100%; display: grid; gap: 8px; padding: 20px; border-radius: var(--radius-m); background: var(--surface); box-shadow: var(--shadow); transition: transform 0.35s var(--spring), background 0.2s; }
.story-card:hover { background: var(--surface-2); }
.story-card:active { transform: scale(0.985); }
.story-card .t { font-size: 19px; font-weight: 700; line-height: 1.25; letter-spacing: -0.02em; }
.story-card .s { color: var(--text-2); font-size: 15px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.story-card .w { font-size: 15px; line-height: 1.45; }
.story-card .w b { font-weight: 700; }
.story-card .src { padding-top: 2px; display: flex; align-items: center; gap: 6px; }
.story-card .src svg { width: 14px; height: 14px; margin-left: auto; color: var(--text-3); }
.empty-card { padding: 18px 20px; border-radius: var(--radius-m); border: 1px dashed var(--hairline); color: var(--text-2); font-size: 15px; }

/* Reader (Apple Books style themes) */
.page--story { background: var(--rbg, var(--bg)); color: var(--rtext, var(--text)); }
.page--story .page-scroll { padding-left: 0; padding-right: 0; }
.reader { max-width: 660px; margin: 0 auto; padding: 8px 28px 0; font-family: var(--read-font); font-size: var(--read-size); }
.reader-kicker { margin: 8px 0 12px; font-family: var(--font); font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--c); }
.reader-title { margin: 12px 0 10px; font-size: 1.75em; line-height: 1.16; font-weight: 700; letter-spacing: -0.025em; }
.reader-meta { margin: 0; font-family: var(--font); font-size: 13px; color: var(--rtext2, var(--text-2)); }
.reader-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0 26px; font-family: var(--font); }
.reader-lead { margin: 0 0 24px; font-size: 1.12em; line-height: 1.5; font-weight: 500; }
.reader-block { margin: 0 0 22px; padding: 18px 20px; border-radius: var(--radius-m); background: var(--rsurface, var(--surface)); }
.reader-block h3 { margin: 0 0 6px; font-family: var(--font); font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--rtext2, var(--text-2)); }
.reader-block p { margin: 0; line-height: 1.6; }
.reader-more { margin: 36px 0 0; font-family: var(--font); }
.reader-more h3 { font-size: 20px; margin: 0 0 12px; letter-spacing: -0.02em; }
.reader-more .story-card { background: var(--rsurface, var(--surface)); color: inherit; }
[data-read-theme="bold"] .reader { font-weight: 600; }
[data-read-theme="bold"] .reader-lead { font-weight: 700; }
[data-read-theme="quiet"] .page--story { --rbg: #4a4a4d; --rtext: #e8e8ea; --rtext2: #b9b9bd; --rsurface: #57575b; }
[data-read-theme="paper"] .page--story { --rbg: #fbf7ef; --rtext: #2b2b2b; --rtext2: #6b665d; --rsurface: #f1ebdf; }
[data-read-theme="calm"] .page--story { --rbg: #eadfc8; --rtext: #44392b; --rtext2: #7a6b55; --rsurface: #e0d3b8; }
[data-read-theme="focus"] .page--story { --rbg: #1b1a17; --rtext: #ece4cf; --rtext2: #a39b86; --rsurface: #27251f; }
[data-read-theme="paper"] .page--story .page-bar, [data-read-theme="calm"] .page--story .page-bar { background: color-mix(in srgb, var(--rbg) 82%, transparent); color: var(--rtext); }
[data-read-theme="quiet"] .page--story .page-bar, [data-read-theme="focus"] .page--story .page-bar { background: color-mix(in srgb, var(--rbg) 82%, transparent); color: var(--rtext); }

/* Reading settings sheet */
.reading-settings { padding: 8px 20px 26px; display: grid; gap: 18px; }
.size-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: var(--radius-s); padding: 6px 8px; }
.size-btn { width: 52px; height: 40px; display: grid; place-items: center; border-radius: 10px; font-weight: 600; }
.size-btn:hover { background: var(--surface-2); }
.size-dots { flex: 1; display: flex; justify-content: center; gap: 10px; }
.size-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-3); transition: background 0.2s, transform 0.3s var(--spring); }
.size-dots i.on { background: var(--accent); transform: scale(1.25); }
.font-list { display: grid; background: var(--surface); border-radius: var(--radius-s); overflow: hidden; }
.font-list button { display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; border-top: 1px solid var(--hairline); font-size: 17px; }
.font-list button:first-child { border-top: 0; }
.font-list button[aria-checked="true"]::after { content: "\2713"; color: var(--accent); font-weight: 700; }
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-grid button { display: grid; justify-items: center; gap: 6px; padding: 14px 6px 10px; border-radius: var(--radius-s); background: var(--tb); color: var(--tt); border: 2px solid transparent; font-size: 13px; font-weight: 500; transition: border-color 0.2s, transform 0.3s var(--spring); }
.theme-grid button b { font-size: 24px; font-weight: 600; font-family: ui-serif, Georgia, serif; }
.theme-grid button[aria-checked="true"] { border-color: var(--accent); }
.theme-grid button:active { transform: scale(0.96); }

/* ---------- Mini player ---------- */
.player {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 70; transform: translateX(-50%);
  width: min(560px, calc(100% - 24px)); display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 10px;
  border-radius: 20px; background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid var(--hairline); box-shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
  animation: rise 0.5s var(--spring);
}
@keyframes rise { from { transform: translate(-50%, 30px); opacity: 0; } }
.player-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--text); }
.player-btn:hover { background: var(--surface-2); }
.player-btn svg { width: 20px; height: 20px; }
#player-toggle { background: var(--accent); color: #fff; }
#player-toggle .i-play { display: none; }
.player.is-paused #player-toggle .i-play { display: block; }
.player.is-paused #player-toggle .i-pause { display: none; }
.player-text { flex: 1; min-width: 0; display: grid; padding: 0 6px; }
.player-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-sub { font-size: 12px; color: var(--text-2); }
.player-rate { min-width: 40px; height: 30px; padding: 0 8px; border-radius: 8px; background: var(--surface-2); font-size: 13px; font-weight: 700; text-align: center; }

/* ---------- Tab bar (mobile only) ---------- */
.tabbar { display: none; }

/* ---------- Sheets ---------- */
.sheet { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-start; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: var(--backdrop); opacity: 0; transition: opacity 0.3s var(--ease); }
.sheet-panel {
  position: relative; width: min(620px, calc(100% - 32px)); max-height: min(80vh, 760px); margin-top: 10vh;
  background: var(--bg); border: 1px solid var(--hairline); border-radius: var(--radius-l); overflow: auto;
  box-shadow: 0 30px 80px rgba(0,0,0,0.35);
  opacity: 0; transform: translateY(16px) scale(0.98); transition: opacity 0.3s var(--ease), transform 0.45s var(--spring);
  overscroll-behavior: contain;
}
.sheet--compact .sheet-panel { width: min(420px, calc(100% - 32px)); }
.sheet.is-visible .sheet-backdrop { opacity: 1; }
.sheet.is-visible .sheet-panel { opacity: 1; transform: none; }
.sheet-bar { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 12px; padding: 16px 20px; background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.sheet-bar h2 { flex: 1; margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.search-field { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); }
.search-field svg { width: 17px; height: 17px; }
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); font: 17px var(--font); letter-spacing: -0.02em; }
.results { list-style: none; margin: 0; padding: 4px 20px 24px; }
.results li { border-top: 1px solid var(--hairline); }
.results li:first-child { border-top: 0; }
.results button { width: 100%; padding: 14px 0; display: grid; gap: 3px; }
.results .r-cat { color: var(--accent); font-size: 12px; font-weight: 600; }
.results .r-t { font-size: 17px; font-weight: 600; line-height: 1.3; }
.results .r-s { color: var(--text-2); font-size: 14px; }
.results .r-empty { padding: 28px 0; color: var(--text-2); text-align: center; border: 0; }
mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; border-radius: 3px; }

.settings { padding: 4px 20px 28px; }
.group-label { margin: 22px 0 8px 16px; color: var(--text-2); font-size: 13px; text-transform: uppercase; letter-spacing: 0.02em; }
.group { background: var(--surface); border-radius: var(--radius-s); overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; min-height: 48px; padding: 8px 16px; border-top: 1px solid var(--hairline); font-size: 16px; }
.group > .row:first-child { border-top: 0; }
.row--link:hover { background: var(--surface-2); }
.row-note { margin: 0; padding: 12px 16px; color: var(--text-2); font-size: 13px; line-height: 1.45; border-top: 1px solid var(--hairline); }
.group > .row-note:first-child { border-top: 0; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 2px; }
.segmented button { padding: 5px 14px; border-radius: 7px; font-size: 13px; font-weight: 500; color: var(--text-2); transition: background 0.2s, color 0.2s; }
.segmented button[aria-checked="true"] { background: var(--bg); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.15); }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 980px; background: var(--surface-2); transition: background 0.25s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.25); transition: transform 0.3s var(--spring); }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:disabled + i { opacity: 0.5; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); z-index: 90; transform: translate(-50%, 20px); opacity: 0;
  max-width: calc(100% - 40px); padding: 12px 20px; border-radius: 980px;
  background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--hairline); color: var(--text); font-size: 14px; font-weight: 500; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25); transition: opacity 0.3s var(--ease), transform 0.45s var(--spring);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
body.has-player .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }

/* ---------- Tablet ---------- */
@media (max-width: 1068px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top3-card { padding: 22px; }
  .top3-title { font-size: 19px; }
}

/* ---------- Mobile: a dedicated layout ---------- */
@media (max-width: 734px) {
  body { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  .hide-mobile, .nav-links { display: none; }
  .nav-inner { padding: 0 16px; gap: 12px; }
  main { padding: 0 16px; }
  body.has-stack main { transform: translateX(-18%); filter: brightness(0.7); }

  body[data-tab="today"] .view:not([data-view="today"]),
  body[data-tab="topics"] .view:not([data-view="topics"]) { display: none; }

  .hero { text-align: left; padding: 26px 4px 22px; }
  .eyebrow { font-size: 15px; margin-bottom: 6px; }
  .hero h1 { font-size: 42px; letter-spacing: -0.03em; }
  .meta { justify-content: flex-start; margin-top: 14px; gap: 8px; font-size: 13px; }
  .hero-actions { margin-top: 22px; display: grid; grid-template-columns: 1fr auto; gap: 10px; }
  .update-btn--hero { width: 100%; height: 52px; min-width: 0; }
  .ghost-btn { height: 52px; padding: 0 20px; }
  .update-status { margin-left: 0; text-align: left; font-size: 13px; }

  .label-row { margin-left: 4px; }
  .label { font-size: 24px; }
  .label-note { display: none; }
  .top3 { grid-template-columns: 1fr; gap: 10px; }
  .top3-card { flex-direction: row; flex-wrap: wrap; align-items: flex-start; gap: 6px 14px; padding: 18px; border-radius: 22px; }
  .top3-card::before { font-size: 40px; width: 28px; }
  .top3-body { flex: 1; min-width: 0; display: grid; gap: 6px; }
  .top3-title { font-size: 18px; }
  .top3-sum { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

  .snapshot { grid-template-columns: 1fr; gap: 10px; }
  .card, .card--lead { padding: 20px; border-radius: 22px; }
  .lead-summary { font-size: 18px; line-height: 1.4; }

  .section-head { text-align: left; padding: 26px 4px 14px; }
  .section-head h2 { font-size: 34px; }
  .section-head p { font-size: 15px; }
  .section-head--sm { padding-top: 36px; }
  .section-head--sm h2 { font-size: 26px; }

  .tiles { grid-template-columns: 1fr; gap: 10px; }
  .tile { padding: 18px; border-radius: 22px; gap: 12px; }
  .tile-name { font-size: 19px; }
  .tile-heads li:nth-child(n+2) { display: none; }
  .reading { padding: 4px 20px; border-radius: 22px; }
  .foot { padding-top: 36px; padding-bottom: 28px; }

  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom);
    background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--hairline);
  }
  .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-3); font-size: 10px; font-weight: 500; letter-spacing: 0; transition: color 0.2s; }
  .tabbar button.is-active { color: var(--accent); }
  .tabbar svg { width: 24px; height: 24px; }

  .stack-panel { width: 100%; }
  .stack-backdrop { display: none; }
  .page { box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3); }
  .page-scroll { padding: 4px 16px calc(110px + env(safe-area-inset-bottom)); }
  .page-title { font-size: 32px; }
  .story-card { padding: 18px; }
  .story-card .t { font-size: 18px; }
  .reader { padding: 4px 20px 0; }

  .player { bottom: calc(var(--tab-h) + 10px + env(safe-area-inset-bottom)); }
  body.has-stack .player { bottom: calc(14px + env(safe-area-inset-bottom)); }

  .sheet { align-items: flex-end; }
  .sheet-panel, .sheet--compact .sheet-panel {
    width: 100%; max-height: calc(100% - env(safe-area-inset-top) - 24px); margin: 0;
    border-radius: 22px 22px 0 0; border-width: 1px 0 0; padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(100%); opacity: 1;
  }
  #sheet-search .sheet-panel { height: calc(100% - env(safe-area-inset-top) - 24px); }
  .sheet-panel::before { content: ""; display: block; width: 36px; height: 5px; border-radius: 3px; background: var(--text-3); opacity: 0.5; margin: 8px auto 0; }
  .sheet-bar { padding: 10px 16px 12px; }
  .results, .settings { padding-left: 16px; padding-right: 16px; }
  .toast { bottom: calc(var(--tab-h) + 14px + env(safe-area-inset-bottom)); }
  body.has-player .toast { bottom: calc(var(--tab-h) + 86px + env(safe-area-inset-bottom)); }
}

@media (min-width: 735px) {
  .page { border-radius: 0; }
  .top3-body { display: contents; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  [data-reveal] { opacity: 1; transform: none; }
}

/* Reader theme fixes */
.reader .tags, .reader .tag { font-family: var(--font); }
.page--story .pill-btn--soft { background: var(--rsurface, var(--surface-2)); color: var(--rtext, var(--text)); }
