/* ==========================================================================
   NewsAI Network — shared stylesheet
   Ported from BaltimoreNewsAI. Every color is a CSS variable. Each generated
   page injects its own brand values in <style id="site-theme"> (see
   scripts/build.js), overriding the neutral fallbacks below.
   Dark is the default (:root); light is [data-theme="light"] on <html>.
   ========================================================================== */

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

:root {
  color-scheme: dark;

  /* Brand (per-site overrides are injected by the build) */
  --brand-primary: #1f2b45;
  --brand-secondary: #5b7fb5;
  --brand-accent: #8fb3e8;
  --brand-surface: #253759;
  --brand-surface-2: #33497a;
  --brand-surface-3: #18243d;
  --brand-on-surface: #c8dcfa;
  --brand-on-surface-text: #f5f7fb;
  --brand-highlight: #9dbdea;
  --brand-highlight-2: #c9dbf5;

  /* Neutrals */
  --color-bg: #0a0c12;
  --color-bg-2: #121827;
  --color-card: #161c2b;
  --color-card-hover: #1f2739;
  --color-glass: rgba(22, 28, 43, 0.72);
  --color-glass-strong: rgba(22, 28, 43, 0.88);
  --color-text: #eef1f7;
  --color-text-muted: #a4adc2;
  --color-border: #2b3449;
  --color-border-brand: rgba(157, 189, 234, 0.25);
  --color-border-brand-strong: rgba(157, 189, 234, 0.5);

  /* Effects */
  --shadow-soft: rgba(37, 55, 89, 0.28);
  --shadow-strong: rgba(37, 55, 89, 0.55);
  --glow: rgba(157, 189, 234, 0.22);
  --canvas-opacity: 1;

  /* Semantic category tones (not brand colors; tuned for contrast per theme) */
  --tone-red: #fca5a5;
  --tone-orange: #fdba74;
  --tone-amber: #fcd34d;
  --tone-green: #86efac;
  --tone-teal: #5eead4;
  --tone-blue: #93c5fd;
  --tone-violet: #c4b5fd;
  --tone-pink: #f9a8d4;
  --tone-slate: #cbd5e1;
  --tone-bg-strength: 16%;
  --state-error: #fca5a5;

  /* How strongly brand surfaces tint neutral UI (per theme mode, not per site) */
  --tint-weak: 16%;
  --tint-mid: 30%;
  --tint-strong: 45%;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Merriweather', Georgia, serif;
}

[data-theme="light"] {
  color-scheme: light;

  --brand-primary: #24406e;
  --brand-secondary: #4f79b8;
  --brand-accent: #24406e;
  --brand-surface: #24406e;
  --brand-surface-2: #2f5190;
  --brand-surface-3: #1a2f52;
  --brand-on-surface: #ffffff;
  --brand-on-surface-text: #ffffff;
  --brand-highlight: #24406e;
  --brand-highlight-2: #2f5a9e;

  --color-bg: #f2f4f8;
  --color-bg-2: #e8ebf2;
  --color-card: #fdfdfe;
  --color-card-hover: #f4f7fc;
  --color-glass: rgba(253, 253, 254, 0.88);
  --color-glass-strong: rgba(253, 253, 254, 0.95);
  --color-text: #161b26;
  --color-text-muted: #545b69;
  --color-border: #d3d9e4;
  --color-border-brand: rgba(36, 64, 110, 0.18);
  --color-border-brand-strong: rgba(36, 64, 110, 0.45);

  --shadow-soft: rgba(10, 16, 28, 0.07);
  --shadow-strong: rgba(36, 64, 110, 0.16);
  --glow: rgba(36, 64, 110, 0.16);
  --canvas-opacity: 0.75;

  --tone-red: #b91c1c;
  --tone-orange: #c2410c;
  --tone-amber: #92400e;
  --tone-green: #15803d;
  --tone-teal: #0f766e;
  --tone-blue: #1d4ed8;
  --tone-violet: #6d28d9;
  --tone-pink: #be185d;
  --tone-slate: #475569;
  --tone-bg-strength: 10%;
  --state-error: #b91c1c;

  --tint-weak: 5%;
  --tint-mid: 9%;
  --tint-strong: 14%;
}

/* ---------- Base ---------- */

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  /* Painted on the canvas so the fixed background layers (z-index < 0) show. */
  background-color: var(--color-bg);
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% -10%, var(--color-bg-2) 0%, transparent 65%),
    radial-gradient(90% 55% at 50% 115%, color-mix(in srgb, var(--brand-surface) var(--tint-mid), transparent) 0%, transparent 70%);
}

#three-background {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--canvas-opacity);
  transition: opacity 0.4s ease;
}

#three-background canvas {
  display: block;
}

a {
  color: var(--brand-highlight);
}

button {
  font: inherit;
  color: inherit;
}

ul {
  list-style: none;
}

