:root {
  --mist: #e3e7e4;
  --mist-rgb: 227 231 228;
  --ink: #1b2a4a;
  --graphite: #4f5a6c;
  --pin: #6d3fc0;
  --basin: #2f6f6a;
  --haze: #c3ccc8;
  --cairn-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 26'%3E%3Cellipse cx='11' cy='22' rx='10' ry='3.6' fill='%231b2a4a'/%3E%3Cellipse cx='11' cy='14.5' rx='7' ry='3' fill='%231b2a4a'/%3E%3Cellipse cx='11' cy='8' rx='4.6' ry='2.6' fill='%231b2a4a'/%3E%3Ccircle cx='11' cy='2.6' r='2.4' fill='%236d3fc0'/%3E%3C/svg%3E");

  --display: "Anybody", "Arial Narrow", sans-serif;
  --text: "Newsreader", Georgia, serif;

  --gutter: clamp(1rem, 6vw, 6.5rem);
  --measure: 34rem;
}

/* Night map: the same survey, drawn in pale ink on deep slate. */
/* Dark palette: follows the system unless the visitor picks a theme with the toggle (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --mist: #131b29;
    --mist-rgb: 19 27 41;
    --ink: #d6dee9;
    --graphite: #939fb3;
    --pin: #a283f2;
    --basin: #03100f;
    --haze: #2d394c;
    --cairn-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 26'%3E%3Cellipse cx='11' cy='22' rx='10' ry='3.6' fill='%23d6dee9'/%3E%3Cellipse cx='11' cy='14.5' rx='7' ry='3' fill='%23d6dee9'/%3E%3Cellipse cx='11' cy='8' rx='4.6' ry='2.6' fill='%23d6dee9'/%3E%3Ccircle cx='11' cy='2.6' r='2.4' fill='%23a283f2'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --mist: #131b29;
  --mist-rgb: 19 27 41;
  --ink: #d6dee9;
  --graphite: #939fb3;
  --pin: #a283f2;
  --basin: #03100f;
  --haze: #2d394c;
  --cairn-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 26'%3E%3Cellipse cx='11' cy='22' rx='10' ry='3.6' fill='%23d6dee9'/%3E%3Cellipse cx='11' cy='14.5' rx='7' ry='3' fill='%23d6dee9'/%3E%3Cellipse cx='11' cy='8' rx='4.6' ry='2.6' fill='%23d6dee9'/%3E%3Ccircle cx='11' cy='2.6' r='2.4' fill='%23a283f2'/%3E%3C/svg%3E");
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

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

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

body {
  margin: 0;
  background: var(--mist);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.125rem;
  font-optical-sizing: auto;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* The landscape sits behind everything; empty areas of the page let clicks through to it. */
#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: pan-y;
}
.no-webgl #map, .no-webgl .drop, .no-webgl .labels { display: none; }

.veil {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg,
    rgb(var(--mist-rgb) / 0.95) 0,
    rgb(var(--mist-rgb) / 0.88) calc(var(--gutter) + var(--measure) - 4rem),
    rgb(var(--mist-rgb) / 0) calc(var(--gutter) + var(--measure) + 12rem));
}

main { position: relative; pointer-events: none; }

main > section {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 18vh var(--gutter);
}

.panel {
  max-width: var(--measure);
  pointer-events: auto;
}

/* Type */
h1 { margin: 0 0 2.2rem; font-weight: normal; }

.name {
  display: block;
  font-family: var(--display);
  font-variation-settings: "wdth" 112;
  font-weight: 560;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
  margin-bottom: 1.1rem;
}

.motto {
  display: block;
  font-family: var(--display);
  font-variation-settings: "wdth" 58;
  font-weight: 780;
  font-size: clamp(3.4rem, 10.5vw, 8.6rem);
  line-height: 0.88;
  letter-spacing: -0.01em;
}

h2 {
  font-family: var(--display);
  font-variation-settings: "wdth" 68;
  font-weight: 720;
  font-size: clamp(2.3rem, 5vw, 3.6rem);
  line-height: 0.95;
  margin: 0 0 1.6rem;
}

h3 {
  font-family: var(--display);
  font-variation-settings: "wdth" 92;
  font-weight: 650;
  font-size: 1.3rem;
  line-height: 1.2;
  margin: 0 0 0.4rem;
}

p { margin: 0 0 1rem; }

.lede { font-size: 1.3rem; line-height: 1.5; }

.aside {
  font-style: italic;
  color: var(--graphite);
  margin-top: 1.6rem;
}

