/* ============================================
   OHPAN — Editorial Information Surface

   Aesthetic: Bloomberg Terminal × Premium Newspaper
   Dark-first. Typography-driven. The decay bar is the signature.
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- Tokens --- */
:root {
  /* Surface */
  --bg-deep: #0a0b0d;
  --bg-surface: #12141a;
  --bg-card: #181b23;
  --bg-card-hover: #1e2130;
  --bg-elevated: #252936;

  /* Text */
  --text-primary: #e8e6e1;
  --text-secondary: #9b978f;
  --text-muted: #5c5952;
  --text-accent: #f0c96e;

  /* Decay bar — the signature */
  --decay-glow: 0.4;

  /* Community hues (set per-card via inline style) */
  --community-hue: 210;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-visible: rgba(255, 255, 255, 0.08);

  /* Spacing scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;

  /* Typography */
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'IBM Plex Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Sizing */
  --max-width: 72rem;
  --card-radius: 2px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg-deep);
  line-height: 1.6;
  min-height: 100vh;
}

/* Noise texture overlay for depth */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

a { color: var(--text-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Masthead — centered editorial layout --- */
.masthead {
  text-align: center;
  padding: var(--space-xl) var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
}

.masthead-brand {
  margin-bottom: var(--space-md);
}

.masthead-kite {
  display: inline-block;
  width: min(300px, 55vw);
  opacity: 0;
  transform: translateY(20px);
  animation: kiteReveal 1.6s cubic-bezier(0.16, 1, 0.3, 1) 0.15s forwards;
}

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

.masthead-kite svg {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 0 30px rgba(240, 201, 110, 0.1));
}

.masthead-kite:hover { text-decoration: none; }

.masthead-user {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

.masthead-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  opacity: 0;
  animation: fadeUp 0.8s ease 0.6s forwards;
}

@keyframes fadeUp {
  to { opacity: 1; }
}

.header-login {
  background: none;
  border: 1px solid var(--border-visible);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  padding: 5px 14px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s;
}

.header-login:hover {
  color: var(--text-accent);
  border-color: var(--text-accent);
}

.header-user {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.header-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
}

.header-logout:hover {
  color: var(--text-accent);
}

.header-tokens {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  margin-left: 2px;
  transition: color 0.2s;
  vertical-align: middle;
  line-height: 1;
}

.header-tokens:hover {
  color: var(--text-accent);
}

/* --- Token Modal --- */

.tokens-dialog {
  max-width: 440px;
}

.tokens-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--text-accent);
  margin: 0 0 var(--space-xs);
}

.tokens-subtitle {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 0 0 var(--space-lg);
}

.tokens-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: var(--space-md) 0;
}

.token-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.token-row .token-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.token-row .token-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.token-row .token-meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.token-revoke-btn {
  background: none;
  border: 1px solid #e85c5c;
  color: #e85c5c;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  padding: 3px 10px;
  cursor: pointer;
  border-radius: var(--card-radius);
  transition: all 0.15s;
}

.token-revoke-btn:hover {
  background: #e85c5c;
  color: #fff;
}

.token-create-row {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.token-name-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-visible);
  color: var(--text-primary);
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.85rem;
  font-family: var(--font-body);
  border-radius: var(--card-radius);
}

.token-name-input:focus {
  outline: none;
  border-color: var(--text-accent);
}

.token-create-btn {
  background: var(--text-accent);
  color: var(--bg-base);
  border: none;
  padding: var(--space-xs) var(--space-lg);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--card-radius);
  transition: opacity 0.15s;
  white-space: nowrap;
}

.token-create-btn:hover { opacity: 0.85; }
.token-create-btn:disabled { opacity: 0.5; cursor: wait; }

.token-revealed {
  margin-top: var(--space-lg);
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--text-accent);
  border-radius: var(--card-radius);
}

.token-revealed-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0 0 var(--space-xs);
}

.token-revealed-value {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.token-revealed-value code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-accent);
  word-break: break-all;
  flex: 1;
}

