:root {
  --bg: #111827;
  --bg-elevated: #16202f;
  --bg-soft: #1c2838;
  --surface: rgba(21, 31, 46, 0.94);
  --surface-strong: rgba(19, 28, 41, 0.98);
  --surface-alt: rgba(27, 39, 58, 0.94);
  --text: #e7edf5;
  --text-muted: #a5b3c5;
  --text-faint: #7f8da1;
  --line: rgba(148, 163, 184, 0.14);
  --text-primary: #e7edf5;
  --text-secondary: #a5b3c5;
  --border-color: rgba(148, 163, 184, 0.14);
  --bg-primary: #0f1724;
  --bg-secondary: rgba(19, 29, 44, 0.92);
  --accent: #3fa874;
  --accent-strong: #2d8a5d;
  --accent-soft: rgba(63, 168, 116, 0.12);
  --accent-warm: #74bf6b;
  --success: #74bf6b;
  --shadow: 0 10px 24px rgba(2, 6, 23, 0.14);
  --radius-xl: 20px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --content-width: 1180px;
  --safe-top: env(safe-area-inset-top, 0px);
  --nav-offset: 88px;
  --theme-select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a5b3c5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  --font-demo-serif: "Baskerville", "Baskerville Old Face", "Libre Baskerville", "Times New Roman", serif;
}

[data-theme="light"] {
  --bg: #f7f7f5;
  --bg-elevated: #fbfbfa;
  --bg-soft: #f1f2ef;
  --surface: rgba(255, 255, 255, 0.98);
  --surface-strong: rgba(255, 255, 255, 0.99);
  --surface-alt: rgba(248, 248, 246, 0.98);
  --text: #162033;
  --text-muted: #5d6a7d;
  --text-faint: #7b8798;
  --line: rgba(22, 32, 51, 0.08);
  --text-primary: #162033;
  --text-secondary: #5d6a7d;
  --border-color: rgba(22, 32, 51, 0.08);
  --bg-primary: #f7f7f5;
  --bg-secondary: rgba(255, 255, 255, 0.98);
  --accent: #2f8f68;
  --accent-strong: #227250;
  --accent-soft: rgba(47, 143, 104, 0.1);
  --accent-warm: #5da154;
  --success: #2f8f68;
  --shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

[data-theme="retro"] {
  --bg: #dff4ff;
  --bg-elevated: #eefaff;
  --bg-soft: #c8ebff;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: rgba(247, 252, 255, 0.96);
  --surface-alt: rgba(228, 246, 255, 0.92);
  --text: #12344f;
  --text-muted: #416884;
  --text-faint: #5f86a1;
  --line: rgba(82, 154, 201, 0.34);
  --text-primary: #12344f;
  --text-secondary: #416884;
  --border-color: rgba(82, 154, 201, 0.34);
  --bg-primary: #dff4ff;
  --bg-secondary: rgba(255, 255, 255, 0.88);
  --accent: #2ca7d8;
  --accent-strong: #1b7fbe;
  --accent-soft: rgba(44, 167, 216, 0.14);
  --accent-warm: #ffd45e;
  --success: #5fad7f;
  --shadow: 0 0 0 2px rgba(130, 197, 232, 0.18), 0 18px 30px rgba(67, 114, 145, 0.18);
  --theme-select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231b7fbe' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

[data-theme="cinematic"] {
  --bg: #060810;
  --bg-elevated: #060810;
  --bg-soft: #0a0e1a;
  --surface: rgba(6, 10, 20, 0.7);
  --surface-strong: rgba(8, 12, 24, 0.9);
  --surface-alt: rgba(10, 14, 28, 0.8);
  --text: #e8f4ff;
  --text-muted: rgba(200, 225, 255, 0.65);
  --text-faint: rgba(160, 200, 240, 0.4);
  --line: rgba(100, 180, 230, 0.15);
  --text-primary: #e8f4ff;
  --text-secondary: rgba(200, 225, 255, 0.65);
  --border-color: rgba(100, 180, 230, 0.15);
  --bg-primary: #060810;
  --bg-secondary: rgba(6, 10, 20, 0.7);
  --accent: #4ab8e8;
  --accent-strong: #2e9fd4;
  --accent-soft: rgba(74, 184, 232, 0.12);
  --accent-warm: #80d4f5;
  --success: #4ab8e8;
  --shadow: 0 0 40px rgba(74, 184, 232, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-top: calc(var(--nav-offset) + var(--safe-top));
  font-family: "Inter", "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, var(--bg-elevated), var(--bg));
  color: var(--text);
  line-height: 1.6;
  transition: background 0.25s ease, color 0.25s ease;
}

[data-font-demo="baskerville"] body {
  font-family: var(--font-demo-serif);
  letter-spacing: 0.004em;
}

[data-theme="retro"] body {
  background:
    radial-gradient(circle at 16% 18%, rgba(255, 255, 255, 0.92) 0 7%, transparent 8%),
    radial-gradient(circle at 23% 21%, rgba(255, 255, 255, 0.9) 0 6%, transparent 7%),
    radial-gradient(circle at 72% 15%, rgba(255, 255, 255, 0.92) 0 8%, transparent 9%),
    radial-gradient(circle at 79% 18%, rgba(255, 255, 255, 0.88) 0 6%, transparent 7%),
    radial-gradient(circle at 38% 34%, rgba(255, 255, 255, 0.68) 0 10%, transparent 11%),
    radial-gradient(circle at 61% 38%, rgba(255, 255, 255, 0.64) 0 9%, transparent 10%),
    linear-gradient(180deg, #f7fdff 0%, #dff4ff 34%, #c6e9ff 100%);
  background-attachment: fixed;
}

[data-theme="retro"] .site-main {
  position: relative;
}

[data-theme="retro"] .site-main::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(124, 177, 206, 0.08) 50%, transparent 50%),
    linear-gradient(rgba(255, 255, 255, 0.1), transparent);
  background-size: 3px 3px, 100% 100%;
  mix-blend-mode: screen;
  opacity: 0.22;
}

a {
  color: inherit;
}

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

.site-shell {
  width: min(var(--content-width), calc(100% - 2rem));
  margin: 0 auto;
}

.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: calc(1rem + var(--safe-top)) 0 1rem;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--surface-strong) 92%, transparent);
  border-bottom: 1px solid var(--line);
}