img,
svg {
  max-width: 100%;
}

/* Scripts toggle UI with the hidden attribute; keep it winning over display rules. */
[hidden] {
  display: none !important;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
  position: relative;
  z-index: 1;
}

/* ---------- Accessibility helpers ---------- */

.visually-hidden {
  position: absolute !important;
  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: 1rem;
  top: -4rem;
  z-index: 1000;
  padding: 0.6rem 1rem;
  background: var(--brand-surface);
  color: var(--brand-on-surface-text);
  border: 2px solid var(--brand-highlight);
  border-radius: var(--radius-md);
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 1rem;
}

:focus-visible {
  outline: 3px solid var(--brand-highlight);
  outline-offset: 2px;
}

main:focus {
  outline: none;
}

/* ---------- Glass surfaces ---------- */

.site-header,
.site-footer,
.story-card,
.theme-toggle {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ---------- Stats banner ---------- */

.stats-banner {
  background: linear-gradient(135deg, var(--brand-surface-3) 0%, var(--brand-surface) 50%, var(--brand-surface-2) 100%);
  color: var(--brand-on-surface-text);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  text-align: center;
  border: 1px solid var(--color-border-brand);
  box-shadow: 0 0 20px var(--glow);
}

.stats-banner strong {
  color: var(--brand-on-surface);
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px var(--glow);
}

/* ---------- Weather widget ---------- */

.weather-widget {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.5rem 1rem;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg,
      color-mix(in srgb, var(--brand-surface) var(--tint-mid), transparent),
      color-mix(in srgb, var(--brand-surface) var(--tint-weak), transparent));
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  font-size: 0.875rem;
  min-height: 2.75rem;
}

.weather-content {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
}

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

.weather-temp {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--brand-highlight);
  font-variant-numeric: tabular-nums;
}

.weather-condition {
  color: var(--color-text);
}

.weather-location,
.weather-extra {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.weather-loading,
.weather-error {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

/* ---------- Header ---------- */

.site-header {
  position: relative;
  text-align: center;
  padding: 2rem 1.5rem;
  margin-bottom: 2rem;
  background: var(--color-glass);
  border: 1px solid var(--color-border-brand);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px var(--shadow-soft);
  overflow: hidden;
}

.site-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-surface-2), var(--brand-secondary), var(--brand-highlight));
  opacity: 0.9;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.monogram {
  display: block;
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 4px 10px var(--shadow-soft));
}

.monogram-sm {
  width: 28px;
  height: 28px;
}

.monogram .mg-stop-a {
  stop-color: var(--brand-surface-3);
}

.monogram .mg-stop-b {
  stop-color: var(--brand-surface-2);
}

.monogram .mg-ring {
  stroke: var(--brand-highlight);
  opacity: 0.55;
}

.monogram .mg-letter {
  fill: var(--brand-on-surface);
  font-family: var(--font-serif);
  font-weight: 700;
}

.logo h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  line-height: 1.2;
  font-weight: 700;
  color: var(--brand-highlight);
  background: linear-gradient(135deg, var(--brand-highlight) 0%, var(--brand-highlight-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  overflow-wrap: anywhere;
}

.tagline {
  font-size: 1.125rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.tagline:empty {
  display: none;
}

.disclaimer {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  max-width: 500px;
  margin: 0 auto 1rem;
}

/* ---------- Navigation ---------- */

.nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.nav-link {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  text-decoration: none;
  color: var(--color-text-muted);
  font-weight: 500;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.nav-link:hover {
  background: color-mix(in srgb, var(--brand-surface) var(--tint-mid), transparent);
  color: var(--color-text);
}

.nav-link.active {
  background: linear-gradient(135deg, var(--brand-surface) 0%, var(--brand-surface-2) 100%);
  color: var(--brand-on-surface);
  border-color: var(--color-border-brand-strong);
}

/* ---------- Date display ---------- */

.date-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

#current-date,
.date-heading {
  font-size: 1rem;
  font-weight: 600;
  color: var(--brand-highlight);
}

.latest-pill {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
  color: var(--brand-on-surface);
  background: var(--brand-surface);
  border: 1px solid var(--color-border-brand);
}

.fallback-note {
  margin: -0.75rem auto 1.5rem;
  max-width: 560px;
  padding: 0.5rem 0.9rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  background: var(--color-glass);
  border: 1px dashed var(--color-border-brand-strong);
  border-radius: var(--radius-md);
}

.fallback-note[hidden] {
  display: none;
}

.refresh-btn {
  background: color-mix(in srgb, var(--brand-surface) var(--tint-strong), transparent);
  border: 1px solid var(--color-border-brand);
  color: var(--color-text);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.125rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.3s ease;
}

.refresh-btn:hover {
  background: var(--brand-surface-2);
  color: var(--brand-on-surface-text);
}

.refresh-btn.spinning {
  transform: rotate(360deg);
}

/* ---------- Stories ---------- */

.stories-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.story-card {
  background: var(--color-glass);
  border: 1px solid var(--color-border-brand);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem;
  box-shadow: 0 4px 20px var(--shadow-soft);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease, background-color 0.3s ease;
}

.story-card:hover {
  box-shadow: 0 8px 32px var(--shadow-strong), 0 0 25px var(--glow);
  border-color: var(--color-border-brand-strong);
  transform: translateY(-4px);
  background: var(--color-glass-strong);
}

.rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--brand-surface) 0%, var(--brand-surface-2) 100%);
  color: var(--brand-on-surface);
  font-weight: 700;
  font-size: 1.125rem;
  font-variant-numeric: tabular-nums;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  border: 1px solid var(--color-border-brand);
}