.token-copy-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-visible);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 3px 10px;
  cursor: pointer;
  border-radius: var(--card-radius);
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.token-copy-btn:hover {
  color: var(--text-accent);
  border-color: var(--text-accent);
}

.token-revealed-warning {
  color: #e85c5c;
  font-size: 0.75rem;
  margin: var(--space-sm) 0 0;
}

.token-error {
  margin-top: var(--space-md);
  color: #e85c5c;
  font-size: 0.8rem;
}

/* --- Theme Toggle --- */
.theme-toggle {
  background: none;
  border: 1px solid var(--border-visible);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
  color: var(--text-accent);
  border-color: var(--text-accent);
}

.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: block; }
.theme-light .theme-toggle .icon-moon { display: block; }
.theme-light .theme-toggle .icon-sun { display: none; }

@media (max-width: 720px) {
  .masthead {
    padding: var(--space-lg) var(--space-md) var(--space-sm);
  }
  .masthead-kite {
    width: min(220px, 65vw);
  }
  .masthead-controls {
    gap: var(--space-sm);
  }
}

/* --- Scroll Reveal --- */
.view-card {
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  filter: blur(4px);
  transition:
    opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    filter 0.5s ease;
}

.view-card.revealed {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
}

.header-meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

/* --- Category Bar --- */
.category-bar {
  position: sticky;
  top: 0;
  z-index: 90;
  background: rgba(10, 11, 13, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--space-sm) 0;
}

.category-scroll {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.cat-pill {
  background: transparent;
  border: 1px solid var(--border-visible);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cat-pill:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--bg-elevated);
}

.cat-pill.active {
  color: var(--text-accent);
  border-color: rgba(240, 201, 110, 0.4);
  background: rgba(240, 201, 110, 0.1);
}

.cat-search {
  width: 120px;
  background: transparent;
  border: 1px solid var(--border-visible);
  border-radius: 2px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  outline: none;
  transition: border-color 0.2s, width 0.3s;
}

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

.cat-search:focus {
  border-color: rgba(240, 201, 110, 0.4);
  width: 180px;
}

@media (max-width: 720px) {
  .category-scroll {
    padding: 0 var(--space-md);
  }
  .cat-search {
    width: 100px;
  }
  .cat-search:focus {
    width: 140px;
  }
}

/* --- Stream --- */
.stream {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 420px));
  justify-content: center;
  gap: var(--space-lg);
}

@media (max-width: 720px) {
  .stream {
    grid-template-columns: 1fr;
    padding: var(--space-md);
    gap: var(--space-md);
  }
}

/* --- View Card --- */
.view-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-radius);
  overflow: hidden;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.view-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-visible);
  transform: translateY(-1px);
}

/* Stagger reveal for cards already in viewport on load */
.view-card.revealed:nth-child(1) { transition-delay: 0s; }
.view-card.revealed:nth-child(2) { transition-delay: 0.07s; }
.view-card.revealed:nth-child(3) { transition-delay: 0.14s; }
.view-card.revealed:nth-child(4) { transition-delay: 0.21s; }
.view-card.revealed:nth-child(5) { transition-delay: 0.28s; }
.view-card.revealed:nth-child(6) { transition-delay: 0.35s; }

/* Inner content staggers after card reveals */
.view-card .card-body h2,
.view-card .card-body .lead,
.view-card .card-footer {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.view-card.revealed .card-body h2 {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.15s;
}

.view-card.revealed .card-body .lead {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.25s;
}

.view-card.revealed .card-footer {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.35s;
}

/* Decay bar glow pulses in on reveal */
.view-card .decay-bar {
  opacity: 0;
  transition: opacity 0.8s ease;
}

.view-card.revealed .decay-bar {
  opacity: 1;
  transition-delay: 0.05s;
}

/* --- The Decay Bar --- the signature element --- */
.decay-bar {
  height: 3px;
  background: linear-gradient(
    90deg,
    hsla(var(--community-hue), 70%, 60%, calc(var(--decay, 1) * 0.9 + 0.1)) 0%,
    hsla(var(--community-hue), 50%, 50%, calc(var(--decay, 1) * 0.5)) calc(var(--decay, 1) * 100%),
    hsla(var(--community-hue), 30%, 30%, 0.05) 100%
  );
  box-shadow:
    0 0 calc(var(--decay, 1) * 8px) hsla(var(--community-hue), 70%, 60%, calc(var(--decay, 1) * var(--decay-glow))),
    0 1px 0 var(--border-subtle);
  transition: all 1s ease;
}

/* Recharge animation when new development arrives */
.decay-bar.recharging {
  animation: recharge 0.8s ease;
}

@keyframes recharge {
  0% { filter: brightness(1); }
  30% { filter: brightness(2.5); }
  100% { filter: brightness(1); }
}

/* --- Decay Progress Bar (bottom of card) --- */
.decay-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: calc(var(--decay, 1) * 100%);
  background: hsla(var(--community-hue), 45%, 50%, 0.35);
  transition: width 2s linear;
  border-radius: 0 1px 0 0;
}