a {
  color: inherit;
  text-decoration-color: var(--pin);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
}
a:hover { color: var(--pin); }

:focus-visible {
  outline: 2px solid var(--pin);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Smaller basins */
.interests { margin: 1.6rem 0 0; }
.interests dt {
  font-family: var(--display);
  font-variation-settings: "wdth" 92;
  font-weight: 620;
  font-size: 1.1rem;
}
.interests dd { margin: 0.15rem 0 1.1rem; color: var(--graphite); }

/* Projects, each marked with the same cairn as on the map */
.cairns { list-style: none; padding: 0; margin: 2rem 0 0; }
.cairns li {
  position: relative;
  padding-left: 2.1rem;
  margin-bottom: 2rem;
}
.cairns li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.2rem;
  width: 1.1rem;
  height: 1.3rem;
  background: var(--cairn-icon) no-repeat center / contain;
}
.cairns p { margin-bottom: 0.5rem; }
.cairns li > a { font-style: italic; }

/* Contact */
.links { list-style: none; padding: 0; margin: 2rem 0 3rem; }
.links li { margin-bottom: 0.3rem; }
.links a {
  font-family: var(--display);
  font-variation-settings: "wdth" 70;
  font-weight: 700;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  line-height: 1.15;
  text-decoration-thickness: 2px;
  overflow-wrap: anywhere;
}
.colophon { font-size: 0.95rem; color: var(--graphite); font-style: italic; }
.links .email { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.8rem; }
.copy-status { font-style: italic; color: var(--pin); font-size: 0.95rem; }

/* Place names on the map, set like a surveyor's map: italic serif */
.labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.label {
  position: absolute;
  left: 0;
  top: 0;
  white-space: pre;
  text-align: center;
  font-style: italic;
  color: var(--ink);
  line-height: 1.15;
  transform: translate(-50%, -50%);
  transition: opacity 0.4s, color 0.4s;
  will-change: transform;
}
.label.rank-1 { font-size: 1.15rem; font-weight: 500; }
.label.rank-2 { font-size: 1rem; }
.label.rank-3 { font-size: 0.88rem; color: var(--graphite); }
.label.is-active { color: var(--pin); }
.label.cairn {
  font-style: normal;
  font-family: var(--display);
  font-variation-settings: "wdth" 90;
  font-weight: 600;
  font-size: 0.85rem;
  opacity: 0;
}
[data-view="projects"] .label.cairn { opacity: 1; }
.label.settled {
  color: var(--pin);
  font-size: 0.85rem;
}