.story-card.rank-top .rank {
  box-shadow: 0 0 16px var(--glow);
  border-color: var(--color-border-brand-strong);
}

.story-content {
  min-width: 0;
}

.story-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.story-card h3 {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.5rem;
  color: var(--color-text);
  overflow-wrap: anywhere;
}

.story-card .summary {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  margin-bottom: 0.75rem;
  line-height: 1.55;
}

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

.source-name {
  font-weight: 600;
  color: var(--brand-highlight);
}

.meta-separator {
  color: var(--color-border-brand-strong);
}

/* Category chip */
.badge {
  --tone: var(--brand-highlight);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) var(--tone-bg-strength), transparent);
  border: 1px solid color-mix(in srgb, var(--tone) 30%, transparent);
}

.badge-emoji {
  font-size: 0.85rem;
  line-height: 1;
}

.tone-red { --tone: var(--tone-red); }
.tone-orange { --tone: var(--tone-orange); }
.tone-amber { --tone: var(--tone-amber); }
.tone-green { --tone: var(--tone-green); }
.tone-teal { --tone: var(--tone-teal); }
.tone-blue { --tone: var(--tone-blue); }
.tone-violet { --tone: var(--tone-violet); }
.tone-pink { --tone: var(--tone-pink); }
.tone-slate { --tone: var(--tone-slate); }
.tone-brand { --tone: var(--brand-highlight); }

.story-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--brand-on-surface);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, var(--brand-surface) 0%, var(--brand-surface-2) 100%);
  border: 1px solid var(--color-border-brand);
  border-radius: var(--radius-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.story-link:hover {
  box-shadow: 0 0 20px var(--glow);
  transform: translateX(4px);
}

.multi-sources {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: color-mix(in srgb, var(--brand-surface) var(--tint-weak), transparent);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-brand);
}

.sources-label {
  display: block;
  font-size: 0.75rem;
  color: var(--brand-highlight);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.source-link {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--brand-on-surface);
  background: linear-gradient(135deg, var(--brand-surface) 0%, var(--brand-surface-2) 100%);
  border-radius: var(--radius-sm);
  text-decoration: none;
  border: 1px solid var(--color-border-brand);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.source-link:hover {
  box-shadow: 0 0 20px var(--glow);
  transform: translateY(-1px);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0 0 0.75rem;
}

.tag {
  font-size: 0.6875rem;
  color: var(--brand-highlight);
  background: color-mix(in srgb, var(--brand-surface) var(--tint-mid), transparent);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-brand);
}

/* ---------- Loading / empty / error ---------- */

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

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--brand-highlight);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-muted);
  font-size: 1.0625rem;
}

.error-state {
  text-align: center;
  padding: 2rem 1rem;
  background: color-mix(in srgb, var(--state-error) 10%, transparent);
  border-radius: var(--radius-md);
  color: var(--state-error);
  border: 1px solid color-mix(in srgb, var(--state-error) 35%, transparent);
}

.retry-btn {
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-brand);
  background: linear-gradient(135deg, var(--brand-surface) 0%, var(--brand-surface-2) 100%);
  color: var(--brand-on-surface);
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Archive ---------- */

.archive-layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 2rem;
}

.date-sidebar {
  position: sticky;
  top: 1rem;
  align-self: start;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 0.85rem;
  background: var(--color-glass);
  border: 1px solid var(--color-border-brand);
  border-radius: var(--radius-lg);
}

