/* ==========================================================================
   Morning Brief: warm editorial cards and a sunrise audio player
   ========================================================================== */
:root {
  --bg: #f7f4ef;
  --bg-2: #efe9e0;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --ink: #1d1b18;
  --ink-2: #4a4640;
  --muted: #7a746b;
  --line: #e6dfd4;
  --accent: #ef5f2f;
  --accent-2: #f5a524;
  --accent-ink: #ffffff;
  --focus: #2f6fed;
  --canada: #d52b1e;
  --tech: #6a4cf5;
  --custom: #0e9f8e;
  --ok: #1a9b5b;
  --warn: #c7811a;
  --err: #d0412f;
  --hero-a: #ff7a45;
  --hero-b: #f7b733;
  --hero-c: #ff5e62;
  --hero-ink: #231710;
  --shadow-sm: 0 1px 2px rgba(40, 28, 10, .06), 0 1px 1px rgba(40, 28, 10, .04);
  --shadow: 0 10px 30px -12px rgba(60, 38, 12, .25), 0 2px 6px rgba(60, 38, 12, .06);
  --shadow-lg: 0 30px 60px -20px rgba(60, 38, 12, .35);
  --radius: 20px;
  --radius-sm: 12px;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Fraunces", Georgia, "Times New Roman", serif;
  --gutter: clamp(16px, 4vw, 32px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --bg-2: #151821; --surface: #181b23; --surface-2: #1d212b; --ink: #eeebe6; --ink-2: #c9c4bc;
    --muted: #979ca6; --line: #2a2f3a; --accent: #ff7a45; --accent-2: #ffb547; --focus: #7aa5ff;
    --canada: #ff5a4e; --tech: #9c88ff; --custom: #2fd1bd; --hero-a: #3b2a55; --hero-b: #b4542d; --hero-c: #2a2f63;
    --hero-ink: #fff4ea; --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6); --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --bg-2: #151821; --surface: #181b23; --surface-2: #1d212b; --ink: #eeebe6; --ink-2: #c9c4bc;
  --muted: #979ca6; --line: #2a2f3a; --accent: #ff7a45; --accent-2: #ffb547; --focus: #7aa5ff;
  --canada: #ff5a4e; --tech: #9c88ff; --custom: #2fd1bd; --hero-a: #3b2a55; --hero-b: #b4542d; --hero-c: #2a2f63;
  --hero-ink: #fff4ea; --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6); --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: 96px;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; flex: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 10px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 14px; border-radius: 10px; z-index: 50; }
.skip-link:focus { left: 8px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px var(--gutter);
  padding-top: max(12px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 9px; }
.brand-name { display: block; font: 700 17px/1.1 var(--font-head); letter-spacing: -.01em; }
.brand-date { display: block; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px;
  border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--ink-2);
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.icon-btn.sm { width: 36px; height: 36px; border-radius: 10px; }
.icon-btn.sm svg { width: 19px; height: 19px; }
.archive-picker select {
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--line); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a746b' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 14px;
  border-radius: 12px; padding: 9px 30px 9px 12px; font-size: 14px; font-weight: 500; max-width: 150px;
}
.archive-picker select:empty { display: none; }

main { max-width: 1180px; margin: 0 auto; padding: 18px var(--gutter) 0; }

/* ---------- Hero / player ---------- */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  border-radius: 28px;
  background: linear-gradient(135deg, var(--hero-a) 0%, var(--hero-b) 55%, var(--hero-c) 110%);
  color: var(--hero-ink);
  box-shadow: var(--shadow-lg);
}
.hero-glow {
  position: absolute; inset: -40% -10% auto auto; width: 520px; height: 520px; z-index: -1;
  background: radial-gradient(circle, rgba(255, 244, 214, .75), rgba(255, 244, 214, 0) 65%);
  animation: rise 14s ease-in-out infinite alternate;
}
:root[data-theme="dark"] .hero-glow { background: radial-gradient(circle, rgba(255, 170, 110, .35), transparent 65%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero-glow { background: radial-gradient(circle, rgba(255, 170, 110, .35), transparent 65%); } }
@keyframes rise { from { transform: translate(40px, 30px) scale(.95); } to { transform: translate(-30px, -10px) scale(1.05); } }
.hero-inner { padding: clamp(22px, 4vw, 38px); }
.hero-top { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.eyebrow { margin: 0 0 4px; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.hero-title { margin: 0; font: 600 clamp(28px, 4.6vw, 44px)/1.08 var(--font-head); letter-spacing: -.02em; max-width: 20ch; }
.hero-meta { margin: 10px 0 0; font-size: 15px; opacity: .85; }
.weather-chip {
  display: flex; align-items: center; gap: 10px; flex: none;
  background: rgba(255, 255, 255, .28); border: 1px solid rgba(255, 255, 255, .35);
  padding: 8px 14px; border-radius: 16px; backdrop-filter: blur(6px);
}
.weather-chip .temp { font: 600 24px/1 var(--font-head); }
.weather-chip small { display: block; font-size: 12px; opacity: .85; line-height: 1.3; }
:root[data-theme="dark"] .weather-chip { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .14); }

.player { margin-top: 26px; }
.player-row { display: flex; align-items: center; gap: 16px; }
.play-btn {
  width: 72px; height: 72px; border-radius: 50%; border: 0; flex: none;
  display: grid; place-items: center; background: #1d1410; color: #fff;
  box-shadow: 0 12px 26px -10px rgba(0, 0, 0, .55); transition: transform .15s ease, box-shadow .15s;
}
:root[data-theme="dark"] .play-btn { background: #fff4ea; color: #1d1410; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .play-btn { background: #fff4ea; color: #1d1410; } }
.play-btn:hover { transform: scale(1.04); }
.play-btn:active { transform: scale(.97); }
.play-btn svg { width: 30px; height: 30px; }
.play-btn .i-pause, .playing .play-btn .i-play { display: none; }
.playing .play-btn .i-pause { display: block; }
.play-btn.sm { width: 44px; height: 44px; }
.play-btn.sm svg { width: 20px; height: 20px; }
.now-playing { min-width: 0; }
.np-label { display: block; font-size: 12.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; opacity: .75; }
.np-title { display: block; font: 600 clamp(17px, 2.3vw, 21px)/1.3 var(--font-head); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.scrubber { margin-top: 20px; }
.track { position: relative; height: 26px; }
.track::before, .track-fill {
  content: ""; position: absolute; left: 0; top: 50%; height: 6px; transform: translateY(-50%); border-radius: 6px;
}
.track::before { right: 0; background: rgba(35, 23, 16, .18); }
:root[data-theme="dark"] .track::before { background: rgba(255, 255, 255, .16); }
.track-fill { width: 0; background: currentColor; }
.track-marks { position: absolute; inset: 0; pointer-events: none; }
.track-marks i { position: absolute; top: 50%; width: 3px; height: 12px; transform: translate(-50%, -50%); border-radius: 2px; background: currentColor; opacity: .4; }
.track-marks i.section { height: 16px; opacity: .75; width: 3px; }
.track input[type="range"] { position: absolute; inset: 0; width: 100%; margin: 0; opacity: 0; cursor: pointer; }
.times { display: flex; justify-content: space-between; font-size: 13px; font-variant-numeric: tabular-nums; opacity: .8; margin-top: 2px; }
.controls { display: flex; align-items: center; justify-content: center; gap: clamp(6px, 2vw, 18px); margin-top: 10px; }
.ctrl {
  display: inline-grid; place-items: center; min-width: 46px; height: 46px; padding: 0 10px; border-radius: 14px;
  border: 0; background: rgba(255, 255, 255, .22); color: inherit; transition: background .15s;
}
.ctrl:hover { background: rgba(255, 255, 255, .38); }
:root[data-theme="dark"] .ctrl { background: rgba(255, 255, 255, .08); }
.ctrl.speed { font-weight: 700; font-size: 15px; min-width: 58px; font-variant-numeric: tabular-nums; }
.ctrl svg { width: 24px; height: 24px; }

.builder { margin-top: 22px; max-width: 640px; }
.builder-copy { margin: 0 0 18px; font-size: 16.5px; opacity: .9; }
.progress { margin-top: 16px; }
.progress-bar { height: 8px; border-radius: 8px; background: rgba(35, 23, 16, .15); overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: currentColor; border-radius: inherit; transition: width .5s ease; }
.progress-label { display: block; margin-top: 8px; font-size: 14px; font-weight: 500; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 14px; border: 1px solid transparent; padding: 11px 18px; font-weight: 600; font-size: 15px;
  transition: transform .12s, background .15s, box-shadow .15s, opacity .15s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { box-shadow: var(--shadow); }
.hero .btn-primary { background: #1d1410; color: #fff; }
:root[data-theme="dark"] .hero .btn-primary { background: #fff4ea; color: #1d1410; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-lg { padding: 14px 24px; font-size: 16px; border-radius: 16px; }

/* ---------- Toolbar & tabs ---------- */
.toolbar {
  position: sticky; top: 67px; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 26px calc(var(--gutter) * -1) 0; padding: 10px var(--gutter);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 24px 2px 2px; mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  padding: 9px 15px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 14.5px; font-weight: 600; color: var(--ink-2); transition: all .15s;
}
.tab:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tab .count { font-size: 12px; font-weight: 700; opacity: .6; }
.view-toggle { display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; flex: none; }
.view-toggle [aria-pressed="true"] { background: var(--bg-2); color: var(--ink); }

/* ---------- Cards ---------- */
.cards {
  display: grid; gap: 22px; margin-top: 18px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
}
.card {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); transition: transform .2s ease, box-shadow .2s ease, border-color .2s;
  animation: card-in .45s ease both;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
@keyframes card-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card.is-playing { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent), var(--shadow); }
.card-media { position: relative; aspect-ratio: 16 / 9; background: var(--bg-2); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease; }
.card:hover .card-media img { transform: scale(1.03); }
.card-media.placeholder { display: grid; place-items: center; }
.card-media.placeholder span { font: 700 44px/1 var(--font-head); color: #fff; opacity: .9; }
.card-media.placeholder[data-section="canada"] { background: linear-gradient(135deg, #d52b1e, #ff7a59); }
.card-media.placeholder[data-section="tech"] { background: linear-gradient(135deg, #5b3cf0, #20b5e8); }
.card-media.placeholder[data-section="custom"] { background: linear-gradient(135deg, #0e9f8e, #9be15d); }
.chip {
  position: absolute; left: 12px; top: 12px; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .02em;
  background: rgba(255, 255, 255, .92); color: #1d1b18; box-shadow: var(--shadow-sm);
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dot, var(--accent)); }
.chip[data-section="canada"] { --dot: #d52b1e; }
.chip[data-section="tech"] { --dot: #6a4cf5; }
.chip[data-section="custom"] { --dot: #0e9f8e; }
.card-body { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px 16px; flex: 1; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.meta b { color: var(--ink-2); font-weight: 600; }
.meta .dot::before { content: "·"; margin-right: 6px; }
.also { color: var(--muted); border-bottom: 1px dotted currentColor; cursor: help; }
.card h3 { margin: 0; font: 600 21px/1.28 var(--font-head); letter-spacing: -.01em; text-wrap: balance; }
.card p.summary { margin: 0; color: var(--ink-2); font-size: 15.5px; line-height: 1.6; }
.card-actions { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); font-size: 14px; font-weight: 600; color: var(--ink);
  text-decoration: none; transition: background .15s, border-color .15s;
}
.pill:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--line)); }
.pill svg { width: 16px; height: 16px; }
.pill.listen { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill .dur { font-weight: 500; opacity: .7; font-variant-numeric: tabular-nums; }
.card-actions .spacer { flex: 1; }
.card-actions .icon-btn { width: 38px; height: 38px; }
.card-actions .icon-btn svg { width: 19px; height: 19px; }
.icon-btn.saved { color: var(--accent); }
.eq { display: none; gap: 2px; align-items: flex-end; height: 14px; }
.eq i { width: 3px; background: currentColor; border-radius: 2px; animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.3s; } .eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }
.card.is-playing.audio-on .pill.listen .eq { display: inline-flex; }
.card.is-playing.audio-on .pill.listen svg { display: none; }

/* Swipe layout (InShorts-style deck) */
.cards.swipe {
  display: flex; gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  margin-left: calc(var(--gutter) * -1); margin-right: calc(var(--gutter) * -1);
  padding: 6px var(--gutter) 18px; scroll-padding: 0 var(--gutter); scrollbar-width: none;
}
.cards.swipe::-webkit-scrollbar { display: none; }
.cards.swipe .card { flex: 0 0 min(88vw, 560px); scroll-snap-align: center; min-height: min(72vh, 720px); }
.cards.swipe .card:hover { transform: none; }
.cards.swipe .card h3 { font-size: clamp(22px, 3vw, 27px); }
.cards.swipe .card p.summary { font-size: 16.5px; }
.swipe-dots { display: flex; justify-content: center; gap: 6px; margin-top: 4px; }
.swipe-dots i { width: 7px; height: 7px; border-radius: 99px; background: var(--line); transition: all .2s; }
.swipe-dots i.on { width: 22px; background: var(--ink); }

.empty {
  grid-column: 1 / -1; text-align: center; padding: 48px 16px; color: var(--muted);
  border: 2px dashed var(--line); border-radius: var(--radius);
}
.empty h3 { font: 600 22px/1.3 var(--font-head); color: var(--ink); margin: 0 0 6px; }
.skeleton { background: linear-gradient(90deg, var(--bg-2), var(--surface-2), var(--bg-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius); height: 380px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.footnote { text-align: center; color: var(--muted); font-size: 13px; margin: 36px 0 12px; }

/* ---------- Mini player ---------- */
.mini-player {
  position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 30;
  width: min(560px, calc(100% - 24px)); transform: translate(-50%, 140%);
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 10px;
  background: color-mix(in srgb, var(--surface) 90%, transparent); color: var(--ink);
  border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); transition: transform .35s cubic-bezier(.2, .8, .2, 1);
}
.mini-player:not(.show) { visibility: hidden; transition: transform .35s cubic-bezier(.2, .8, .2, 1), visibility 0s .35s; }
.mini-player.show { transform: translate(-50%, 0); }
.mini-player .play-btn { background: var(--ink); color: var(--bg); box-shadow: none; }
.mini-text { flex: 1; min-width: 0; }
.mini-text span { display: block; font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-bar { height: 4px; border-radius: 4px; background: var(--line); margin-top: 7px; overflow: hidden; }
.mini-bar span { display: block; height: 100%; width: 0; background: var(--accent); }
.mini-player .ctrl { background: var(--bg-2); min-width: 42px; height: 42px; }

/* ---------- Sheets (dialogs) ---------- */
.sheet {
  width: min(640px, 100%); max-height: min(88vh, 900px); padding: 0; border: 0; border-radius: 24px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
  display: none; flex-direction: column; overflow: hidden;
}
.sheet[open] { display: flex; animation: sheet-in .28s cubic-bezier(.2, .8, .2, 1); }
.sheet::backdrop { background: rgba(15, 12, 8, .45); backdrop-filter: blur(3px); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) {
  .sheet { margin: auto 0 0; max-height: 92vh; width: 100%; max-width: 100%; border-radius: 24px 24px 0 0; }
  @keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font: 600 24px/1.2 var(--font-head); }
.sheet-body { padding: 18px 20px 24px; overflow-y: auto; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }

.field-label { display: block; font-weight: 700; font-size: 15px; margin: 0 0 4px; }
.hint { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
input[type="url"], .text-input, .time-input {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 11px 13px; font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
input[type="url"]:focus, .text-input:focus, .time-input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.segmented { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: inline-block; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.segmented input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.add-source { padding: 16px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--line); }
.preview { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); animation: sheet-in .25s ease; }
.preview .kind { display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; background: color-mix(in srgb, var(--custom) 15%, transparent); color: var(--custom); }
.preview input { width: 100%; margin: 10px 0 8px; }
.preview ul { margin: 0 0 12px; padding-left: 18px; color: var(--ink-2); font-size: 14px; }
.preview li { margin: 3px 0; }
.preview .error { color: var(--err); font-weight: 500; margin: 0; }

.source-group { margin-top: 22px; }
.source-group h3 { display: flex; align-items: center; gap: 8px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.source-row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.source-row:last-child { border-bottom: 0; }
.source-info { flex: 1; min-width: 0; }
.source-name { display: block; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-sub { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.status-dot.ok { background: var(--ok); }
.status-dot.err { background: var(--err); }
.tag { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 5px; background: var(--bg-2); color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.source-row .icon-btn { width: 36px; height: 36px; color: var(--muted); }
.source-row .icon-btn:hover { color: var(--err); }

.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.set-section + .set-section { margin-top: 26px; }
.set-label { font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }
.setting-group { padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting-group:last-child { border-bottom: 0; }
.setting-group h3, .setting-group h4 { font-weight: 700; font-size: 15px; margin: 0 0 8px; }
.setting-group .setting-row + .hint { margin: 6px 0 0 54px; }
.setting-group .hint:empty { display: none; }
.setting-row > label:not(.switch) { flex: 1; min-width: 0; }
.city-input { flex: 1; min-width: 120px; padding: 8px 12px; }
.voice-picker > summary { list-style: none; cursor: pointer; }
.voice-picker > summary::-webkit-details-marker { display: none; }
.voice-summary { display: flex; align-items: center; gap: 12px; }
.voice-summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; border-radius: 12px; }
.voice-summary .avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; background: linear-gradient(135deg, var(--hero-a), var(--hero-c)); }
.voice-summary .v-text { flex: 1; min-width: 0; }
.voice-summary .v-label { display: block; font-size: 12.5px; color: var(--muted); }
.voice-summary .v-name { display: block; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.voice-change { pointer-events: none; padding: 7px 14px; font-size: 13.5px; }
.voice-picker[open] .voice-change { visibility: hidden; }
.voice-body { margin-top: 14px; }
.voice-body h4 { margin-top: 16px; }
.how-it-works { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }
.how-it-works .limits { margin-top: 10px; }
#settingsSheet .sheet-body { flex: 1; }
@media (max-width: 640px) { .voice-grid { max-height: 230px; } }
.setting-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 15px; }
.voice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; max-height: 250px; overflow-y: auto; padding: 2px; margin: 0 -2px; overscroll-behavior: contain; }
.voice-card { position: relative; display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.voice-card:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--line)); }
.voice-card input { position: absolute; opacity: 0; }
.voice-card:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.voice-card:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.voice-card .avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; background: linear-gradient(135deg, var(--hero-a), var(--hero-c)); }
.voice-card .v-text { min-width: 0; flex: 1; }
.voice-card .v-name { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14.5px; }
.voice-card .v-meta { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; }
.voice-card .badge { font-size: 9.5px; font-weight: 700; padding: 1px 6px; border-radius: 99px; background: var(--accent); color: #fff; letter-spacing: .03em; text-transform: uppercase; }
.voice-card .preview-btn { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; flex: none; position: relative; z-index: 1; }
.voice-card .preview-btn svg { width: 14px; height: 14px; }
.voice-card .preview-btn.loading { animation: pulse 1s infinite; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip-btn { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); border-radius: 99px; padding: 5px 12px; font-size: 13px; font-weight: 600; }
.chip-btn.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.range-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.range-row input { flex: 1; accent-color: var(--accent); }
.range-row output { font-weight: 700; color: var(--ink); min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.steppers { display: grid; gap: 10px; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stepper-ctrl { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stepper-ctrl button { width: 38px; height: 36px; border: 0; background: var(--surface-2); font-size: 18px; font-weight: 600; }
.stepper-ctrl output { min-width: 36px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.advanced { margin-top: 10px; font-size: 14px; color: var(--muted); }
.advanced summary { cursor: pointer; }
.advanced .input-row { margin-top: 8px; }
#settingsProgress .progress-bar { background: var(--bg-2); }
#settingsProgress .progress-bar span { background: var(--accent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; top: 18px; z-index: 100; transform: translate(-50%, calc(-100% - 40px)); visibility: hidden;
  max-width: min(520px, calc(100% - 24px)); padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-weight: 500; font-size: 14.5px; box-shadow: var(--shadow-lg);
  transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }
.toast.error { background: var(--err); color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .brand-date { display: none; }
  .topbar-actions { gap: 2px; }
  .icon-btn { width: 38px; height: 38px; }
  .archive-picker select { max-width: 112px; padding: 8px 26px 8px 10px; font-size: 13px; }
  .hero { border-radius: 24px; margin: 0 -6px; }
  .hero-top { flex-direction: column; }
  .play-btn { width: 62px; height: 62px; }
  .controls { justify-content: space-between; }
  .toolbar { top: 63px; }
  .card h3 { font-size: 19.5px; }
  .cards.swipe .card { min-height: 66vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Signed-out landing ------------------------------------------------------- */
body.signed-out { padding-bottom: 0; }
body.signed-out > :not(.landing):not(.toast):not(svg) { display: none; }
.landing { max-width: 1080px; margin: 0 auto; padding: 0 var(--gutter) 48px; }
.landing-top { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; }
.landing-top .brand { display: flex; align-items: center; gap: 10px; }
.landing-hero {
  position: relative; overflow: hidden; isolation: isolate; border-radius: 28px;
  padding: clamp(24px, 5vw, 56px); color: var(--hero-ink); box-shadow: var(--shadow-lg);
  background: linear-gradient(135deg, var(--hero-a) 0%, var(--hero-b) 55%, var(--hero-c) 110%);
}
.landing-hero h1 { margin: 0; font: 600 clamp(32px, 6vw, 58px)/1.04 var(--font-head); letter-spacing: -.025em; max-width: 16ch; }
.landing-hero h1 em { font-style: italic; }
.landing-hero .lead { margin: 16px 0 0; font-size: clamp(16px, 2vw, 18.5px); max-width: 52ch; opacity: .9; }
.sample-player {
  margin-top: 28px; display: grid; grid-template-columns: auto 1fr; gap: 12px 16px; align-items: center; max-width: 620px;
  padding: 14px 18px 14px 14px; border-radius: 22px;
  background: rgba(255, 255, 255, .26); border: 1px solid rgba(255, 255, 255, .38); backdrop-filter: blur(8px);
}
:root[data-theme="dark"] .sample-player { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .14); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .sample-player { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .14); } }
.sample-player .play-btn { width: 64px; height: 64px; }
.sample-player .play-btn .i-pause, .sample-player.playing .play-btn .i-play { display: none; }
.sample-player.playing .play-btn .i-pause { display: block; }
.sample-player.playing .play-btn { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(255, 255, 255, .18), 0 12px 26px -10px rgba(0, 0, 0, .55); } }
.sample-player.disabled { opacity: .7; }
.sample-bar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: rgba(0, 0, 0, .12); overflow: hidden; }
.sample-bar span { display: block; height: 100%; width: 0; background: currentColor; transition: width .25s linear; }
.landing-cta { margin-top: 26px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.landing-cta .hint { margin: 0; color: inherit; opacity: .8; }
.landing-hero .btn-primary { background: #1d1410; color: #fff; border-color: transparent; }
:root[data-theme="dark"] .landing-hero .btn-primary { background: #fff4ea; color: #1d1410; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .landing-hero .btn-primary { background: #fff4ea; color: #1d1410; } }

.landing-section { margin-top: 44px; }
.landing-section h2, .landing-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.landing-heading .hint { margin: 0 0 14px; }
.sample-cards {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 300px); gap: 14px;
  overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 14px; margin: 0 -2px;
  overscroll-behavior-x: contain;
}
.sample-card {
  scroll-snap-align: start; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s, border-color .2s;
}
.sample-card .card-media { aspect-ratio: 16 / 9; }
.sample-card .card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.sample-card h3 { margin: 0; font: 600 17px/1.3 var(--font-head); }
.sample-card p { margin: 0; font-size: 14px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.sample-card .meta { font-size: 12.5px; color: var(--muted); }
.sample-card.reading { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent), var(--shadow); transform: translateY(-3px); }
.sample-card.reading .meta::after { content: " · Reading now"; color: var(--accent); font-weight: 600; }

.voice-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.voice-chip {
  display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-sm); text-align: left;
}
.voice-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--hero-a), var(--hero-c));
}
.voice-chip small { display: block; font-size: 12px; color: var(--muted); }
.voice-chip.playing { border-color: var(--accent); }
.voice-chip.playing .avatar { animation: pulse 1.6s ease-in-out infinite; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; color: var(--ink-2); font-size: 15px; }
.steps b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 6px; }

.signin {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(8px);
}
.login-card {
  position: relative; width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 32px 24px; text-align: center;
}
.login-card img { margin: 0 auto; }
.signin-close { position: absolute; top: 10px; right: 10px; }
.login-card h1 { font: 700 26px/1.2 var(--font-head); margin: 12px 0 6px; }
.btn-google { background: #fff; color: #1f1f1f; border: 1px solid #dadce0; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.btn-google:hover:not(:disabled) { background: #f8f9fa; }
.login-form { display: grid; gap: 12px; margin-top: 8px; }
.login-form .text-input { text-align: center; font-size: 17px; }
.code-input { letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.sent-waiting { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px; border-radius: 14px; background: var(--bg-2); color: var(--ink-2); font-size: 14.5px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sent-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 8px; color: var(--muted); font-size: 14px; }
.link-btn { background: none; border: 0; padding: 4px 2px; font: inherit; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.login-form a.btn { text-decoration: none; }
#showCode, #useEmail { justify-self: center; font-size: 13.5px; color: var(--muted); }
.link-btn:disabled { color: var(--muted); text-decoration: none; cursor: default; }
.signin .error { color: var(--err); font-weight: 500; margin: 12px 0 0; }

/* ---- Notices about today's briefing -------------------------------------------- */
.notice {
  margin-top: 16px; padding: 12px 14px; border-radius: var(--radius-sm); max-width: 720px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--ink);
  border-left: 4px solid var(--warn); font-size: 14.5px; box-shadow: var(--shadow-sm);
}
.notice.error { border-left-color: var(--err); }
.notice p { margin: 0; }
.notice p + p { margin-top: 6px; }

/* ---- Settings extras ------------------------------------------------------------ */
.limits { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; }
.limits li + li { margin-top: 6px; }
.account-email { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

@media (min-width: 641px) { .welcome { width: min(460px, 100%); } }
.welcome form { display: flex; flex-direction: column; min-height: 0; }
.welcome .text-input { width: 100%; }
.form-error { color: var(--err); font-weight: 500; margin: 0; min-height: 1em; }
.form-error:empty { display: none; }

/* Install the app */
.install-btn { color: var(--accent); }
.setting-row > span:first-child:not(.switch) { flex: 1; min-width: 0; }
.install-list { margin: 0; padding-left: 20px; display: grid; gap: 12px; font-size: 15px; line-height: 1.5; }
.inline-icon { width: 17px; height: 17px; vertical-align: -3px; }

/* Welcome steps */
.step-dots { display: flex; gap: 6px; }
.step-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: background .2s, width .2s; }
.step-dots span.on { width: 18px; border-radius: 99px; background: var(--accent); }
.welcome .sheet-body { overflow-y: auto; }
.source-pick { margin: 14px 0 4px; }
.source-pick h3 { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.source-pick .chip-row { margin: 0; }
.source-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 99px; border: 1.5px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); color: var(--ink); font-size: 13.5px; font-weight: 600; }
.source-chip::before { content: "✓"; font-weight: 700; color: var(--accent); }
.source-chip[aria-pressed="false"] { border-color: var(--line); background: transparent; color: var(--muted); text-decoration: line-through; }
.source-chip[aria-pressed="false"]::before { content: "+"; color: var(--muted); }
.first-brief { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: 18px; margin-bottom: 6px; background: linear-gradient(135deg, color-mix(in srgb, var(--hero-a) 22%, var(--surface)), color-mix(in srgb, var(--hero-c) 22%, var(--surface))); }
.first-brief-icon { font-size: 34px; line-height: 1; }
.first-brief-label { display: block; font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.first-brief-when { display: block; font: 600 22px/1.25 var(--font-head); margin: 2px 0 4px; }
.first-brief-what { display: block; font-size: 13.5px; color: var(--ink-2); }

/* Delete account */
.btn-danger { background: var(--err); color: #fff; }
.btn-danger[disabled] { opacity: .4; cursor: not-allowed; }
.btn-danger-ghost { background: transparent; border-color: color-mix(in srgb, var(--err) 45%, var(--line)); color: var(--err); }
.btn-danger-ghost:hover { background: color-mix(in srgb, var(--err) 8%, transparent); }
.danger-box { padding: 14px 16px; border-radius: 14px; border: 1px solid color-mix(in srgb, var(--err) 40%, var(--line)); background: color-mix(in srgb, var(--err) 8%, var(--surface)); font-size: 14.5px; margin-bottom: 14px; }
.danger-box ul { margin: 8px 0 0; padding-left: 20px; color: var(--ink-2); }
.danger-box li + li { margin-top: 4px; }
.confirm-check { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; font-weight: 600; cursor: pointer; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.confirm-check input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--err); }
#deleteStatus { margin: 12px 0 0; }
#deleteStatus:empty { display: none; }
