:root {
  --bg-top: #edf4f6;
  --bg-bottom: #dce6ea;
  --sheet: #fdfcf9;
  --sheet-strong: #ffffff;
  --ink: #10191d;
  --muted: #4c5d64;
  --line: #c6d3d9;
  --accent: #0f6d80;
  --accent-soft: #e5f4f7;
  --warning-bg: #fff2dd;
  --warning-line: #d8b06d;
  --card-shadow: rgba(14, 32, 39, 0.12);
  --tone-rust: #a04d2c;
  --tone-gold: #b38a38;
  --tone-plum: #6a3f72;
  --tone-forest: #3f6b4c;
}

:root[data-theme="dark"] {
  --bg-top: #0b1114;
  --bg-bottom: #121b20;
  --sheet: #162028;
  --sheet-strong: #1a2630;
  --ink: #e5edf2;
  --muted: #9fb2bc;
  --line: #31424d;
  --accent: #6ec7da;
  --accent-soft: #18323c;
  --warning-bg: #3a2b1a;
  --warning-line: #7f5c2b;
  --card-shadow: rgba(0, 0, 0, 0.36);
  --tone-rust: #d58a6d;
  --tone-gold: #d4b56f;
  --tone-plum: #ba9ad8;
  --tone-forest: #7cb493;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: 2.4rem;
  color: var(--ink);
  font-family: "Newsreader", serif;
  background:
    radial-gradient(circle at 5% -10%, #f5fbfd 0%, transparent 50%),
    radial-gradient(circle at 95% 2%, #e6f2f6 0%, transparent 44%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.09;
  background-image: radial-gradient(circle at 30% 20%, rgba(0, 0, 0, 0.2) 0.4px, transparent 0.4px);
  background-size: 4px 4px;
}

.site-shell {
  position: relative;
  max-width: 1240px;
  margin: 1.2rem auto 2rem;
  border: 1px solid #bcd0d8;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), var(--sheet) 14%, var(--sheet-strong) 100%);
  box-shadow: 0 20px 45px var(--card-shadow);
  overflow-x: clip;
  overflow-y: visible;
}

.site-shell::before {
  content: "";
  position: absolute;
  top: 0;
  left: -22%;
  width: 22%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(15, 109, 128, 0.17), transparent);
  transform: skewX(-14deg);
  animation: sweep 900ms ease-out 120ms both;
  pointer-events: none;
  z-index: 2;
}

.source-note {
  margin: 0;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-family: "Archivo Narrow", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #d8ebf1;
  background: rgba(11, 35, 43, 0.93);
  border-top: 1px solid rgba(150, 190, 202, 0.45);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  backdrop-filter: blur(3px);
}

.source-note a {
  color: #9adff1;
  text-decoration: none;
  border-bottom: 1px dotted rgba(154, 223, 241, 0.55);
}

.privacy-note {
  margin-left: auto;
  opacity: 0.7;
  white-space: nowrap;
}

.masthead {
  padding: 1.4rem 1rem 1.15rem;
  text-align: center;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, #f9fdff 0%, rgba(249, 253, 255, 0.6) 35%, transparent 100%);
  animation: settle 560ms ease both;
  position: relative;
}

.masthead::after {
  content: "";
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 0.35rem;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--tone-gold), var(--tone-rust), var(--tone-plum));
}

.masthead-kicker {
  margin: 0;
  font-family: "Archivo Narrow", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.68rem;
  color: var(--tone-rust);
}