/* Drop control */
.drop {
  position: fixed;
  right: calc(1.25rem + env(safe-area-inset-right, 0px));
  bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  max-width: 19rem;
  text-align: right;
  font-size: 0.95rem;
  line-height: 1.4;
}
.drop p { margin: 0 0 0.5rem; font-style: italic; color: var(--graphite); }
.drop button {
  font: inherit;
  font-family: var(--display);
  font-variation-settings: "wdth" 90;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--mist);
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  cursor: pointer;
}
.drop button:hover { background: var(--pin); }
.drop-actions { display: flex; gap: 0.5rem; justify-content: flex-end; flex-wrap: wrap; }
.drop button.quiet { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.drop button.quiet:hover { background: transparent; color: var(--pin); box-shadow: inset 0 0 0 1.5px var(--pin); }
.drop button.quiet[aria-pressed="true"] { color: var(--pin); box-shadow: inset 0 0 0 1.5px var(--pin); }
.inline-button {
  font-family: var(--display);
  font-variation-settings: "wdth" 90;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1.5px var(--ink);
  padding: 0.45rem 1rem;
  cursor: pointer;
}
.inline-button:hover { color: var(--pin); box-shadow: inset 0 0 0 1.5px var(--pin); }

/* Frequency chart on the IEM page */
.chart { margin: 1.6rem 0 0.6rem; overflow-x: auto; }
.chart svg { display: block; width: 100%; min-width: 30rem; height: auto; }
.chart .grid { stroke: var(--haze); stroke-width: 1; }
.chart .axis-label { fill: var(--graphite); font-family: var(--text); font-size: 13px; font-style: italic; }
.chart .curve { fill: none; stroke: var(--pin); stroke-width: 2.5; stroke-linejoin: round; }
.chart .ref { fill: var(--ink); }
.chart .ref-label { fill: var(--ink); font-family: var(--display); font-size: 13px; font-weight: 600; }
.chart-note { font-size: 0.95rem; color: var(--graphite); font-style: italic; }

/* One orchestrated entrance: the motto arrives as the first idea rolls in. */
@media (prefers-reduced-motion: no-preference) {
  .hero .panel > * { animation: rise 1.1s cubic-bezier(.2, .7, .2, 1) both; }
  .hero .panel > :nth-child(2) { animation-delay: 0.25s; }
  .hero .panel > :nth-child(3) { animation-delay: 0.4s; }
  .hero .panel > :nth-child(4) { animation-delay: 1.4s; }
  .motto { animation: stretch 1.6s cubic-bezier(.2, .7, .2, 1) both; }
}
@keyframes rise { from { opacity: 0; transform: translateY(0.6rem); } }
@keyframes stretch { from { font-variation-settings: "wdth" 150; opacity: 0; } }

@media (max-width: 760px) {
  body { font-size: 1.06rem; }
  .veil { background: rgb(var(--mist-rgb) / 0.3); }
  /* Each section opens with a window onto the map, then the text. */
  main > section { padding: 48svh 1rem 6rem; align-items: flex-start; }
  .panel {
    background: rgb(var(--mist-rgb) / 0.9);
    padding: 1.25rem 1rem;
    margin: 0 -1rem;
    border-radius: 6px;
  }
  .label.rank-3, .label.cairn:not(.is-here) { display: none; }
  .drop {
    left: calc(1rem + env(safe-area-inset-left, 0px));
    right: calc(1rem + env(safe-area-inset-right, 0px));
    bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    max-width: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    text-align: left;
    background: var(--mist);
    box-shadow: 0 0 0 1px var(--haze);
    padding: 0.5rem 0.5rem 0.5rem 0.9rem;
    border-radius: 999px;
  }
  .drop p { margin: 0; font-size: 0.85rem; }
  .drop button { flex: none; }
  .drop #sound { display: none; }
}

/* ---------- Top bar, shared by every page ---------- */
.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 5;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(0.9rem + env(safe-area-inset-top, 0px)) var(--gutter) 0.9rem;
  background: linear-gradient(rgb(var(--mist-rgb) / 0.96) 55%, rgb(var(--mist-rgb) / 0));
}
.brand {
  font-family: var(--display);
  font-variation-settings: "wdth" 112;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
}
.topbar nav { display: flex; gap: 1.4rem; flex-wrap: wrap; justify-content: flex-end; }
.topbar nav a {
  font-family: var(--display);
  font-variation-settings: "wdth" 88;
  font-weight: 520;
  font-size: 0.95rem;
  text-decoration: none;
}
.topbar nav a:hover, .brand:hover { color: var(--pin); }
.home .hero .name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.home h1 { margin-top: 0; }

.chapter {
  font-style: italic;
  color: var(--pin);
  margin-bottom: 0.4rem;
}
section[id] { scroll-margin-top: 5rem; }

/* Toolkit: a label column and a plain-language column */
.toolkit {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.7rem 1.6rem;
  margin: 1.6rem 0 0;
}
.toolkit dt {
  font-family: var(--display);
  font-variation-settings: "wdth" 92;
  font-weight: 620;
  font-size: 1.05rem;
  padding-top: 0.15rem;
}
.toolkit dd { margin: 0; }

.cairns h3 a { text-decoration: none; }
.cairns h3 a:hover { text-decoration: underline; text-decoration-color: var(--pin); }
.status { font-style: italic; color: var(--graphite); font-size: 1rem; }
.smaller { color: var(--graphite); }

.label.cairn { color: var(--ink); text-decoration: none; }
[data-view="projects"] .label.cairn { pointer-events: auto; }
.label.cairn:hover { color: var(--pin); }

/* ---------- Project pages ---------- */
.project { overflow-x: hidden; }
.project-head {
  position: relative;
  min-height: 78vh;
  min-height: 78svh;
  display: flex;
  align-items: flex-end;
  padding: 7rem var(--gutter) 3rem;
  overflow: hidden;
}
.project-head #map { position: absolute; }
.project-head .veil, .project-head .labels { position: absolute; }
.project-head .panel { position: relative; max-width: 36rem; }
.project-head h1 {
  font-family: var(--display);
  font-variation-settings: "wdth" 62;
  font-weight: 780;
  font-size: clamp(3rem, 8vw, 6.4rem);
  line-height: 0.9;
  margin: 0.8rem 0 1.2rem;
}
.back { font-style: italic; }
.label.is-here { opacity: 1; color: var(--pin); font-size: 1rem; }

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1.2rem 2rem;
  margin: 0;
  padding: 1.6rem var(--gutter);
  border-block: 1px solid var(--haze);
  position: relative;
  background: var(--mist);
}
.facts div { min-width: 0; }
.facts dt { font-style: italic; color: var(--graphite); font-size: 0.95rem; }
.facts dd {
  margin: 0.1rem 0 0;
  font-family: var(--display);
  font-variation-settings: "wdth" 90;
  font-weight: 560;
  font-size: 1.05rem;
  line-height: 1.35;
}