/* --- Recency Indicator (top of card) --- */
.card-recency {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: var(--space-sm) var(--space-lg) 0;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.signal-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-right: 5px;
}

.sig-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
}

.dot-live {
  background: #ef4444;
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.5);
}

.dot-fresh {
  background: #22c55e;
  box-shadow: 0 0 4px rgba(34, 197, 94, 0.4);
}

.dot-warm {
  background: #6b8f71;
  opacity: 0.6;
}

.dot-muted {
  background: var(--text-muted);
  opacity: 0.25;
}

/* Modal: text labels */
.tempo-live {
  color: #ef4444;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.tempo-fresh {
  color: #22c55e;
  font-weight: 500;
  letter-spacing: 0.06em;
}

/* Cards: override to colored dots only, hide text */
.card-recency .tempo-live,
.card-recency .tempo-fresh {
  font-size: 0;
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  vertical-align: middle;
  margin-left: 2px;
}

.card-recency .tempo-live {
  background: #ef4444;
  box-shadow: 0 0 5px rgba(239, 68, 68, 0.5);
}

.card-recency .tempo-fresh {
  background: #22c55e;
  box-shadow: 0 0 5px rgba(34, 197, 94, 0.4);
}

/* --- Card Content --- */
.card-body {
  padding: var(--space-lg);
}

.card-hero {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  border-bottom: 1px solid var(--border-subtle);
}

.card-body h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1.3;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  letter-spacing: -0.01em;
}

.card-body .lead {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: var(--space-md);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Image-Forward Card --- */
.view-card.card-image-forward {
  padding: 0;
  overflow: hidden;
  position: relative;
}

.view-card.card-image-forward .card-hero-wrap {
  position: relative;
  width: 100%;
  min-height: 220px;
  overflow: hidden;
}

.view-card.card-image-forward .card-hero-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.view-card.card-image-forward .card-hero-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 30%,
    var(--bg-surface) 100%
  );
  pointer-events: none;
}

.view-card.card-image-forward .card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-md) var(--space-lg);
  z-index: 1;
}

.view-card.card-image-forward .card-overlay h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text-primary);
  margin: 0 0 var(--space-xs) 0;
}

.view-card.card-image-forward .card-overlay .card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.view-card.card-image-forward .card-overlay .dev-count {
  color: hsla(var(--community-hue), 50%, 65%, 0.8);
}

.view-card.card-image-forward .card-footer {
  display: none;
}

/* --- Card Footer --- */
.card-footer {
  padding: var(--space-sm) var(--space-lg) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.dev-count {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: hsla(var(--community-hue), 50%, 65%, 0.8);
  font-weight: 500;
  font-size: 0.7rem;
}

.attribution {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.75rem;
}

.attribution strong {
  color: var(--text-secondary);
  font-weight: 500;
}

/* --- Card Actions --- */
.card-actions {
  display: flex;
  gap: var(--space-sm);
  padding: 0 var(--space-lg) var(--space-md);
}

.card-actions button {
  background: transparent;
  border: 1px solid var(--border-visible);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--space-xs) var(--space-sm);
  border-radius: 1px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.card-actions button:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: rgba(255, 255, 255, 0.15);
}