[data-theme="retro"] .site-nav {
  backdrop-filter: none;
  background: linear-gradient(180deg, rgba(231, 247, 255, 0.98), rgba(206, 236, 252, 0.96));
  border-bottom: 2px solid var(--accent);
  box-shadow: inset 0 -2px 0 rgba(255, 212, 94, 0.32), 0 10px 24px rgba(86, 145, 182, 0.14);
}

.site-nav__inner {
  width: min(var(--content-width), calc(100% - 2rem));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-nav__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
  flex: 0 0 auto;
}

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

.site-brand__mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 700;
}

[data-theme="retro"] .site-brand__mark {
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(203, 236, 255, 0.9)),
    #cfeeff;
  border: 2px solid var(--accent);
  box-shadow: inset 0 0 0 2px rgba(255, 212, 94, 0.28);
  color: var(--accent-strong);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.site-brand__title {
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

[data-theme="retro"] .site-brand__title {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.6);
}

.site-nav__menu {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-start;
  flex: 1 1 auto;
  min-width: 0;
}

.site-nav__menu::-webkit-scrollbar {
  display: none;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 600;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.nav-link:hover,
.nav-link:focus-visible,
.nav-link.is-active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 10%, var(--line));
  outline: none;
}

[data-theme="retro"] .nav-link {
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

[data-theme="retro"] .nav-link:hover,
[data-theme="retro"] .nav-link:focus-visible,
[data-theme="retro"] .nav-link.is-active {
  color: var(--accent-strong);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(200, 234, 252, 0.86));
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 212, 94, 0.3);
}

.theme-toggle {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  transform: translateY(-1px);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 16%, var(--line));
  outline: none;
}

.theme-toggle--footer {
  display: none;
}

.theme-select {
  min-width: 7rem;
  height: 38px;
  padding: 0 2.25rem 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background-color: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  background-image: var(--theme-select-arrow);
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px 12px;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.theme-select:hover,
.theme-select:focus-visible {
  transform: translateY(-1px);
  background-color: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 16%, var(--line));
  outline: none;
}

.theme-select--enhanced {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

.theme-picker {
  position: relative;
  flex: 0 0 auto;
}

.theme-picker__button {
  min-width: 7.25rem;
  height: 38px;
  padding: 0 0.95rem 0 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.theme-picker__button:hover,
.theme-picker__button:focus-visible {
  transform: translateY(-1px);
  background-color: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 16%, var(--line));
  outline: none;
}

.theme-picker__label {
  white-space: nowrap;
}

.theme-picker__chevron {
  width: 0.7rem;
  height: 0.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-picker__chevron::before {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
}

.theme-picker__menu {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  min-width: 100%;
  padding: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: color-mix(in srgb, var(--surface-strong) 97%, transparent);
  box-shadow: 0 18px 34px rgba(2, 6, 23, 0.28);
  display: none;
  z-index: 1015;
  backdrop-filter: blur(14px);
}

.theme-picker.is-open .theme-picker__menu {
  display: grid;
  gap: 0.1rem;
}

.theme-picker.is-open .theme-picker__button {
  background-color: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 20%, var(--line));
}

.theme-picker__item {
  width: 100%;
  padding: 0.58rem 0.8rem;
  border: 0;
  border-radius: 0.8rem;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 700;
  text-align: left;
  line-height: 1.2;
  cursor: pointer;
}

.theme-picker__item:hover,
.theme-picker__item:focus-visible,
.theme-picker__item.is-active {
  background: var(--accent-soft);
  color: var(--text);
  outline: none;
}

.theme-select--footer {
  display: none;
}

.theme-select--footer + .theme-picker {
  display: none;
}

[data-theme="retro"] .theme-picker__button {
  border: 2px solid var(--accent);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(205, 236, 252, 0.88)),
    #d5efff;
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px rgba(255, 212, 94, 0.24);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

[data-theme="retro"] .theme-picker__button:hover,
[data-theme="retro"] .theme-picker__button:focus-visible,
[data-theme="retro"] .theme-picker.is-open .theme-picker__button {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(188, 228, 249, 0.94)),
    #d5efff;
  border-color: var(--accent);
}

