:root {
  --bg: #0d1117;
  --surface: #131a23;
  --surface-soft: #17202d;
  --line: #233142;
  --text: #eaf1fb;
  --muted: #9fb0c6;
  --accent: #ff6a00;
  --accent-soft: #ff9f5a;
  --good: #42d78a;
  --bad: #ff7b7b;
  --radius: 14px;
}

body.light {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-soft: #f0f3f7;
  --line: #d5dce8;
  --text: #0f1923;
  --muted: #6b7e96;
  --good: #1a9e5c;
  --bad: #cc3333;
}

body.light {
  background: radial-gradient(circle at 0% 0%, #dde8f5 0%, transparent 34%),
    radial-gradient(circle at 100% 10%, #fde8d4 0%, transparent 36%),
    var(--bg);
}

body.light .bg-grid {
  background-image: linear-gradient(rgba(0,0,0,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.04) 1px, transparent 1px);
}

body.light .top-header {
  background: linear-gradient(130deg, #ffffff 0%, #fafbfd 60%, #fff7f0 100%);
  border-top: 1px solid #e2eaf5;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

body.light .featured-card {
  background: linear-gradient(125deg, #ffffff, #f7f9fc);
  box-shadow: 0 4px 20px rgba(0,0,0,0.07);
}

body.light .featured-card a { color: var(--text); }
body.light .featured-card p { color: #4a5f75; }

body.light .story-card {
  background: #ffffff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

body.light .story-card a { color: var(--text); }
body.light .story-card p { color: #4e6278; }

body.light .rail-panel { background: #ffffff; }

body.light .ticker {
  background: #ffffff;
}

body.light .ticker-item { color: #2a3a4e; }
body.light .ticker-item strong { color: #c45500; }

body.light .category-btn {
  background: #eef1f6;
  color: #4e6278;
}

body.light .search-input {
  background: #ffffff;
  color: var(--text);
}

body.light .meta-row span {
  border-color: #ccd6e4;
  color: #5a7090;
}

body.light .meta-row .cat {
  background: #ff6a00;
  color: #fff;
}

body.light .story-source { color: #c45500; }
body.light .story-read { color: #c45500; border-bottom-color: rgba(196,85,0,0.4); }

body.light .pulse-item p { color: #2e3f52; }
body.light .pulse-item span { color: #c45500; }

body.light .region-chip { border-color: #ccd6e4; color: #5a7090; }

body.light .meta-stat {
  background: rgba(26, 158, 92, 0.08);
  border-color: rgba(26, 158, 92, 0.25);
}

body.light .legal-expanded { background: #f4f6f9; }

body.light .page-footer { color: #7a8fa6; }
body.light .footer-legal { color: #9aafbf; }

body.light .brand-tagline { color: #8a9fb8; }
body.light .tiny-label { color: #8a9fb8; }
body.light .meta-updated { color: #9aafbf; }

* {
  box-sizing: border-box;
}

button {
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at 0% 0%, #1a2a3d 0%, transparent 34%),
    radial-gradient(circle at 100% 10%, #31210f 0%, transparent 36%),
    var(--bg);
  font-family: "Source Sans 3", sans-serif;
  padding: 20px;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  z-index: -1;
}

.top-header {
  max-width: 1260px;
  margin: 0 auto;
  background: linear-gradient(130deg, #151d2a 0%, #111822 60%, #1a1208 100%);
  border: 1px solid var(--line);
  border-top: 1px solid #2e4060;
  border-radius: var(--radius);
  padding: 22px 24px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  box-shadow: 0 14px 40px rgba(1, 4, 9, 0.55), inset 0 1px 0 rgba(255,255,255,0.04);
}

.brand-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand-top-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  font-family: "Chakra Petch", sans-serif;
  border-radius: 999px;
  background: rgba(255, 43, 43, 0.15);
  border: 1px solid rgba(255, 43, 43, 0.4);
  color: #ff6b6b;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 4px 10px 4px 8px;
  font-weight: 700;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff3b3b;
  box-shadow: 0 0 6px #ff3b3b;
  animation: pulse-dot 1.4s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

.tiny-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #5a7090;
  font-size: 0.72rem;
}

h1 {
  margin: 0;
  font-family: "Archivo Black", sans-serif;
  letter-spacing: 0.02em;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1;
}

.ai-word {
  background: linear-gradient(100deg, #ff6a00, #ffb347);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-tagline {
  margin: 0;
  font-size: 0.84rem;
  color: #4e6480;
  letter-spacing: 0.01em;
}

.top-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.meta-stat {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(66, 215, 138, 0.07);
  border: 1px solid rgba(66, 215, 138, 0.2);
  border-radius: 999px;
  padding: 5px 12px 5px 9px;
}

.meta-stat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  flex-shrink: 0;
}

.health {
  color: var(--good);
  font-weight: 700;
  font-size: 0.8rem;
  font-family: "Chakra Petch", sans-serif;
  letter-spacing: 0.03em;
}

.health.warn {
  color: var(--bad);
}

.meta-updated {
  margin: 0;
  color: #405060;
  font-size: 0.78rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px 8px 10px;
  color: var(--text);
  font-family: "Chakra Petch", sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  user-select: none;
  white-space: nowrap;
}

.theme-toggle:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.15);
}

.theme-toggle.is-light {
  background: #fff3e0;
  border-color: #ff8c00;
  color: #b85000;
  box-shadow: 0 0 0 3px rgba(255, 140, 0, 0.12);
}

/* pill switch track */
.theme-track {
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: #2a3a52;
  border: 1px solid #3a5070;
  position: relative;
  flex-shrink: 0;
  transition: background 0.25s, border-color 0.25s;
}

.theme-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #5a7a9a;
  transition: transform 0.25s, background 0.25s;
}

/* active (light) state */
.theme-toggle.is-light .theme-track {
  background: #ffb347;
  border-color: #ff8c00;
}

.theme-toggle.is-light .theme-thumb {
  transform: translateX(14px);
  background: #fff;
}

.theme-toggle.is-light {
  border-color: #ffb347;
  color: #c45500;
}

.theme-icon {
  font-size: 1rem;
  line-height: 1;
}

/* light mode overrides for the toggle itself */
body.light .theme-track {
  background: #d0dcea;
  border-color: #b0c0d8;
}

body.light .theme-thumb {
  background: #8aa0bc;
}

body.light .theme-toggle.is-light .theme-track {
  background: #ffb347;
  border-color: #ff8c00;
}

body.light .theme-toggle.is-light .theme-thumb {
  background: #fff;
}

@media (max-width: 980px) {
  .top-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .top-meta {
    align-items: flex-start;
  }
}

.nav-search-row {
  max-width: 1260px;
  margin: 12px auto 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.category-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.category-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--surface-soft);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.category-btn.active,
.category-btn:hover {
  color: #111;
  background: linear-gradient(120deg, var(--accent), var(--accent-soft));
  border-color: transparent;
}

.search-input {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  color: var(--text);
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.86rem;
  outline: none;
  transition: border-color 0.15s, width 0.2s;
}

.search-input::placeholder {
  color: var(--muted);
}

.search-input:focus {
  border-color: var(--accent);
  width: 280px;
}

@media (max-width: 680px) {
  .search-input {
    width: 100%;
  }
  .search-input:focus {
    width: 100%;
  }
}

.ticker {
  max-width: 1260px;
  margin: 12px auto;
  border: 1px solid var(--line);
  background: #0e1520;
  border-radius: 12px;
  overflow: hidden;
  height: 46px;
  position: relative;
}

.ticker-track {
  position: absolute;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 24px;
  padding: 13px;
  animation: ticker-move 48s linear infinite;
}

.ticker-item {
  font-size: 0.9rem;
  color: #d6e0ef;
}

.ticker-item strong {
  color: #ffc287;
  margin-right: 6px;
}

@keyframes ticker-move {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-50%);
  }
}

.main-grid {
  max-width: 1260px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 2.15fr) minmax(260px, 1fr);
  gap: 14px;
  align-items: start;
}

.featured-card {
  background: linear-gradient(125deg, #1b2636, #111a24);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  min-height: 210px;
  box-shadow: 0 10px 30px rgba(4, 7, 11, 0.45);
}

.featured-label {
  margin: 0 0 4px;
  color: #ffbc7a;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-size: 0.75rem;
  font-weight: 700;
}

.featured-card h2 {
  margin: 0;
  font-size: clamp(1.3rem, 2.5vw, 2rem);
  line-height: 1.2;
}

.featured-card a {
  color: var(--text);
  text-decoration: none;
}

.featured-card a:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

.featured-card p {
  color: #bfd0e6;
}

.story-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.pagination {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

.pagination.hidden {
  display: none;
}

.pagination button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--surface-soft);
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pagination p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.scroll-sentinel {
  height: 2px;
  margin-top: 6px;
}

.scroll-sentinel.hidden {
  display: none;
}

.story-card {
  background: #131c29;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.story-source {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #ffbe83;
  font-weight: 700;
  font-size: 0.72rem;
}

.story-card h3 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.35;
}

.story-card a {
  color: var(--text);
  text-decoration: none;
}

.story-card a:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

.story-card p {
  margin: 0;
  color: #b5c5db;
  line-height: 1.55;
}

.story-summary {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-read {
  width: fit-content;
  color: #ffcf9f;
  text-decoration: none;
  border-bottom: 1px dashed rgba(255, 207, 159, 0.5);
  font-size: 0.86rem;
  line-height: 1.3;
}

.story-read:hover {
  color: #ffe3c2;
  border-bottom-color: rgba(255, 227, 194, 0.9);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  align-items: center;
}

.meta-row span {
  display: inline-flex;
  align-items: center;
  border: 1px solid #2a3c52;
  border-radius: 999px;
  padding: 3px 9px;
  min-height: 22px;
  line-height: 1;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #95acc8;
  white-space: nowrap;
  max-width: 145px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-row .cat {
  color: #1e2329;
  background: #ffbf84;
  border-color: transparent;
  font-weight: 700;
  max-width: 120px;
}

.right-rail {
  display: grid;
  gap: 12px;
  align-content: start;
  position: sticky;
  top: 20px;
  height: fit-content;
}

.rail-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101824;
  padding: 14px;
}

.rail-panel h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: "Chakra Petch", sans-serif;
}

.pulse-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  padding: 8px 0;
  border-top: 1px solid rgba(143, 171, 203, 0.22);
}

.pulse-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.pulse-item span {
  color: #ffbd81;
  font-family: "Chakra Petch", sans-serif;
  font-weight: 700;
}

.pulse-item p {
  margin: 0;
  color: #c1d0e3;
  line-height: 1.35;
}

.pulse-item:hover p {
  color: #fff;
}

.why-list {
  margin: 0;
  padding: 0 0 0 16px;
  color: #b5c5db;
  font-size: 0.88rem;
  line-height: 1.7;
}

.why-list li {
  margin-bottom: 2px;
}

.region-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.region-chip {
  border: 1px solid #2b3f58;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.74rem;
  color: #afc1da;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.placeholder {
  color: var(--muted);
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px 20px;
  color: var(--muted);
  font-size: 0.95rem;
}

.page-footer {
  max-width: 1260px;
  margin: 18px auto 0;
  border-top: 1px solid var(--line);
  padding: 12px 0 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.page-footer p {
  margin: 0 0 4px;
}

.footer-legal {
  font-size: 0.78rem;
  color: #6a7f96;
}

.legal-toggle {
  background: none;
  border: none;
  color: #7fa4c8;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0 0 0 6px;
  text-decoration: underline dotted;
}

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

.legal-expanded {
  margin-top: 8px;
  padding: 10px 12px;
  background: #0d1520;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.8rem;
  color: #7f96b0;
  line-height: 1.55;
}

.reveal {
  animation: reveal-in 320ms ease both;
}

@keyframes reveal-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .right-rail {
    position: static;
  }
}

@media (max-width: 680px) {
  body {
    padding: 8px;
  }

  /* ── Header: compact single row ── */
  .top-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    gap: 10px;
  }

  .brand-wrap {
    gap: 3px;
  }

  .brand-top-row {
    gap: 6px;
  }

  .live-pill {
    font-size: 0.62rem;
    padding: 3px 7px 3px 6px;
  }

  .live-dot {
    width: 5px;
    height: 5px;
  }

  .tiny-label {
    display: none;
  }

  h1 {
    font-size: 1.45rem;
    letter-spacing: 0.01em;
  }

  .brand-tagline {
    display: none;
  }

  /* ── Top meta: only show toggle on mobile ── */
  .top-meta {
    align-items: flex-end;
    gap: 6px;
  }

  .meta-stat,
  .meta-updated {
    display: none;
  }

  .theme-toggle {
    padding: 6px 10px 6px 8px;
    font-size: 0.68rem;
    gap: 6px;
  }

  .theme-track {
    width: 26px;
    height: 15px;
  }

  .theme-thumb {
    width: 10px;
    height: 10px;
  }

  .theme-toggle.is-light .theme-thumb {
    transform: translateX(11px);
  }

  /* ── Nav + search: stack vertically ── */
  .nav-search-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: 8px;
  }

  .category-nav {
    gap: 6px;
  }

  .category-btn {
    padding: 6px 10px;
    font-size: 0.68rem;
  }

  .search-input {
    width: 100%;
    font-size: 0.9rem;
    padding: 9px 14px;
  }

  .search-input:focus {
    width: 100%;
  }

  /* ── Ticker ── */
  .ticker-track {
    animation-duration: 32s;
  }

  /* ── Cards ── */
  .featured-card {
    min-height: unset;
    padding: 14px;
  }

  .featured-card h2 {
    font-size: 1.2rem;
  }

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

  /* ── Right rail: hide less important panels on mobile ── */
  .rail-panel:nth-child(2),
  .rail-panel:nth-child(3) {
    display: none;
  }
}