.card-actions button.tracked {
  background: hsla(var(--community-hue), 50%, 40%, 0.2);
  border-color: hsla(var(--community-hue), 50%, 50%, 0.3);
  color: hsla(var(--community-hue), 60%, 70%, 1);
}

/* --- Caught Up --- */
.caught-up {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
}

.caught-up p {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text-muted);
  font-style: italic;
}

.caught-up .meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-md);
  letter-spacing: 0.05em;
}

.caught-up button {
  margin-top: var(--space-lg);
  background: transparent;
  border: 1px solid var(--border-visible);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--space-sm) var(--space-lg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.caught-up button:hover {
  border-color: var(--text-accent);
  color: var(--text-accent);
}

/* --- Expanded View --- */
.view-expanded {
  max-width: 48rem;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
}

.view-expanded h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1.2;
  margin-bottom: var(--space-md);
}

.view-expanded .summary {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.7;
  margin-bottom: var(--space-xl);
  border-left: 2px solid hsla(var(--community-hue), 50%, 50%, 0.3);
  padding-left: var(--space-lg);
}

/* Development timeline */
.development-list {
  list-style: none;
}

.development-item {
  position: relative;
  padding: var(--space-lg) 0;
  padding-left: var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
}

.development-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: var(--space-lg);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: hsla(var(--community-hue), 60%, 55%, 0.6);
  box-shadow: 0 0 6px hsla(var(--community-hue), 60%, 55%, 0.2);
}

.development-item::after {
  content: '';
  position: absolute;
  left: 3.5px;
  top: calc(var(--space-lg) + 12px);
  bottom: 0;
  width: 1px;
  background: var(--border-visible);
}

.development-item:last-child::after { display: none; }

.development-item .synthesis {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.development-item .dev-meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: var(--space-sm);
  letter-spacing: 0.03em;
}

.development-item .source-link {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-accent);
  opacity: 0.7;
}

.development-item .source-link:hover { opacity: 1; }

/* --- Modal Overlay --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: background 0.3s ease, backdrop-filter 0.3s ease;
}

.modal-overlay.open {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.modal-container {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-visible);
  border-radius: 3px;
  width: 90%;
  max-width: 800px;
  max-height: 85vh;
  overflow-y: auto;
  padding: var(--space-xl);
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.modal-overlay.open .modal-container {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* --- Modal Top Bar (close + TTS) --- */
.modal-top-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  float: right;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-left: var(--space-md);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 var(--space-xs);
  line-height: 1;
  transition: color 0.15s;
}

.modal-close:hover {
  color: var(--text-primary);
}

/* Modal content inherits the expanded view styles */
.modal-container .view-expanded {
  padding: 0;
}

/* --- TTS Play Button --- */
.tts-play-btn {
  position: relative;
  background: transparent;
  border: 1px solid var(--border-visible);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.tts-play-btn:hover {
  color: var(--text-accent);
  border-color: rgba(240, 201, 110, 0.4);
  background: rgba(240, 201, 110, 0.06);
}

/* Loading — spinner throbber */
.tts-play-btn.tts-loading {
  border-color: rgba(240, 201, 110, 0.3);
  cursor: wait;
}

.tts-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(240, 201, 110, 0.15);
  border-top-color: var(--text-accent);
  border-radius: 50%;
  animation: tts-spin 0.7s linear infinite;
}

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

/* Playing */
.tts-play-btn.tts-playing {
  color: var(--text-accent);
  border-color: rgba(240, 201, 110, 0.5);
  background: rgba(240, 201, 110, 0.1);
  box-shadow: 0 0 8px rgba(240, 201, 110, 0.15);
}

/* Error — red flash */
.tts-play-btn.tts-error {
  color: #e55;
  border-color: rgba(238, 85, 85, 0.5);
  background: rgba(238, 85, 85, 0.08);
}

/* --- TTS Mini Player (persistent) --- */
.tts-mini-player {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(18, 20, 26, 0.94);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-visible);
  border-radius: 10px;
  max-width: 340px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.tts-mini-player.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.mini-tts-progress-bar {
  position: absolute;
  top: 0;
  left: 10px;
  right: 10px;
  height: 2px;
  background: rgba(240, 201, 110, 0.08);
  border-radius: 1px;
  overflow: hidden;
}