[data-theme="retro"] .theme-picker__menu {
  border: 2px solid var(--accent);
  border-radius: 1.15rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), transparent 24%),
    rgba(233, 247, 255, 0.96);
  box-shadow:
    inset 0 0 0 1px rgba(255, 212, 94, 0.22),
    0 18px 34px rgba(86, 145, 182, 0.2);
}

[data-theme="retro"] .theme-picker__item {
  border-radius: 0.9rem;
  color: var(--text-muted);
}

[data-theme="retro"] .theme-picker__item:hover,
[data-theme="retro"] .theme-picker__item:focus-visible,
[data-theme="retro"] .theme-picker__item.is-active {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.92), rgba(200, 234, 252, 0.9));
  color: var(--accent-strong);
}

.site-main {
  padding-bottom: 5rem;
}

.hero {
  padding: 2.2rem 0 1rem;
}

.hero-copy > * {
  opacity: 0;
  transform: translateY(14px);
  animation: rise-in 0.7s ease forwards;
}

.hero-copy .eyebrow {
  animation-delay: 0.05s;
}

.hero-copy .display {
  animation-delay: 0.14s;
}

.hero-copy .lead {
  animation-delay: 0.24s;
}

.hero-copy .hero-actions {
  animation-delay: 0.34s;
}

.hero-copy .metrics {
  animation-delay: 0.44s;
}

.hero__layout,
.split-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 1.5rem;
  align-items: center;
}

.hero__layout {
  align-items: start;
}

.hero-copy {
  padding-top: clamp(1rem, 4vw, 3.2rem);
}

.hero-card {
  align-self: start;
  margin-top: -0.25rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  background: color-mix(in srgb, var(--accent) 55%, transparent);
}

.display {
  margin: 0;
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: clamp(2.1rem, 5vw, 3.3rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  font-weight: 700;
}

[data-font-demo="baskerville"] .display,
[data-font-demo="baskerville"] .section-head h2,
[data-font-demo="baskerville"] .section-head h1,
[data-font-demo="baskerville"] .page-title {
  font-family: var(--font-demo-serif);
  font-weight: 700;
  letter-spacing: -0.015em;
  text-transform: none;
  text-shadow: none;
}

[data-font-demo="baskerville"] .lead,
[data-font-demo="baskerville"] .page-subtitle,
[data-font-demo="baskerville"] .card p,
[data-font-demo="baskerville"] .library-card p,
[data-font-demo="baskerville"] .writing-card p,
[data-font-demo="baskerville"] .stat-card p,
[data-font-demo="baskerville"] .info-card p,
[data-font-demo="baskerville"] .expand-card__summary p,
[data-font-demo="baskerville"] .expand-card__body,
[data-font-demo="baskerville"] .note,
[data-font-demo="baskerville"] textarea,
[data-font-demo="baskerville"] input,
[data-font-demo="baskerville"] .results-panel,
[data-font-demo="baskerville"] .info-banner {
  font-family: var(--font-demo-serif);
}

[data-font-demo="baskerville"] .eyebrow,
[data-font-demo="baskerville"] .page-eyebrow,
[data-font-demo="baskerville"] .expand-card__eyebrow,
[data-font-demo="baskerville"] .nav-link,
[data-font-demo="baskerville"] .theme-picker__button,
[data-font-demo="baskerville"] .status,
[data-font-demo="baskerville"] .meta-pill,
[data-font-demo="baskerville"] .metric,
[data-font-demo="baskerville"] .chip,
[data-font-demo="baskerville"] .tag,
[data-font-demo="baskerville"] .button,
[data-font-demo="baskerville"] .button-ghost,
[data-font-demo="baskerville"] .button-soft,
[data-font-demo="baskerville"] .button-substack,
[data-font-demo="baskerville"] .card-link,
[data-font-demo="baskerville"] .section-link {
  font-family: var(--font-demo-serif);
  letter-spacing: 0.02em;
  text-transform: none;
}

[data-theme="retro"] .display,
[data-theme="retro"] .section-head h2,
[data-theme="retro"] .section-head h1,
[data-theme="retro"] .page-title {
  font-family: "Courier New", "Lucida Console", monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.75);
}

.display .accent {
  color: var(--accent);
}

.headline-animated {
  display: flex;
  flex-wrap: wrap;
  gap: 0.18em;
}

