:root {
  --bg: #f2efe8;
  --surface: #e7e1d4;
  --ink: #1a1916;
  --muted: #5c5952;
  --line: #cdc6b8;
  --line-strong: #b7af9f;
  --accent: #b23e24;
  --accent-fill: #cf4d2f;
  --sans: Inter, "Helvetica Neue", "PingFang SC", "Noto Sans SC", "Noto Sans CJK SC", system-ui, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.4rem;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

html.i18n-wait body {
  opacity: 0;
}

::selection {
  background: rgba(178, 62, 36, 0.18);
  color: var(--ink);
}

.page {
  width: min(100% - 3rem, 76rem);
  margin: 0 auto;
}

.skip-link {
  position: fixed;
  z-index: 30;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.9rem;
  background: var(--ink);
  color: var(--bg);
  transform: translateY(-150%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 5.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.header-end {
  display: flex;
  align-items: center;
  gap: clamp(0.85rem, 2.4vw, 1.75rem);
  margin-left: auto;
}

.wordmark {
  display: grid;
  flex: none;
  width: 2.4rem;
  height: 2.4rem;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.wordmark:hover,
.wordmark:focus-visible {
  background: var(--ink);
  color: var(--bg);
  outline: none;
}

nav {
  display: flex;
  gap: clamp(0.85rem, 2.2vw, 1.85rem);
  font-size: 0.84rem;
}

nav a {
  padding: 0.4rem 0;
  color: var(--ink);
  text-decoration: none;
}

nav a::after {
  display: block;
  width: 0;
  height: 1px;
  margin-top: 0.12rem;
  background: var(--accent);
  content: "";
  transition: width 180ms ease;
}

nav a:hover::after,
nav a:focus-visible::after {
  width: 100%;
}

.lang-switch {
  display: inline-flex;
  flex: none;
  align-items: center;
  padding: 0.18rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 70%, white);
}

.lang-switch button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1;
  min-height: 1.9rem;
  padding: 0.38rem 0.62rem;
}

.lang-switch button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
}

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

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(14rem, 0.4fr);
  gap: clamp(2.5rem, 7vw, 6.5rem);
  align-items: end;
  min-height: clamp(28rem, 64vh, 40rem);
  padding: 5.75rem 0 4.75rem;
}

.hero-copy {
  min-width: 0;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.45rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 1.65rem;
  height: 1px;
  background: var(--accent);
  content: "";
  flex: none;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.85rem, 7vw, 6.5rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.92;
}

html[lang="zh-Hans"] h1 {
  font-size: clamp(3.6rem, 10vw, 8.15rem);
  letter-spacing: -0.06em;
  line-height: 0.86;
}

h1 .name-primary,
h1 .name-secondary {
  display: block;
}

h1 .name-secondary {
  margin-top: 1.05rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: clamp(1rem, 1.8vw, 1.28rem);
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

html[lang="zh-Hans"] h1 .name-secondary {
  letter-spacing: 0.01em;
}

.intro {
  max-width: 38rem;
  margin: 2.15rem 0 0;
  font-family: var(--serif);
  font-size: clamp(1.28rem, 2.15vw, 1.7rem);
  line-height: 1.5;
  text-wrap: pretty;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 2.15rem;
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 2.85rem;
  padding: 0.65rem 1.2rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.84rem;
  text-decoration: none;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}

button.button {
  font: inherit;
  background: transparent;
  cursor: pointer;
}

.button:hover,
.button:focus-visible {
  border-color: var(--ink);
  outline: none;
}

.button-primary {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

.button-primary:hover,
.button-primary:focus-visible {
  border-color: var(--accent);
  background: var(--accent);
  color: #f7f4ee;
}

.hero-mark {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  position: relative;
}

.hero-mark::before,
.hero-mark::after {
  position: absolute;
  background: var(--line);
  content: "";
}

.hero-mark::before {
  width: 100%;
  height: 1px;
}

.hero-mark::after {
  width: 1px;
  height: 100%;
}

.hero-mark span {
  z-index: 3;
  display: grid;
  width: 42%;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-fill);
  color: #f7f4ee;
  font-family: var(--serif);
  font-size: clamp(2.5rem, 5vw, 4.35rem);
  line-height: 1;
}

.hero-mark small {
  position: absolute;
  z-index: 1;
  bottom: 9%;
  padding: 0.2rem 0.55rem;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
}

.section {
  display: grid;
  grid-template-columns: minmax(7.5rem, 0.24fr) minmax(0, 1fr);
  gap: clamp(1.75rem, 5vw, 5.5rem);
  padding: 5.35rem 0;
  border-top: 1px solid var(--line-strong);
  scroll-margin-top: 5.4rem;
}

.section-label {
  display: flex;
  gap: 0.85rem;
  align-items: baseline;
  padding-top: 0.55rem;
}

.section-label p,
.section-label h2 {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-label p {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.section-label h2 {
  font-weight: 700;
}

.statement {
  max-width: 46rem;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.55rem, 2.7vw, 2.35rem);
  font-weight: 500;
  line-height: 1.38;
  text-wrap: pretty;
}

.focus-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 3.15rem 0 0;
  padding: 0;
  list-style: none;
}

.focus-list li {
  display: flex;
  flex-direction: column;
  min-height: 12.5rem;
  padding: 1.15rem 1.15rem 1.25rem;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 42%, var(--bg));
}