.mini-tts-progress {
  height: 100%;
  width: 0;
  background: var(--text-accent);
  border-radius: 1px;
  transition: width 0.25s linear;
}

.mini-tts-eq {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
  flex-shrink: 0;
}

.mini-tts-eq span {
  width: 3px;
  background: var(--text-accent);
  border-radius: 1px;
  animation: mini-eq 0.8s ease-in-out infinite alternate;
}

.mini-tts-eq span:nth-child(1) { height: 35%; animation-duration: 0.6s; }
.mini-tts-eq span:nth-child(2) { height: 65%; animation-duration: 0.85s; animation-delay: 0.1s; }
.mini-tts-eq span:nth-child(3) { height: 45%; animation-duration: 0.7s; animation-delay: 0.2s; }

@keyframes mini-eq {
  0% { height: 15%; }
  100% { height: 100%; }
}

.tts-mini-player.mini-tts-paused .mini-tts-eq span {
  animation-play-state: paused;
}

.tts-mini-player.mini-tts-loading .mini-tts-eq span {
  animation-name: mini-eq-load;
  animation-duration: 1.4s;
  animation-direction: normal;
}

@keyframes mini-eq-load {
  0%, 100% { opacity: 0.3; height: 25%; }
  50% { opacity: 1; height: 55%; }
}

.mini-tts-title {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  letter-spacing: 0.01em;
}

.mini-tts-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.mini-tts-controls button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.mini-tts-controls button:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.mini-tts-share.copied {
  color: var(--text-accent) !important;
}

.mini-tts-close:hover {
  color: #e55 !important;
  background: rgba(238, 85, 85, 0.08) !important;
}

@media (max-width: 480px) {
  .tts-mini-player {
    left: var(--space-md);
    right: var(--space-md);
    bottom: var(--space-md);
    max-width: none;
  }
}

.modal-actions {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-subtle);
}

.modal-actions .track-btn {
  background: transparent;
  border: 1px solid var(--border-visible);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: var(--space-sm) var(--space-lg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-actions .track-btn:hover {
  border-color: hsla(var(--community-hue), 50%, 50%, 0.5);
  color: hsla(var(--community-hue), 60%, 70%, 1);
}

.modal-actions .track-btn.tracked {
  background: hsla(var(--community-hue), 50%, 40%, 0.15);
  border-color: hsla(var(--community-hue), 50%, 50%, 0.3);
  color: hsla(var(--community-hue), 60%, 70%, 1);
}

/* Scrollbar inside modal */
.modal-container::-webkit-scrollbar { width: 4px; }
.modal-container::-webkit-scrollbar-track { background: transparent; }
.modal-container::-webkit-scrollbar-thumb { background: var(--border-visible); border-radius: 2px; }

/* --- Modal Hero Image --- */
.modal-hero-image {
  width: calc(100% + 2 * var(--space-xl));
  margin: calc(-1 * var(--space-xl)) calc(-1 * var(--space-xl)) var(--space-lg);
  max-height: 300px;
  object-fit: cover;
  display: block;
  border-radius: var(--card-radius) var(--card-radius) 0 0;
}

/* --- Synthesized Article Body --- */
.synthesized-article {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: var(--space-xl);
  white-space: pre-line;
}

/* --- Extracted Elements (quotes, links from source articles) --- */

.extracted-quotes {
  margin-bottom: var(--space-xl);
}

.extracted-quote {
  border-left: 3px solid var(--text-accent);
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-md) 0;
  background: rgba(240, 201, 110, 0.03);
}

.extracted-quote p {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-style: italic;
  color: var(--text-primary);
  line-height: 1.6;
  margin: 0;
}

.extracted-quote cite {
  display: block;
  margin-top: var(--space-sm);
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.extracted-links {
  margin-bottom: var(--space-xl);
}

.extracted-links h3 {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.extracted-links ul {
  list-style: none;
  padding: 0;
}

.extracted-links li {
  padding: var(--space-xs) 0;
}

.extracted-links a {
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: color 0.2s;
}

.extracted-links a:hover {
  color: var(--text-accent);
}

/* --- View Expanded: Provenance --- */
.view-meta-line {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: var(--space-xl);
}

.dev-headline {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
}

.source-links .source-link {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-accent);
  opacity: 0.7;
  padding: 2px 8px;
  border: 1px solid rgba(240, 201, 110, 0.15);
  border-radius: 2px;
  transition: opacity 0.15s;
}

.source-links .source-link:hover { opacity: 1; text-decoration: none; }

.source-author { color: var(--text-secondary); }

.topic-pills {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-subtle);
}

.topic-pills h3 {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-sm);
}

