:root {
  --paper: #f4f0e8;
  --paper-deep: #ebe5d9;
  --ink: #1c1915;
  --ink-soft: #5c564c;
  --ink-faint: #8a8276;
  --accent: #2f4a3a;
  --accent-deep: #1e3328;
  --accent-soft: #e4ebe6;
  --card: #fffcf6;
  --border: #ddd4c4;
  --border-soft: #e8e1d4;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(28, 25, 21, 0.04), 0 12px 32px rgba(28, 25, 21, 0.06);
  --max: 720px;
  --list-max: 880px;
  --pad: clamp(1.15rem, 5.5vw, 1.75rem);
  --tap: 44px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Source Serif 4", "Iowan Old Style", Palatino, Georgia, serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 36% at 50% -10%, rgba(47, 74, 58, 0.07), transparent 55%),
    linear-gradient(180deg, var(--paper) 0%, #efe9de 100%);
  line-height: 1.55;
  overflow-x: hidden;
}

body > main {
  flex: 1;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-deep);
}

.wrap {
  width: min(var(--max), calc(100% - 2 * var(--pad) - var(--safe-left) - var(--safe-right)));
  margin-inline: auto;
  padding-inline: max(0px, var(--safe-left)) max(0px, var(--safe-right));
}

.wrap--wide {
  width: min(var(--list-max), calc(100% - 2 * var(--pad) - var(--safe-left) - var(--safe-right)));
}

.ui {
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 0.75rem 0;
  padding-top: max(0.75rem, var(--safe-top));
  background: rgba(244, 240, 232, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(221, 212, 196, 0.75);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--tap);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  flex-shrink: 0;
  color: inherit;
  text-decoration: none;
  font-family: "Inter", system-ui, sans-serif;
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  line-height: 1.2;
}

.brand:hover {
  color: var(--ink);
}

.brand-mark {
  color: var(--ink);
}

.brand-dot {
  color: var(--accent);
  font-weight: 700;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-wrap: nowrap;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
}

.header-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 0.65rem;
  border-radius: 999px;
  white-space: nowrap;
}

.header-nav a:hover,
.header-nav a[aria-current="page"] {
  color: var(--ink);
}

.header-nav a[aria-current="page"] {
  background: rgba(47, 74, 58, 0.08);
  color: var(--accent-deep);
  font-weight: 600;
}

.header-nav a.ext {
  color: var(--accent);
}

/* Hide external nav links on narrow screens — they live in the footer */
@media (max-width: 640px) {
  .header-nav a.ext {
    display: none;
  }

  .header-nav {
    gap: 0.1rem;
  }

  .header-nav a {
    padding: 0 0.7rem;
    font-size: 0.9rem;
  }
}

@media (min-width: 641px) {
  .header-nav {
    gap: 0.35rem;
  }

  .header-nav a {
    padding: 0 0.75rem;
  }
}

/* Surprise home */
.surprise-main {
  padding: 1.75rem 0 3rem;
}

.surprise-hero {
  text-align: center;
  margin-bottom: 1.35rem;
}

.surprise-kicker {
  margin: 0 0 0.4rem;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.surprise-title {
  margin: 0;
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.surprise-subtitle {
  margin: 0.55rem auto 0;
  max-width: 28rem;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.surprise-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1.25rem 0 1.65rem;
}

.cta {
  appearance: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: var(--tap);
  padding: 0.85rem 1.45rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.cta:hover {
  background: var(--accent-deep);
  color: var(--paper);
  transform: translateY(-1px);
  text-decoration: none;
}

.cta:active {
  transform: translateY(0);
}

.cta:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.cta:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.cta-spark {
  font-size: 0.95rem;
  opacity: 0.9;
}

.cta--ghost {
  background: var(--card);
  color: var(--ink);
  border: 1.5px solid var(--border);
  box-shadow: none;
}

.cta--ghost:hover {
  background: #fff;
  color: var(--ink);
  border-color: #cfc5b3;
  text-decoration: none;
}

@media (max-width: 640px) {
  .surprise-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    margin: 1.15rem 0 1.75rem;
  }

  .surprise-actions .cta {
    width: 100%;
  }
}

.demo-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.25rem 1.5rem;
}

.demo-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.7rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.handle {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.8rem;
  color: var(--ink-faint);
  text-decoration: none;
}

.handle:hover {
  color: var(--accent);
}

.demo-title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.25rem, 3.5vw, 1.55rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.demo-desc {
  margin: 0 0 1.25rem;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.925rem;
  color: var(--ink-soft);
  line-height: 1.55;
}

.demo-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1.35rem;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.875rem;
  font-weight: 550;
}