h1 {
  margin: 0.35rem 0 0;
  font-weight: 600;
  font-size: clamp(2.2rem, 6.1vw, 5rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
  animation: title-reveal 620ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.statusline {
  margin: 0;
  min-height: 0;
}

.controls {
  display: grid;
  grid-template-columns: auto minmax(180px, 260px) auto 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, #f6fbfc 0%, #f8f5ef 45%, #f1f9f6 100%);
}

.topic-strip {
  padding: 0.52rem 1rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(244, 249, 250, 0.84), rgba(247, 244, 238, 0.84));
}

.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.topic-chip {
  border: 1px solid #b8cad1;
  background: #ffffff;
  color: #17323a;
  font-family: "Archivo Narrow", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.34rem 0.58rem;
  cursor: pointer;
}

.topic-chip.is-active {
  border-color: #28697a;
  background: #e8f7fb;
  color: #144957;
  font-weight: 700;
}

label {
  font-family: "Archivo Narrow", sans-serif;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--muted);
}

select,
button {
  font: inherit;
}

select,
#refreshButton,
#themeToggle,
.load-more {
  border: 1px solid #b8cad1;
  color: #17323a;
  background: #ffffff;
  padding: 0.52rem 0.74rem;
  min-height: 2.45rem;
  line-height: 1;
}

#refreshButton,
#themeToggle,
.load-more {
  font-family: "Archivo Narrow", sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

#refreshButton:hover,
#themeToggle:hover,
.load-more:hover {
  transform: translateY(-1px);
  background: #f8fff4;
  box-shadow: 0 5px 0 #c7d8bf;
}

.freshness {
  margin: 0;
  justify-self: end;
  font-family: "Archivo Narrow", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #486169;
}

main {
  padding: 1rem;
}

.banner {
  margin-bottom: 1rem;
  border: 1px solid var(--warning-line);
  background: var(--warning-bg);
  color: #65411d;
  padding: 0.75rem 0.9rem;
}

.hidden {
  display: none;
}

.feed-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
}

.story-card {
  grid-column: span 12;
  background: #ffffff;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  box-shadow: 0 10px 18px rgba(18, 42, 52, 0.08);
  overflow: hidden;
  opacity: 0;
  animation: card-enter 520ms cubic-bezier(0.21, 0.8, 0.23, 1) both;
  animation-delay: var(--entry-delay, 0ms);
}

.story-card:nth-child(3n + 2) {
  border-top-color: var(--tone-rust);
}

.story-card:nth-child(3n + 3) {
  border-top-color: var(--tone-forest);
}

.story-link {
  text-decoration: none;
  color: inherit;
  display: grid;
  grid-template-columns: 170px 1fr;
  min-height: 100%;
}