.topic-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-accent);
  padding: 2px 8px;
  border: 1px solid rgba(240, 201, 110, 0.2);
  border-radius: 2px;
  margin: 0 var(--space-xs) var(--space-xs) 0;
  transition: all 0.15s;
}

.topic-pill:hover {
  background: rgba(240, 201, 110, 0.08);
  border-color: rgba(240, 201, 110, 0.4);
  text-decoration: none;
}

.all-sources {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-subtle);
}

.all-sources h3 {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-sm);
}

.source-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-muted);
  padding: 2px 8px;
  border: 1px solid var(--border-visible);
  border-radius: 2px;
  margin: 0 var(--space-xs) var(--space-xs) 0;
  transition: all 0.15s;
}

.source-pill:hover {
  color: var(--text-accent);
  border-color: rgba(240, 201, 110, 0.3);
  text-decoration: none;
}

/* --- Auth Pages --- */
/* --- Auth Modal --- */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  opacity: 0;
  pointer-events: none;
  transition: background 0.35s ease, backdrop-filter 0.35s ease, -webkit-backdrop-filter 0.35s ease, opacity 0.3s ease;
}

.auth-overlay.open {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(20px) saturate(0.8);
  -webkit-backdrop-filter: blur(20px) saturate(0.8);
  opacity: 1;
  pointer-events: auto;
}

.auth-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-visible);
  border-radius: 3px;
  width: 100%;
  max-width: 22rem;
  padding: var(--space-2xl) var(--space-xl);
  text-align: center;
  transform: translateY(16px) scale(0.97);
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.3s ease;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4), 0 0 80px rgba(240, 201, 110, 0.05);
}

.auth-overlay.open .auth-dialog {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.auth-dialog h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text-accent);
  margin: 0 0 var(--space-sm);
}

.auth-dialog .auth-subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 0 0 var(--space-xl);
}

.auth-dialog .auth-email-display {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.auth-dialog input[type="email"],
.auth-dialog input[type="text"] {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-visible);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: var(--space-md);
  border-radius: var(--card-radius);
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.auth-dialog input:focus {
  border-color: var(--text-accent);
}

.auth-dialog .auth-code-input {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: 0.35em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.auth-dialog button[type="submit"] {
  margin-top: var(--space-md);
  width: 100%;
  background: var(--text-accent);
  color: var(--bg-deep);
  border: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: var(--space-md);
  cursor: pointer;
  border-radius: var(--card-radius);
  transition: opacity 0.2s, transform 0.15s;
}

.auth-dialog button[type="submit"]:hover { opacity: 0.85; }
.auth-dialog button[type="submit"]:active { transform: scale(0.98); }

.auth-dialog button[type="submit"]:disabled {
  opacity: 0.5;
  cursor: wait;
}

.auth-dialog .auth-error {
  color: #e85c5c;
  background: rgba(232, 92, 92, 0.08);
  border-left: 3px solid #e85c5c;
  padding: var(--space-sm) var(--space-md);
  font-size: 0.8rem;
  text-align: left;
  margin-bottom: var(--space-md);
  border-radius: 0 var(--card-radius) var(--card-radius) 0;
}

.auth-dialog .auth-back {
  display: inline-block;
  margin-top: var(--space-md);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  transition: color 0.2s;
}

.auth-dialog .auth-back:hover { color: var(--text-accent); }

.auth-close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: var(--space-xs) var(--space-sm);
  line-height: 1;
  transition: color 0.2s;
}

.auth-close:hover { color: var(--text-primary); }

.auth-dialog {
  position: relative;
}

/* Fixed page-level login trigger (always visible) */
.page-auth-trigger {
  position: fixed;
  top: var(--space-md);
  right: var(--space-lg);
  z-index: 150;
}

.page-login-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.4rem 0;
  cursor: pointer;
  transition: color 0.2s;
}