.focus-list span {
  color: var(--accent);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.focus-list strong {
  display: block;
  margin-top: auto;
  padding-top: 2rem;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 500;
}

.focus-list p {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem 2rem;
  align-items: end;
  margin-bottom: 1.6rem;
}

.section-heading .statement {
  font-size: clamp(1.6rem, 2.6vw, 2.25rem);
}

.section-heading a {
  flex: none;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: none;
}

.section-heading a:hover,
.section-heading a:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.projects {
  display: grid;
  gap: 0.7rem;
}

.project {
  display: grid;
  grid-template-columns: 2.1rem minmax(0, 1fr) auto;
  gap: 0.35rem 1.15rem;
  align-items: start;
  padding: 1.2rem 1.15rem 1.25rem;
  border: 1px solid var(--line);
  background: color-mix(in srgb, white 35%, transparent);
  color: var(--ink);
  text-decoration: none;
  transition: background 180ms ease, border-color 180ms ease;
}

.project.featured {
  border-color: color-mix(in srgb, var(--ink) 28%, var(--line));
  background: color-mix(in srgb, var(--surface) 70%, var(--bg));
}

.project:hover,
.project:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line-strong));
  background: var(--surface);
  outline: none;
}

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

.project-number {
  padding-top: 0.32rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.project.featured .project-number {
  color: var(--accent);
}

.project h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.2rem, 1.8vw, 1.48rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  transition: color 180ms ease;
}

.project:hover h3,
.project:focus-visible h3 {
  color: var(--accent);
}

.project p {
  max-width: 44rem;
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
  text-wrap: pretty;
}

.project-meta {
  justify-self: end;
  margin-top: 0.15rem;
  padding: 0.28rem 0.55rem 0.24rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}

.project-meta i {
  margin-left: 0.2rem;
  font-style: normal;
}

.facts {
  margin: 2.85rem 0 0;
  border-top: 1px solid var(--line-strong);
}

.facts > div {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 1rem 1.5rem;
  padding: 1.25rem 0 1.3rem;
  border-bottom: 1px solid var(--line);
}