.demo-links a {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--ink);
  background: #fff;
}

.demo-links a:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
}

.demo-links a.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #f7faf8;
}

.demo-links a.primary:hover {
  background: var(--accent-deep);
  color: #fff;
}

@media (max-width: 640px) {
  .demo-card {
    padding: 1.25rem 1.1rem 1.4rem;
  }

  .demo-links {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    margin-bottom: 1.45rem;
  }

  .demo-links a {
    width: 100%;
  }
}

.tweet-embed {
  min-height: 120px;
  display: flex;
  justify-content: center;
  margin-top: 0.15rem;
}

.tweet-embed--loading {
  opacity: 0.75;
}

.tweet-embed .twitter-tweet {
  margin: 0 auto !important;
}

.tweet-embed iframe {
  max-width: 100% !important;
}

.loading-msg,
.error-msg {
  margin: 0;
  padding: 1.5rem;
  text-align: center;
  font-family: "Inter", system-ui, sans-serif;
  color: var(--ink-faint);
}

.fallback-link {
  display: block;
  text-align: center;
  padding: 1.5rem;
  font-family: "Inter", system-ui, sans-serif;
}

/* List page */
.list-main {
  padding: 1.5rem 0 3rem;
}

.list-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.35rem;
}

.list-header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.03em;
}

.list-header p {
  margin: 0.35rem 0 0;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.view-toggle {
  display: inline-flex;
  padding: 0.2rem;
  border-radius: 999px;
  background: var(--paper-deep);
  border: 1px solid var(--border);
  font-family: "Inter", system-ui, sans-serif;
}

.view-toggle button {
  appearance: none;
  border: none;
  background: transparent;
  cursor: pointer;
  min-height: var(--tap);
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  font-family: inherit;
}

.view-toggle button[aria-pressed="true"] {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(28, 25, 21, 0.06);
}

.view-toggle button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .list-header {
    align-items: stretch;
    gap: 0.85rem;
  }

  .view-toggle {
    width: 100%;
  }

  .view-toggle button {
    flex: 1;
  }
}

/* Cards view */
.demo-grid {
  display: grid;
  gap: 1rem;
}

.demo-grid.view-cards {
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .demo-grid.view-cards {
    grid-template-columns: 1fr 1fr;
  }
}

.list-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem 1.25rem;
  box-shadow: 0 1px 2px rgba(28, 25, 21, 0.03);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.list-card:hover {
  border-color: #cfc5b3;
  box-shadow: var(--shadow);
}

.list-card h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.list-card h2 a {
  color: inherit;
  text-decoration: none;
}

.list-card h2 a:hover {
  color: var(--accent-deep);
}

.list-card .desc {
  margin: 0;
  flex: 1;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.list-card .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.8rem;
}

.list-card .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 550;
}

.list-card .actions a {
  text-decoration: none;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
}

.list-card .actions a:hover {
  color: var(--accent-deep);
}

@media (max-width: 640px) {
  .list-card .actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
  }

  .list-card .actions a {
    justify-content: center;
    min-height: var(--tap);
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--ink);
  }

  .list-card .actions a:first-child {
    background: var(--accent);
    border-color: var(--accent);
    color: #f7faf8;
  }

  .list-card .actions .sep {
    display: none;
  }
}

/* Compact view */
.demo-grid.view-compact {
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
}

.compact-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.7fr) auto;
  gap: 0.75rem 1rem;
  align-items: center;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.875rem;
}

.compact-row:last-child {
  border-bottom: none;
}

.compact-row:hover {
  background: rgba(244, 240, 232, 0.55);
}

