:root {
  --bg: #ffffff;
  --bg-alt: #f6f6f6;
  --text: #121212;
  --text-muted: #545658;
  --border: #e6e6e6;
  --border-strong: #121212;
  --accent: #ea580c;
  --accent-hover: #c2410c;
  --brand-orange: #ea580c;
  --brand-purple: #7c3aed;
  --ai: #7c3aed;
  --tech: #006699;
  --world: #007a3d;
  --font: "Inter", system-ui, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --wrap: 1280px;
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-alt: #141414;
  --text: #f2f2f2;
  --text-muted: #a3a3a3;
  --border: #2a2a2a;
  --border-strong: #f2f2f2;
  --accent: #f97316;
  --accent-hover: #fb923c;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 0.9375rem;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding-left: 1rem; padding-right: 1rem; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  padding: 0.75rem 1rem; background: var(--accent); color: #fff;
}
.skip-link:focus { left: 1rem; top: 1rem; }

.muted { color: var(--text-muted); }
.hidden { display: none !important; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-top { border-bottom: 1px solid var(--border); }

.header-top-inner {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 56px; gap: 1rem;
}

.brand {
  display: flex; align-items: center; gap: 0.65rem;
}
.brand-logo { flex-shrink: 0; }
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-text strong {
  font-size: 1.75rem; font-weight: 700; letter-spacing: -0.03em;
  color: var(--brand-orange);
}
.brand-tagline {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.header-utils { display: flex; align-items: center; gap: 0.5rem; }

.search-wrap input {
  width: min(200px, 40vw);
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  font: inherit; font-size: 0.875rem;
}
.search-wrap input:focus { outline: 2px solid var(--text); outline-offset: 0; }

.icon-btn {
  width: 36px; height: 36px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
  display: grid; place-items: center; cursor: pointer;
}
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }

.btn-refresh {
  border: none; background: var(--text); color: var(--bg);
  font: inherit; font-size: 0.8125rem; font-weight: 600;
  padding: 0.45rem 0.85rem; cursor: pointer;
}
.btn-refresh:hover { opacity: 0.85; }
.btn-refresh:disabled { opacity: 0.5; cursor: wait; }

/* Category nav */
.category-nav {
  display: flex; gap: 0; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cat-link {
  border: none; background: none; color: var(--text-muted);
  font: inherit; font-size: 0.875rem; font-weight: 600;
  padding: 0.85rem 1rem; cursor: pointer;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.cat-link:hover { color: var(--text); background: var(--bg-alt); }
.cat-link.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Breaking bar */
.breaking-bar {
  display: flex; align-items: stretch;
  background: linear-gradient(90deg, var(--brand-orange), var(--brand-purple));
  color: #fff;
  min-height: 40px; overflow: hidden;
}
.breaking-label {
  flex-shrink: 0;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.65rem 1rem;
  background: rgba(0,0,0,0.15);
}
.breaking-track {
  display: flex; align-items: center; gap: 2.5rem;
  padding: 0 1rem; white-space: nowrap;
  animation: ticker 50s linear infinite;
  font-size: 0.875rem; font-weight: 500;
}
@keyframes ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* Status strip */
.status-strip {
  display: flex; flex-wrap: wrap; gap: 0.35rem 1.25rem;
  padding-top: 0.75rem; padding-bottom: 0.75rem;
  font-size: 0.8125rem; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.status-meta { margin: 0; }
#next-refresh { margin-left: auto; font-weight: 600; color: var(--text); }

/* Main */
.main { padding-top: 1.25rem; padding-bottom: 3rem; }

.section-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.65rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--border-strong);
}
.section-more {
  font-size: 0.8125rem; font-weight: 600; color: var(--text-muted);
  text-decoration: underline; text-underline-offset: 3px;
}
.section-more:hover { color: var(--text); }

/* Editorial brief */
.editorial-brief {
  margin-bottom: 1.5rem;
  padding: 1rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
}
.brief-copy {
  margin: 0.65rem 0 0;
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.55;
  font-style: italic;
  color: var(--text);
}

/* Lead grid */
.lead-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: 2rem;
}

.lead-main, .lead-sidebar { background: var(--bg); }

.lead-main .story-lead { padding: 0; }

.story-lead-image img,
.story-card-image img,
.story-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  image-rendering: auto;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.story-lead-image {
  aspect-ratio: 16 / 9;
  background: var(--bg-alt);
  overflow: hidden;
}
.story-card-image {
  aspect-ratio: 16 / 10;
  background: var(--bg-alt);
  overflow: hidden;
}

.story-lead-body { padding: 1rem 1.25rem 1.25rem; }

.story-lead-title {
  margin: 0 0 0.5rem;
  font-family: var(--serif);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.story-lead-title a:hover { text-decoration: underline; text-underline-offset: 4px; }

.story-lead-excerpt {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

/* Sidebar stack */
.lead-sidebar {
  display: flex; flex-direction: column;
}

.story-side {
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
  flex: 1;
}
.story-side:last-child { border-bottom: none; }

.story-side-title {
  margin: 0.35rem 0 0;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
}
.story-side-title a:hover { text-decoration: underline; }

/* Category rows */
.news-section { margin-bottom: 2.25rem; }

.story-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}
.story-row-wide { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.story-card {
  background: var(--bg);
  display: flex; flex-direction: column;
}

.story-card-body { padding: 0.85rem 1rem 1rem; flex: 1; }

.story-card-title {
  margin: 0.4rem 0 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}
.story-card-title a:hover { text-decoration: underline; }

.story-card-excerpt {
  margin: 0.45rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-meta {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.75rem; color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Tags */
.tag {
  display: inline-block;
  font-size: 0.6875rem; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  padding: 0.15rem 0.4rem;
}
.tag-ai { color: var(--ai); border-left: 3px solid var(--ai); padding-left: 0.35rem; }
.tag-tech { color: var(--tech); border-left: 3px solid var(--tech); padding-left: 0.35rem; }
.tag-world { color: var(--world); border-left: 3px solid var(--world); padding-left: 0.35rem; }

/* Skeletons */
.skeleton-block {
  background: linear-gradient(90deg, var(--bg-alt) 25%, var(--border) 50%, var(--bg-alt) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.lead-skeleton { min-height: 360px; }

.feed-empty {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-muted);
}

.story-title-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.breaking-track a {
  color: inherit;
  text-decoration: none;
}
.breaking-track a:hover { text-decoration: underline; }

/* Article page */
.article-page { padding: 1.5rem 1rem 3rem; max-width: 720px; }
.article-breadcrumb {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.article-breadcrumb a:hover { color: var(--brand-orange); text-decoration: underline; }

.article-header { margin-bottom: 1.5rem; }
.article-title {
  margin: 0.65rem 0 0.75rem;
  font-family: var(--serif);
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
}
.article-deck {
  margin: 0 0 1rem;
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--text-muted);
}
.article-meta-row {
  display: flex; flex-wrap: wrap; gap: 0.35rem 1rem;
  font-size: 0.8125rem; color: var(--text-muted);
}
.article-hero {
  margin: 0 0 1.75rem;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-alt);
}
.article-hero img { width: 100%; height: 100%; object-fit: cover; }

.article-body {
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.65;
  color: var(--text);
}
.article-body p { margin: 0 0 1.15rem; }
.article-body h2, .article-body h3 {
  font-family: var(--font);
  font-size: 1.25rem;
  margin: 1.75rem 0 0.75rem;
}
.article-body a {
  color: var(--brand-orange);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.article-body img {
  max-width: 100%;
  height: auto;
  margin: 1rem 0;
}
.article-body pre, .article-body code {
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
}
.article-body pre {
  overflow-x: auto;
  padding: 1rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
}
.article-note {
  font-style: italic;
  color: var(--text-muted);
  border-left: 3px solid var(--brand-orange);
  padding-left: 1rem;
}

.article-footer {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.article-attribution {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.article-attribution a { text-decoration: underline; }
.article-error { padding: 2rem 0; }

/* Footer — Moltbook */
.site-footer {
  border-top: 3px solid var(--brand-orange);
  padding: 2rem 0 2.5rem;
  background: var(--bg-alt);
  margin-top: 2rem;
}
.footer-inner { max-width: var(--wrap); margin: 0 auto; padding: 0 1rem; }
.footer-top {
  display: flex; flex-wrap: wrap; align-items: flex-start;
  justify-content: space-between; gap: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.footer-brand-block { max-width: 280px; }
.footer-brand {
  display: flex; align-items: center; gap: 0.55rem;
  margin-bottom: 0.35rem;
}
.footer-brand strong { font-size: 1.35rem; color: var(--brand-orange); }
.footer-tagline { margin: 0; font-size: 0.875rem; color: var(--text-muted); line-height: 1.5; }
.footer-nav {
  display: flex; flex-wrap: wrap; gap: 0.35rem 1.25rem;
}
.footer-nav a, .footer-nav button {
  font: inherit; font-size: 0.875rem; font-weight: 600;
  color: var(--text); background: none; border: none;
  padding: 0; cursor: pointer;
}
.footer-nav a:hover, .footer-nav button:hover { color: var(--brand-orange); text-decoration: underline; }
.footer-nav button.is-active { color: var(--brand-orange); }
.footer-disclaimer {
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.55;
  max-width: 52rem;
}
.footer-meta {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem;
  font-size: 0.75rem; color: var(--text-muted);
}
.footer-meta a { text-decoration: underline; text-underline-offset: 2px; }
.footer-meta a:hover { color: var(--text); }

@media (max-width: 960px) {
  .lead-grid { grid-template-columns: 1fr; }
  .story-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .story-row { grid-template-columns: 1fr; }
  .header-top-inner { flex-wrap: wrap; }
  #next-refresh { margin-left: 0; width: 100%; }
}