.date-sidebar h2 {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.date-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.month-group {
  margin-bottom: 0.5rem;
}

.month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem;
  background: color-mix(in srgb, var(--brand-surface) var(--tint-strong), transparent);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.month-header:hover {
  background: var(--brand-surface-2);
  color: var(--brand-on-surface-text);
}

.month-label {
  flex: 1;
  text-align: left;
  white-space: nowrap;
}

.month-count {
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.month-header:hover .month-count {
  color: inherit;
}

.month-toggle {
  font-size: 0.7rem;
  opacity: 0.75;
  transition: transform 0.2s ease;
}

.month-header[aria-expanded="true"] .month-toggle {
  transform: rotate(90deg);
}

.month-dates {
  padding-left: 0.5rem;
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.month-dates[hidden] {
  display: none;
}

.date-btn {
  background: none;
  border: 1px solid transparent;
  text-align: left;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--color-text);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.date-btn:hover {
  background: color-mix(in srgb, var(--brand-surface) var(--tint-mid), transparent);
}

.date-btn.active {
  background: linear-gradient(135deg, var(--brand-surface) 0%, var(--brand-surface-2) 100%);
  color: var(--brand-on-surface);
  border-color: var(--color-border-brand-strong);
  font-weight: 600;
}

.loading-text {
  color: var(--color-text-muted);
  font-style: italic;
  padding: 1rem 0;
}

/* ---------- About ---------- */

.about-section {
  margin-top: 3rem;
  padding: 2rem;
  background: linear-gradient(135deg, var(--brand-surface-3) 0%, var(--brand-surface) 50%, var(--brand-surface-2) 100%);
  border-radius: var(--radius-lg);
  color: var(--brand-on-surface-text);
  border: 1px solid var(--color-border-brand);
  box-shadow: 0 10px 30px var(--shadow-strong);
}

.about-section h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--brand-on-surface);
}

.about-section p {
  margin-bottom: 1rem;
  line-height: 1.7;
  font-size: 0.9375rem;
}

.about-section p:last-child {
  margin-bottom: 0;
}

.about-section strong {
  color: var(--brand-on-surface);
}

/* ---------- Sources & rules ---------- */

.sources-section,
.rules-section {
  margin-top: 2rem;
  padding: 2rem;
  background: linear-gradient(145deg, var(--color-glass-strong) 0%, color-mix(in srgb, var(--brand-surface) var(--tint-weak), var(--color-glass)) 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

.sources-section h2,
.rules-section h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--brand-highlight);
}

.rules-section h2 {
  margin-bottom: 1.5rem;
  text-align: center;
}

.sources-section > p {
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.sources-grid > li {
  display: flex;
}

.source-card {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1rem;
  background: linear-gradient(145deg, var(--color-card) 0%, color-mix(in srgb, var(--brand-surface) var(--tint-weak), var(--color-card)) 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

a.source-card:hover {
  border-color: var(--color-border-brand-strong);
  transform: translateY(-2px);
  box-shadow: 0 10px 15px var(--shadow-soft);
}

.source-card strong {
  color: var(--color-text);
  font-size: 0.9375rem;
  margin-bottom: 0.25rem;
}

.source-card span {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.source-card-empty {
  color: var(--color-text-muted);
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.rule-card {
  padding: 1.25rem;
  background: linear-gradient(145deg, var(--color-card) 0%, color-mix(in srgb, var(--brand-surface) var(--tint-weak), var(--color-card)) 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

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

.rule-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.5rem;
}

.rule-card strong {
  display: block;
  color: var(--brand-highlight);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.rule-card p {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* ---------- Footer ---------- */

.site-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  margin-top: 2rem;
  margin-bottom: 4.5rem; /* keep clear of the floating theme toggle */
  background: var(--color-glass);
  border: 1px solid var(--color-border-brand);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px var(--shadow-soft);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.site-footer p {
  margin-bottom: 0.25rem;
}

.site-footer a {
  color: var(--brand-highlight);
}

.legal {
  margin-top: 0.5rem;
  font-size: 0.75rem;
}

.powered-by {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.8125rem;
  color: var(--brand-highlight);
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.95rem 0.55rem 0.7rem;
  border-radius: 999px;
  border: 2px solid var(--color-border-brand-strong);
  background: var(--color-glass-strong);
  color: var(--color-text);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  box-shadow: 0 4px 20px var(--shadow-strong);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.theme-toggle:hover {
  transform: scale(1.05);
  border-color: var(--brand-highlight);
}

.toggle-dot {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand-primary) 0 50%, var(--brand-secondary) 50% 100%);
  box-shadow: 0 0 0 2px var(--color-card), 0 0 0 3px var(--brand-highlight);
}

.toggle-label-light {
  display: none;
}

[data-theme="light"] .toggle-label-dark {
  display: none;
}

[data-theme="light"] .toggle-label-light {
  display: inline;
}

/* ---------- Terms page ---------- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.5rem 0 1rem;
  padding: 0.35rem 0.8rem 0.35rem 0.4rem;
  color: var(--brand-highlight);
  background: var(--color-glass);
  border: 1px solid var(--color-border-brand);
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
}

.back-link:hover {
  border-color: var(--color-border-brand-strong);
}

.terms-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
  background: var(--color-glass-strong);
  border: 1px solid var(--color-border-brand);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px var(--shadow-soft);
}

.terms-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.terms-header h1 {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  line-height: 1.25;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}

.terms-header p {
  color: var(--color-text-muted);
}

.terms-content {
  counter-reset: terms-section;
}

.terms-content h2 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  margin-top: 2.25rem;
  margin-bottom: 0.75rem;
  color: var(--brand-highlight);
}

.terms-content h2::before {
  counter-increment: terms-section;
  content: counter(terms-section) ". ";
}

.terms-content p,
.terms-content li {
  line-height: 1.7;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.terms-content ul {
  list-style: disc;
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.terms-content li {
  margin-bottom: 0.4rem;
}

.terms-content strong {
  color: var(--color-text);
}

.terms-content a {
  color: var(--brand-highlight);
  overflow-wrap: anywhere;
}

/* ---------- Directory page (public/index.html) ---------- */

.directory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.directory-link {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  height: 100%;
  padding: 1rem;
  background: var(--color-glass);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--color-text);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.directory-link:hover {
  transform: translateY(-2px);
  border-color: var(--color-border-brand-strong);
}

.directory-badge svg {
  display: block;
  border-radius: 10px;
}

.directory-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.directory-text span {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.directory-text .directory-domain {
  color: var(--brand-highlight);
}

.page-directory .powered-by {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
  .archive-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
  }

  .date-sidebar {
    position: static;
    max-height: none;
  }

  /* One swipeable row of date chips per month keeps the stories near the top. */
  .month-dates {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.4rem;
    padding: 0.1rem 0.1rem 0.6rem;
    margin-top: 0.5rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .date-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    scroll-snap-align: start;
    border-color: var(--color-border);
  }

  .logo h1 {
    font-size: 1.5rem;
  }

  .monogram {
    width: 38px;
    height: 38px;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 0.75rem;
  }

  .site-header {
    padding: 1.5rem 1rem;
    margin-bottom: 1.5rem;
  }

  .story-card {
    padding: 1rem;
    gap: 0.75rem;
  }

  .rank {
    width: 32px;
    height: 32px;
    font-size: 0.9375rem;
  }

  .story-card h3 {
    font-size: 1.0625rem;
  }

  .about-section,
  .sources-section,
  .rules-section {
    padding: 1.5rem 1.1rem;
  }

  .sources-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
  }

  .rules-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .terms-page {
    padding: 1.5rem 1.1rem;
  }

  .terms-header h1 {
    font-size: 1.75rem;
  }

  .theme-toggle {
    bottom: 0.9rem;
    right: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .story-card:hover,
  .story-link:hover,
  .source-link:hover,
  a.source-card:hover,
  .rule-card:hover,
  .theme-toggle:hover,
  .directory-link:hover {
    transform: none;
  }

  .loading-spinner {
    animation: spin 1.6s linear infinite !important;
    animation-duration: 1.6s !important;
    animation-iteration-count: infinite !important;
  }
}

/* ---------- Network hub: US map + site list (usanewsai.com) ---------- */

.network-section {
  margin: 2rem 0;
  padding: 2rem;
  background: linear-gradient(145deg, var(--color-glass-strong) 0%, color-mix(in srgb, var(--brand-surface) var(--tint-weak), var(--color-glass)) 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  scroll-margin-top: 1rem;
}

.network-section h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--brand-highlight);
  text-align: center;
}

.network-intro {
  max-width: 560px;
  margin: 0 auto 1.25rem;
  color: var(--color-text-muted);
  text-align: center;
}

.network-map {
  margin: 0 auto 0.5rem;
}

.us-map {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.map-land {
  fill: color-mix(in srgb, var(--brand-surface) var(--tint-mid), var(--color-card));
  stroke: var(--color-border-brand-strong);
  stroke-width: 1;
  stroke-linejoin: round;
}

.map-borders {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 0.6;
  stroke-linejoin: round;
}

/* Each marker carries its own city's colors (--m-dark / --m-light). */
.map-marker {
  --m: var(--m-dark);
  cursor: pointer;
}

[data-theme="light"] .map-marker {
  --m: var(--m-light);
}

.map-hit {
  fill: transparent;
}

.map-dot,
.map-pulse {
  transform-box: fill-box;
  transform-origin: center;
}

.map-dot {
  fill: var(--m);
  stroke: var(--color-bg);
  stroke-width: 1.5;
  transition: transform 0.15s ease;
}

.map-pulse {
  fill: var(--m);
  opacity: 0;
  animation: map-pulse 3s ease-out infinite;
}

.map-label {
  fill: var(--color-text);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  paint-order: stroke;
  stroke: var(--color-bg);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.map-leader {
  stroke: var(--color-text-muted);
  stroke-width: 0.8;
}

.map-marker:hover .map-dot,
.map-marker:focus-visible .map-dot {
  transform: scale(1.5);
}

.map-marker:hover .map-label,
.map-marker:focus-visible .map-label {
  fill: var(--m);
}

.map-marker:focus-visible {
  outline: none;
}

.map-marker:focus-visible .map-hit {
  stroke: var(--brand-highlight);
  stroke-width: 2;
}

@keyframes map-pulse {
  from {
    transform: scale(1);
    opacity: 0.5;
  }
  to {
    transform: scale(3);
    opacity: 0;
  }
}

.network-subtitle {
  margin: 1.25rem 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.network-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.network-list > li {
  display: flex;
}

.network-card {
  --c: var(--c-dark);
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  padding: 0.75rem 0.9rem;
  background: var(--color-glass);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--c);
  border-radius: var(--radius-md);
  color: var(--color-text);
  text-decoration: none;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

[data-theme="light"] .network-card {
  --c: var(--c-light);
}

.network-card:hover {
  transform: translateY(-2px);
  border-color: var(--c);
  box-shadow: 0 10px 15px var(--shadow-soft);
}

.network-badge {
  flex-shrink: 0;
}

.network-badge svg {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 9px;
}

.network-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.network-text strong {
  font-size: 0.95rem;
}

.network-text span {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.network-domain {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.network-footer a {
  font-weight: 600;
}

@media (max-width: 600px) {
  .network-section {
    padding: 1.25rem;
  }

  /* Labels are unreadable at phone width; the list below names every city. */
  .map-label,
  .map-leader {
    display: none;
  }

  .network-list {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 380px) {
  .network-list {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-pulse {
    display: none;
  }

  .network-card:hover,
  .map-marker:hover .map-dot {
    transform: none;
  }
}

/* ==========================================================================
   NewsAI All-Access: header account bar, "more stories", upsell, and the
   hub's account (account.html) and sign-in hand-off (connect.html) pages.
   ========================================================================== */

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0.6rem 1.25rem;
  border: 1px solid var(--color-border-brand);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-surface) 0%, var(--brand-surface-2) 100%);
  color: var(--brand-on-surface);
  border-color: var(--color-border-brand-strong);
}

.btn-primary:hover {
  box-shadow: 0 0 20px var(--glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--color-glass-strong);
  color: var(--color-text);
  border-color: var(--color-border-brand-strong);
}

.btn-secondary:hover {
  border-color: var(--brand-highlight);
  background: var(--color-card-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}

.btn-ghost:hover {
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn[aria-busy="true"] {
  opacity: 1;
  cursor: progress;
}

/* ---------- Premium badge ---------- */

.premium-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.5;
  white-space: nowrap;
  color: var(--brand-on-surface);
  background: linear-gradient(135deg, var(--brand-surface) 0%, var(--brand-surface-2) 100%);
  border: 1px solid var(--color-border-brand-strong);
}

/* ---------- Header account bar ---------- */

.account-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  min-height: 2rem;
  margin: -1rem -0.75rem 0.85rem;
  font-size: 0.8125rem;
}

/* Rendered from the stored pass by common.js; avoids a "Sign in" flash. */
.account-bar[data-state="pending"] {
  visibility: hidden;
}

.account-user {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  max-width: 100%;
}

.account-action {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  min-height: 2rem;
  padding: 0.3rem 0.85rem;
  border: 1px solid var(--color-border-brand-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand-surface) var(--tint-weak), transparent);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.account-action:hover {
  background: var(--brand-surface);
  color: var(--brand-on-surface-text);
  border-color: var(--brand-highlight);
}

#account-signin {
  background: linear-gradient(135deg, var(--brand-surface) 0%, var(--brand-surface-2) 100%);
  color: var(--brand-on-surface);
}

.account-upgrade {
  color: var(--brand-highlight);
}

#account-signout {
  padding-inline: 0.55rem;
  border-color: transparent;
  background: transparent;
  color: var(--color-text-muted);
}

#account-signout:hover {
  color: var(--color-text);
  border-color: var(--color-border);
  background: transparent;
}

.account-email {
  min-width: 0;
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text-muted);
  text-decoration: none;
}

.account-email:hover {
  color: var(--color-text);
  text-decoration: underline;
}

/* ---------- Home: more stories (All-Access) ---------- */

.more-stories {
  margin-top: 2.5rem;
}

.more-stories-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border-brand);
}

.more-stories-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  line-height: 1.3;
  color: var(--brand-highlight);
}

.more-stories-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.more-stories-list {
  gap: 0.75rem;
}

.story-card-compact {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  padding: 1rem 1.15rem;
}

.story-card-compact:hover {
  transform: translateY(-2px);
}

.story-card-compact .story-kicker {
  margin-bottom: 0.3rem;
}

.story-card-compact h3 {
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.story-card-compact .summary {
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.story-card-compact .story-meta {
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
}

.story-card-compact .story-link {
  padding: 0.35rem 0.8rem;
  font-size: 0.8125rem;
}

.story-card-compact .multi-sources {
  margin-top: 0.5rem;
  padding: 0.6rem;
}

.story-card-compact .source-link {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}

/* ---------- Home: upsell ---------- */

.upsell-card {
  position: relative;
  margin-top: 2.5rem;
  padding: 2rem;
  overflow: hidden;
  text-align: center;
  color: var(--brand-on-surface-text);
  background: linear-gradient(135deg, var(--brand-surface-3) 0%, var(--brand-surface) 55%, var(--brand-surface-2) 100%);
  border: 1px solid var(--color-border-brand-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px var(--shadow-strong), 0 0 30px var(--glow);
}

.upsell-eyebrow,
.account-eyebrow {
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.upsell-eyebrow {
  color: var(--brand-on-surface);
}

.upsell-card h2 {
  margin-bottom: 0.75rem;
  font-family: var(--font-serif);
  font-size: 1.6rem;
  line-height: 1.3;
  color: var(--brand-on-surface-text);
}

.upsell-copy {
  max-width: 34rem;
  margin: 0 auto 1.25rem;
}

.upsell-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* The card is brand-colored, so the button inverts. */
.upsell-card .btn-primary {
  min-width: 12rem;
  background: var(--brand-on-surface);
  color: var(--brand-surface-3);
  border-color: transparent;
}

.upsell-card .btn-primary:focus-visible,
.upsell-signin a:focus-visible {
  outline-color: var(--brand-on-surface-text);
}

.upsell-signin {
  font-size: 0.875rem;
}

.upsell-signin a {
  color: var(--brand-on-surface);
  font-weight: 600;
}

/* ---------- Clerk components (hub pages) ---------- */

/* Clerk reads these CSS variables, so its forms follow the site theme live.
   Primary doubles as Clerk's link color, so it uses the readable highlight. */
.clerk-theme {
  --clerk-color-primary: var(--brand-highlight);
  --clerk-color-primary-foreground: var(--color-bg);
  --clerk-color-background: var(--color-card);
  --clerk-color-foreground: var(--color-text);
  --clerk-color-muted-foreground: var(--color-text-muted);
  --clerk-color-neutral: var(--color-text);
  --clerk-color-input: var(--color-bg);
  --clerk-color-input-foreground: var(--color-text);
  --clerk-color-ring: var(--brand-highlight);
  --clerk-color-danger: var(--state-error);
  --clerk-font-family: var(--font-sans);
  --clerk-border-radius: var(--radius-md);
}

/* Clerk replaces the mount node's class names, so layout lives on this wrapper. */
.clerk-slot {
  display: flex;
  justify-content: center;
  min-width: 0;
  max-width: 100%;
}

.clerk-slot > * {
  min-width: 0;
  max-width: 100%;
}

/* ---------- Account page ---------- */

.account-page {
  max-width: 820px;
  margin: 0 auto;
}

.account-hero,
.account-card,
.plan-card,
.connect-card {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.account-hero {
  position: relative;
  margin-bottom: 1.5rem;
  padding: 2rem 1.5rem 1.75rem;
  overflow: hidden;
  text-align: center;
  background: var(--color-glass);
  border: 1px solid var(--color-border-brand);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px var(--shadow-soft);
}

.account-hero::before,
.connect-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-surface-2), var(--brand-secondary), var(--brand-highlight));
  opacity: 0.9;
}

.account-eyebrow {
  color: var(--brand-highlight);
}

.account-hero h1 {
  margin-bottom: 0.75rem;
  font-family: var(--font-serif);
  font-size: 2rem;
  line-height: 1.25;
  color: var(--color-text);
}

.account-lede {
  max-width: 38rem;
  margin: 0 auto;
  color: var(--color-text-muted);
}

.account-notice {
  --notice: var(--brand-highlight);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding: 0.85rem 1rem;
  color: var(--color-text);
  background: color-mix(in srgb, var(--notice) 10%, var(--color-glass-strong));
  border: 1px solid color-mix(in srgb, var(--notice) 40%, transparent);
  border-left: 4px solid var(--notice);
  border-radius: var(--radius-md);
}

.notice-success { --notice: var(--tone-green); }
.notice-warning { --notice: var(--tone-amber); }
.notice-error { --notice: var(--state-error); }

.notice-spinner {
  flex-shrink: 0;
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid var(--color-border);
  border-top-color: var(--brand-highlight);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.account-loading {
  padding: 2rem 1rem;
}

.account-card {
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: var(--color-glass-strong);
  border: 1px solid var(--color-border-brand);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px var(--shadow-soft);
}

.account-card h2,
.account-section-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  line-height: 1.3;
  color: var(--brand-highlight);
}

.setup-state {
  text-align: center;
}

.setup-state h2 {
  margin-bottom: 0.4rem;
}

.setup-state p {
  color: var(--color-text-muted);
}

.summary-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.summary-id {
  min-width: 0;
}

.summary-id h2 {
  margin-bottom: 0.2rem;
}

.summary-email {
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}

.summary-email strong {
  color: var(--color-text);
}

.clerk-user-button {
  flex-shrink: 0;
  min-width: 2rem;
  min-height: 2rem;
}

.summary-status {
  margin-bottom: 1rem;
  padding: 1rem;
  background: color-mix(in srgb, var(--brand-surface) var(--tint-weak), transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.summary-plan {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
}

.summary-detail {
  margin-top: 0.35rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.summary-detail:empty {
  display: none;
}

.summary-detail.is-warning {
  color: var(--tone-amber);
  font-weight: 600;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.signout-note {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.plans {
  margin: 2rem 0 1.5rem;
}

.account-section-title {
  margin-bottom: 1.25rem;
  text-align: center;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.plan-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1.75rem 1.25rem 1.5rem;
  text-align: center;
  background: var(--color-glass-strong);
  border: 1px solid var(--color-border-brand);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px var(--shadow-soft);
}

.plan-card-featured {
  border: 2px solid var(--brand-highlight);
  box-shadow: 0 8px 32px var(--shadow-strong), 0 0 24px var(--glow);
}

.plan-flag {
  position: absolute;
  top: -0.8rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.1rem 0.7rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--color-bg);
  background: var(--brand-highlight);
}

.plan-card h3 {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.plan-price strong {
  font-size: 2.25rem;
  line-height: 1.2;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.plan-price span {
  margin-left: 0.15rem;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

.plan-note {
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.plan-btn {
  width: 100%;
  margin-top: auto;
}

.plans-note {
  margin-top: 0.9rem;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--brand-highlight);
}

.plans-note:empty {
  display: none;
}

.plan-features {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 1.5rem;
  max-width: 44rem;
  margin: 1.25rem auto 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.plan-features li {
  position: relative;
  padding-left: 1.5rem;
}

.plan-features li::before {
  content: "✓";
  position: absolute;
  left: 0;
  font-weight: 700;
  color: var(--brand-highlight);
}

.signin-panel {
  text-align: center;
  scroll-margin-top: 1rem;
}

.signin-panel h2 {
  margin-bottom: 0.3rem;
}

.signin-panel h2:focus {
  outline: none;
}

.signin-intro {
  margin-bottom: 1.25rem;
  color: var(--color-text-muted);
}

.account-sites {
  margin-top: 2rem;
  padding: 2rem;
  background: linear-gradient(145deg, var(--color-glass-strong) 0%, color-mix(in srgb, var(--brand-surface) var(--tint-weak), var(--color-glass)) 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

/* ---------- Connect page (sign-in hand-off) ---------- */

.connect-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem 1rem;
}

.connect-card {
  position: relative;
  width: 100%;
  max-width: 30rem;
  padding: 2rem 1.5rem;
  overflow: hidden;
  text-align: center;
  background: var(--color-glass-strong);
  border: 1px solid var(--color-border-brand);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px var(--shadow-soft);
}

.connect-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.connect-title {
  margin-bottom: 0.5rem;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  line-height: 1.3;
  color: var(--color-text);
  overflow-wrap: anywhere;
}

.connect-message {
  margin-bottom: 1.25rem;
  color: var(--color-text-muted);
}

.connect-spinner {
  margin: 0.25rem auto 1.25rem;
}

.connect-sign-in {
  margin: 0 -0.75rem 1rem;
}

.connect-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.connect-back {
  font-size: 0.875rem;
  color: var(--brand-highlight);
}

.connect-noscript {
  position: fixed;
  bottom: 1rem;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--color-text-muted);
}

/* ---------- All-Access responsive ---------- */

@media (max-width: 600px) {
  .account-bar {
    margin: -0.5rem -0.25rem 0.75rem;
    gap: 0.35rem;
  }

  .account-user {
    gap: 0.35rem;
  }

  .account-email {
    max-width: 8.5rem;
  }

  .account-action {
    padding: 0.3rem 0.7rem;
  }

  .upsell-card {
    padding: 1.5rem 1.1rem;
  }

  .upsell-card h2 {
    font-size: 1.35rem;
  }

  .more-stories-title {
    font-size: 1.2rem;
  }

  .story-card-compact {
    padding: 0.9rem 1rem;
  }

  .account-hero {
    padding: 1.5rem 1rem;
  }

  .account-hero h1 {
    font-size: 1.6rem;
  }

  .account-card {
    padding: 1.25rem 1rem;
  }

  .plan-grid,
  .plan-features {
    grid-template-columns: minmax(0, 1fr);
  }

  .plan-grid {
    gap: 1.5rem;
  }

  .account-actions .btn {
    flex: 1 1 auto;
  }

  .account-sites {
    padding: 1.25rem;
  }

  .connect-card {
    padding: 1.75rem 1rem;
  }

  .connect-sign-in {
    margin-inline: -0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn-primary:hover,
  .story-card-compact:hover {
    transform: none;
  }

  .notice-spinner {
    animation: spin 1.6s linear infinite !important;
    animation-duration: 1.6s !important;
    animation-iteration-count: infinite !important;
  }
}