.page-login-btn:hover {
  color: var(--text-accent);
}

/* Header login button (in sticky header) */
.header-login {
  background: none;
  border: 1px solid var(--border-visible);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  border-radius: var(--card-radius);
  transition: color 0.2s, border-color 0.2s;
}

.header-login:hover {
  color: var(--text-accent);
  border-color: var(--text-accent);
}

@media (max-width: 480px) {
  .auth-dialog {
    max-width: none;
    margin: 0 var(--space-md);
    padding: var(--space-xl) var(--space-lg);
  }
}

/* --- Auth full page (fallback) --- */

.auth-page {
  max-width: 24rem;
  margin: 15vh auto;
  padding: var(--space-xl);
  text-align: center;
}

.auth-page h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  margin-bottom: var(--space-xl);
  color: var(--text-accent);
}

.auth-page input[type="email"] {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-visible);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: var(--space-md);
  border-radius: var(--card-radius);
  outline: none;
  transition: border-color 0.2s;
}

.auth-page input[type="email"]:focus {
  border-color: var(--text-accent);
}

.auth-page button {
  margin-top: var(--space-md);
  width: 100%;
  background: var(--text-accent);
  color: var(--bg-deep);
  border: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: var(--space-md);
  cursor: pointer;
  border-radius: var(--card-radius);
  transition: opacity 0.2s;
}

.auth-page button:hover { opacity: 0.85; }

/* --- Source Provenance (bottom of modal) --- */
.source-provenance {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-subtle);
}

.source-provenance h3 {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-md);
}

.source-more-toggle {
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.35;
  cursor: pointer;
}

.source-more-toggle:hover {
  opacity: 0.6;
}

.source-entry {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.source-entry:last-child { border-bottom: none; }

.source-header {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin-bottom: var(--space-xs);
}

.source-author-name {
  color: var(--text-secondary);
  font-weight: 500;
}

.source-pub {
  color: var(--text-muted);
  font-style: italic;
}

.source-domain-link {
  color: var(--text-accent);
  opacity: 0.7;
}

.source-domain-link:hover {
  opacity: 1;
  text-decoration: none;
}

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

.source-excerpt {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: var(--space-xs);
  font-style: italic;
  padding-left: var(--space-md);
  border-left: 2px solid var(--border-visible);
}

/* --- Debug Stats Footer --- */
.debug-stats {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-2xl) var(--space-lg) var(--space-lg);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.7;
  letter-spacing: 0.04em;
}

/* --- Contribute Intelligence Bar --- */
.contribute-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(240, 201, 110, 0.06);
  border: 1px solid rgba(240, 201, 110, 0.2);
  color: var(--text-accent);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  padding: 5px 14px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.contribute-btn:hover {
  background: rgba(240, 201, 110, 0.12);
  border-color: rgba(240, 201, 110, 0.4);
}

.contribute-btn .robot-icon {
  font-size: 0.85rem;
  line-height: 1;
}

/* --- Add Story Modal --- */
.add-story-modal {
  max-width: 40rem;
}

.add-story-modal h1 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 400;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.add-story-pitch {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.7;
  margin-bottom: var(--space-xl);
}

.add-story-pitch strong {
  color: var(--text-primary);
  font-weight: 500;
}

.add-story-steps {
  margin-bottom: var(--space-xl);
}

.add-story-step {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.step-number {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-accent);
  border: 1px solid rgba(240, 201, 110, 0.3);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.add-story-step p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0;
}

