:root {
  /* light: latte and walnut */
  --bg: #dccab4;
  --surface: #e7d8c4;
  --surface-2: #cdb89e;
  --line: #bda585;
  --text: #2a1a11;
  --muted: #5a4435;
  --accent: #7a4524;
  --accent-ink: #f3e7d6;
  --bar: rgba(220, 202, 180, 0.88);

  --serif: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b120e;
    --surface: #271a14;
    --surface-2: #35241b;
    --line: #4a3326;
    --text: #eadccb;
    --muted: #b39d88;
    --accent: #c9965c;
    --accent-ink: #1b120e;
    --bar: rgba(27, 18, 14, 0.88);
  }
}
:root[data-theme="dark"] {
  --bg: #1b120e;
  --surface: #271a14;
  --surface-2: #35241b;
  --line: #4a3326;
  --text: #eadccb;
  --muted: #b39d88;
  --accent: #c9965c;
  --accent-ink: #1b120e;
  --bar: rgba(27, 18, 14, 0.88);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; scroll-behavior: smooth; scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 76px); }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 17px; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.wrap { width: min(1080px, 100% - 40px); margin-inline: auto; }

/* top bar */
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  background: var(--bar); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.mark { font-family: var(--serif); font-size: 26px; text-decoration: none; letter-spacing: 0.01em; white-space: nowrap; }
.bar nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.bar nav::-webkit-scrollbar { display: none; }
.bar nav a {
  text-decoration: none; font-size: 15px; font-weight: 500; color: var(--muted);
  padding: 6px 11px; border-radius: 999px; white-space: nowrap;
}
.bar nav a:hover, .bar nav a.on { color: var(--text); background: var(--surface-2); }
.bar nav { margin-left: auto; }
.tools { display: flex; gap: 8px; flex: none; }
.bar::after { content: ""; position: absolute; left: 0; bottom: -1px; height: 2px; width: calc(var(--p, 0) * 100%); background: var(--accent); }
.tbtn { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: none; color: var(--text); cursor: pointer; padding: 0; }
.tbtn:hover { border-color: var(--accent); color: var(--accent); }
.tbtn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.tbtn .sun { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tbtn .sun { display: block; } :root:not([data-theme="light"]) .tbtn .moon { display: none; } }
:root[data-theme="dark"] .tbtn .sun { display: block; }
:root[data-theme="dark"] .tbtn .moon { display: none; }

/* hero */
.hero { overflow: hidden; overflow: clip; padding: clamp(64px, 12vw, 148px) 0 clamp(56px, 9vw, 108px); border-bottom: 1px solid var(--line); }
.hero h1 {
  font-family: var(--serif); font-weight: 400; margin: 0;
  font-size: clamp(54px, 11.5vw, 148px); line-height: 0.95; letter-spacing: -0.02em;
}
.hero h1 span { display: block; }
.hero h1 .soft { font-style: italic; color: var(--accent); }
.hero p.lede { max-width: 34em; margin: 32px 0 0; font-size: clamp(18px, 2.2vw, 21px); color: var(--muted); }
.hero .row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 600; font-size: 15px;
  padding: 11px 20px; border-radius: 999px; border: 1px solid var(--accent);
}
.btn.solid { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { color: var(--text); border-color: var(--line); }
.btn:hover { filter: brightness(1.08); }

/* sections */
section { padding: clamp(56px, 8vw, 104px) 0; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: 0; }
.head { display: grid; gap: 10px; margin-bottom: 40px; max-width: 40em; }
h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(38px, 6vw, 64px); line-height: 1.02; margin: 0; letter-spacing: -0.01em; }
.head p { margin: 0; color: var(--muted); }

