:root {
  color-scheme: dark;
  --bg: #0a0e14;
  --bg-soft: #0d131c;
  --surface: #121a25;
  --surface-2: #16202d;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #eef3f9;
  --muted: #92a2b8;
  --faint: #64748b;
  --accent: #6ea8fe;
  --accent-soft: rgba(110, 168, 254, 0.14);
  --news: #ff7a6b;
  --sports: #4ade80;
  --business: #fbbf24;
  --other: #b69cff;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 22px 48px -28px rgba(0, 0, 0, 0.95);
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia,
    "Times New Roman", serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(900px 480px at 12% -8%, rgba(110, 168, 254, 0.12), transparent 60%),
    radial-gradient(760px 420px at 92% 4%, rgba(182, 156, 255, 0.08), transparent 62%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 50;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #04101f;
  font-weight: 650;
  text-decoration: none;
  transition: top 0.18s ease;
}

.skip-link:focus-visible {
  top: 12px;
}

/* ------------------------------------------------------------------ header */

.masthead {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: var(--safe-top);
  background: rgba(10, 14, 20, 0.82);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  backdrop-filter: blur(18px) saturate(130%);
}

.masthead__inner {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 14px clamp(16px, 4vw, 32px) 10px;
}

.masthead__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  min-width: 0;
}

.brand__kicker {
  margin: 0 0 2px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.brand__title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.015em;
}

.refresh-button {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-top: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease,
    transform 0.18s ease;
}

.refresh-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.refresh-button:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--surface-2);
}

.refresh-button:active {
  transform: scale(0.94);
}

.refresh-button.is-busy svg {
  animation: spin 0.9s linear infinite;
}

.masthead__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.masthead__meta p {
  margin: 0;
}

.stats {
  color: var(--faint);
}

.stats strong {
  color: var(--text);
  font-weight: 650;
}

.jump {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-bottom: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.jump::-webkit-scrollbar {
  display: none;
}

.jump a {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: var(--muted);
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.jump a::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cat, var(--accent));
  box-shadow: 0 0 10px color-mix(in srgb, var(--cat, var(--accent)) 55%, transparent);
}

.jump a:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
}

.jump a[data-category="news"] { --cat: var(--news); }
.jump a[data-category="sports"] { --cat: var(--sports); }
.jump a[data-category="business"] { --cat: var(--business); }
.jump a[data-category="other"] { --cat: var(--other); }

.loadbar {
  position: relative;
  height: 2px;
  overflow: hidden;
  background: transparent;
}

.loadbar span {
  position: absolute;
  inset: 0;
  width: 40%;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: loadslide 1.1s ease-in-out infinite;
}

/* ------------------------------------------------------------------- layout */

.wrap {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 30px) clamp(16px, 4vw, 32px) 48px;
}

.section {
  margin-bottom: clamp(28px, 4vw, 40px);
  scroll-margin-top: 156px;
}

.section__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.section__dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--cat, var(--accent));
  box-shadow: 0 0 14px color-mix(in srgb, var(--cat, var(--accent)) 60%, transparent);
}

.section__title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text);
}

.section__count {
  margin-left: auto;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
}

.section[data-category="news"] { --cat: var(--news); }
.section[data-category="sports"] { --cat: var(--sports); }
.section[data-category="business"] { --cat: var(--business); }
.section[data-category="other"] { --cat: var(--other); }

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(12px, 1.4vw, 16px);
}

@media (min-width: 560px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 860px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1080px) {
  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.section__empty {
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  color: var(--faint);
}

/* -------------------------------------------------------------------- card */

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-soft) 100%);
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.card__media {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface-2);
}

.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.3s ease;
}

.card:hover .card__media img {
  transform: scale(1.045);
}

.card__media::after {
  content: "";
  position: absolute;
  inset: 55% 0 0;
  background: linear-gradient(180deg, transparent, rgba(4, 7, 12, 0.55));
  pointer-events: none;
}

.card__source {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 1;
  max-width: calc(100% - 20px);
  padding: 4px 9px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(6, 10, 16, 0.66);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: 0.66rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #e6edf6;
}

.card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 7px;
  padding: 11px 13px 12px;
}

.card__title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(0.97rem, 0.92rem + 0.28vw, 1.09rem);
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -0.005em;
  text-wrap: pretty;
}

.card__title a {
  text-decoration: none;
  color: var(--text);
  transition: color 0.16s ease;
}

.card__title a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.card__summary {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: 0.845rem;
  line-height: 1.45;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.card__summary:empty {
  display: none;
}

.card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 6px;
}

.card__time {
  font-size: 0.73rem;
  color: var(--faint);
  white-space: nowrap;
}

.card__read {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 5px 11px 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.card__read svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card__read:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.card__read:disabled {
  cursor: progress;
  opacity: 0.55;
}

.card.is-reading {
  opacity: 0.7;
}

.card.is-leaving {
  animation: card-out 0.24s ease forwards;
}

.card.is-new {
  animation: card-in 0.36s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---------------------------------------------------------------- states */

.state {
  max-width: 460px;
  margin: 12vh auto 0;
  padding: 28px clamp(20px, 4vw, 32px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.state h2 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
}

.state p {
  margin: 0 0 18px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}

.pill-button {
  padding: 10px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--text);
  cursor: pointer;
}

.pill-button:hover {
  border-color: var(--accent);
}

.skeleton__section {
  width: 120px;
  height: 14px;
  margin-bottom: 18px;
  border-radius: 999px;
  background: var(--surface-2);
  animation: pulse 1.4s ease-in-out infinite;
}

.skeleton__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(12px, 1.4vw, 16px);
}

.skeleton__card {
  height: 300px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-soft) 100%);
  animation: pulse 1.4s ease-in-out infinite;
}

/* ------------------------------------------------------------------ footer */

.footer {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 22px clamp(16px, 4vw, 32px) calc(36px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  font-size: 0.76rem;
  line-height: 1.55;
  color: var(--faint);
}

.footer p {
  margin: 0 0 10px;
  max-width: 68ch;
}

.footer__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.text-button {
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
  cursor: pointer;
}

.text-button:hover {
  color: var(--text);
}

.footer__dot {
  color: var(--faint);
}

/* ------------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-bottom));
  z-index: 40;
  max-width: min(92vw, 420px);
  padding: 11px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(18, 26, 37, 0.96);
  box-shadow: 0 16px 40px -18px rgba(0, 0, 0, 0.9);
  font-size: 0.82rem;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* --------------------------------------------------------------- animation */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes loadslide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(340%);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 0.9;
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes card-out {
  to {
    opacity: 0;
    transform: scale(0.97) translateY(-4px);
  }
}

@media (max-width: 560px) {
  .jump {
    flex-wrap: wrap;
    overflow: visible;
  }

  .jump a {
    padding: 6px 10px;
    font-size: 0.75rem;
  }
}

@media (max-width: 520px) {
  .masthead__inner {
    padding-top: 12px;
  }

  .masthead__meta {
    margin-top: 6px;
  }

  .section {
    scroll-margin-top: 150px;
  }

  .card__body {
    padding: 12px 14px 13px;
  }

  .card__summary {
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }
}

@media (min-width: 560px) {
  .skeleton__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 860px) {
  .skeleton__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1080px) {
  .skeleton__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .masthead,
  .footer,
  .toast,
  .card__read,
  .refresh-button {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .card {
    break-inside: avoid;
    border-color: #ddd;
    box-shadow: none;
  }
}