.headline-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(18px);
  animation: word-lift 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.headline-word:nth-child(1) {
  animation-delay: 0.12s;
}

.headline-word:nth-child(2) {
  animation-delay: 0.24s;
}

.headline-word:nth-child(3) {
  animation-delay: 0.36s;
}

.lead {
  max-width: 64ch;
  margin: 1.35rem 0 0;
  color: var(--text-muted);
  font-size: clamp(0.98rem, 1.4vw, 1.08rem);
}

.hero-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 1.6rem;
}

.button,
.button-ghost,
.button-substack,
.button-soft {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 42px;
  padding: 0.72rem 1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 600;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.button {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #f8fbff;
}

.button-ghost {
  color: var(--text);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.button-substack {
  color: #fff7f2;
  background: linear-gradient(135deg, #ff5c1a, #ff7a1a);
  border-color: rgba(255, 122, 26, 0.28);
  box-shadow: 0 10px 18px rgba(255, 122, 26, 0.18);
}

.button-soft {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

[data-theme="light"] .button {
  color: #ffffff;
}

[data-theme="retro"] .button {
  border: 2px solid var(--accent);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(208, 238, 252, 0.9)),
    linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #12344f;
  box-shadow: inset 0 0 0 1px rgba(255, 212, 94, 0.26);
}

[data-theme="retro"] .button-ghost {
  border: 2px dashed var(--accent);
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.62);
}

[data-theme="retro"] .button-soft {
  border: 2px solid var(--accent);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(220, 241, 252, 0.86)),
    rgba(255, 255, 255, 0.8);
  color: var(--accent-strong);
}

.button:hover,
.button-ghost:hover,
.button-substack:hover,
.button-soft:hover,
.button:focus-visible,
.button-ghost:focus-visible,
.button-substack:focus-visible,
.button-soft:focus-visible {
  transform: translateY(-1px);
  outline: none;
}

.button:hover {
  box-shadow: 0 8px 16px rgba(47, 143, 131, 0.16);
}

.button-substack:hover,
.button-substack:focus-visible {
  box-shadow: 0 12px 22px rgba(255, 122, 26, 0.24);
}

.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.hero-card,
.panel,
.card,
.library-card,
.writing-card,
.stat-card,
.info-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

[data-theme="retro"] .hero-card,
[data-theme="retro"] .panel,
[data-theme="retro"] .card,
[data-theme="retro"] .library-card,
[data-theme="retro"] .writing-card,
[data-theme="retro"] .stat-card,
[data-theme="retro"] .info-card,
[data-theme="retro"] .expand-card,
[data-theme="retro"] .about-card,
[data-theme="retro"] .content-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), transparent 18%),
    linear-gradient(180deg, rgba(205, 236, 252, 0.3), transparent 60%),
    var(--surface);
  border: 2px solid var(--accent);
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 212, 94, 0.24),
    0 0 0 2px rgba(195, 232, 250, 0.18),
    0 18px 28px rgba(86, 145, 182, 0.16);
}

.hero-card {
  padding: 1rem;
}

.hero-card__cta {
  display: grid;
  gap: 0.55rem;
  margin-top: 1rem;
}

.hero-card__cta .button-soft {
  justify-self: start;
}

.hero-card__cta .faint {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

.portrait {
  aspect-ratio: 1 / 0.88;
  width: 100%;
  border-radius: calc(var(--radius-xl) - 8px);
  overflow: hidden;
  background: linear-gradient(160deg, rgba(125, 211, 252, 0.1), rgba(246, 193, 119, 0.08));
  border: 1px solid var(--line);
}

[data-theme="retro"] .portrait,
[data-theme="retro"] .card-media {
  border: 2px solid var(--accent);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 212, 94, 0.22);
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.1) contrast(1.02);
}

.hero-notes,
.metrics,
.chip-row,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.metric,
.chip,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

[data-theme="retro"] .metric,
[data-theme="retro"] .chip,
[data-theme="retro"] .tag,
[data-theme="retro"] .meta-pill,
[data-theme="retro"] .status {
  border-radius: 4px;
  border: 1px solid var(--accent);
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

[data-theme="retro"] .status.is-live {
  color: var(--success);
}

[data-theme="retro"] .status.is-r-and-d,
[data-theme="retro"] .status.is-planning {
  color: var(--text-muted);
}

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

.section {
  padding: 1rem 0 0;
}

.section-soft {
  position: relative;
}

.section-soft::before {
  content: "";
  position: absolute;
  inset: 0.2rem 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line) 18%, var(--line) 82%, transparent);
}

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

.section-head h2,
.section-head h1 {
  margin: 0;
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1.15;
  font-weight: 700;
}

.section-head p {
  margin: 0.5rem 0 0;
  max-width: 56ch;
  color: var(--text-muted);
}

.section-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
}