.compact-title {
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.compact-title:hover {
  color: var(--accent-deep);
}

.compact-meta {
  color: var(--ink-faint);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compact-links {
  display: flex;
  gap: 0.65rem;
  justify-content: flex-end;
  font-size: 0.8rem;
  font-weight: 550;
  white-space: nowrap;
}

.compact-links a {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
}

@media (max-width: 640px) {
  .compact-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
    padding: 0.85rem 1rem;
  }

  .compact-links {
    justify-content: flex-start;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .compact-links a {
    min-height: var(--tap);
    padding: 0 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--ink);
  }

  .compact-links .sep {
    display: none;
  }
}

/* Footer */
.site-footer {
  padding: 1.5rem 0 calc(1.5rem + var(--safe-bottom));
  border-top: 1px solid rgba(221, 212, 196, 0.7);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.8rem;
  color: var(--ink-faint);
  text-align: center;
}

.site-footer a {
  color: var(--ink-soft);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 1rem;
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.footer-links a {
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
}

.footer-credit {
  margin: 0;
}

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

/* Theme toggle */
.theme-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink-soft);
  min-height: var(--tap);
  padding: 0 0.7rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-shrink: 0;
  cursor: pointer;
  font: 600 0.78rem/1 "Inter", system-ui, sans-serif;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

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

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

@media (max-width: 640px) {
  .theme-toggle {
    width: var(--tap);
    padding: 0;
  }

  .theme-toggle [data-theme-label] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* List embed placeholders stay light until their batch is activated. */
.list-card .tweet-embed {
  margin-top: 0.65rem;
}

.tweet-embed--placeholder {
  width: 100%;
  min-height: 104px;
  align-items: center;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--paper-deep);
  color: var(--ink-faint);
  font: 500 0.78rem/1.4 "Inter", system-ui, sans-serif;
  text-align: center;
}

.tweet-placeholder-copy::before {
  content: "✦ ";
  color: var(--accent);
}

/* Compact rows retain their metadata while giving embeds a contained column. */
.compact-row {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 330px);
  align-items: start;
}

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

.compact-desc {
  margin: 0.4rem 0 0;
  color: var(--ink-soft);
  font: 400 0.8rem/1.45 "Inter", system-ui, sans-serif;
}

.compact-row .tweet-embed {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  min-height: 88px;
}

@media (max-width: 640px) {
  .compact-row {
    grid-template-columns: 1fr;
  }

  .compact-row .tweet-embed {
    grid-column: 1;
    grid-row: auto;
    margin-top: 0.7rem;
  }
}

/* Fast, low-key transition for a newly selected surprise demo. */
.demo-card--enter {
  animation: demo-card-enter 420ms cubic-bezier(0.2, 0.75, 0.25, 1) both;
}

@keyframes demo-card-enter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Dark is the default; the inline head script applies this before first paint. */
html[data-theme="dark"] {
  --paper: #111713;
  --paper-deep: #202a23;
  --ink: #edf1eb;
  --ink-soft: #b7c2b9;
  --ink-faint: #8d9b90;
  --accent: #84b795;
  --accent-deep: #b5d7bf;
  --accent-soft: #263a2e;
  --card: #1a231d;
  --border: #35473a;
  --border-soft: #2b382f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 12px 32px rgba(0, 0, 0, 0.2);
  color-scheme: dark;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(ellipse 80% 36% at 50% -10%, rgba(118, 167, 137, 0.1), transparent 55%),
    linear-gradient(180deg, #111713 0%, #18211b 100%);
  color: #edf1eb;
}

html[data-theme="dark"] .cta {
  background: #dbe8df;
  color: #132018;
}

html[data-theme="dark"] .cta:hover {
  background: #b9d2c1;
  color: #102017;
}

html[data-theme="dark"] .site-header {
  background: rgba(17, 23, 19, 0.92);
  border-bottom-color: rgba(73, 93, 79, 0.72);
}

html[data-theme="dark"] .header-nav a[aria-current="page"] {
  background: rgba(118, 167, 137, 0.14);
}

html[data-theme="dark"] .cta--ghost,
html[data-theme="dark"] .demo-links a,
html[data-theme="dark"] .view-toggle button[aria-pressed="true"],
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .list-card .actions a,
html[data-theme="dark"] .compact-links a {
  background: #202a23;
  color: #edf1eb;
}

html[data-theme="dark"] .cta--ghost:hover,
html[data-theme="dark"] .demo-links a:hover,
html[data-theme="dark"] .theme-toggle:hover,
html[data-theme="dark"] .list-card .actions a:hover,
html[data-theme="dark"] .compact-links a:hover {
  background: #29372e;
}

html[data-theme="dark"] .demo-links a.primary,
html[data-theme="dark"] .list-card .actions a:first-child {
  background: #4d7b5e;
  border-color: #4d7b5e;
  color: #f4faf5;
}

html[data-theme="dark"] .demo-links a.primary:hover,
html[data-theme="dark"] .list-card .actions a:first-child:hover {
  background: #60926f;
}

html[data-theme="dark"] .compact-row:hover {
  background: rgba(118, 167, 137, 0.08);
}

html[data-theme="dark"] .site-footer {
  border-top-color: rgba(73, 93, 79, 0.7);
}

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