.project-body {
  position: relative;
  background: var(--mist);
  display: grid;
  grid-template-columns: minmax(0, 40rem) minmax(0, 14rem);
  justify-content: space-between;
  gap: 3rem;
  padding: 4rem var(--gutter) 2rem;
}
.project-body article { min-width: 0; }
.project-body article > section { margin-bottom: 3.4rem; }
.project-body h2 { font-size: clamp(1.9rem, 3.6vw, 2.6rem); margin-bottom: 1.1rem; }
.project-body h3 { margin-top: 1.6rem; }
.project-body ul { padding-left: 1.2rem; }
.project-body li { margin-bottom: 0.5rem; }
.project-body li::marker { color: var(--pin); }

.toc { position: sticky; top: 5.5rem; align-self: start; font-size: 1rem; }
.toc p { font-style: italic; color: var(--graphite); margin-bottom: 0.5rem; }
.toc ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.35rem; }
.toc a { text-decoration: none; }
.toc a:hover { color: var(--pin); }

/* A real sequence: steps of a process, numbered */
.steps { list-style: none; padding: 0; margin: 1.4rem 0; counter-reset: step; display: grid; gap: 1.1rem; }
.steps > li { counter-increment: step; display: grid; grid-template-columns: 2.2rem 1fr; gap: 0 0.6rem; margin: 0; }
.steps > li::before {
  content: counter(step);
  font-family: var(--display);
  font-variation-settings: "wdth" 70;
  font-weight: 760;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--pin);
  grid-row: span 2;
}
.steps strong { font-family: var(--display); font-variation-settings: "wdth" 92; font-weight: 640; }

/* Dated decisions, in order */
.timeline { list-style: none; padding: 0; margin: 1.6rem 0; border-left: 1.5px solid var(--haze); }
.timeline > li { position: relative; padding: 0 0 1.6rem 1.6rem; margin: 0; }
.timeline > li::before {
  content: "";
  position: absolute;
  left: -0.42rem;
  top: 0.45rem;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--mist);
  border: 2px solid var(--pin);
}
.timeline time { font-style: italic; color: var(--graphite); display: block; }
.timeline h3 { margin: 0.1rem 0 0.4rem; }

pre {
  font-size: 0.9rem;
  line-height: 1.5;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  border-radius: 6px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
}
code { font-size: 0.92em; }

.project-foot {
  position: relative;
  background: var(--mist);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem 2rem;
  padding: 2.4rem var(--gutter) calc(3rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--haze);
}
.project-foot a {
  font-family: var(--display);
  font-variation-settings: "wdth" 76;
  font-weight: 700;
  font-size: clamp(1.4rem, 3vw, 2rem);
}
.project-foot span { display: block; font-style: italic; color: var(--graphite); font-size: 1rem; }