[data-theme="retro"] .eyebrow,
[data-theme="retro"] .expand-card__eyebrow,
[data-theme="retro"] .page-eyebrow {
  color: var(--accent-strong);
  letter-spacing: 0.16em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

[data-theme="retro"] .eyebrow::before,
[data-theme="retro"] .page-eyebrow::before {
  width: 36px;
  height: 6px;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent), var(--accent-warm));
  box-shadow: 0 0 10px rgba(132, 206, 238, 0.26);
}

[data-theme="retro"] .section-link,
[data-theme="retro"] .card-link,
[data-theme="retro"] .related-links a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-decoration-style: dotted;
}

.section-links {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.section-link:hover,
.section-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

.grid-two,
.grid-three,
.grid-four {
  display: grid;
  gap: 0.85rem;
}

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

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

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

.card,
.library-card,
.writing-card,
.stat-card,
.info-card,
.panel {
  padding: 1rem;
}

.card,
.library-card,
.writing-card {
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.card:hover,
.library-card:hover,
.writing-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 14%, var(--line));
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
}

[data-theme="retro"] .card:hover,
[data-theme="retro"] .library-card:hover,
[data-theme="retro"] .writing-card:hover,
[data-theme="retro"] .about-card:hover,
[data-theme="retro"] .expand-card:hover {
  transform: translateY(-4px) scale(1.01);
  border-color: var(--accent);
  box-shadow:
    inset 0 0 0 1px rgba(255, 212, 94, 0.28),
    0 0 0 2px rgba(132, 206, 238, 0.22),
    0 20px 32px rgba(86, 145, 182, 0.18);
}

.card h3,
.library-card h3,
.writing-card h3,
.stat-card h3,
.info-card h3 {
  margin: 0.2rem 0 0.55rem;
  font-size: 1.02rem;
}

.card p,
.library-card p,
.writing-card p,
.stat-card p,
.info-card p {
  margin: 0;
  color: var(--text-muted);
}

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

.icon-box {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.95rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.status.is-live {
  color: var(--success);
}

.status.is-r-and-d {
  color: var(--accent-warm);
}

.status.is-planning {
  color: color-mix(in srgb, var(--accent) 78%, #ffffff 22%);
}

.card-media {
  margin-bottom: 1rem;
  overflow: hidden;
  border-radius: 14px;
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, rgba(125, 211, 252, 0.14), rgba(246, 193, 119, 0.08));
  border: 1px solid var(--line);
}

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

.card-media.is-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 2rem;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.75rem 0 0.9rem;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-faint);
  border: 1px solid var(--line);
  font-size: 0.72rem;
  font-weight: 600;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.card-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 800;
}

.card-link.is-muted {
  color: var(--text-faint);
  pointer-events: none;
}

.card-link:hover,
.card-link:focus-visible {
  text-decoration: underline;
  outline: none;
}

.library-card {
  display: grid;
  gap: 0.95rem;
}

.explore-card {
  position: relative;
  overflow: hidden;
  gap: 1rem;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--accent) 12%, transparent), transparent 42%),
    var(--surface);
}

[data-theme="retro"] .explore-card {
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.5), transparent 38%),
    radial-gradient(circle at bottom left, rgba(153, 220, 248, 0.22), transparent 42%),
    var(--surface);
}

.explore-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 38%);
  pointer-events: none;
}

.explore-card__header {
  position: relative;
  z-index: 1;
}

.explore-card__lead {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
}

.explore-card__icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 82%, transparent), rgba(255, 255, 255, 0.03));
  border: 1px solid color-mix(in srgb, var(--accent) 14%, var(--line));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.explore-card h3,
.explore-card p,
.explore-card .library-card__meta,
.explore-card .card-actions {
  position: relative;
  z-index: 1;
}

.library-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.library-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.writing-card {
  display: grid;
  gap: 1rem;
}

.writing-card__excerpt {
  padding-left: 1rem;
  border-left: 2px solid color-mix(in srgb, var(--accent) 60%, transparent);
  color: var(--text-muted);
}

.page-intro {
  padding: 1.6rem 0 0.5rem;
}

.page-intro .section-head {
  margin-bottom: 0.5rem;
}

.intro-slab {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 1rem;
  padding: 1rem;
}

.about-carousel {
  position: relative;
}

.about-grid,
.accordion-stack {
  display: grid;
  gap: 0.9rem;
}

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

.about-card {
  position: relative;
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  min-width: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease;
}

.about-card.is-clone {
  display: none;
}

.about-card::before {
  content: "";
  position: absolute;
  inset: auto -12% -45% auto;
  width: 180px;
  height: 180px;
  border-radius: 999px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 26%, transparent), transparent 68%);
  opacity: 0;
  transform: scale(0.86);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.about-card:hover,
.about-card:focus-visible {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 22%, var(--line));
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.12);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 70%, transparent), rgba(255, 255, 255, 0.02));
  outline: none;
}

.about-card:hover::before,
.about-card:focus-visible::before {
  opacity: 1;
  transform: scale(1);
}