.story-image-wrap {
  margin: 0;
  background: linear-gradient(145deg, #d8e8ed, #f2f7fa);
  border-right: 1px solid var(--line);
}

.story-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.story-body {
  padding: 0.9rem 1rem 1rem;
}

.story-meta {
  margin: 0;
  font-family: "Archivo Narrow", sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #4f6471;
}

.story-title {
  margin: 0.45rem 0;
  font-size: clamp(1.1rem, 2.3vw, 1.5rem);
  font-weight: 600;
  line-height: 1.14;
}

.story-link:hover .story-title {
  color: var(--tone-plum);
}

.story-summary {
  margin: 0;
  color: #364951;
  font-size: 0.91rem;
  line-height: 1.45;
}

.story-card:nth-child(1) {
  grid-column: span 12;
  border: 1px solid #90bcc8;
  border-top: 4px solid var(--tone-gold);
  background: linear-gradient(180deg, #f8fdff 0%, #ffffff 100%);
}

.story-card:nth-child(1) .story-link {
  grid-template-columns: minmax(320px, 45%) 1fr;
}

.story-card:nth-child(1) .story-image-wrap {
  max-height: 380px;
}

.story-card:nth-child(1) .story-title {
  font-size: clamp(1.7rem, 4.2vw, 2.7rem);
  line-height: 1.05;
}

.story-card:nth-child(1) .story-summary {
  font-size: 0.99rem;
}

.load-more-wrap {
  margin-top: 1.2rem;
  display: flex;
  justify-content: center;
}

.load-more {
  border-color: #9fc0ca;
  background: #f7fcfe;
}

@media (min-width: 920px) {
  .story-card {
    grid-column: span 6;
  }

  .story-card:nth-child(1) {
    grid-column: span 12;
  }
}

@media (max-width: 900px) {
  .controls {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .freshness {
    justify-self: start;
  }

  .story-link {
    grid-template-columns: 1fr;
  }

  .story-image-wrap {
    max-height: 210px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .story-card:nth-child(1) .story-link {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .site-shell {
    margin: 0;
    border-left: none;
    border-right: none;
  }

  .masthead,
  .controls,
  .topic-strip,
  main {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
  }

  .source-note {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
  }
}

:root[data-theme="dark"] .grain {
  opacity: 0.05;
}

:root[data-theme="dark"] .site-shell {
  border-color: #3a4a56;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.45);
}

:root[data-theme="dark"] .controls {
  background: linear-gradient(90deg, #1b2a31 0%, #1e2730 45%, #1d2d2f 100%);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3);
}

:root[data-theme="dark"] .topic-strip {
  background: linear-gradient(90deg, rgba(22, 36, 43, 0.9), rgba(24, 33, 39, 0.9));
}

:root[data-theme="dark"] .topic-chip {
  border-color: #49606c;
  color: #dce8ee;
  background: #24343e;
}

:root[data-theme="dark"] .topic-chip.is-active {
  border-color: #7fd7e9;
  color: #08212a;
  background: #9adff1;
}

:root[data-theme="dark"] .masthead {
  background: linear-gradient(180deg, #162631 0%, rgba(22, 38, 49, 0.62) 38%, transparent 100%);
  border-bottom-color: #3f5663;
}

:root[data-theme="dark"] .masthead::after {
  background: linear-gradient(90deg, #7fd7e9, #e7c780, #e1a48b, #ccb5e8);
}

:root[data-theme="dark"] h1 {
  color: #ffffff;
  font-weight: 700;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

:root[data-theme="dark"] .masthead-kicker {
  color: #d6e7ed;
}

:root[data-theme="dark"] select,
:root[data-theme="dark"] #refreshButton,
:root[data-theme="dark"] #themeToggle,
:root[data-theme="dark"] .load-more {
  border-color: #49606c;
  color: #e3edf3;
  background: #24343e;
}

:root[data-theme="dark"] #refreshButton:hover,
:root[data-theme="dark"] #themeToggle:hover,
:root[data-theme="dark"] .load-more:hover {
  background: #304652;
  box-shadow: 0 5px 0 #1a2a31;
}

:root[data-theme="dark"] .freshness {
  color: #b9cbd3;
}

:root[data-theme="dark"] .story-card {
  background: #1f2d36;
  box-shadow: 0 10px 16px rgba(0, 0, 0, 0.28);
}

:root[data-theme="dark"] .story-image-wrap {
  background: linear-gradient(145deg, #253843, #2c4450);
}

:root[data-theme="dark"] .story-meta {
  color: #a9bdc7;
}

:root[data-theme="dark"] .story-summary {
  color: #c7d5dc;
}

:root[data-theme="dark"] .banner {
  border-color: #d0a55e;
  background: linear-gradient(180deg, #4a3518 0%, #3c2b14 100%);
  color: #ffe7be;
  box-shadow: inset 0 0 0 1px rgba(255, 209, 138, 0.2);
}

:root[data-theme="dark"] .source-note {
  background: rgba(7, 16, 20, 0.95);
  color: #c7dde6;
}

:root[data-theme="dark"] .source-note a {
  color: #9adff1;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes settle {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sweep {
  from {
    left: -28%;
    opacity: 0;
  }
  to {
    left: 125%;
    opacity: 1;
  }
}

@keyframes title-reveal {
  from {
    opacity: 0;
    transform: translateY(12px);
    letter-spacing: 0.08em;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    letter-spacing: 0.01em;
  }
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.988);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