.facts h3 {
  margin: 0.15rem 0 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.facts ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.facts li {
  font-size: 1rem;
  line-height: 1.6;
}

.facts li + li {
  margin-top: 0.85rem;
}

.facts li:has(span) {
  display: grid;
  grid-template-columns: 7.25rem minmax(0, 1fr);
  column-gap: 0.85rem;
  align-items: baseline;
}

.facts li span:first-child {
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.facts a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
}

.facts a:hover,
.facts a:focus-visible {
  color: var(--accent);
  border-bottom-color: var(--accent);
  outline: none;
}

.facts small {
  display: block;
  margin-top: 0.32rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.contact {
  padding-bottom: 6.5rem;
}

.contact-content .eyebrow {
  margin-bottom: 1.05rem;
}

.contact-title {
  max-width: 12em;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.25rem, 4.6vw, 3.9rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.08;
  text-wrap: balance;
}

html[lang="zh-Hans"] .contact-title {
  max-width: 8em;
  font-size: clamp(2.55rem, 5.8vw, 5.15rem);
}

.email {
  display: inline-block;
  max-width: 100%;
  margin-top: 2.6rem;
  border-bottom: 1px solid var(--ink);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.2vw, 1.7rem);
  overflow-wrap: anywhere;
  text-decoration: none;
}

.email:hover,
.email:focus-visible,
.github-link:hover,
.github-link:focus-visible {
  color: var(--accent);
  outline: none;
}

.email:hover,
.email:focus-visible {
  border-bottom-color: var(--accent);
}

.github-link {
  display: block;
  width: fit-content;
  margin-top: 1.05rem;
  color: var(--muted);
  font-size: 0.86rem;
  text-decoration: none;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.35rem 0 2.4rem;
  border-top: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

footer p {
  margin: 0;
}

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

  .focus-list li {
    min-height: 0;
  }

  .focus-list strong {
    margin-top: 0.85rem;
    padding-top: 0;
  }
}

@media (max-width: 760px) {
  .page {
    width: min(100% - 1.75rem, 40rem);
  }

  .site-header {
    min-height: 4.25rem;
    padding: 0.7rem 0;
  }

  nav {
    gap: 0.85rem;
    font-size: 0.8rem;
  }

  .hero {
    display: block;
    min-height: 0;
    padding: 3.6rem 0 3.4rem;
  }

  h1 {
    font-size: clamp(2.7rem, 12vw, 4.6rem);
  }

  html[lang="zh-Hans"] h1 {
    font-size: clamp(3.15rem, 16vw, 5.4rem);
  }

  .hero-mark {
    width: min(13.5rem, 62vw);
    margin: 2.75rem 0 0 auto;
  }

  .section {
    display: block;
    padding: 3.6rem 0;
  }

  .section-label {
    margin-bottom: 1.35rem;
    padding-top: 0;
  }

  .focus-list {
    margin-top: 1.75rem;
  }

  .section-heading {
    display: block;
    margin-bottom: 1.15rem;
  }

  .section-heading a {
    display: inline-block;
    margin-top: 0.9rem;
  }

  .facts {
    margin-top: 2.2rem;
  }

  .facts > div {
    grid-template-columns: 1fr;
    gap: 0.45rem;
    padding: 1.05rem 0;
  }

  .project {
    grid-template-columns: 1.6rem minmax(0, 1fr);
    gap: 0.35rem 0.75rem;
    padding: 1.05rem 0.95rem 1.1rem;
  }

  .project-meta {
    grid-column: 2;
    justify-self: start;
    margin-top: 0.15rem;
  }

  .contact {
    padding-bottom: 4.25rem;
  }

  .email {
    margin-top: 2rem;
  }
}

@media (max-width: 420px) {
  .page {
    width: min(100% - 1.5rem, 40rem);
  }

  .site-header {
    align-items: center;
  }

  .header-end {
    gap: 0.55rem;
  }

  nav {
    gap: 0.62rem;
    font-size: 0.76rem;
  }

  .lang-switch button {
    min-height: 1.85rem;
    padding: 0.36rem 0.48rem;
  }

  .intro {
    font-size: 1.18rem;
  }

  .facts li:has(span) {
    grid-template-columns: 1fr;
    row-gap: 0.12rem;
  }

  .contact-title {
    font-size: clamp(2.05rem, 9.2vw, 2.55rem);
  }

  html[lang="zh-Hans"] .contact-title {
    font-size: clamp(2.25rem, 10vw, 2.9rem);
  }

  footer {
    display: block;
  }

  footer p + p {
    margin-top: 0.45rem;
  }
}

/* ---- footer easter eggs ---- */

.footer-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: baseline;
  gap: 0.45rem;
}

.ghost-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  text-decoration: underline dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.24em;
}

.ghost-btn:hover,
.ghost-btn:focus-visible {
  color: var(--accent);
  outline: none;
}

.ghost-btn.busy {
  color: var(--accent);
  text-decoration-style: solid;
}

.ghost-mono {
  font-family: var(--mono);
}

/* ---- hero mark: SME outer-product easter egg (hover / click) ----
   JS owns the trigger (.playing): while the pointer stays on the mark the
   end state holds (ZA tile filled, seal away); leaving resets to the seal. */

.hero-mark {
  cursor: pointer;
  touch-action: manipulation;
}

.mark-vec {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
}

.mark-vec .op-bar,
.mark-vec .seg,
.mark-vec .to,
.mark-vec .tf,
.mark-vec .vec-label,
.mark-vec .vec-op {
  opacity: 0;
}

.mark-vec .op-bar {
  fill: var(--ink);
  transform-box: fill-box;
}

.mark-vec .op-bar-h {
  transform-origin: 0 50%;
}

.mark-vec .op-bar-v {
  transform-origin: 50% 0;
}

