:root {
  --paper: #f5f0e6;
  --paper-deep: #e9dfcf;
  --card: #fffdf8;
  --ink: #17212b;
  --navy: #17324d;
  --muted: #6f716f;
  --line: #d9d0c2;
  --coral: #e76f51;
  --gold: #e9b44c;
  --teal: #3e8e7e;
  --blue: #547aa5;
  --shadow: 0 18px 50px rgba(35, 35, 31, .08);
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #151b20; --paper-deep: #20282e; --card: #1d252b; --ink: #f3eee5;
    --navy: #8fb6d8; --muted: #a9aca9; --line: #344047; --shadow: 0 18px 50px rgba(0,0,0,.22);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans);
  line-height: 1.5; -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.topbar {
  position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(18px); border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
}
.topbar-inner { height: 74px; max-width: 1440px; margin: auto; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: .75rem; }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; color: #fffaf0; background: var(--navy);
  border-radius: 11px 11px 11px 3px; font: 700 1.45rem/1 var(--serif); box-shadow: inset 0 -3px 0 rgba(0,0,0,.12);
}
.brand strong { display: block; font: 700 1.35rem/1 var(--serif); letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: .69rem; letter-spacing: .04em; text-transform: uppercase; }
.topbar-actions { display: flex; gap: .45rem; }
.icon-button { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: var(--card); color: var(--ink); cursor: pointer; }
.icon-button:hover { border-color: var(--ink); transform: translateY(-1px); }

.search-drawer { border-top: 1px solid var(--line); }
.search-inner { max-width: 780px; margin: auto; padding: 12px 24px; display: flex; gap: .8rem; align-items: center; }
.search-inner > svg { color: var(--muted); flex: 0 0 auto; }
.search-inner input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 1.05rem; }
.search-close, .text-button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: .25rem; }
.search-close:hover, .text-button:hover { color: var(--ink); }