.about-card h3 {
  margin: 0;
  font-size: 1.02rem;
  min-width: 0;
}

.about-card p {
  margin: 0;
  min-width: 0;
  max-width: 30ch;
  color: var(--text-muted);
  overflow-wrap: break-word;
  word-break: normal;
  white-space: normal;
}

[data-theme="retro"] .about-card {
  border-color: var(--accent);
}

[data-theme="retro"] .about-card__icon {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.about-card__icon {
  width: 46px;
  height: 46px;
  border-radius: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 12%, var(--line));
  font-size: 1rem;
}

.expand-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

.expand-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 14%, var(--line));
}

.expand-card[open] {
  border-color: color-mix(in srgb, var(--accent) 18%, var(--line));
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.1);
}

.expand-card summary {
  list-style: none;
}

.expand-card summary::-webkit-details-marker {
  display: none;
}

.expand-card__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  cursor: pointer;
}

.expand-card__summary:focus-visible {
  outline: none;
}

.expand-card__title-wrap {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.expand-card__title-wrap > div:last-child {
  min-width: 0;
}

.expand-card__eyebrow {
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.expand-card__summary h3 {
  margin: 0.18rem 0 0.2rem;
}

.expand-card__summary p {
  margin: 0;
  color: var(--text-muted);
}

.expand-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  padding-right: 2.2rem;
  position: relative;
}

.expand-card__meta::after {
  content: "+";
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 700;
  transition: color 0.2s ease, background 0.2s ease;
}

.expand-card[open] .expand-card__meta::after {
  content: "-";
  color: var(--accent);
  background: var(--accent-soft);
}

.expand-card__body {
  display: grid;
  gap: 0.95rem;
  padding: 0 1rem 1rem;
  color: var(--text-muted);
}

.expand-card--media .expand-card__body {
  grid-template-columns: minmax(0, 240px) minmax(0, 1fr);
  align-items: center;
}

.list {
  display: grid;
  gap: 0.7rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.list li {
  padding: 0.72rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.footer {
  padding: 1.4rem 0 2rem;
}

[data-theme="retro"] .footer {
  position: relative;
}

[data-theme="retro"] .footer::before {
  content: "WELCOME TO MY HOMEPAGE";
  display: block;
  width: fit-content;
  margin: 0 auto 1rem;
  padding: 0.4rem 0.8rem;
  border: 2px solid var(--accent);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.82), rgba(205, 236, 252, 0.9));
  color: var(--accent-strong);
  font-family: "Courier New", monospace;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(255, 212, 94, 0.2);
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.footer__nav,
.footer__social {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center;
}

.footer__nav a,
.footer__social a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 700;
}

.footer__nav a:hover,
.footer__social a:hover,
.footer__nav a:focus-visible,
.footer__social a:focus-visible {
  color: var(--text);
  outline: none;
}

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

.faint {
  color: var(--text-faint);
}

.divider {
  height: 1px;
  border: 0;
  margin: 0;
  background: var(--line);
}

.empty-state {
  padding: 1.4rem;
  text-align: center;
}

.projects-mobile-note {
  display: none;
}

.projects-carousel {
  display: grid;
  gap: 0.9rem;
}

.projects-head-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.projects-head-hint {
  color: var(--text-faint);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.carousel-viewport {
  position: relative;
  overflow: hidden;
}

.carousel-overlay-controls {
  position: absolute;
  top: clamp(4.4rem, 18vw, 7rem);
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  transform: translateY(-50%);
  padding-inline: 0.65rem;
}

.carousel-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 2rem) / 3);
  gap: 1rem;
  transition: transform 0.35s ease;
  will-change: transform;
}

.carousel-track--two-up {
  grid-auto-columns: calc((100% - 1rem) / 2);
}

.writing-carousel .carousel-overlay-controls {
  top: clamp(5.8rem, 20vw, 7.6rem);
}

.carousel-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.carousel-buttons {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.carousel-btn {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.carousel-btn--overlay {
  width: 44px;
  height: 44px;
  pointer-events: auto;
  background: color-mix(in srgb, var(--bg-elevated) 82%, #ffffff 18%);
  border-color: color-mix(in srgb, var(--accent) 24%, var(--line));
  color: #f8fbff;
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 24px rgba(2, 6, 23, 0.28);
}

[data-theme="retro"] .carousel-btn,
[data-theme="retro"] .carousel-btn--overlay {
  border: 2px solid var(--accent);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(204, 236, 252, 0.88)),
    var(--surface-strong);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px rgba(255, 212, 94, 0.22);
}

.carousel-btn--overlay:hover,
.carousel-btn--overlay:focus-visible {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-strong));
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  color: #ffffff;
}

.carousel-btn:hover,
.carousel-btn:focus-visible {
  transform: translateY(-1px);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 14%, var(--line));
  outline: none;
}

.carousel-btn:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