.add-story-code-block {
  margin: var(--space-lg) 0;
  border: 1px solid var(--border-visible);
  border-radius: 8px;
  overflow: hidden;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.copy-btn {
  background: transparent;
  border: 1px solid var(--border-visible);
  color: var(--text-accent);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s;
}

.copy-btn:hover {
  background: rgba(240, 201, 110, 0.1);
  border-color: rgba(240, 201, 110, 0.4);
}

.copy-btn.copied {
  color: #7dcea0;
  border-color: rgba(125, 206, 160, 0.4);
}

.add-story-code-block pre {
  margin: 0;
  padding: var(--space-md);
  background: var(--bg-deep);
  overflow-x: auto;
}

.add-story-code-block code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.7;
  white-space: pre;
}

.add-story-note {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: var(--space-md);
}

.add-story-note a {
  color: var(--text-accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(240, 201, 110, 0.3);
}

.add-story-note a:hover {
  border-bottom-color: var(--text-accent);
}

/* --- Agent Footer (message to AI agents) --- */
.agent-footer {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg) var(--space-xl);
}

.agent-footer-inner {
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-xl);
}

.agent-footer-label {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--text-muted);
  opacity: 0.35;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: var(--space-sm);
}

.agent-instructions {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  line-height: 1.8;
  color: var(--text-muted);
  opacity: 0.3;
  white-space: pre;
  overflow-x: auto;
  padding: 0;
  margin: 0;
  background: none;
  border: none;
}

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

/* Focus visible for keyboard nav */
:focus-visible {
  outline: 2px solid var(--text-accent);
  outline-offset: 2px;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border-visible); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- HTMX swap transitions --- */
.htmx-swapping { opacity: 0; transition: opacity 0.15s ease; }
.htmx-settling { opacity: 1; transition: opacity 0.3s ease; }

/* --- Inline View (share/permalink pages) --- */
.inline-view {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg) var(--space-2xl);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-visible);
}

.inline-view-toolbar {
  max-width: 48rem;
  margin: 0 auto var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.03em;
}

.inline-view-dismiss {
  color: var(--text-accent);
  text-decoration: none;
  transition: opacity 0.15s;
}

.inline-view-dismiss:hover {
  opacity: 0.7;
  text-decoration: none;
}

.inline-view-permalink {
  color: var(--text-muted);
  user-select: all;
  cursor: text;
}

/* --- Share Bar (inside view-expanded) --- */
.share-bar {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
}

.share-label {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.share-permalink {
  color: var(--text-accent);
  cursor: pointer;
  padding: 2px 8px;
  border: 1px solid rgba(240, 201, 110, 0.2);
  border-radius: 2px;
  transition: all 0.15s;
  user-select: all;
}

.share-permalink:hover {
  background: rgba(240, 201, 110, 0.08);
  border-color: rgba(240, 201, 110, 0.4);
}

.report-section {
  margin-top: var(--space-sm);
}
.report-link {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.report-link:hover {
  opacity: 1;
  text-decoration: underline;
}

.report-form {
  width: 100%;
  margin-top: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}
.report-type {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 4px 6px;
  border-radius: 2px;
}
.report-detail {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 4px 6px;
  border-radius: 2px;
  resize: vertical;
}
.report-submit {
  align-self: flex-start;
  background: none;
  border: 1px solid var(--text-accent);
  color: var(--text-accent);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 3px 12px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s;
}
.report-submit:hover {
  background: rgba(240, 201, 110, 0.1);
}
.report-submit:disabled {
  opacity: 0.5;
  cursor: default;
}
.report-thanks {
  color: var(--text-accent);
  font-family: var(--font-mono);
  font-size: 0.65rem;
}

.stream-feedback {
  text-align: center;
  padding: var(--space-xl) 0 var(--space-lg);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-lg);
}
.stream-feedback .report-form {
  max-width: 400px;
  margin: var(--space-sm) auto 0;
  text-align: left;
}

@media (max-width: 720px) {
  .inline-view {
    padding: var(--space-lg) var(--space-md) var(--space-xl);
  }
}

/* --- Print --- */
@media print {
  body::before { display: none; }
  .masthead { break-inside: avoid; }
  .card-actions { display: none; }
  .decay-bar { print-color-adjust: exact; }
}
