:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #eef4ff;
  --ink: #172033;
  --muted: #67728a;
  --line: #d9e2f1;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #00a884;
  --danger: #dc2626;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 34rem),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 38%, #edf4fb 100%);
  color: var(--ink);
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid rgba(217, 226, 241, 0.84);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, #2563eb, #00a884);
  color: #ffffff;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.ghost-button,
.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 2.5rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0.75rem;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.ghost-button {
  padding: 0 0.9rem;
  background: var(--surface-soft);
  color: var(--primary-dark);
}

.primary-button {
  padding: 0 1.05rem;
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.26);
}

.secondary-button {
  padding: 0 1.05rem;
  background: #e9eef8;
  color: #263248;
}

.reader-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2rem);
}

.article-card,
.state-card {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(217, 226, 241, 0.92);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
}

.state-card {
  margin: 12vh auto 0;
  max-width: 620px;
  padding: clamp(1.5rem, 5vw, 2.5rem);
  text-align: center;
}

.state-card h1 {
  margin: 1rem 0 0.5rem;
  font-size: clamp(1.7rem, 6vw, 2.65rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.state-card p {
  margin: 0 auto;
  max-width: 34rem;
  color: var(--muted);
  line-height: 1.55;
}

.loader {
  display: inline-block;
  width: 2.7rem;
  height: 2.7rem;
  border: 4px solid #dce7fb;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.hero-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: 34rem;
  margin: 0;
  background: #dce7fb;
}

.hero-media img,
.inline-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-inner {
  padding: clamp(1.1rem, 4vw, 2.2rem);
}

.byline {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1.25rem;
}

.avatar {
  display: grid;
  width: 2.7rem;
  height: 2.7rem;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(135deg, #dbeafe, #d1fae5);
  color: var(--primary-dark);
  font-weight: 900;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.byline strong,
.byline span {
  display: block;
}

.byline span {
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.article-title {
  margin: 0;
  font-size: clamp(2rem, 8vw, 4.7rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.dek {
  max-width: 48rem;
  margin: 1rem 0 0;
  color: #39465f;
  font-size: clamp(1.02rem, 3vw, 1.22rem);
  line-height: 1.58;
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.35rem 0 0;
}

.ad-slot {
  display: grid;
  min-height: 5.25rem;
  margin: 1.5rem 0;
  place-items: center;
  border: 1px dashed #b6c6df;
  border-radius: 1rem;
  background: linear-gradient(135deg, #f8fbff, #eef6ff);
  color: #657189;
  font-size: 0.85rem;
  font-weight: 800;
  text-align: center;
}

.article-body {
  margin-top: 1.5rem;
}

.article-body h2 {
  margin: 1.8rem 0 0.65rem;
  font-size: clamp(1.45rem, 5vw, 2.15rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.article-body p {
  margin: 0 0 1.05rem;
  color: #1f2a3d;
  font-size: clamp(1.03rem, 3.8vw, 1.22rem);
  line-height: 1.74;
}

.inline-image {
  overflow: hidden;
  margin: 1.35rem 0;
  border-radius: 1rem;
  background: #dce7fb;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.4rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
}

.stats span {
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: #f1f5fb;
}

.footer-note {
  margin: 1.4rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.code-form {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.code-form input {
  min-width: 0;
  flex: 1;
  min-height: 2.75rem;
  padding: 0 0.9rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  color: var(--ink);
}

.error-mark {
  display: grid;
  width: 3rem;
  height: 3rem;
  margin: 0 auto;
  place-items: center;
  border-radius: 1rem;
  background: #fee2e2;
  color: var(--danger);
  font-weight: 900;
}

@media (max-width: 640px) {
  .reader-shell {
    padding: 0.85rem;
  }

  .article-card,
  .state-card {
    border-radius: 1rem;
  }

  .hero-media {
    aspect-ratio: 4 / 3;
  }

  .topbar {
    padding: 0.7rem 0.85rem;
  }

  .code-form {
    flex-direction: column;
  }
}