.mark-vec .seg {
  fill: color-mix(in srgb, var(--surface) 55%, transparent);
  stroke: var(--line-strong);
  stroke-width: 1.1;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.mark-vec .to {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}

.mark-vec .tf {
  fill: var(--accent-fill);
  transform-box: fill-box;
  transform-origin: 50% 100%;
}

.mark-vec .vec-label {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 7px;
}

.mark-vec .vec-op {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 8.5px;
  text-anchor: middle;
}

.hero-mark.playing > span {
  animation: mark-seal 2.4s ease both;
}

.hero-mark.playing .op-bar-h {
  animation: mark-bar-h 2.4s ease both;
}

.hero-mark.playing .op-bar-v {
  animation: mark-bar-v 2.4s ease both;
}

.hero-mark.playing .vec-label {
  animation: mark-label 2.4s ease both;
}

.hero-mark.playing .to {
  animation: mark-tile 2.4s ease both;
}

.hero-mark.playing .vec-op {
  animation: mark-op 2.4s ease both;
}

.hero-mark.playing .segs-h .seg:nth-child(1),
.hero-mark.playing .segs-v .seg:nth-child(1) {
  animation: mark-seg-1 2.4s ease both;
}

.hero-mark.playing .segs-h .seg:nth-child(2),
.hero-mark.playing .segs-v .seg:nth-child(2) {
  animation: mark-seg-2 2.4s ease both;
}

.hero-mark.playing .segs-h .seg:nth-child(3),
.hero-mark.playing .segs-v .seg:nth-child(3) {
  animation: mark-seg-3 2.4s ease both;
}

.hero-mark.playing .segs-h .seg:nth-child(4),
.hero-mark.playing .segs-v .seg:nth-child(4) {
  animation: mark-seg-4 2.4s ease both;
}

.hero-mark.playing .tile .tf.d0 {
  animation: mark-fill-d0 2.4s cubic-bezier(0.25, 0.8, 0.3, 1) both;
}

.hero-mark.playing .tile .tf.d1 {
  animation: mark-fill-d1 2.4s cubic-bezier(0.25, 0.8, 0.3, 1) both;
}

.hero-mark.playing .tile .tf.d2 {
  animation: mark-fill-d2 2.4s cubic-bezier(0.25, 0.8, 0.3, 1) both;
}

.hero-mark.playing .tile .tf.d3 {
  animation: mark-fill-d3 2.4s cubic-bezier(0.25, 0.8, 0.3, 1) both;
}

.hero-mark.playing .tile .tf.d4 {
  animation: mark-fill-d4 2.4s cubic-bezier(0.25, 0.8, 0.3, 1) both;
}

.hero-mark.playing .tile .tf.d5 {
  animation: mark-fill-d5 2.4s cubic-bezier(0.25, 0.8, 0.3, 1) both;
}

.hero-mark.playing .tile .tf.d6 {
  animation: mark-fill-d6 2.4s cubic-bezier(0.25, 0.8, 0.3, 1) both;
}

@keyframes mark-seal {
  0%, 6% { transform: scale(1); opacity: 1; }
  14% { transform: scale(0.12); opacity: 0; }
  100% { transform: scale(0.12); opacity: 0; }
}

@keyframes mark-bar-h {
  0%, 4% { opacity: 0; transform: scaleX(0.02); }
  6% { opacity: 1; }
  13% { transform: scaleX(1); }
  15% { opacity: 1; transform: scaleX(1); }
  19% { opacity: 0; transform: scaleX(1); }
  100% { opacity: 0; transform: scaleX(1); }
}

@keyframes mark-bar-v {
  0%, 4% { opacity: 0; transform: scaleY(0.02); }
  6% { opacity: 1; }
  13% { transform: scaleY(1); }
  15% { opacity: 1; transform: scaleY(1); }
  19% { opacity: 0; transform: scaleY(1); }
  100% { opacity: 0; transform: scaleY(1); }
}

@keyframes mark-label {
  0%, 7% { opacity: 0; }
  14% { opacity: 1; }
  100% { opacity: 1; }
}

@keyframes mark-seg-1 {
  0%, 15% { opacity: 0; stroke-dashoffset: 1; }
  16% { opacity: 1; }
  21% { stroke-dashoffset: 0; }
  100% { opacity: 1; stroke-dashoffset: 0; }
}

@keyframes mark-seg-2 {
  0%, 16.8% { opacity: 0; stroke-dashoffset: 1; }
  17.8% { opacity: 1; }
  22.8% { stroke-dashoffset: 0; }
  100% { opacity: 1; stroke-dashoffset: 0; }
}

@keyframes mark-seg-3 {
  0%, 18.6% { opacity: 0; stroke-dashoffset: 1; }
  19.6% { opacity: 1; }
  24.6% { stroke-dashoffset: 0; }
  100% { opacity: 1; stroke-dashoffset: 0; }
}

@keyframes mark-seg-4 {
  0%, 20.4% { opacity: 0; stroke-dashoffset: 1; }
  21.4% { opacity: 1; }
  26.4% { stroke-dashoffset: 0; }
  100% { opacity: 1; stroke-dashoffset: 0; }
}

@keyframes mark-tile {
  0%, 17% { opacity: 0; }
  25% { opacity: 1; }
  100% { opacity: 1; }
}

@keyframes mark-fill-d0 {
  0%, 30% { transform: scaleY(0); opacity: 0; }
  31.5% { opacity: 0.9; }
  39% { transform: scaleY(1); }
  100% { transform: scaleY(1); opacity: 0.9; }
}

@keyframes mark-fill-d1 {
  0%, 35.6% { transform: scaleY(0); opacity: 0; }
  37.1% { opacity: 0.9; }
  44.6% { transform: scaleY(1); }
  100% { transform: scaleY(1); opacity: 0.9; }
}

@keyframes mark-fill-d2 {
  0%, 41.2% { transform: scaleY(0); opacity: 0; }
  42.7% { opacity: 0.9; }
  50.2% { transform: scaleY(1); }
  100% { transform: scaleY(1); opacity: 0.9; }
}

@keyframes mark-fill-d3 {
  0%, 46.8% { transform: scaleY(0); opacity: 0; }
  48.3% { opacity: 0.9; }
  55.8% { transform: scaleY(1); }
  100% { transform: scaleY(1); opacity: 0.9; }
}

@keyframes mark-fill-d4 {
  0%, 52.4% { transform: scaleY(0); opacity: 0; }
  53.9% { opacity: 0.9; }
  61.4% { transform: scaleY(1); }
  100% { transform: scaleY(1); opacity: 0.9; }
}

@keyframes mark-fill-d5 {
  0%, 58% { transform: scaleY(0); opacity: 0; }
  59.5% { opacity: 0.9; }
  67% { transform: scaleY(1); }
  100% { transform: scaleY(1); opacity: 0.9; }
}

@keyframes mark-fill-d6 {
  0%, 63.6% { transform: scaleY(0); opacity: 0; }
  65.1% { opacity: 0.9; }
  72.6% { transform: scaleY(1); }
  100% { transform: scaleY(1); opacity: 0.9; }
}

@keyframes mark-op {
  0%, 42% { opacity: 0; transform: translateY(3px); }
  50% { opacity: 1; transform: translateY(0); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ---- mini terminal (~ or the >_ footer link) ---- */

.terminal {
  position: fixed;
  z-index: 40;
  bottom: 1.1rem;
  left: 1.1rem;
  display: flex;
  flex-direction: column;
  width: min(33rem, calc(100vw - 2.2rem));
  height: min(23rem, 62vh);
  background: var(--ink);
  color: var(--surface);
  border: 1px solid #3b382f;
  border-radius: 10px;
  box-shadow: 0 18px 48px rgba(23, 21, 15, 0.3);
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms;
}

.terminal.open {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.terminal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.45rem 0.5rem 0.85rem;
  border-bottom: 1px solid #3b382f;
  color: #97917f;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
}

.terminal-close {
  padding: 0.15rem 0.45rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  line-height: 1.4;
}

.terminal-close:hover {
  background: #2b2921;
  color: #f2efe8;
}

.terminal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.terminal-body {
  flex: 1;
  padding: 0.7rem 0.85rem 0.4rem;
  overflow-y: auto;
}

.terminal-body::-webkit-scrollbar {
  width: 8px;
}

.terminal-body::-webkit-scrollbar-thumb {
  background: #3b382f;
  border-radius: 4px;
}

.t-line {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.t-dim { color: #97917f; }
.t-acc, .t-user { color: #e0603f; }
.t-path { color: #97917f; }
.t-cmd { color: #f2efe8; }

.t-sw {
  display: inline-block;
  width: 1.15em;
  height: 0.95em;
  margin-right: 0.24em;
  border: 1px solid rgba(242, 239, 232, 0.16);
  border-radius: 2px;
  vertical-align: -0.12em;
}

.terminal-input-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem 0.75rem;
  border-top: 1px solid #3b382f;
}

.terminal-prompt {
  flex: none;
}

.terminal-input-row input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: #f2efe8;
  caret-color: #e0603f;
  font: inherit;
  outline: none;
}

@media (max-width: 760px) {
  .terminal {
    bottom: 0.75rem;
    left: 0.75rem;
    width: calc(100vw - 1.5rem);
    height: 60vh;
  }

  .footer-tools {
    justify-content: flex-start;
  }
}

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

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