@media (max-width: 960px) {
  .project-body { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 760px) {
  .topbar nav { gap: 0.9rem; }
  .topbar nav a { font-size: 0.9rem; }
  .topbar .brand { display: none; }
  .topbar { justify-content: flex-start; }
  .home .hero .name { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
  .project-head { min-height: 86svh; padding: 6rem 1rem 2rem; }
  .project-head .panel { background: rgb(var(--mist-rgb) / 0.9); padding: 1rem; margin: 0 -1rem; border-radius: 6px; }
  .project-body { padding: 2.6rem 1rem 1rem; }
  .facts { padding: 1.4rem 1rem; }
  .toolkit { grid-template-columns: 1fr; gap: 0.15rem; }
  .toolkit dd { margin-bottom: 0.7rem; }
}

/* Find the boost */
.game { margin-top: 1.4rem; display: grid; gap: 1rem; }
.game-status { margin: 0; min-height: 3.2em; }
.game-row { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; }
.game-score { margin: 0; font-family: var(--display); font-variation-settings: "wdth" 90; font-weight: 600; font-variant-numeric: tabular-nums; }
.game button {
  font-family: var(--display);
  font-variation-settings: "wdth" 90;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: 0;
}
.game-play { background: var(--pin); color: var(--mist); border-radius: 999px; padding: 0.55rem 1.4rem; min-width: 5.5rem; }
.game-play:hover { background: var(--ink); }
.ab { display: inline-flex; border-radius: 999px; box-shadow: inset 0 0 0 1.5px var(--ink); padding: 3px; }
.ab button { background: transparent; color: var(--ink); border-radius: 999px; padding: 0.4rem 0.95rem; }
.ab button[aria-pressed="true"] { background: var(--ink); color: var(--mist); }
.bands { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.4rem; }
.bands button {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--haze);
  border-radius: 6px;
  padding: 0.6rem 0.2rem;
  font-variant-numeric: tabular-nums;
}
.bands button:hover:not(:disabled) { box-shadow: inset 0 0 0 1.5px var(--ink); }
.bands button:disabled { cursor: default; color: var(--graphite); }
.bands button.is-target { background: var(--pin); color: var(--mist); box-shadow: none; }
.bands button.is-wrong { text-decoration: line-through; box-shadow: inset 0 0 0 1.5px var(--graphite); }
.eq { width: 100%; height: auto; display: block; }
.eq-zero { stroke: var(--haze); stroke-width: 1; stroke-dasharray: 3 4; }
.eq-curve { fill: none; stroke: var(--pin); stroke-width: 2.5; stroke-linejoin: round; }
@media (max-width: 420px) { .bands { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .drop { transition: opacity 0.2s; }
  .in-game .drop { opacity: 0; pointer-events: none; }
  /* On phones the drop bar only shows where the map is the point: the opening view and the playground. */
  .home:not([data-view="hero"]):not([data-view="playground"]) .drop { opacity: 0; pointer-events: none; }
}

/* What I listen on */
.gear { display: grid; gap: 1.4rem; margin-top: 0.4rem; }
.gear h3 { font-style: italic; font-family: var(--text); font-weight: 400; font-size: 1.05rem; color: var(--pin); margin: 0 0 0.5rem; }
.gear ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.7rem; }
.gear li { margin: 0; }
.gear strong { display: block; font-family: var(--display); font-variation-settings: "wdth" 90; font-weight: 640; font-size: 1.08rem; }
.gear span { display: block; color: var(--graphite); font-style: italic; line-height: 1.45; }

.label.cairn.is-hover { color: var(--pin); font-size: 1rem; }
#map { cursor: crosshair; }

/* Hobbies page */
.buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.2rem; }
.brew { display: grid; gap: 0.5rem; max-width: 26rem; margin-top: 1.2rem; }
.brew label { font-family: var(--display); font-variation-settings: "wdth" 92; font-weight: 600; margin-top: 0.6rem; }
.brew output { color: var(--pin); font-variant-numeric: tabular-nums; margin-left: 0.4rem; }
.brew input[type="number"] {
  font: inherit;
  font-variant-numeric: tabular-nums;
  width: 8rem;
  padding: 0.45rem 0.7rem;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
}
.brew input[type="range"] { accent-color: var(--pin); width: 100%; }
.brew-presets { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4rem; }
.brew-result {
  font-family: var(--display);
  font-variation-settings: "wdth" 80;
  font-weight: 700;
  font-size: 1.4rem;
  line-height: 1.25;
  margin: 0.8rem 0 0;
  font-variant-numeric: tabular-nums;
}
.hobbies .gear { grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1.6rem 2rem; }

