:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --surface-2: #efece3;
  --text: #16202e;
  --muted: #5d6673;
  --line: #e2ddd0;
  --navy: #0b1f3a;
  --navy-ink: #ffffff;
  --gold: #c9961f;
  --gold-soft: #f3e3b7;
  --link: #0b4a8b;
  --shadow: 0 1px 2px rgba(11, 31, 58, .06), 0 6px 18px rgba(11, 31, 58, .06);
  --radius: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
}
:root[data-theme="dark"] {
  --bg: #0a1322;
  --surface: #111c2e;
  --surface-2: #182640;
  --text: #e9edf3;
  --muted: #9aa6b8;
  --line: #243653;
  --navy: #06101e;
  --gold: #e8b84a;
  --gold-soft: #3a2f12;
  --link: #8fc1ff;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1322;
    --surface: #111c2e;
    --surface-2: #182640;
    --text: #e9edf3;
    --muted: #9aa6b8;
    --line: #243653;
    --navy: #06101e;
    --gold: #e8b84a;
    --gold-soft: #3a2f12;
    --link: #8fc1ff;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.wrap { width: min(1200px, 100% - 32px); margin-inline: auto; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--gold); color: #000; padding: 8px 12px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }

/* Masthead */
.masthead { background: var(--navy); color: var(--navy-ink); position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
.masthead__row { display: flex; align-items: center; gap: 16px; padding: 12px 0; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand__mark { width: 40px; height: 40px; flex: none; stroke: none; }
.brand__text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand__name { font-family: var(--serif); font-weight: 700; font-size: 1.35rem; letter-spacing: .01em; }
.brand__tag { font-size: .78rem; color: #c8d2e2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.masthead__tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search { display: flex; align-items: center; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); border-radius: 999px; padding: 2px 4px 2px 14px; }
.search:focus-within { background: rgba(255,255,255,.16); border-color: var(--gold); }
.search input { background: transparent; border: 0; color: inherit; font: inherit; width: clamp(120px, 24vw, 260px); outline: none; }
.search input::placeholder { color: #aab6c9; }
.search button, .icon-btn { background: transparent; border: 0; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; position: relative; color: inherit; }
.search button:hover, .icon-btn:hover { background: rgba(255,255,255,.14); }
.icon-btn svg, .search svg { width: 20px; height: 20px; }
.icon-btn[aria-pressed="true"] svg path { fill: var(--gold); stroke: var(--gold); }
.badge { position: absolute; top: 2px; right: 0; background: var(--gold); color: #000; font-size: .66rem; font-weight: 700; border-radius: 999px; padding: 0 5px; line-height: 1.5; }
#themeBtn .moon { display: none; }
:root[data-theme="dark"] #themeBtn .sun { display: none; }
:root[data-theme="dark"] #themeBtn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #themeBtn .sun { display: none; }
  :root:not([data-theme="light"]) #themeBtn .moon { display: block; }
}

/* Category nav */
.cats { background: var(--navy); border-top: 1px solid rgba(255,255,255,.1); }
.cats__row { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 6px 0; }
.cats__row::-webkit-scrollbar { display: none; }
.cat { flex: none; background: transparent; border: 0; color: #d6deeb; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: .92rem; }
.cat:hover { background: rgba(255,255,255,.1); }
.cat[aria-current="true"] { background: var(--gold); color: #0b1f3a; }

/* Toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0 10px; flex-wrap: wrap; }
.status { margin: 0; color: var(--muted); font-size: .9rem; }
.toolbar__right { display: flex; gap: 8px; }
.select select { appearance: none; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 32px 7px 12px; font: inherit; font-size: .9rem; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; max-width: 200px; }

/* Hero */
.hero { display: grid; gap: 16px; grid-template-columns: 1.6fr 1fr; margin-bottom: 20px; }
.hero .card { margin: 0; }
.hero .lead { grid-row: span 3; }
.hero .lead .card__media { aspect-ratio: 16 / 9; }
.hero .lead .card__title { font-size: clamp(1.35rem, 2.4vw, 1.9rem); }
.hero .lead .card__summary { display: -webkit-box; -webkit-line-clamp: 4; }
.hero .side { display: grid; grid-template-columns: 112px minmax(0, 1fr); }
.hero .side .card__media { aspect-ratio: auto; height: 100%; min-height: 112px; width: 100%; }
.hero .side .card__summary { display: none; }
.hero .side .card__title { font-size: 1rem; }
.hero .side .save { top: auto; bottom: 8px; }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.grid--grouped { display: block; }
.group { margin-bottom: 28px; }
.group__head { display: flex; align-items: baseline; gap: 10px; border-bottom: 2px solid var(--gold); padding-bottom: 6px; margin: 0 0 14px; }
.group__head h2 { margin: 0; font-family: var(--serif); font-size: 1.25rem; }
.group__head a { color: var(--muted); font-size: .85rem; }
.group .grid { margin: 0; }
.card { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; }
.card:hover { transform: translateY(-2px); }
.card__media { display: block; aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden; }
.card__media img { width: 100%; height: 100%; object-fit: cover; }
.card--noimg .card__media { display: none; }
.card__body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card__meta { display: flex; gap: 6px; align-items: center; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.card__source { color: var(--gold); filter: saturate(1.1) brightness(.85); }
:root[data-theme="dark"] .card__source { filter: none; }
.dot { opacity: .6; }
.card__title { margin: 0; font-family: var(--serif); font-size: 1.1rem; line-height: 1.3; font-weight: 700; padding-right: 28px; }
.card__title a:hover { color: var(--link); }
.card__summary { margin: 0; color: var(--muted); font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.save { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0,0,0,.35); color: #fff; display: grid; place-items: center; opacity: 0; transition: opacity .15s; }
.save svg { width: 16px; height: 16px; }
.card:hover .save, .save:focus-visible, .save[aria-pressed="true"] { opacity: 1; }
.save[aria-pressed="true"] { background: var(--gold); color: #0b1f3a; }
.save[aria-pressed="true"] svg path { fill: currentColor; }
.card--noimg .save { background: var(--surface-2); color: var(--text); }

mark { background: var(--gold-soft); color: inherit; border-radius: 2px; padding: 0 1px; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }
.more { display: flex; justify-content: center; padding: 28px 0 8px; }
.btn { background: var(--navy); color: #fff; border: 0; border-radius: 999px; padding: 10px 28px; font-weight: 600; }
.btn:hover { background: #163a6a; }
:root[data-theme="dark"] .btn { background: var(--gold); color: #0b1f3a; }

.footer { margin-top: 48px; border-top: 1px solid var(--line); background: var(--surface); }
.footer__row { padding: 24px 0; color: var(--muted); font-size: .88rem; display: flex; gap: 24px; justify-content: space-between; flex-wrap: wrap; }
.footer p { margin: 0; max-width: 70ch; }
.footer__meta { text-align: right; }

/* Skeleton */
.skeleton .card__media { background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skeleton .card__title, .skeleton .card__summary, .skeleton .card__meta { height: 1em; background: var(--surface-2); border-radius: 4px; color: transparent; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; }
  .hero .lead { grid-row: auto; }
  .brand__tag { display: none; }
}
@media (max-width: 600px) {
  .wrap { width: min(1200px, 100% - 24px); }
  .masthead__row { gap: 8px; }
  .brand__name { font-size: 1.1rem; }
  .search input { width: 0; padding: 0; }
  .search { padding-left: 4px; }
  .search:focus-within input, .search.open input { width: 46vw; padding-left: 8px; }
  .hero .side { grid-template-columns: 96px 1fr; }
  .footer__meta { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .save { transition: none; }
  .skeleton .card__media { animation: none; }
}

/* Kinds: news | article | video | social */
.card__kind { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 999px; font-size: .68rem; background: var(--surface-2); color: var(--muted); margin-right: 4px; }
.card--video .card__kind { background: #fde8e8; color: #b42318; }
.card--social .card__kind { background: #e5f0ff; color: #1d4ed8; }
.card--article .card__kind { background: var(--gold-soft); color: #7a5a0e; }
:root[data-theme="dark"] .card--video .card__kind { background: #4a1d1d; color: #fca5a5; }
:root[data-theme="dark"] .card--social .card__kind { background: #1e2f55; color: #93c5fd; }
:root[data-theme="dark"] .card--article .card__kind { color: var(--gold); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card--video .card__kind { background: #4a1d1d; color: #fca5a5; }
  :root:not([data-theme="light"]) .card--social .card__kind { background: #1e2f55; color: #93c5fd; }
  :root:not([data-theme="light"]) .card--article .card__kind { color: var(--gold); }
}
.play { display: none; position: absolute; inset: 0; margin: auto; width: 52px; height: 52px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; place-items: center; pointer-events: none; }
.play svg { width: 24px; height: 24px; fill: currentColor; stroke: none; margin-left: 3px; }
.card--video .card__media { position: relative; }
.card--video .card__media .play { display: grid; }
.card--video:hover .play { background: #e53e3e; }
.card--social .card__title { font-family: var(--font); font-weight: 500; font-size: 1rem; line-height: 1.45; }
.card--social .card__title::before { content: "“"; color: var(--gold); font-family: var(--serif); font-size: 1.4em; line-height: 0; margin-right: 2px; }
.card--social .card__title::after { content: "”"; color: var(--gold); font-family: var(--serif); font-size: 1.4em; line-height: 0; margin-left: 2px; }
.card--social.card--noimg { border-left: 3px solid #3b82f6; }
.card__author { font-weight: 400; text-transform: none; letter-spacing: 0; }
.footer__verse { font-family: var(--serif); font-style: italic; color: var(--text); margin-bottom: 8px !important; }

/* Layout fixes: cards without an image, and meta wrapping */
.card__meta { flex-wrap: wrap; row-gap: 2px; min-width: 0; }
.card__time, .card__author, .card__kind { white-space: nowrap; }
.card__source { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.hero .side.card--noimg { grid-template-columns: 1fr; }
.hero .lead.card--noimg .card__body { justify-content: center; }

/* My Feed */
.cat--mine { display: inline-flex; align-items: center; gap: 6px; }
.cat--mine svg { width: 15px; height: 15px; }
.cat--mine[aria-current="true"] svg path { fill: currentColor; }
.btn--small { padding: 7px 14px; font-size: .9rem; display: inline-flex; align-items: center; gap: 6px; }
.btn--small svg { width: 16px; height: 16px; }
.setup { text-align: center; max-width: 520px; margin: 40px auto; padding: 36px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.setup__icon { width: 56px; height: 56px; stroke: none; margin: 0 auto 8px; }
.setup h2 { font-family: var(--serif); margin: 0 0 8px; }
.setup p { color: var(--muted); margin: 0 0 20px; }
.picker { border: 0; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); max-height: min(85vh, 760px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.picker::backdrop { background: rgba(5, 12, 24, .55); backdrop-filter: blur(2px); }
.picker__form { display: flex; flex-direction: column; max-height: min(85vh, 760px); }
.picker__head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.picker__head h2 { margin: 0; font-family: var(--serif); font-size: 1.2rem; flex: 1; }
.picker__count { margin: 0; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.icon-btn--plain { color: var(--muted); }
.icon-btn--plain:hover { background: var(--surface-2); color: var(--text); }
.picker__tools { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.picker__tools input { flex: 1; min-width: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
.link { background: none; border: 0; color: var(--link); padding: 4px 2px; font-size: .9rem; }
.link:hover { text-decoration: underline; }
.picker__list { overflow-y: auto; padding: 8px 20px 16px; flex: 1; }
.pgroup { margin-top: 12px; }
.pgroup__head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 4px; }
.pgroup__head h3 { margin: 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.pgroup__head .link { font-size: .8rem; }
.pitem { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.pitem:hover { background: var(--surface-2); }
.pitem input { width: 18px; height: 18px; accent-color: var(--gold); margin: 0; flex: none; }
.pitem__name { flex: 1; }
.pitem__kind { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pitem[hidden], .pgroup[hidden] { display: none; }
.picker__foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }
.follow { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 3px 12px; font-size: .8rem; margin-left: auto; }
.follow[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #0b1f3a; }

/* PWA */
.banner { margin: 14px 0 0; padding: 10px 14px; border-radius: 8px; background: var(--gold-soft); color: var(--text); font-size: .9rem; }
.banner--update { background: var(--surface-2); }
.banner .link { padding: 0; font-weight: 600; }
@media (display-mode: standalone) {
  .masthead { padding-top: env(safe-area-inset-top); }
  .footer { padding-bottom: env(safe-area-inset-bottom); }
}

/* Picks */
.card--pick .card__kind { background: var(--navy); color: #fff; }
:root[data-theme="dark"] .card--pick .card__kind { background: var(--gold); color: #0b1f3a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .card--pick .card__kind { background: var(--gold); color: #0b1f3a; } }
.card--pinned { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), var(--shadow); }
.card__note { margin: 4px 0 0; padding: 8px 12px; border-left: 3px solid var(--gold); background: var(--gold-soft); color: var(--text); font-size: .9rem; font-style: italic; border-radius: 0 6px 6px 0; }
.card__note::before { content: "Editor's note: "; font-style: normal; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