.app-layout { max-width: 1440px; margin: auto; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.side-rail { position: sticky; top: 74px; height: calc(100vh - 74px); padding: 36px 28px; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.rail-nav { display: grid; gap: .35rem; }
.rail-nav a { display: flex; align-items: center; gap: .8rem; padding: .65rem .8rem; border-radius: 10px; color: var(--muted); font-weight: 650; }
.rail-nav a span { width: 1.2rem; text-align: center; color: var(--ink); }
.rail-nav a:hover, .rail-nav a.active { background: var(--card); color: var(--ink); box-shadow: 0 5px 20px rgba(30,30,25,.04); }
.rail-nav a.active::after { content: ""; width: 6px; height: 6px; margin-left: auto; border-radius: 50%; background: var(--coral); }
.rail-topics { margin: 2rem .8rem 0; display: grid; gap: .65rem; }
.rail-topics a { color: var(--muted); font-size: .9rem; }
.rail-topics a:hover { color: var(--ink); }
.rail-foot { margin-top: auto; color: var(--muted); font-size: .78rem; }
.collection-state { display: flex; align-items: center; gap: .45rem; }
.collection-state span { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 18%, transparent); }

#main-content { min-width: 0; width: 100%; max-width: 1120px; padding: 54px clamp(28px, 5vw, 76px) 110px; }
.page-intro { max-width: 760px; margin-bottom: 54px; }
.eyebrow { margin: 0 0 .55rem; color: var(--coral); font-size: .71rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.page-intro h1 { margin: 0; font: 700 clamp(2.6rem, 6vw, 5.2rem)/.98 var(--serif); letter-spacing: -.055em; }
.page-intro .dek { max-width: 610px; margin: 1rem 0 0; color: var(--muted); font: 400 clamp(1.05rem, 2vw, 1.3rem)/1.5 var(--serif); }
.briefing-count { margin-top: 1.25rem; color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; }
.briefing-count strong { color: var(--ink); }
.briefing-count span { margin: 0 .35rem; }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 17px; }
.section-heading h2 { margin: 0; font: 700 2rem/1 var(--serif); letter-spacing: -.035em; }
.section-heading > span, .section-heading > a { color: var(--muted); font-size: .8rem; }
.section-heading > a:hover { color: var(--coral); }
.lead-section { margin-bottom: 64px; }
.briefing-section { margin: 0 0 66px; }

.story-card {
  position: relative; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 15px;
  overflow: hidden; box-shadow: 0 4px 18px rgba(35,35,31,.035); transition: transform .2s ease, box-shadow .2s ease, opacity .25s ease;
}
.story-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.story-card.is-read { opacity: .72; }
.story-card.is-removing { transform: translateX(-18px); opacity: 0; }
.story-body { padding: 19px 20px 16px; }
.story-kicker { display: flex; align-items: center; gap: .4rem; min-width: 0; color: var(--muted); font-size: .72rem; }
.story-kicker .source { color: var(--ink); font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--coral); flex: 0 0 auto; }
.is-read .unread-dot { background: transparent; border: 1px solid var(--muted); }
.story-card h3 { margin: .65rem 0 0; font: 700 1.25rem/1.19 var(--serif); letter-spacing: -.025em; }
.story-card h3 a:hover { color: var(--coral); }
.story-summary { margin: .65rem 0 0; color: var(--muted); font-size: .88rem; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.story-footer { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: 1rem; }
.hn-context { display: flex; gap: .65rem; align-items: center; margin-top: .7rem; color: var(--muted); font-size: .76rem; }
.hn-context a { color: var(--accent); font-weight: 700; }
.category-tag { color: var(--muted); font-size: .67rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.category-tag:hover { color: var(--ink); }
.story-actions { display: flex; gap: .2rem; }
.story-actions button { display: flex; align-items: center; gap: .3rem; border: 0; border-radius: 8px; padding: .35rem .45rem; background: transparent; color: var(--muted); font-size: .7rem; cursor: pointer; }
.story-actions button:hover { background: var(--paper); color: var(--ink); }
.story-actions button[aria-pressed="true"] { color: var(--coral); }
.story-actions svg { width: 1rem; height: 1rem; }

.story-image { display: block; aspect-ratio: 16 / 8.3; background: var(--paper-deep); overflow: hidden; }
.story-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .45s ease; }
.story-card:hover .story-image img { transform: scale(1.025); }
.story-art { position: relative; display: grid; place-items: center; background: var(--navy); color: #fff9ec; isolation: isolate; }
.story-art::before, .story-art::after { content: ""; position: absolute; border-radius: 50%; z-index: -1; }
.story-art::before { width: 220px; height: 220px; background: var(--coral); left: 7%; top: -55%; }
.story-art::after { width: 150px; height: 150px; background: var(--gold); right: 9%; bottom: -55%; }
.story-art span { font: italic 700 clamp(2.4rem, 7vw, 5rem)/1 var(--serif); }
.story-lead { display: grid; grid-template-columns: minmax(240px, 1.1fr) minmax(300px, 1fr); min-height: 350px; border-radius: 19px; }
.story-lead .story-image { aspect-ratio: auto; min-height: 100%; }
.story-lead .story-body { display: flex; flex-direction: column; justify-content: center; padding: clamp(28px, 5vw, 54px); }
.story-lead h3 { font-size: clamp(2rem, 4vw, 3.25rem); line-height: 1.02; }
.story-lead .story-summary { font-size: 1rem; -webkit-line-clamp: 4; }
.story-lead .story-footer { margin-top: 1.5rem; }

.story-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.story-list { display: grid; gap: 16px; }
.story-list .story-card { display: grid; grid-template-columns: minmax(180px, 28%) 1fr; }
.story-list .story-image { height: 100%; aspect-ratio: auto; min-height: 190px; }
.story-list .story-body { padding: 22px 25px 18px; }
.story-list .story-card:not(:has(.story-image)) { display: block; }
.story-list h3 { font-size: clamp(1.3rem, 2.2vw, 1.75rem); }

.view-tools { display: flex; align-items: center; gap: .65rem; margin-top: 1.5rem; }
.view-tools label { font-size: .75rem; color: var(--muted); }
.view-tools select { border: 1px solid var(--line); border-radius: 9px; padding: .5rem 2rem .5rem .7rem; background: var(--card); color: var(--ink); }
.discovery-tools { align-items: flex-start; }
.source-filter { position: relative; }
.source-filter summary { cursor: pointer; list-style: none; border: 1px solid var(--line); border-radius: 9px; padding: .55rem .75rem; background: var(--card); font-size: .8rem; font-weight: 700; }
.source-filter summary span { margin-left: .35rem; color: var(--muted); font-weight: 500; }
.source-filter-panel { position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; width: min(330px, calc(100vw - 40px)); max-height: 360px; overflow: auto; padding: .65rem; border: 1px solid var(--line); border-radius: 12px; background: var(--card); box-shadow: var(--shadow); }
.source-filter-panel label { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .55rem; padding: .45rem .35rem; color: var(--ink); }
.source-filter-panel label small { color: var(--muted); }
.source-filter-commands { display: flex; gap: .35rem; padding: .2rem .25rem .5rem; border-bottom: 1px solid var(--line); margin-bottom: .25rem; }
.source-filter-commands button { border: 0; background: transparent; color: var(--accent); font-weight: 700; cursor: pointer; }
.unread-toggle { display: flex; align-items: center; gap: .4rem; min-height: 37px; color: var(--ink) !important; }
.rss-link { margin-left: auto; color: var(--muted); font-size: .75rem; }
.category-intro { position: relative; }
.category-intro::after { content: ""; position: absolute; width: 70px; height: 7px; bottom: -18px; left: 0; border-radius: 4px; background: var(--coral); }
[data-category="ai"] { --section-accent: #9b6bb0; }
[data-category="dev"] { --section-accent: var(--blue); }
[data-category="world"] { --section-accent: var(--coral); }
[data-category="tech"] { --section-accent: var(--teal); }
[data-category="community"] { --section-accent: var(--gold); }
.category-intro::after, .topic-card .topic-shape { background: var(--section-accent, var(--coral)); }

.topic-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.topic-card { position: relative; display: flex; flex-direction: column; min-height: 230px; padding: 28px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); overflow: hidden; transition: transform .2s, box-shadow .2s; }
.topic-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.topic-card h2 { margin: 0; font: 700 2.2rem/1 var(--serif); }
.topic-card > p:not(.eyebrow) { max-width: 75%; color: var(--muted); font-size: .8rem; }
.topic-headlines { max-width: 82%; margin: 1rem 0 .75rem; padding-left: 1rem; color: var(--ink); font-size: .78rem; line-height: 1.35; }
.topic-headlines li { margin: .3rem 0; }
.topic-sources { margin-top: auto; }
.topic-all { grid-column: 1 / -1; min-height: 210px; }
.topic-shape { position: absolute; width: 140px; height: 140px; right: -45px; bottom: -50px; border-radius: 45% 55% 60% 40%; opacity: .85; transform: rotate(20deg); }
.topic-arrow { position: absolute; right: 25px; top: 25px; font-size: 1.4rem; }

.empty-state { margin: 5rem auto; max-width: 470px; text-align: center; color: var(--muted); }
.empty-state > span { display: block; margin-bottom: 1rem; font-size: 2rem; }
.empty-state h1, .empty-state h2 { margin: 0; color: var(--ink); font: 700 2rem/1.1 var(--serif); }
.empty-state p { margin: .8rem 0; }
.source-health { margin-top: 5rem; border-top: 1px solid var(--line); padding-top: 1.3rem; color: var(--muted); font-size: .74rem; }
.source-health summary { cursor: pointer; }
.source-health > div { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1rem; }
.health-pill { padding: .25rem .55rem; background: var(--paper-deep); border-radius: 99px; }
.health-pill.error { color: var(--coral); }

.toast { position: fixed; z-index: 80; left: 50%; bottom: 34px; transform: translateX(-50%); display: flex; align-items: center; gap: 1rem; min-width: 230px; padding: .8rem 1rem; border-radius: 12px; background: var(--ink); color: var(--paper); box-shadow: var(--shadow); font-size: .85rem; }
.toast[hidden] { display: none; }
.toast button { margin-left: auto; border: 0; background: none; color: var(--gold); font-weight: 750; cursor: pointer; }
.mobile-nav { display: none; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--navy); }
.login-page::before { content: ""; position: fixed; width: 38vw; height: 38vw; min-width: 320px; min-height: 320px; border-radius: 50%; background: var(--coral); top: -22vw; right: -10vw; opacity: .8; }
.login-card { position: relative; width: min(100%, 470px); padding: clamp(30px, 6vw, 55px); border-radius: 22px; background: var(--paper); box-shadow: 0 30px 100px rgba(0,0,0,.28); }
.login-brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 3rem; font: 700 1.3rem var(--serif); }
.login-card h1 { margin: 0; font: 700 3.2rem/.95 var(--serif); letter-spacing: -.05em; }
.login-card .dek { color: var(--muted); font-family: var(--serif); }
.login-card form { display: grid; gap: .65rem; margin-top: 2rem; }
.login-card label { color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.login-card input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: .8rem .9rem; background: var(--card); color: var(--ink); outline: 0; }
.login-card input:focus { border-color: var(--navy); box-shadow: 0 0 0 3px color-mix(in srgb, var(--navy) 15%, transparent); }
.login-card form button { display: flex; justify-content: space-between; margin-top: .45rem; border: 0; border-radius: 10px; padding: .85rem 1rem; background: var(--navy); color: #fff; font-weight: 750; cursor: pointer; }
.form-error { padding: .7rem .8rem; border-radius: 9px; background: color-mix(in srgb, var(--coral) 15%, transparent); color: var(--coral); font-size: .85rem; }

@media (max-width: 900px) {
  .app-layout { display: block; }
  .side-rail { display: none; }
  #main-content { padding: 38px 24px 110px; margin: auto; }
  .topbar-inner { height: 64px; padding: 0 18px; }
  .brand small { display: none; }
  .brand-mark { width: 36px; height: 36px; }
  .desktop-only { display: none; }
  .mobile-nav {
    position: fixed; display: grid; grid-template-columns: repeat(3, 1fr); z-index: 50; left: 12px; right: 12px;
    bottom: max(10px, env(safe-area-inset-bottom)); height: 64px; padding: 5px; border: 1px solid var(--line);
    border-radius: 17px; background: color-mix(in srgb, var(--card) 94%, transparent); backdrop-filter: blur(16px); box-shadow: 0 12px 40px rgba(0,0,0,.14);
  }
  .mobile-nav a { display: grid; place-items: center; align-content: center; gap: 2px; color: var(--muted); font-size: .63rem; border-radius: 12px; }
  .mobile-nav a.active { color: var(--ink); background: var(--paper-deep); }
  .mobile-nav svg { width: 1.2rem; height: 1.2rem; }
  .toast { bottom: 88px; }
}

@media (max-width: 680px) {
  #main-content { padding: 30px 16px 108px; }
  .page-intro { margin-bottom: 38px; }
  .page-intro h1 { font-size: clamp(2.7rem, 14vw, 4.1rem); }
  .page-intro .dek { font-size: 1.08rem; }
  .section-heading { align-items: center; }
  .section-heading h2 { font-size: 1.75rem; }
  .lead-section, .briefing-section { margin-bottom: 48px; }
  .story-lead { display: block; min-height: 0; }
  .story-lead .story-image { aspect-ratio: 16/9; min-height: 0; }
  .story-lead .story-body { padding: 24px 21px 19px; }
  .story-lead h3 { font-size: 2rem; }
  .story-grid { grid-template-columns: 1fr; gap: 13px; }
  .story-list { gap: 13px; }
  .story-list .story-card { display: block; }
  .story-list .story-image { height: auto; aspect-ratio: 16/8.5; min-height: 0; }
  .story-list .story-body { padding: 19px 18px 15px; }
  .story-card:hover { transform: none; box-shadow: 0 4px 18px rgba(35,35,31,.035); }
  .story-summary { -webkit-line-clamp: 2; }
  .story-actions button span { display: none; }
  .story-actions button { padding: .45rem; }
  .story-actions svg { width: 1.12rem; height: 1.12rem; }
  .topic-grid { grid-template-columns: 1fr; gap: 13px; }
  .topic-card { min-height: 190px; padding: 24px; }
  .view-tools { flex-wrap: wrap; }
  .rss-link { margin-left: 0; }
  .source-filter-panel { position: fixed; left: 20px; right: 20px; top: auto; width: auto; }
  .topic-all { grid-column: auto; }
  .topic-headlines { max-width: 88%; }
  .hn-context { flex-wrap: wrap; }
  .search-inner { padding: 10px 16px; }
  .toast { left: 16px; right: 16px; transform: none; min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

.rail-secondary { margin-top: .35rem; opacity: .72; font-size: .9rem; }
.pulse-card { display: flex; align-items: center; gap: 1rem; margin: 0 0 2rem; padding: 1rem 1.15rem; border: 1px solid var(--line); border-left: 4px solid var(--accent); background: var(--paper); }
.pulse-card .eyebrow { margin: 0; white-space: nowrap; }
.pulse-card p:not(.eyebrow) { margin: 0; flex: 1; }
.pulse-card a { color: var(--accent); font-weight: 700; white-space: nowrap; }
.music-discovery { margin: 2.5rem 0 1rem; padding: 1.35rem 1.5rem; border-radius: 18px; color: #f8f4ed; background: linear-gradient(120deg, #17324d, #5d3659); display: grid; grid-template-columns: 1.2fr 1fr auto; align-items: center; gap: 1.25rem; }
.music-discovery .eyebrow { margin: 0 0 .25rem; color: #d9c8de; }
.music-discovery h2 { margin: 0; font-size: 1.15rem; }
.music-discovery p { margin: 0; color: #e5dfe5; font-size: .92rem; }
.music-discovery a { color: white; font-weight: 750; white-space: nowrap; }

@media (max-width: 760px) {
  .pulse-card { display: block; }
  .pulse-card p:not(.eyebrow) { margin: .35rem 0 .6rem; }
  .music-discovery { grid-template-columns: 1fr; gap: .65rem; padding: 1.2rem; }
}