/* Recent activity: a year of GitHub contributions, one square a day, inside Contact */
.activity { margin: 0 0 2.6rem; --gap: 2px; }
.activity[hidden] { display: none; }
.activity h3 { margin-bottom: 0.3rem; }
.activity-note { font-style: italic; color: var(--graphite); font-size: 1rem; margin-bottom: 0.9rem; }
.activity figure { margin: 0 0 0.8rem; }
.activity-months, .activity-grid {
  display: grid;
  grid-template-columns: repeat(var(--weeks, 53), minmax(0, 1fr));
  column-gap: var(--gap);
}
.activity-months { margin-bottom: 0.3rem; font-size: 0.78rem; font-style: italic; color: var(--graphite); line-height: 1; }
.activity-months span { white-space: nowrap; grid-row: 1; }
.activity-grid { grid-template-rows: repeat(7, auto); grid-auto-flow: column; row-gap: var(--gap); }
.activity-grid span { aspect-ratio: 1; border-radius: 1.5px; background: color-mix(in srgb, var(--ink) 8%, transparent); }
.activity-grid .activity-pad { background: none; }
.activity-grid [data-level="1"] { background: color-mix(in srgb, var(--pin) 30%, transparent); }
.activity-grid [data-level="2"] { background: color-mix(in srgb, var(--pin) 52%, transparent); }
.activity-grid [data-level="3"] { background: color-mix(in srgb, var(--pin) 76%, transparent); }
.activity-grid [data-level="4"] { background: var(--pin); }
.activity-summary { font-family: var(--display); font-variation-settings: "wdth" 90; font-weight: 560; font-size: 1.05rem; line-height: 1.4; margin-bottom: 0.3rem; font-variant-numeric: tabular-nums; }
.activity-updated { font-size: 0.95rem; color: var(--graphite); margin: 0; }
@media (max-width: 760px) {
  .activity { --gap: 1px; }
  .activity-months span:nth-child(even) { display: none; }
}
/* Notes: the top bar gained a link, so tighten it on narrow phones to keep one line. */
@media (max-width: 420px) {
  .topbar nav { gap: 0.4rem 0.6rem; }
  .topbar nav a { font-size: 0.85rem; }
}
/* ---------- Optimizer playground (home, playground.js) ---------- */
.tuner { display: grid; gap: 0.35rem; max-width: 28rem; margin-top: 1.4rem; }
.tuner label { font-family: var(--display); font-variation-settings: "wdth" 92; font-weight: 600; margin-top: 0.5rem; }
.tuner output { color: var(--pin); font-variant-numeric: tabular-nums; margin-left: 0.4rem; }
.tuner input[type="range"] { accent-color: var(--pin); width: 100%; margin: 0; }
.tuner-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.tuner .inline-button[aria-pressed="true"] { color: var(--pin); box-shadow: inset 0 0 0 1.5px var(--pin); }
.tuner-note { font-size: 0.95rem; color: var(--graphite); font-style: italic; margin: 0.5rem 0 0; }
.no-webgl #playground { display: none; }

/* Theme switch in the top bar: a small track with a knob that carries the sun by day and the moon by night. */
.theme-toggle {
  flex: none;
  align-self: center;
  margin-left: 1.2rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  border-radius: 999px;
}
.tt-track {
  position: relative;
  display: block;
  width: 3.4rem;
  height: 1.8rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--pin) 14%, var(--mist));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ink) 22%, transparent);
  overflow: hidden;
  transition: background-color 0.5s, box-shadow 0.3s;
}
.theme-toggle:hover .tt-track { box-shadow: inset 0 0 0 1.5px var(--pin); }
.tt-knob {
  position: absolute;
  top: 0.2rem;
  left: 0.2rem;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--ink);
  color: var(--mist);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.25);
  transition: transform 0.6s cubic-bezier(0.68, -0.4, 0.27, 1.4), background-color 0.5s;
}
.tt-knob svg {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 0.95rem;
  height: 0.95rem;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  transition: transform 0.6s cubic-bezier(0.65, 0, 0.25, 1), opacity 0.35s;
}
.tt-knob .sun path { fill: none; }
.tt-star {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.4s var(--d), transform 0.4s var(--d);
}
/* Day: knob on the left wearing the sun. Night: knob slides right, the sun spins away, the moon rises, stars come out. */
.theme-toggle[data-mode="light"] .moon { transform: rotate(-120deg) scale(0.4); opacity: 0; }
.theme-toggle[data-mode="dark"] .tt-knob { transform: translateX(1.6rem) rotate(360deg); }
.theme-toggle[data-mode="dark"] .sun { transform: rotate(120deg) scale(0.4); opacity: 0; }
.theme-toggle[data-mode="dark"] .tt-star { left: calc(var(--x) - 42%); opacity: 0.85; transform: scale(1); }
.theme-toggle:focus-visible { outline: 2px solid var(--pin); outline-offset: 3px; }
@media (max-width: 760px) { .theme-toggle { margin-left: auto; } }

/* The switch itself: the new theme washes over the page as a soft-edged wave from the switch,
   while the old page sinks back a little. */