/* photography */
.gallery { columns: 3 260px; column-gap: 14px; }
.shot { break-inside: avoid; margin: 0 0 14px; position: relative; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.shot img { width: 100%; height: auto; }
.shot .ph { position: relative; width: 100%; display: grid; place-items: end start; padding: 14px; color: var(--muted); font-size: 14px;
  background: linear-gradient(155deg, var(--surface-2), var(--surface) 60%, var(--line)); }
.shot:nth-child(3n+2) .ph { background: linear-gradient(200deg, var(--line), var(--surface-2) 55%, var(--surface)); }
.shot:nth-child(3n) .ph { background: linear-gradient(120deg, var(--surface), var(--line)); }
.shot .ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.more { margin-top: 24px; }

/* about */
.about { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: clamp(28px, 6vw, 72px); align-items: start; }
.portrait { position: relative; overflow: hidden; aspect-ratio: 4 / 5; border-radius: 6px; background: linear-gradient(170deg, var(--surface-2), var(--line)); display: grid; place-items: end start; padding: 14px; color: var(--muted); font-size: 14px; }
.portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.about .prose { max-width: 36em; }
.about .prose p { margin: 0 0 1.1em; }
.about .prose p:first-child { font-family: var(--serif); font-size: clamp(24px, 3.2vw, 32px); line-height: 1.25; color: var(--text); }
.about .prose p:not(:first-child) { color: var(--muted); }

/* papers */
.papers { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: clamp(28px, 4vw, 48px); }
.paper { display: grid; grid-template-columns: 200px 1fr; gap: 28px; align-items: center; }
.cover-link { display: block; text-decoration: none; color: inherit; }
.cover {
  aspect-ratio: 3 / 4; border-radius: 3px 8px 8px 3px; padding: 22px 20px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-left: 6px solid var(--accent);
  box-shadow: 0 14px 28px -18px rgba(20, 8, 2, 0.55);
  transition: transform .2s ease;
}
.cover b { font-family: var(--serif); font-weight: 400; font-size: 21px; line-height: 1.12; }
.cover small { color: var(--muted); font-size: 13px; }
.paper h3 { margin: 0 0 8px; font-family: var(--serif); font-weight: 400; font-size: 28px; line-height: 1.1; }
.paper p { margin: 0; color: var(--muted); font-size: 15px; }

/* certificates */
.certs { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.certs li { display: grid; grid-template-columns: 76px 1fr auto; gap: 18px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.thumb { aspect-ratio: 4 / 3; border-radius: 4px; background: linear-gradient(135deg, var(--surface-2), var(--line)); }
.thumb.mark { display: grid; place-items: center; font-family: var(--serif); font-size: 30px; color: var(--accent); }
.certs a { color: var(--accent); }
.certs.edu li { grid-template-columns: 1fr auto; }
.sub { font-family: var(--serif); font-weight: 400; font-size: clamp(28px, 4vw, 38px); margin: 52px 0 18px; }
.note { margin: 18px 0 0; color: var(--muted); font-size: 15px; }
.certs strong { display: block; font-weight: 600; }
.certs span { color: var(--muted); font-size: 15px; }
.certs time { color: var(--muted); font-size: 15px; }

/* profiles */
.profiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.profile { display: flex; align-items: center; gap: 14px; text-decoration: none; padding: 16px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.profile:hover { border-color: var(--accent); }
.profile svg { width: 28px; height: 28px; flex: none; color: var(--accent); }
.profile b { display: block; font-weight: 600; line-height: 1.2; }
.profile small { color: var(--muted); font-size: 14px; }

/* amc */
.amc { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: clamp(28px, 6vw, 72px); align-items: center; padding: clamp(28px, 5vw, 56px); border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.amc h2 { font-size: clamp(34px, 5vw, 54px); }
.amc p { color: var(--muted); max-width: 32em; margin: 16px 0 24px; }
.orbit { width: 100%; max-width: 280px; justify-self: center; color: var(--accent); }

/* contact */
.contact { display: grid; gap: 24px; justify-items: start; }
.contact a.mail { font-family: var(--serif); font-size: clamp(30px, 6vw, 60px); line-height: 1.1; text-decoration: none; border-bottom: 2px solid var(--accent); }
.contact p { margin: 0; color: var(--muted); max-width: 32em; }
.contact .mailrow { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; }
.contact .local { font-size: 15px; }

footer { padding: 32px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.shot button { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; line-height: 0; }
.shot button:hover img { filter: brightness(1.07); }
dialog#viewer { border: 0; padding: 0; background: transparent; width: 100%; max-width: 100vw; height: 100%; max-height: 100vh; color: #eadccb; }
dialog#viewer::backdrop { background: rgba(18, 10, 7, 0.96); }
dialog#viewer[open] { display: grid; place-items: center; }
#viewer img { max-width: min(94vw, 1500px); max-height: 84vh; object-fit: contain; border-radius: 3px; }
#viewer .vbtn { position: absolute; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; border: 1px solid rgba(234, 220, 203, 0.35); background: rgba(27, 18, 14, 0.6); color: #eadccb; cursor: pointer; padding: 0; }
#viewer .vbtn:hover { border-color: #c9965c; color: #c9965c; }
#viewer .vbtn svg { width: 22px; height: 22px; }
#viewer .vclose { top: calc(env(safe-area-inset-top, 0px) + 14px); right: 14px; }
#viewer .vprev { left: 14px; top: 50%; transform: translateY(-50%); }
#viewer .vnext { right: 14px; top: 50%; transform: translateY(-50%); }
#viewer .vcount { position: absolute; bottom: calc(env(safe-area-inset-bottom, 0px) + 14px); left: 0; right: 0; text-align: center; margin: 0; font-size: 14px; color: #b39d88; }
@media (max-width: 720px) { #viewer .vprev, #viewer .vnext { top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 44px); transform: none; } #viewer img { max-height: 74vh; } }

/* paper grain behind everything */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .16 0 0 0 0 .1 0 0 0 0 .07 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }

@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body::before { opacity: .25; } }
:root[data-theme="dark"] body::before { opacity: .25; }

/* hero regime line */
.regime { display: block; width: 100%; height: 64px; margin-top: clamp(44px, 7vw, 72px); color: var(--accent); opacity: .75; overflow: visible; }
.regime path { fill: none; stroke: currentColor; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: miter; }

/* research covers */
.cover .kind { display: block; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.cover .motif { width: 100%; height: auto; color: var(--accent); }
.cover .crest { width: 54px; height: auto; color: var(--accent); }
.cover .crest path { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.cover .crest .inner { opacity: .45; stroke-width: 1; }
.cover .crest .step { stroke-dasharray: 3 3; opacity: .8; }
.cover .uni { width: 46px; height: auto; }
.cover .motif path { fill: none; stroke: currentColor; stroke-width: 2; }
.cover .motif .ghost { stroke-dasharray: 4 5; opacity: .6; }
.paper .status { color: var(--accent); font-weight: 600; font-size: 14px; }
a.cover-link[href]:hover .cover { transform: translateY(-4px); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 12px; }
.paper .actions .status { margin: 0; text-decoration: none; }
a.status[href]:hover { text-decoration: underline; text-underline-offset: 3px; }
.chip { font: inherit; font-size: 13px; font-weight: 600; color: var(--text); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 5px 13px; cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.done { border-color: var(--accent); color: var(--accent); }

.skip { position: absolute; left: 12px; top: -60px; z-index: 20; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 999px; text-decoration: none; font-weight: 600; }
.skip:focus { top: calc(env(safe-area-inset-top, 0px) + 10px); }

/* one orchestrated moment: the name settles in */
@media (prefers-reduced-motion: no-preference) {
  .hero h1 span { animation: settle 1s cubic-bezier(.2,.7,.2,1) both; }
  .hero h1 span:nth-child(2) { animation-delay: .14s; }
  .orbit .spin { transform-box: view-box; transform-origin: 120px 120px; animation: spin 40s linear infinite; }
  .orbit .s2 { animation-duration: 70s; }
  .orbit .s3 { animation-duration: 110s; }
  @keyframes spin { to { transform: rotate(360deg); } }
  .regime { animation: reveal 1.6s cubic-bezier(.6,.1,.2,1) .5s both; }
  @keyframes reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
  @keyframes settle { from { opacity: 0; transform: translateY(22px); letter-spacing: 0.03em; } to { opacity: 1; transform: none; } }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .cover { transition: none; } }

@media (max-width: 720px) {
  .bar .wrap { flex-direction: column; align-items: flex-start; gap: 0; padding: 8px 0 6px; }
  .bar .wrap { position: relative; }
  .tools { position: absolute; right: 0; top: 8px; gap: 6px; }
  .tbtn { width: 32px; height: 32px; }
  .bar nav { width: 100%; margin-left: -8px; gap: 0; }
  .bar nav a { font-size: 14px; padding: 6px 8px; }
  html { scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 104px); }
  .amc { grid-template-columns: 1fr; }
  .certs li { grid-template-columns: 60px 1fr; }
  .paper { grid-template-columns: 1fr; }

  .certs time { grid-column: 2; }
}

/* =========================================================
   Additions: subpages, accessibility, menu, clock, orbit, CV
   ========================================================= */

/* current page in nav */
.bar nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

/* page header for subpages */
.page-head { padding: clamp(56px, 10vw, 128px) 0 clamp(32px, 5vw, 56px); }
.page-head h1 { font-family: var(--serif); font-weight: 400; margin: 0; font-size: clamp(56px, 10vw, 128px); line-height: .95; letter-spacing: -0.02em; }
.page-head p { margin: 22px 0 0; max-width: 36em; color: var(--muted); font-size: clamp(17px, 2vw, 20px); }
.page-head .row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.page-body { padding: 0 0 clamp(64px, 9vw, 120px); }

/* footer with Dublin clock */
.foot-r { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
.clockline { display: inline-flex; gap: 8px; align-items: center; }
.clock { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; color: var(--accent); }
.clock .mh { stroke-width: 1.2; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.linkish:hover { color: var(--accent); }

/* thesis cover subtitle */
.cover .subt { display: block; margin-top: 8px; color: var(--muted); font-size: 12.5px; line-height: 1.35; }

/* ---------- AmC orbit: tilts toward the pointer, rings light up ---------- */
.amc { position: relative; overflow: hidden; }
.orbit { transform: perspective(700px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .6s cubic-bezier(.2,.7,.2,1); }
.orbit .ring { transition: opacity .25s, stroke-width .25s; }
.orbit .hit { fill: none; stroke: transparent; stroke-width: 18; pointer-events: stroke; cursor: crosshair; }
.orbit .spin circle { transform-box: fill-box; transform-origin: center; transition: transform .3s; }
.orbit[data-ring="1"] .r1, .orbit[data-ring="2"] .r2, .orbit[data-ring="3"] .r3 { opacity: 1; stroke-width: 3; }
.orbit[data-ring="1"] .s1 circle, .orbit[data-ring="2"] .s2 circle, .orbit[data-ring="3"] .s3 circle { transform: scale(1.7); }
.orbit .core { transition: transform .3s; transform-box: fill-box; transform-origin: center; }
.orbit[data-ring] .core { transform: scale(.85); }

/* ---------- photography page ---------- */
.empty { padding: 40px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); max-width: 36em; }
.empty p { margin: 0 0 16px; }
.shot img { background: var(--surface-2); }

/* ---------- CV page ---------- */
.cv-tools { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.cv { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: clamp(32px, 6vw, 72px); align-items: start; }
.cv h2 { font-size: clamp(28px, 3.4vw, 36px); margin: 0 0 6px; }
.cv-block { margin-bottom: 44px; }
.ent { padding: 16px 0; border-top: 1px solid var(--line); }
.ent:last-child { border-bottom: 1px solid var(--line); }
.ent-h { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.ent-h strong { font-weight: 600; line-height: 1.35; }
.ent-h time { color: var(--muted); font-size: 15px; white-space: nowrap; }
.ent .org { color: var(--accent); font-size: 15px; margin-top: 2px; }
.ent p { margin: 8px 0 0; color: var(--muted); font-size: 15.5px; }
.ent p em { color: var(--text); }
.cv aside .ent p { font-size: 15px; }
.contacts { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; font-size: 15px; }
.contacts a { color: var(--accent); }

/* ---------- accessibility panel ---------- */
.a11y-panel { position: fixed; z-index: 40; top: calc(env(safe-area-inset-top, 0px) + 70px); right: max(16px, calc((100vw - 1080px) / 2)); width: min(340px, calc(100vw - 32px)); max-height: calc(100vh - 100px); overflow: auto; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px 14px; box-shadow: 0 24px 48px -24px rgba(20, 8, 2, .55); }
.a11y-panel .t { font-family: var(--serif); font-size: 28px; line-height: 1.1; margin: 0 0 4px; }
.a11y-panel .d { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; padding: 12px 0; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.opt b { display: block; font-weight: 600; font-size: 15.5px; }
.opt small { display: block; color: var(--muted); font-size: 13px; line-height: 1.4; }
.sw { position: relative; flex: none; width: 42px; height: 24px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .2s; }
.opt[aria-pressed="true"] .sw { background: var(--accent); border-color: var(--accent); }
.opt[aria-pressed="true"] .sw::after { transform: translateX(18px); background: var(--accent-ink); }
.a11y-panel .reset { margin-top: 12px; }

/* modes */
html[data-text="large"] body { zoom: 1.22; }
html[data-font="readable"] { --serif: "Atkinson Hyperlegible", "Hanken Grotesk", system-ui, sans-serif; --sans: "Atkinson Hyperlegible", "Hanken Grotesk", system-ui, sans-serif; }
html[data-font="readable"] h1, html[data-font="readable"] h2, html[data-font="readable"] .page-head h1 { letter-spacing: 0; }
html[data-motion="reduced"] *, html[data-motion="reduced"] *::before, html[data-motion="reduced"] *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
html[data-contrast="high"] { --bg: #fffaf3; --surface: #ffffff; --surface-2: #efe3d3; --line: #3b2416; --text: #000000; --muted: #1f130b; --accent: #5a2a0c; --accent-ink: #ffffff; --bar: rgba(255, 250, 243, .97); }
@media (prefers-color-scheme: dark) {
  html[data-contrast="high"]:not([data-theme="light"]) { --bg: #000000; --surface: #0f0a07; --surface-2: #2a1d14; --line: #d3ac80; --text: #ffffff; --muted: #f4e9dc; --accent: #ffc480; --accent-ink: #000000; --bar: rgba(0, 0, 0, .97); }
}
html[data-contrast="high"][data-theme="dark"] { --bg: #000000; --surface: #0f0a07; --surface-2: #2a1d14; --line: #d3ac80; --text: #ffffff; --muted: #f4e9dc; --accent: #ffc480; --accent-ink: #000000; --bar: rgba(0, 0, 0, .97); }
html[data-contrast="high"] body::before { display: none; }
html[data-contrast="high"] main a:not(.btn):not(.profile):not(.cover-link) { text-decoration: underline; text-underline-offset: 3px; }
html[data-contrast="high"] :focus-visible { outline-width: 3px; }

/* ---------- custom right-click menu ---------- */
.cmenu { position: fixed; z-index: 60; min-width: 230px; padding: 6px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 24px 48px -20px rgba(20, 8, 2, .55); }
.cmenu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: 15px; text-align: left; cursor: pointer; }
.cmenu button:hover, .cmenu button:focus-visible { background: var(--surface-2); outline: none; }
.cmenu svg { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cmenu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 6px; }
.cmenu .hint { padding: 4px 12px 6px; color: var(--muted); font-size: 12.5px; }

/* credits dialog */
dialog.credits { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); padding: 28px 28px 22px; width: min(440px, calc(100vw - 32px)); }
dialog.credits::backdrop { background: rgba(18, 10, 7, .55); }
dialog.credits h2 { font-size: 34px; margin-bottom: 14px; }
dialog.credits dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 15px; }
dialog.credits dt { color: var(--muted); }
dialog.credits dd { margin: 0; }
dialog.credits .btn { margin-top: 22px; cursor: pointer; background: none; font: inherit; font-weight: 600; font-size: 15px; color: var(--text); }

/* ---------- deliberate mobile compositions ---------- */
.regime .m { display: none; }
@media (max-width: 720px) {
  /* hero: the name fills the screen edge to edge */
  .hero h1 { font-size: 25.5vw; line-height: .86; letter-spacing: -0.03em; }
  .hero p.lede { margin-top: 26px; }
  .regime { height: 54px; }
  .regime .d { display: none; }
  .regime .m { display: inline; }
  .regime path { stroke-width: 2.5; }

  /* about: portrait sits beside the opening line, the rest runs full width */
  .about { grid-template-columns: 112px 1fr; gap: 20px 18px; align-items: center; }
  .about .prose { display: contents; }
  .about .portrait { aspect-ratio: 4 / 5; }
  .about .portrait img { object-position: center 18%; }
  .about .prose p:first-child { font-size: 21px; margin: 0; }
  .about .prose p:not(:first-child) { grid-column: 1 / -1; margin: 0; }

  /* research: covers become wide bands with the emblem tucked top right */
  .cover { aspect-ratio: auto; min-height: 168px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: 1fr auto; gap: 12px 18px; }
  .cover > div { grid-column: 1; grid-row: 1; }
  .cover .crest, .cover .uni, .cover .motif { grid-column: 2; grid-row: 1; align-self: start; }
  .cover .motif { width: 92px; }
  .cover small { grid-column: 1 / -1; grid-row: 2; }

  /* AmC: the orbit is cropped into the corner behind the words */
  .amc { display: block; padding: 30px 24px 32px; }
  .amc > div { position: relative; z-index: 1; }
  .amc .orbit { position: absolute; z-index: 0; width: 300px; max-width: none; top: -70px; right: -110px; opacity: .32; transform: none; }
  .amc h2 { max-width: 8em; }

  /* photography: full-bleed tight grid */
  .gallery { columns: 2; column-gap: 6px; margin-inline: -20px; }
  .shot { margin-bottom: 6px; border-radius: 0; }

  /* cv: single column */
  .cv { grid-template-columns: 1fr; }
  .ent-h { flex-direction: column; gap: 2px; }

  .foot-r { gap: 12px; }
}

/* ---------- print: the CV becomes a clean two-page document ---------- */
@media print {
  @page { size: A4; margin: 14mm 14mm 12mm; }
  html:root, html:root:not([data-theme="light"]), html:root[data-theme="dark"], html:root[data-contrast="high"] {
    --bg: #ffffff; --surface: #ffffff; --surface-2: #f3ece3; --line: #d9c9b5; --text: #1a1009; --muted: #4a3a2e; --accent: #7a4524; --accent-ink: #ffffff;
  }
  html[data-text="large"] body { zoom: 1; }
  body { background: #fff; font-size: 10pt; line-height: 1.45; }
  body::before, .bar, .skip, footer, .cv-tools, .a11y-panel, .cmenu, dialog { display: none !important; }
  .page-head { padding: 0 0 10pt; }
  .page-head h1 { font-size: 30pt; }
  .page-head p { font-size: 10.5pt; margin-top: 6pt; }
  .page-body { padding: 0; }
  .wrap { width: 100%; }
  .cv { grid-template-columns: minmax(0, 1fr) 58mm; gap: 9mm; }
  .cv h2 { font-size: 15pt; }
  .cv-block { margin-bottom: 12pt; }
  .ent { padding: 5pt 0; break-inside: avoid; }
  .ent-h time { font-size: 9pt; }
  .ent .org { font-size: 9.5pt; }
  .ent p { font-size: 9.5pt; margin-top: 3pt; }
  .contacts { font-size: 9.5pt; }
  a { color: inherit !important; text-decoration: none !important; }
}

/* =========================================================
   Round 3: skills, beyond, research page, simulator, palette
   ========================================================= */
.hero h1 .soft { position: relative; }
.hero h1 .soft::after { content: attr(data-alt); position: absolute; left: 100%; bottom: 18%; margin-left: 18px; white-space: nowrap; font-family: var(--sans); font-style: normal; font-size: 14px; letter-spacing: 0; color: var(--muted); opacity: 0; transform: translateX(-6px); transition: opacity .3s, transform .3s; pointer-events: none; }
.hero h1 .soft:hover::after { opacity: 1; transform: none; }
.section-link { margin-top: 32px; }

/* skills */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.skills { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.skills li[hidden] { display: none; }
.skill { font: inherit; font-size: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; cursor: pointer; transition: border-color .2s, transform .2s; }
.skill:hover, .skill:focus-visible, .skill.on { border-color: var(--accent); transform: translateY(-2px); }
.skill .g { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.used { min-height: 1.65em; margin: 22px 0 0; color: var(--muted); font-size: 16px; }
.used b { color: var(--text); font-weight: 600; }

/* beyond the work */
.beyond { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 16px; }
.b-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.b-card h3 { font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.05; margin: 0 0 10px; }
.b-card p { margin: 0; color: var(--muted); font-size: 15.5px; }
.b-card a { color: var(--accent); }
.b-card.wide { grid-column: span 2; }
.braille { display: flex; gap: 14px; margin: 6px 0 18px; cursor: default; }
.braille .cell { display: grid; justify-items: center; gap: 8px; }
.braille svg { width: 34px; height: 50px; }
.braille .dot { fill: var(--line); opacity: .45; transition: fill .25s, opacity .25s; }
.braille .dot.up { fill: var(--accent); opacity: 1; }
.braille .lt { font-family: var(--serif); font-size: 22px; line-height: 1; opacity: 0; transform: translateY(-4px); transition: opacity .3s, transform .3s; }
.braille:hover .lt, .braille:focus-within .lt, .braille.read .lt { opacity: 1; transform: none; }
.braille .cell:nth-child(2) .lt { transition-delay: .05s; } .braille .cell:nth-child(3) .lt { transition-delay: .1s; }
.braille .cell:nth-child(4) .lt { transition-delay: .15s; } .braille .cell:nth-child(5) .lt { transition-delay: .2s; }

/* research page */
.feature { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: clamp(28px, 5vw, 56px); align-items: start; }
.feature h2 { margin-bottom: 8px; }
.feature .meta { color: var(--accent); font-size: 15px; margin: 0 0 18px; }
.feature p.body { color: var(--muted); margin: 0 0 12px; max-width: 40em; }
.feature p.body b { color: var(--text); font-weight: 600; }
.r-block { padding: clamp(48px, 7vw, 88px) 0; border-top: 1px solid var(--line); }
.r-block:first-child { border-top: 0; padding-top: 0; }

/* simulator */
.sim { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: clamp(20px, 3vw, 32px); }
.sim-plot { width: 100%; height: 280px; display: block; color: var(--accent); }
.sim-plot .band { fill: var(--accent); opacity: .14; }
.sim-plot .line { fill: none; stroke: currentColor; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.sim-plot .axis { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.legend { display: flex; flex-wrap: wrap; gap: 18px; margin: 14px 0 22px; font-size: 14px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 14px; height: 10px; margin-right: 8px; vertical-align: middle; border-radius: 2px; }
.legend .lc::before { height: 2px; background: var(--accent); }
.legend .lv::before { background: var(--accent); opacity: .25; }
.controls { display: grid; grid-template-columns: 1fr 1fr auto; gap: 18px 28px; align-items: end; }
.controls label, .controls .ctl { display: grid; gap: 6px; font-size: 15px; }
.controls label b { font-weight: 600; }
.controls output { color: var(--muted); font-size: 14px; }
.controls input[type="range"] { width: 100%; height: 36px; accent-color: var(--accent); touch-action: pan-y; }
.sim-summary { margin: 22px 0 0; color: var(--text); font-size: 16px; }
.sim-note { margin: 10px 0 0; color: var(--muted); font-size: 14px; }

/* tool card */
.tool { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 26px; }
.tool svg { width: 44px; height: 44px; color: var(--accent); fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool h3 { font-family: var(--serif); font-weight: 400; font-size: 30px; margin: 0 0 8px; }
.tool p { margin: 0 0 14px; color: var(--muted); }

/* command palette */
dialog.palette { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); padding: 0; width: min(560px, calc(100vw - 32px)); margin-top: 14vh; }
dialog.palette::backdrop { background: rgba(18, 10, 7, .5); }
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text); font: inherit; font-size: 18px; padding: 18px 20px; outline: none; }
.palette ul { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow: auto; }
.palette li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.palette li small { color: var(--muted); }
.palette li[aria-selected="true"] { background: var(--surface-2); }
.palette .none { color: var(--muted); padding: 14px 12px; }
kbd { font-family: var(--sans); font-size: 12px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--muted); }

@media (max-width: 720px) {
  .hero h1 .soft::after { display: none; }
  .b-card.wide { grid-column: auto; }
  .feature { grid-template-columns: 1fr; }
  .feature .cover { max-width: none; }
  .controls { grid-template-columns: 1fr; }
  .sim-plot { height: 200px; }
  .sim { margin-inline: -8px; }
  .tool { grid-template-columns: 1fr; }
}
@media print { .palette { display: none !important; } }
button.btn { font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; background: none; color: var(--text); }
button.btn.solid { background: var(--accent); color: var(--accent-ink); }
.actions .status { color: var(--accent); font-weight: 600; font-size: 14px; text-decoration: none; }
@media (pointer: coarse) { .palette-open kbd { display: none; } }

/* ---------- hero background equations ---------- */
.hero .wrap { position: relative; }
.hero h1, .hero p.lede, .hero .row, .hero .regime { position: relative; z-index: 1; }
.eqs { position: absolute; inset: -40px -20px 0; z-index: 0; pointer-events: none; color: var(--muted); transform: translate(var(--ex, 0px), var(--ey, 0px)); transition: transform 1.2s cubic-bezier(.2,.7,.2,1); }
.eq { position: absolute; white-space: nowrap; opacity: .2; }
.eq .katex { font-size: 1em; }
.k1 { top: 2%;  left: 52%; font-size: 23px; transform: rotate(-3deg); }
.k2 { top: 21%; left: 66%; font-size: 21px; transform: rotate(2deg); }
.k3 { top: 39%; left: 72%; font-size: 20px; transform: rotate(-1.5deg); }
.k4 { top: 9%;  left: 1%;  font-size: 17px; transform: rotate(1.5deg); }
.k5 { top: 57%; left: 67%; font-size: 19px; transform: rotate(-2deg); }
.k6 { top: 74%; left: 79%; font-size: 17px; transform: rotate(1deg); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .eq { opacity: .24; } }
:root[data-theme="dark"] .eq { opacity: .24; }
@media (prefers-reduced-motion: no-preference) {
  .eq { animation: eqin 1.8s cubic-bezier(.2,.7,.2,1) both; }
  .k1 { animation-delay: .7s; } .k2 { animation-delay: .85s; } .k3 { animation-delay: 1s; }
  .k4 { animation-delay: 1.15s; } .k5 { animation-delay: 1.3s; } .k6 { animation-delay: 1.45s; }
  @keyframes eqin { from { opacity: 0; filter: blur(4px); } }
}
html[data-contrast="high"] .eqs { display: none; }
@media (max-width: 1000px) { .k3, .k6 { display: none; } .k2 { left: 58%; } .k5 { left: 52%; } }
@media (max-width: 720px) {
  .eqs { inset: -20px -20px 0; }
  .k5 { display: none; }
  .k1 { top: 1%;  left: 38%; font-size: 15px; }
  .k2 { top: 24%; left: 46%; font-size: 14px; }
  .k4 { top: 13%; left: 54%; font-size: 13px; }
}

/* =========================================================
   Round 4: tactile buttons, drawn underlines, back to top,
   loading and error states, findings, 404, fixes
   ========================================================= */
html { scrollbar-gutter: stable; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.no-katex .eqs { display: none; }

/* buttons press in slightly */
.btn, .chip, .tbtn, .vbtn, .cmenu button, .palette-open, .credits-open { transition: transform .14s cubic-bezier(.2,.7,.2,1), background-color .2s, border-color .2s, color .2s, filter .2s; }
.btn:active, .chip:active, .tbtn:active, .vclose:active, .cmenu button:active, .skill:active { transform: translateY(1px) scale(.96); }
.profile { transition: border-color .2s, transform .14s cubic-bezier(.2,.7,.2,1); }
.profile:active { transform: translateY(1px) scale(.985); }
.opt:active .sw { transform: scale(.92); }
.cover-link:active .cover { transform: translateY(-1px) scale(.985); }

/* links: a faint resting line, and a solid one that draws in on hover or focus */
main p a:not(.btn):not(.status), .contacts a, .b-card a, .certs a, .ent .org a, .linkish, a.status[href], .suggest a {
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor), linear-gradient(var(--line), var(--line));
  background-size: 0% 1.5px, 100% 1px; background-position: 0 100%, 0 100%; background-repeat: no-repeat;
  padding-bottom: 2px;
  transition: background-size .38s cubic-bezier(.2,.7,.2,1), color .2s;
}
main p a:not(.btn):not(.status):hover, .contacts a:hover, .b-card a:hover, .certs a:hover, .ent .org a:hover, .linkish:hover, a.status[href]:hover, .suggest a:hover,
main p a:not(.btn):not(.status):focus-visible, .contacts a:focus-visible, .b-card a:focus-visible, .certs a:focus-visible, .ent .org a:focus-visible, .linkish:focus-visible, a.status[href]:focus-visible, .suggest a:focus-visible {
  background-size: 100% 1.5px, 100% 1px; text-decoration: none;
}
a.status[href] { background-size: 0% 1.5px, 0% 1px; }
a.status[href]:hover, a.status[href]:focus-visible { background-size: 100% 1.5px, 0% 1px; }
html[data-contrast="high"] :is(main p a, .contacts a, .b-card a, .certs a, .ent .org a, .linkish, a.status[href]) { background-image: none; text-decoration: underline; }

/* back to top: the arrow swings round into place as it appears */
.to-top { position: fixed; z-index: 25; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); width: 46px; height: 46px; display: grid; place-items: center; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; box-shadow: 0 10px 24px -14px rgba(20, 8, 2, .6);
  opacity: 0; visibility: hidden; transform: translateY(14px); transition: opacity .3s, transform .3s cubic-bezier(.2,.7,.2,1), visibility 0s .3s, border-color .2s; }
.to-top.show { opacity: 1; visibility: visible; transform: none; transition: opacity .3s, transform .3s cubic-bezier(.2,.7,.2,1), visibility 0s, border-color .2s; }
.to-top svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transform: rotate(180deg); transition: transform .6s cubic-bezier(.34,1.45,.55,1) .08s; }
.to-top.show svg { transform: rotate(0deg); }
.to-top:hover { border-color: var(--accent); color: var(--accent); }
.to-top:hover svg { transform: translateY(-2px); transition-delay: 0s; }
.to-top.show:active { transform: translateY(1px) scale(.94); }
@media print { .to-top { display: none !important; } }

/* gallery loading and error states */
.shot.sk { aspect-ratio: 4 / 5; background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface) 50%, var(--surface-2) 70%); background-size: 300% 100%; animation: shimmer 1.4s linear infinite; }
.shot.sk:nth-child(3n+2) { aspect-ratio: 1 / 1; } .shot.sk:nth-child(3n) { aspect-ratio: 4 / 3; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.shot .broken { aspect-ratio: 4 / 3; display: grid; place-items: center; padding: 16px; text-align: center; color: var(--muted); font-size: 14px; background: var(--surface-2); }
.gallery-error { padding: 32px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); max-width: 38em; }
.gallery-error p { margin: 0 0 16px; color: var(--muted); }
.gallery-error b { display: block; font-family: var(--serif); font-weight: 400; font-size: 28px; color: var(--text); margin-bottom: 8px; }

/* research findings */
.findings { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 28px 24px; }
.fd { border-top: 2px solid var(--accent); padding-top: 16px; }
.fd b { display: block; font-family: var(--serif); font-weight: 400; font-size: clamp(42px, 5vw, 58px); line-height: 1; color: var(--text); }
.fd p { margin: 12px 0 0; color: var(--muted); font-size: 15px; }
.policy { margin: 34px 0 0; max-width: 44em; font-family: var(--serif); font-size: clamp(21px, 2.4vw, 27px); line-height: 1.3; }

/* 404 */
.nf .code { margin: 0; font-family: var(--serif); font-style: italic; font-size: clamp(120px, 24vw, 280px); line-height: .82; color: var(--accent); letter-spacing: -0.03em; }
.nf h1 { margin-top: 18px; }
.nf .regime path.ghost { stroke-dasharray: 6 7; opacity: .55; }
.nf .row { margin-top: 34px; }

@media (max-width: 720px) {
  .certs.edu li { grid-template-columns: 1fr; gap: 4px; }
  .certs.edu time { grid-column: 1; }
  .to-top { width: 42px; height: 42px; }
}
.nf-path { font-family: var(--sans); font-size: .92em; background: var(--surface-2); padding: 1px 7px; border-radius: 5px; }
main:focus { outline: none; }

/* =========================================================
   Photography page: darkroom, film edges, camcorder OSD,
   viewfinder hero, autofocus contact card
   ========================================================= */
:root { --osd: "VT323", "Courier New", ui-monospace, monospace; --stamp: #ff9d3d; }
html[data-font="readable"] { --osd: "Atkinson Hyperlegible", system-ui, sans-serif; }

/* the lights go down: brown fades to near-black */
html.darkroom:not([data-contrast="high"]) { --bg: #0b0908; --surface: #151110; --surface-2: #221b17; --line: #3a2f28; --text: #efe7db; --muted: #a99b8c; --accent: #e3a463; --accent-ink: #0b0908; --bar: rgba(11, 9, 8, .9); }
.photo-page, .photo-page .bar, .photo-page footer, .photo-page .exif, .photo-page .gallery-error, .photo-page .empty {
  transition: background-color 2.8s ease, color 2.8s ease, border-color 2.8s ease;
}
.photo-page .btn { transition: transform .14s cubic-bezier(.2,.7,.2,1), background-color 2.8s ease, color 2.8s ease, border-color 2.8s ease; }
.photo-page::before { transition: opacity 2.8s ease; }
html.darkroom .photo-page::before { opacity: .12; }
html.darkroom.quick .photo-page, html.darkroom.quick .photo-page .bar, html.darkroom.quick .photo-page footer, html.darkroom.quick .photo-page .btn { transition-duration: .6s; }

/* film edges with sprocket holes */
.film { position: fixed; top: 0; bottom: 0; z-index: 20; width: 34px; pointer-events: none; background-color: #060504;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='28' viewBox='0 0 34 28'%3E%3Crect x='11' y='6' width='12' height='16' rx='2.6' fill='%23e8dcc8'/%3E%3C/svg%3E");
  background-size: 34px 28px; background-repeat: repeat-y; opacity: 0; transition: opacity 2.8s ease 0.4s; }
.film-l { left: 0; } .film-r { right: 0; }
html.darkroom .film { opacity: .92; }
.film .edge { position: absolute; right: 1px; top: 22vh; writing-mode: vertical-rl; font-family: var(--osd); font-size: 11px; letter-spacing: .12em; color: var(--stamp); opacity: .85; white-space: nowrap; }
.film-l .edge { right: auto; left: 1px; top: 58vh; transform: rotate(180deg); }
.photo-page .wrap { width: min(1080px, 100% - 120px); }

/* camcorder on-screen display */
.osd { font-family: var(--osd); letter-spacing: .06em; color: #f4efe6; text-shadow: 0 0 6px rgba(255, 255, 255, .35); }
.osd-rec { display: inline-flex; align-items: center; gap: 10px; font-size: 22px; margin: 0 0 14px; color: var(--text); text-shadow: none; }
html.darkroom .osd-rec { color: #f4efe6; text-shadow: 0 0 6px rgba(255, 255, 255, .35); }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #e0332b; box-shadow: 0 0 10px rgba(224, 51, 43, .8); }
@media (prefers-reduced-motion: no-preference) { .rec-dot { animation: blink 1.1s steps(2, start) infinite; } }
@keyframes blink { to { visibility: hidden; } }
.photo-page .page-head h1 { font-family: var(--osd); font-weight: 400; text-transform: uppercase; letter-spacing: .02em; font-size: clamp(64px, 11vw, 132px); line-height: .82; }
html.darkroom .photo-page .page-head h1 { text-shadow: 0 0 18px rgba(255, 240, 220, .18); }

/* viewfinder hero */
.vf-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: clamp(28px, 5vw, 64px); align-items: center; }
.viewfinder { position: relative; margin: 0; aspect-ratio: 4 / 5; overflow: hidden; border-radius: 4px; background: #000; }
.viewfinder img { width: 100%; height: 100%; object-fit: cover; object-position: center 30%; filter: contrast(1.04) saturate(.92); }
.viewfinder::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(to bottom, rgba(0,0,0,.08) 0 1px, transparent 1px 3px); pointer-events: none; }
.vf-ui { position: absolute; inset: 14px; pointer-events: none; z-index: 1; }
.vf-ui .c { position: absolute; width: 26px; height: 26px; border: 2px solid rgba(255, 255, 255, .85); }
.vf-ui .tl { top: 0; left: 0; border-right: 0; border-bottom: 0; } .vf-ui .tr { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.vf-ui .bl { bottom: 0; left: 0; border-right: 0; border-top: 0; } .vf-ui .br { bottom: 0; right: 0; border-left: 0; border-top: 0; }
.vf-ui .osd { position: absolute; font-size: 20px; line-height: 1; }
.vf-ui .o-tl { top: 34px; left: 6px; } .vf-ui .o-tr { top: 34px; right: 6px; } .vf-ui .o-bl { bottom: 34px; left: 6px; }
.vf-ui .o-br { bottom: 34px; right: 6px; color: var(--stamp); text-shadow: 0 0 6px rgba(255, 157, 61, .6); }
.vf-ui .batt { display: inline-block; width: 22px; height: 11px; border: 2px solid currentColor; position: relative; vertical-align: -1px; margin-left: 6px; }
.vf-ui .batt::before { content: ""; position: absolute; inset: 1px 5px 1px 1px; background: currentColor; }
.vf-ui .batt::after { content: ""; position: absolute; right: -5px; top: 2px; width: 3px; height: 3px; background: currentColor; }
.ig svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* camcorder footer clock */
.photo-page .clockline .clock { display: none; }
.photo-page .clockline { font-family: var(--osd); font-size: 19px; letter-spacing: .06em; }
html.darkroom .photo-page .clockline { color: #f4efe6; text-shadow: 0 0 6px rgba(255, 255, 255, .3); }
.photo-page .clockline .osd-date { color: var(--stamp); margin-right: 8px; }

/* autofocus contact card */
.af-sec { padding: clamp(40px, 7vw, 96px) 0 clamp(64px, 9vw, 120px); }
.af-sec h2 { font-family: var(--osd); text-transform: uppercase; font-size: clamp(40px, 6vw, 64px); margin-bottom: 22px; }
.af { position: relative; max-width: 640px; padding: 34px 34px 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; outline: none; cursor: crosshair; }
.af:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.af .b { position: absolute; width: 22px; height: 22px; border: 2px solid var(--muted); transition: border-color .25s, transform .35s cubic-bezier(.2,.7,.2,1); }
.af .b1 { top: 10px; left: 10px; border-right: 0; border-bottom: 0; } .af .b2 { top: 10px; right: 10px; border-left: 0; border-bottom: 0; }
.af .b3 { bottom: 10px; left: 10px; border-right: 0; border-top: 0; } .af .b4 { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }
.af .pt { position: absolute; left: 50%; top: 50%; width: 46px; height: 32px; margin: -16px 0 0 -23px; border: 1.5px solid var(--muted); opacity: .35; transition: border-color .25s, opacity .25s; }
.af-file { font-family: var(--osd); font-size: 22px; letter-spacing: .08em; color: var(--accent); margin: 0 0 14px; }
.exif { display: grid; grid-template-columns: max-content 1fr; gap: 9px 26px; margin: 0; font-family: var(--osd); font-size: 21px; line-height: 1.15; letter-spacing: .04em; }
.exif dt { color: var(--muted); text-transform: uppercase; }
.exif dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.exif a { color: var(--text); text-decoration: none; background-image: linear-gradient(var(--accent), var(--accent)); background-size: 0% 1.5px; background-position: 0 100%; background-repeat: no-repeat; transition: background-size .35s; }
.exif a:hover, .exif a:focus-visible { background-size: 100% 1.5px; color: var(--accent); }
.af-status { display: flex; gap: 10px; align-items: center; margin: 20px 0 0; font-family: var(--osd); font-size: 18px; letter-spacing: .1em; color: var(--muted); }
.af-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); transition: background-color .2s, box-shadow .2s; }
.af.locked .b, .af.locked .pt { border-color: #5fd36a; }
.af.locked .pt { opacity: .9; }
.af.locked .af-dot { background: #5fd36a; box-shadow: 0 0 10px rgba(95, 211, 106, .7); }
.af.locked .af-status { color: #8fe39a; }
.af.hunting .exif, .af.hunting .af-file { animation: hunt 1.05s ease-out both; }
.af.hunting .b1 { animation: bTL 1.05s ease-out both; } .af.hunting .b2 { animation: bTR 1.05s ease-out both; }
.af.hunting .b3 { animation: bBL 1.05s ease-out both; } .af.hunting .b4 { animation: bBR 1.05s ease-out both; }
@keyframes hunt { 0% { filter: blur(3.5px); } 30% { filter: blur(.4px); } 50% { filter: blur(2px); } 72% { filter: blur(.2px); } 84% { filter: blur(.9px); } 100% { filter: blur(0); } }
@keyframes bTL { 0% { transform: translate(-10px, -10px); } 50% { transform: translate(5px, 5px); } 100% { transform: none; } }
@keyframes bTR { 0% { transform: translate(10px, -10px); } 50% { transform: translate(-5px, 5px); } 100% { transform: none; } }
@keyframes bBL { 0% { transform: translate(-10px, 10px); } 50% { transform: translate(5px, -5px); } 100% { transform: none; } }
@keyframes bBR { 0% { transform: translate(10px, 10px); } 50% { transform: translate(-5px, -5px); } 100% { transform: none; } }
html[data-motion="reduced"] .af.hunting .exif, html[data-motion="reduced"] .af.hunting .af-file { filter: none !important; }

@media (max-width: 720px) {
  .film { width: 10px; background-size: 10px 14.8px; }
  .film .edge { display: none; }
  .photo-page .wrap { width: calc(100% - 32px); }
  .photo-page .gallery { margin-inline: 0; }
  .photo-page .page-head h1 { font-size: clamp(36px, 9vw, 64px); }
  .photo-page .clockline { flex-wrap: wrap; }
  .vf-grid { grid-template-columns: 1fr; }
  .viewfinder { aspect-ratio: 4 / 4.4; }
  .vf-ui .osd { font-size: 17px; }
  .af { padding: 30px 22px 24px; }
  .exif { grid-template-columns: 1fr; gap: 2px; font-size: 20px; }
  .exif dt { font-size: 15px; margin-top: 10px; }
  .exif dt:first-child { margin-top: 0; }
}
@media print { .film { display: none !important; } }
.vf-ui .osd { text-shadow: 0 0 2px rgba(0, 0, 0, .85), 0 1px 3px rgba(0, 0, 0, .6); }
.vf-ui .c { filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, .7)); }
.af .pt { left: auto; right: 64px; margin: -16px 0 0; }
@media (max-width: 720px) { .af .pt { display: none; } }

/* UCD crest: sized by height (it is tall), with room above and below */
.cover .uni { width: auto; height: 34px; margin: 4px 0; align-self: flex-start; }
@media (max-width: 720px) { .cover .uni { height: 40px; margin: 0; } }

/* SHRED maths: colour families, cards, tappable terms, sliders */
:root {
  --c-shrink: #a14a22;
  --c-tails: #96650f;
  --c-lag: #566a2a;
  --c-regime: #365c70;
  --c-cov: #80416a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c-shrink: #e48b5e;
    --c-tails: #dba843;
    --c-lag: #a3b960;
    --c-regime: #82b4cd;
    --c-cov: #cf90b3;
  }
}
:root[data-theme="dark"] {
  --c-shrink: #e48b5e;
  --c-tails: #dba843;
  --c-lag: #a3b960;
  --c-regime: #82b4cd;
  --c-cov: #cf90b3;
}
[data-k="shrink"] { --tc: var(--c-shrink); }
[data-k="tails"] { --tc: var(--c-tails); }
[data-k="lag"] { --tc: var(--c-lag); }
[data-k="regime"] { --tc: var(--c-regime); }
[data-k="cov"] { --tc: var(--c-cov); }

.m-legend { display: flex; flex-wrap: wrap; gap: 10px 22px; list-style: none; margin: -14px 0 8px; padding: 0; font-size: 14px; color: var(--muted); }
.m-legend li { display: inline-flex; align-items: center; gap: 8px; }
.m-legend i { width: 20px; height: 4px; border-radius: 2px; background: var(--tc); }
.grp { display: flex; align-items: center; gap: 16px; margin: 44px 0 18px; font-family: var(--serif); font-weight: 400; font-size: clamp(26px, 3.4vw, 34px); line-height: 1.1; }
.grp::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.math-grid { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); align-items: start; }
.math-card { position: relative; min-width: 0; padding: 24px 22px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.math-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--tc, var(--accent)); opacity: .9; }
.mc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.math-card h4 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 28px; line-height: 1.12; }
.gk { font-family: var(--serif); font-style: italic; font-size: 1.08em; }
.mc-head .chip { flex: none; white-space: nowrap; }
.math-card .msub { margin: 6px 0 16px; color: var(--muted); font-size: 15px; line-height: 1.5; }

/* the equation sits on its own panel */
.mathlines { margin: 0 0 14px; padding: 8px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.mathline { overflow-x: auto; overflow-y: hidden; padding: 8px 4px; margin: 0 -4px; font-size: 1.2em; scrollbar-width: none; }
.mathline::-webkit-scrollbar { display: none; }
.mathline .katex { white-space: nowrap; }
.mathline [data-t] {
  --u: var(--tc, var(--muted));
  cursor: pointer; border-radius: 5px; padding: 0 1px .08em;
  box-shadow: inset 0 -2px 0 var(--u);
  -webkit-tap-highlight-color: transparent;
  transition: background-color .18s, color .18s;
}
.mathline [data-t][data-k="plain"] { --u: var(--muted); box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--muted) 55%, transparent); }
.mathline [data-t]:hover { background-color: color-mix(in srgb, var(--u) 14%, transparent); }
.mathline [data-t].on { background-color: color-mix(in srgb, var(--u) 24%, transparent); }

/* chips: the accessible, big-target way to pick a symbol */
.mchips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.mchip {
  display: inline-flex; align-items: center; gap: 9px; min-height: 40px; padding: 6px 14px;
  font: inherit; font-size: 15px; line-height: 1; color: var(--text);
  background: none; border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: border-color .18s, background-color .18s, transform .14s cubic-bezier(.2,.7,.2,1);
}
.mchip::before { content: ""; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--tc, var(--muted)); }
.mchip .katex { font-size: 1em; }
.mchip:hover { border-color: var(--tc, var(--accent)); }
.mchip:active { transform: scale(.96); }
.mchip[aria-pressed="true"] { border-color: var(--tc, var(--accent)); background: color-mix(in srgb, var(--tc, var(--accent)) 16%, transparent); }
@media (pointer: coarse) { .mchip { min-height: 46px; padding: 8px 16px; } }

/* explanation: every variant is laid out on top of the others so the card never changes height */
.math-say { display: grid; margin: 0; padding: 2px 0 2px 14px; border-left: 4px solid var(--tc, var(--line)); transition: border-color .25s; }
.math-say .v { grid-area: 1 / 1; opacity: 0; visibility: hidden; transform: translateY(5px); transition: opacity .22s, transform .22s, visibility 0s .22s; }
.math-say .v.on { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.vk { display: flex; align-items: center; gap: 8px; margin: 0 0 3px; font-size: 12.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.vk::before { content: ""; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--tc, var(--muted)); }
.vt { margin: 0; font-size: 16px; line-height: 1.55; color: var(--text); }

/* try-it panels */
.try { margin-top: 20px; padding-top: 18px; border-top: 1px dashed var(--line); }
.try-h { margin: 0 0 12px; font-size: 12.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.try-note { margin: 12px 0 0; font-size: 15px; line-height: 1.5; color: var(--muted); }
.try-note b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.try .btn { margin-top: 14px; }
.viz { display: block; width: 100%; height: auto; }
.viz .ax { stroke: var(--line); stroke-width: 1; }
.viz .tk { stroke: var(--muted); stroke-width: 1; }
.viz .g { fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-dasharray: 4 4; }
.viz .t { fill: none; stroke: var(--c-tails); stroke-width: 2.6; stroke-linejoin: round; }
.viz .tf { fill: var(--c-tails); opacity: .75; }
.viz .gd { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.viz text { fill: var(--muted); font: 12px var(--sans); }
.vkey { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 8px 0 0; font-size: 13.5px; color: var(--muted); }
.vkey span { display: inline-flex; align-items: center; gap: 8px; }
.vkey i { width: 22px; height: 0; border-top: 2.6px solid var(--c-tails); }
.vkey i.dash { border-top: 1.6px dashed var(--muted); }

.rng { display: grid; gap: 0; margin-top: 10px; font-size: 15px; }
.rng > span { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.rng b { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
input.sl {
  -webkit-appearance: auto; appearance: auto; width: 100%; height: 44px; margin: 0; padding: 0;
  accent-color: var(--accent); cursor: pointer; touch-action: pan-y;
}
input.sl:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.lbars { display: grid; gap: 7px; }
.lbar { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.lbar .tr { height: 14px; border-radius: 7px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.lbar .tr i { display: block; height: 100%; width: var(--w, 0%); border-radius: 7px; background: var(--c-lag); transition: width .25s ease; }
.lbar b { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); text-align: right; }

.tm { display: grid; grid-template-columns: auto 1fr 1fr; gap: 6px; font-size: 14px; }
.tm .h { align-self: center; padding: 2px 6px; color: var(--muted); text-align: center; }
.tm .c { position: relative; display: grid; place-items: center; min-height: 54px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tm .c::before { content: ""; position: absolute; inset: 0; background: var(--c-regime); opacity: var(--a, .1); transition: opacity .25s; }
.tm .c span { position: relative; }

.gauge { position: relative; height: 12px; margin: 52px 8px 10px; border-radius: 6px; background: linear-gradient(to right, var(--c-regime), var(--surface-2)); box-shadow: inset 0 0 0 1px var(--line); }
.gauge .pin { position: absolute; top: -8px; left: var(--x); width: 3px; height: 28px; margin-left: -1.5px; border-radius: 2px; background: var(--text); }
.gauge .pin span { position: absolute; bottom: 32px; left: 50%; transform: translateX(-50%); white-space: nowrap; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; font-style: normal; font-weight: 600; color: var(--text); }
.gscale { display: flex; justify-content: space-between; margin: 0 8px; font-size: 13px; color: var(--muted); }

/* entrance: only armed from script, so the cards are always visible without it */
.math-grid.rv .math-card { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s cubic-bezier(.2,.7,.2,1); transition-delay: calc(var(--n, 0) * 90ms); }
.math-grid.rv .math-card.in { opacity: 1; transform: none; }
@keyframes termhint { 0%, 100% { background-color: transparent; } 35% { background-color: color-mix(in srgb, var(--u) 26%, transparent); } }
.math-grid.rv .math-card.in:not(.touched) .mathline [data-t] { animation: termhint 1.6s ease backwards; animation-delay: calc(.7s + var(--i, 0) * 140ms); }

html[data-motion="reduced"] .math-card *, html[data-motion="reduced"] .math-card { transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) { .math-card *, .math-card { transition: none !important; animation: none !important; } }
@media (max-width: 520px) {
  .math-card { padding: 22px 16px 18px; }
  .mathline { font-size: 1.05em; }
  .math-card h4 { font-size: 25px; }
}

/* easier taps on inline links for touch screens, without moving any text */
@media (pointer: coarse) { main li a:not(.btn), main p a:not(.btn) { padding-block: .3em; } }