.carousel-dots {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  justify-content: center;
  flex: 1;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: 0;
  padding: 0;
  background: color-mix(in srgb, var(--text-faint) 45%, transparent);
  cursor: pointer;
  transition: width 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.dot.active {
  width: 24px;
  background: var(--accent);
}

[data-theme="retro"] .dot {
  border: 1px solid rgba(44, 167, 216, 0.36);
  background: rgba(153, 220, 248, 0.46);
}

[data-theme="retro"] .dot.active {
  background: var(--accent);
  box-shadow: 0 0 12px rgba(44, 167, 216, 0.28);
}

.dot:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent);
  outline-offset: 2px;
}

@keyframes rise-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes word-lift {
  0% {
    opacity: 0;
    transform: translateY(18px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 961px) {
  .hero {
    padding: 2rem 0 1.5rem;
  }

  .hero__layout {
    grid-template-columns: minmax(0, 1.12fr) minmax(360px, 0.88fr);
    gap: 2rem;
    min-height: 37rem;
  }

  .hero-copy {
    padding-top: clamp(0.8rem, 2.8vw, 2rem);
  }

  .hero-copy .display {
    max-width: 11ch;
    font-size: clamp(2.8rem, 5.4vw, 4.5rem);
  }

  .hero-copy .lead {
    max-width: 34ch;
    font-size: 1.14rem;
  }

  .hero-card {
    padding: 1.15rem;
    margin-top: -0.5rem;
  }

  .portrait {
    aspect-ratio: 1 / 0.8;
  }

  .section {
    padding-top: 1.35rem;
  }

  .about-grid {
    gap: 1rem;
  }

  .about-card {
    min-height: 16rem;
    align-content: start;
  }

  .explore-card {
    min-height: 15.5rem;
  }
}

@media (max-width: 960px) {
  :root {
    --nav-offset: 122px;
  }

  .hero__layout,
  .split-hero,
  .intro-slab,
  .about-grid,
  .grid-four,
  .grid-three,
  .grid-two {
    grid-template-columns: 1fr;
  }

  .expand-card__summary,
  .expand-card--media .expand-card__body {
    display: grid;
    grid-template-columns: 1fr;
  }

  .expand-card__meta {
    justify-content: flex-start;
  }

  .site-nav__inner {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.8rem;
  }

  .site-nav__actions {
    order: 2;
    width: auto;
    margin-left: auto;
    justify-content: flex-end;
  }

  .hero-copy {
    padding-top: 0;
  }

  .hero-card {
    margin-top: 0;
  }

  .site-nav__menu {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.2rem;
    -webkit-overflow-scrolling: touch;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .projects-head-actions {
    align-self: stretch;
    justify-content: space-between;
    width: 100%;
  }

  .carousel-overlay-controls {
    padding-inline: 0.45rem;
  }

  .carousel-track {
    grid-auto-columns: calc((100% - 1rem) / 2);
  }
}

@media (max-width: 640px) {
  :root {
    --nav-offset: 116px;
  }

  .site-shell,
  .site-nav__inner {
    width: min(var(--content-width), calc(100% - 1.2rem));
  }

  .hero .site-shell {
    width: min(var(--content-width), calc(100% - 2rem));
  }

  .page-intro .site-shell,
  .section > .site-shell {
    width: min(var(--content-width), calc(100% - 2rem));
  }

  .site-nav {
    padding: calc(0.7rem + var(--safe-top)) 0 0.55rem;
  }

  .site-nav__inner {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .site-brand__mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .site-brand {
    flex: 0 0 auto;
    gap: 0.55rem;
  }

  .site-brand__title {
    font-size: 0.92rem;
  }

  .site-nav__menu {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    gap: 0.35rem;
    flex-wrap: wrap;
    overflow: visible;
    padding-bottom: 0;
  }

  .site-nav__actions {
    order: 2;
    width: auto;
    margin-left: auto;
    justify-content: flex-end;
  }

  .nav-link {
    flex: 0 0 auto;
    min-height: 32px;
    padding: 0.22rem 0.18rem;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
  }

  .nav-link:hover,
  .nav-link:focus-visible,
  .nav-link.is-active {
    background: transparent;
    border-color: transparent;
    border-bottom-color: color-mix(in srgb, var(--accent) 72%, transparent);
  }

  [data-theme="retro"] .nav-link {
    border-bottom-width: 3px;
  }

  [data-theme="retro"] .nav-link:hover,
  [data-theme="retro"] .nav-link:focus-visible,
  [data-theme="retro"] .nav-link.is-active {
    border-color: transparent;
    border-bottom-color: var(--accent-warm);
  }

  .site-nav .theme-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    margin-left: 0.2rem;
  }

  .theme-toggle--footer {
    display: none;
  }

  .site-nav .theme-select {
    display: inline-flex;
    flex: 0 0 auto;
    height: 36px;
    margin-left: 0.2rem;
  }

  .site-nav .theme-picker__button {
    min-width: 7rem;
    height: 36px;
    padding-inline: 0.95rem 0.9rem;
    border-radius: 1.25rem;
  }

  .site-nav .theme-picker__menu {
    right: 0;
    left: auto;
    min-width: max(7rem, 100%);
    border-radius: 1.1rem;
  }

  .theme-select--footer {
    display: none;
  }

  .display {
    font-size: clamp(2rem, 9.8vw, 2.9rem);
    line-height: 1.02;
    max-width: none;
  }

  .hero {
    padding-top: 0.45rem;
    padding-bottom: 1.1rem;
  }

  .page-intro {
    padding: 0.45rem 0 0.5rem;
  }

  .headline-animated {
    gap: 0.12em;
  }

  .eyebrow {
    margin-bottom: 0.55rem;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
  }

  .lead {
    margin-top: 0.8rem;
    max-width: 34ch;
    font-size: 0.98rem;
    line-height: 1.58;
  }

  .hero-actions,
  .button-row {
    gap: 0.7rem;
    margin-top: 1rem;
  }

  .button,
  .button-ghost,
  .button-substack,
  .button-soft {
    width: 100%;
    justify-content: center;
  }

  .metrics,
  .chip-row,
  .tag-row,
  .hero-notes {
    gap: 0.42rem;
  }

  .about-carousel {
    overflow-x: auto;
    padding: 0.95rem 0.55rem 0.95rem;
    margin: -0.35rem -0.3rem -0.95rem;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 0.55rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    cursor: grab;
  }

  .about-carousel::-webkit-scrollbar {
    display: none;
  }

  .about-carousel.is-dragging {
    cursor: grabbing;
    scroll-snap-type: none;
  }

  .about-carousel .about-grid {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(260px, calc(100vw - 6.2rem));
    gap: 1rem;
    width: max-content;
    padding-inline: 0.15rem;
  }

  .about-carousel .about-card {
    scroll-snap-align: center;
    width: min(calc(100vw - 3.6rem), 320px);
    min-height: 100%;
    transform-origin: center center;
  }

  .about-carousel .about-card.is-clone {
    display: grid;
  }

  .about-carousel .about-card.is-active {
    transform: translateY(-10px) scale(1.02);
    border-color: color-mix(in srgb, var(--accent) 24%, var(--line));
    box-shadow: 0 20px 34px rgba(15, 23, 42, 0.16);
    background: linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 72%, transparent), rgba(255, 255, 255, 0.02));
  }

  .about-carousel .about-card.is-active::before {
    opacity: 1;
    transform: scale(1);
  }

  .about-carousel .about-grid {
    grid-auto-columns: minmax(250px, calc(100vw - 3.6rem));
  }

  .about-carousel .about-card {
    width: min(calc(100vw - 3.8rem), 300px);
  }

  .about-card p {
    max-width: 24ch;
  }

  .metric,
  .chip,
  .tag {
    padding: 0.34rem 0.6rem;
    font-size: 0.82rem;
    line-height: 1.28;
  }

  .section-head h2,
  .section-head h1 {
    line-height: 1.2;
  }

  .carousel-track {
    grid-auto-columns: 88%;
    gap: 0.85rem;
  }

  .carousel-controls {
    gap: 0.75rem;
    align-items: center;
  }

  .card,
  .library-card,
  .writing-card,
  .panel,
  .stat-card,
  .info-card,
  .hero-card {
    padding: 0.9rem;
  }

  .hero-card {
    padding: 0.8rem;
  }

  .portrait {
    aspect-ratio: 1 / 0.72;
  }

  .hero-notes {
    margin-top: 0.7rem !important;
  }

  .card-top,
  .library-card__header,
  .section-links,
  .footer__inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .explore-card {
    gap: 0.9rem;
  }

  .explore-card h3 {
    margin-bottom: 0.2rem;
  }

  .explore-card p {
    max-width: 24ch;
  }

  .explore-card__lead {
    gap: 0.6rem;
  }

  .explore-card__icon {
    width: 50px;
    height: 50px;
    border-radius: 17px;
  }

  .expand-card__summary {
    gap: 0.8rem;
  }

  .projects-head-actions {
    gap: 0.65rem;
  }

  .carousel-overlay-controls {
    top: 5.4rem;
    padding-inline: 0.35rem;
  }

  .writing-carousel .carousel-overlay-controls {
    position: absolute;
    top: 8.9rem;
    left: 0;
    right: 0;
    justify-content: space-between;
    gap: 0;
    transform: translateY(-50%);
    padding-inline: 0.45rem;
    margin: 0;
  }

  .writing-carousel .carousel-btn--overlay,
  .writing-carousel .carousel-btn--overlay:hover,
  .writing-carousel .carousel-btn--overlay:focus-visible {
    transform: none;
  }

  .writing-carousel .writing-card .status {
    margin-left: 2.7rem;
  }

  .carousel-btn--overlay {
    width: 40px;
    height: 40px;
  }
}