@property --tt-wave { syntax: "<length>"; inherits: false; initial-value: 0px; }
::view-transition-old(root),
::view-transition-new(root) { mix-blend-mode: normal; }
.theme-switching::view-transition-group(root) { animation-duration: 1s; }
.theme-switching::view-transition-old(root) {
  animation: tt-recede 1s cubic-bezier(0.65, 0, 0.25, 1) both;
}
.theme-switching::view-transition-new(root) {
  z-index: 2;
  -webkit-mask-image: radial-gradient(circle at var(--tt-x) var(--tt-y), #000 calc(var(--tt-wave) - 180px), transparent var(--tt-wave));
  mask-image: radial-gradient(circle at var(--tt-x) var(--tt-y), #000 calc(var(--tt-wave) - 180px), transparent var(--tt-wave));
  animation: tt-wave 1s cubic-bezier(0.65, 0, 0.25, 1) both;
}
@keyframes tt-wave { from { --tt-wave: 0px; } to { --tt-wave: var(--tt-reach); } }
@keyframes tt-recede { to { transform: scale(0.965); filter: blur(3px) brightness(0.8); } }

/* Browsers without view transitions get a short cross-fade instead. */
.theme-fading, .theme-fading * { transition: background-color 0.5s, color 0.5s, border-color 0.5s, box-shadow 0.5s, fill 0.5s !important; }

@media (prefers-reduced-motion: reduce) {
  .tt-knob, .tt-knob svg, .tt-star, .tt-track { transition: none; }
}

/* Small phones: the section links stay on one line and scroll sideways, with a soft fade
   at the right edge, so the theme switch keeps its place at the end of the bar. */
@media (max-width: 480px) {
  .topbar { align-items: center; }
  .topbar nav {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent);
    mask-image: linear-gradient(90deg, #000 82%, transparent);
    padding-right: 1.2rem;
  }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a { white-space: nowrap; }
  .theme-toggle { margin-left: 0.6rem; }
}

/* ---------- Phones: a shorter, tighter home page and easier tapping ---------- */
@media (max-width: 760px) {
  /* Sections size to their content, with a smaller window onto the map above each one. */
  main > section { min-height: 0; padding: 30svh 1rem 2.5rem; }
  main > section.hero { min-height: 0; padding-top: 38svh; padding-bottom: 3.5rem; }
  .motto { font-size: clamp(3.4rem, 18vw, 5.6rem); line-height: 0.86; }
  .home .hero .name { font-size: 1.15rem; margin-bottom: 0.6rem; }

  /* Menu links get a taller hit area without changing how the bar looks. */
  .topbar { padding-top: calc(0.5rem + env(safe-area-inset-top, 0px)); padding-bottom: 0.5rem; }
  .topbar nav a { padding-block: 0.7rem; font-size: 0.92rem; }

  /* Project pages: facts in two columns, and the contents become a row of chips under them. */
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.2rem; }
  .project-body { display: flex; flex-direction: column; gap: 0; padding-top: 1.2rem; }
  /* min-width: 0 lets the chip row scroll inside its own box; without it the row's full width
     stretched the whole page on phones. */
  .toc { display: block; position: static; order: -1; margin: 0 -1rem 2rem; padding: 0 1rem; min-width: 0; max-width: calc(100% + 2rem); }
  .toc p { display: none; }
  .toc ol {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 0.2rem;
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
    mask-image: linear-gradient(90deg, #000 88%, transparent);
  }
  .toc ol::-webkit-scrollbar { display: none; }
  .toc li { flex: none; }
  .toc a {
    display: block;
    white-space: nowrap;
    font-family: var(--display);
    font-variation-settings: "wdth" 90;
    font-weight: 560;
    font-size: 0.9rem;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    box-shadow: inset 0 0 0 1.5px var(--haze);
  }
  .toc a:hover, .toc a:focus-visible { color: var(--pin); box-shadow: inset 0 0 0 1.5px var(--pin); }
  .project-body article > section { margin-bottom: 2.6rem; }

  /* Bigger targets on the playground and calculator buttons. */
  .tuner-actions .inline-button, .brew-presets .inline-button { padding: 0.6rem 1rem; }
}

/* ---------- Phone top bar: name on the left, theme switch and Menu on the right ---------- */
.menu-toggle { display: none; }
@media (max-width: 760px) {
  .topbar {
    align-items: center;
    justify-content: flex-start;
    gap: 0.6rem;
    padding: calc(0.55rem + env(safe-area-inset-top, 0px)) 1rem 0.55rem;
    background: linear-gradient(rgb(var(--mist-rgb) / 0.97) 70%, rgb(var(--mist-rgb) / 0));
  }
  .topbar .brand { display: block; font-size: 1rem; margin-right: auto; padding-block: 0.45rem; }
  .home .hero .name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .theme-toggle { margin-left: 0; }

  .menu-toggle {
    position: relative;
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 2.3rem;
    height: 2.3rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: var(--ink);
    background: color-mix(in srgb, var(--pin) 14%, var(--mist));
    box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ink) 22%, transparent);
    cursor: pointer;
    transition: background-color 0.35s, color 0.35s, box-shadow 0.35s, transform 0.15s;
  }
  .menu-toggle:active { transform: scale(0.92); }
  .menu-toggle:focus-visible { outline: 2px solid var(--pin); outline-offset: 3px; }
  .menu-open .menu-toggle { background: var(--ink); color: var(--mist); box-shadow: none; }
  .menu-icon { position: relative; width: 1.05rem; height: 0.8rem; }
  .menu-icon i {
    position: absolute;
    right: 0;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transform-origin: center;
    transition: transform 0.45s cubic-bezier(0.68, -0.35, 0.27, 1.35), width 0.35s cubic-bezier(0.65, 0, 0.25, 1), top 0.35s cubic-bezier(0.65, 0, 0.25, 1), opacity 0.2s;
  }
  .menu-icon i:nth-child(1) { top: 0; width: 100%; }
  .menu-icon i:nth-child(2) { top: calc(50% - 1px); width: 72%; }
  .menu-icon i:nth-child(3) { top: calc(100% - 2px); width: 44%; }
  .menu-open .menu-icon i:nth-child(1) { top: calc(50% - 1px); width: 100%; transform: rotate(135deg); }
  .menu-open .menu-icon i:nth-child(2) { width: 0; opacity: 0; }
  .menu-open .menu-icon i:nth-child(3) { top: calc(50% - 1px); width: 100%; transform: rotate(-135deg); }

  /* The links become a panel that drops down under the bar. */
  .topbar nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
    padding: 0.4rem 1rem 1.2rem;
    background: var(--mist);
    border-bottom: 1px solid var(--haze);
    box-shadow: 0 18px 30px -18px rgb(0 0 0 / 0.35);
    overflow: visible;
    -webkit-mask-image: none;
    mask-image: none;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-0.6rem);
    transition: opacity 0.25s, transform 0.3s cubic-bezier(0.65, 0, 0.25, 1), visibility 0s 0.3s;
  }
  .menu-open { background: var(--mist); }
  .menu-open nav { visibility: visible; opacity: 1; transform: none; transition: opacity 0.25s, transform 0.3s cubic-bezier(0.65, 0, 0.25, 1); }
  .topbar nav a {
    font-size: 1.6rem;
    font-variation-settings: "wdth" 72;
    font-weight: 700;
    padding: 0.45rem 0;
    white-space: normal;
    border-bottom: 1px solid color-mix(in srgb, var(--haze) 60%, transparent);
  }
  .topbar nav a:last-child { border-bottom: 0; }
  .topbar nav a { opacity: 0; transform: translateY(-0.4rem); transition: opacity 0.3s, transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1); }
  .menu-open nav a { opacity: 1; transform: none; transition-delay: calc(var(--i, 0) * 45ms + 60ms); }

  /* Drop bar: a compact card that can hold a longer "came to rest" message on two or three lines. */
  .drop { border-radius: 18px; align-items: center; padding: 0.5rem 0.5rem 0.5rem 0.95rem; }
  .drop p {
    font-size: 0.9rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
  }
  .drop-actions { flex: none; }
  .drop button { min-height: 2.4rem; }
}
@media (prefers-reduced-motion: reduce) {
  .topbar nav, .topbar nav a, .menu-icon i, .menu-toggle { transition: none !important; }
}

/* The headline in Vekhyat's own handwriting: real text for readers and search, the traced
   writing for the eye. On load each line is written in left to right behind a soft pen edge. */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.motto.motto-hand { font-size: 1rem; line-height: 1; animation: none; }
.motto-hand .hand { display: block; margin-bottom: 0.9rem; width: min(34rem, calc(100vw - 2 * var(--gutter))); height: auto; fill: currentColor; overflow: visible; }
.motto-hand .hand path { stroke: currentColor; stroke-width: 0.4; stroke-linejoin: round; }
.pen { transform: translateX(0); }
@media (prefers-reduced-motion: no-preference) {
  .pen { animation: pen-write 1.5s cubic-bezier(0.45, 0.05, 0.35, 1) both; }
  .pen-1 { animation-delay: 0.15s; }
  .pen-2 { animation-delay: 1.35s; animation-duration: 1.3s; }
}
@keyframes pen-write { from { transform: translateX(-1300px); } to { transform: translateX(0); } }
@media (max-width: 760px) {
  .motto.motto-hand { font-size: 1rem; line-height: 1; }
  .motto-hand .hand { width: 86%; }
  .motto-hand .hand path { stroke-width: 0.6; }
}
