:root {
  --paper: #fbfcfd;
  --ink: #1b1f24;
  --ink-soft: #545b65;
  --rule: #d9dee5;
  --panel: #f1f4f8;
  --link: #2450b3;
  --link-visited: #6a3fb0;
  --detractor: #c4402f;
  --passive: #b88a12;
  --promoter: #2f8a55;
  --f-display: "Libre Caslon Text", "Iowan Old Style", Georgia, serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #13161b; --ink: #e6e9ee; --ink-soft: #9aa3ae; --rule: #2c323b;
    --panel: #1b2027; --link: #8aaefc; --link-visited: #b99af0;
    --detractor: #ec7a69; --passive: #e2b947; --promoter: #6cc792;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #13161b; --ink: #e6e9ee; --ink-soft: #9aa3ae; --rule: #2c323b;
  --panel: #1b2027; --link: #8aaefc; --link-visited: #b99af0;
  --detractor: #ec7a69; --passive: #e2b947; --promoter: #6cc792;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  background: var(--paper); color: var(--ink);
  font: 400 16px/1.65 var(--f-body);
  padding-inline: 16px; padding-block: 0 64px;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 2px; }

/* Masthead */
.masthead {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-block: 18px; border-bottom: 1px solid var(--rule);
}
.wordmark { font: 700 1.15rem/1 var(--f-display); color: var(--ink); letter-spacing: .01em; }
.wordmark span { font-family: var(--f-mono); font-weight: 400; font-size: .72rem; color: var(--ink-soft); margin-left: 8px; letter-spacing: .06em; text-transform: uppercase; }
.masthead nav { display: flex; gap: 18px; flex-wrap: wrap; font-size: .9rem; }

/* Shell */
.shell {
  max-width: 1180px; margin: 0 auto;
  display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 48px;
  padding-top: 28px;
}
.toc { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 20px); align-self: start; font-size: .88rem; }
.toc h2 { font: 500 .7rem/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 12px; }
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; counter-reset: toc; }
.toc li { counter-increment: toc; display: flex; gap: 8px; }
.toc li::before { content: counter(toc); font-family: var(--f-mono); font-size: .75rem; color: var(--ink-soft); min-width: 1.2em; padding-top: 2px; }
.toc a { color: var(--ink); }
.toc a.active { color: var(--link); font-weight: 500; }

/* Article header */
.title-row { border-bottom: 1px solid var(--rule); }
h1 {
  font: 400 clamp(2rem, 4.5vw, 2.9rem)/1.1 var(--f-display);
  margin: 0 0 14px; text-wrap: balance;
}
.tabs { display: flex; gap: 2px; margin-bottom: -1px; }
.tab {
  font: 500 .85rem/1 var(--f-body); color: var(--ink-soft);
  background: none; border: 1px solid transparent; border-bottom: none;
  padding: 10px 14px; cursor: pointer; border-radius: 4px 4px 0 0;
}
.tab[aria-selected="true"] { color: var(--ink); background: var(--paper); border-color: var(--rule); }
.tab:hover { color: var(--ink); }
.meta-line { font: .8rem/1.5 var(--f-mono); color: var(--ink-soft); margin: 14px 0 22px; }

/* Article body */
.article { min-width: 0; }
.article p { max-width: 68ch; margin: 0 0 1.05em; }
.article h2 {
  font: 400 1.6rem/1.2 var(--f-display); margin: 2.2em 0 .7em;
  padding-bottom: 6px; border-bottom: 1px solid var(--rule); text-wrap: balance;
  scroll-margin-top: 20px;
}
.article h3 { font: 600 1.02rem/1.3 var(--f-body); margin: 1.8em 0 .5em; }
.article h3 .yrs { font: 400 .78rem var(--f-mono); color: var(--ink-soft); margin-left: 8px; letter-spacing: .02em; }
sup.cite { font: 500 .68rem var(--f-mono); margin-left: 1px; }
.lead { font-size: 1.06rem; }

/* Infobox */
.infobox {
  float: right; width: 300px; margin: 0 0 24px 32px;
  border: 1px solid var(--rule); background: var(--panel); font-size: .86rem;
}
.infobox .ib-name { font: 700 1.05rem/1.3 var(--f-display); text-align: center; padding: 12px; border-bottom: 1px solid var(--rule); }
.infobox figure { margin: 0; padding: 12px; text-align: center; border-bottom: 1px solid var(--rule); }
.infobox figcaption { font-size: .78rem; color: var(--ink-soft); margin-top: 8px; }
.infobox dl { margin: 0; padding: 8px 12px 12px; display: grid; grid-template-columns: 96px minmax(0,1fr); gap: 8px 10px; }
.infobox dt { font-weight: 600; }
.infobox dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Image frames: intentional placeholder when a picture is missing */
.frame {
  display: block; width: 100%; max-width: 100%; aspect-ratio: 3 / 3; object-fit: cover;
  background: repeating-linear-gradient(135deg, var(--panel) 0 8px, transparent 8px 16px), var(--paper);
  border: 1px solid var(--rule);
}
.frame.square { aspect-ratio: 1; width: 160px; margin: 0 auto; border-radius: 50%; }
figure.thumb { float: right; clear: right; width: 240px; margin: 4px 0 16px 28px; font-size: .78rem; color: var(--ink-soft); }
figure.thumb figcaption { margin-top: 6px; line-height: 1.4; }

/* Notice box */
.hatnote { font-style: italic; color: var(--ink-soft); font-size: .92rem; padding-left: 16px; margin: 0 0 18px; }

/* Cases */
.cases { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; margin-top: 12px; clear: both; }
.case { display: grid; gap: 8px; color: var(--ink); min-width: 0; }
.case:hover { text-decoration: none; }
.case:hover h4 { color: var(--link); }
.case .org { font: 500 .7rem var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.case h4 { font: 400 1.1rem/1.3 var(--f-display); margin: 0; }
.case p { font-size: .9rem; color: var(--ink-soft); margin: 0; }
.case .frame { aspect-ratio: 13 / 10; }

/* Toolkit */
.stack { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; max-width: 72ch; }
.stack li { font: .82rem/1 var(--f-mono); padding: 7px 10px; border: 1px solid var(--rule); border-radius: 3px; }

/* References */
.refs { font-size: .88rem; padding-left: 1.6em; max-width: 72ch; }
.refs li { margin-bottom: 6px; }
.refs i { color: var(--ink-soft); }
.ext { padding-left: 1.2em; }
.categories {
  clear: both; margin-top: 40px; padding: 10px 12px; border: 1px solid var(--rule); background: var(--panel);
  font-size: .82rem; display: flex; flex-wrap: wrap; gap: 6px 14px;
}
.categories b { font-weight: 600; }

/* Feedback tab: NPS survey */
.survey { max-width: 640px; border: 1px solid var(--rule); background: var(--panel); padding: 24px; margin-top: 8px; }
.survey h2 { border: none !important; margin-top: 0 !important; }
.scale { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 4px; margin: 16px 0 6px; }
.scale button {
  font: 500 .95rem/1 var(--f-mono); padding: 12px 0; cursor: pointer;
  background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-radius: 3px;
  transition: background .15s, color .15s, border-color .15s;
}
.scale button:hover { border-color: var(--ink-soft); }
.scale button[aria-pressed="true"] { color: var(--paper); border-color: transparent; }
.scale button.d[aria-pressed="true"] { background: var(--detractor); }
.scale button.p[aria-pressed="true"] { background: var(--passive); }
.scale button.r[aria-pressed="true"] { background: var(--promoter); }
.scale-ends { display: flex; justify-content: space-between; font: .72rem var(--f-mono); color: var(--ink-soft); text-transform: uppercase; letter-spacing: .08em; }
.followup { margin-top: 20px; border-top: 1px solid var(--rule); padding-top: 18px; }
.chip { display: inline-block; font: 500 .7rem/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; padding: 5px 8px; border-radius: 3px; color: var(--paper); }
.email-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.email-row code { font: .95rem var(--f-mono); background: var(--paper); border: 1px solid var(--rule); padding: 8px 10px; user-select: all; overflow-wrap: anywhere; }
.btn { font: 500 .85rem var(--f-body); padding: 8px 14px; border-radius: 3px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); cursor: pointer; }

footer.site { max-width: 1180px; margin: 48px auto 0; border-top: 1px solid var(--rule); padding-top: 16px; font-size: .8rem; color: var(--ink-soft); }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0,1fr); gap: 0; }
  .toc { position: static; border: 1px solid var(--rule); background: var(--panel); padding: 14px 16px; margin-bottom: 24px; }
  .toc ol { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 640px) {
  .infobox, figure.thumb { float: none; width: 100%; margin: 0 0 22px; }
  .scale { grid-template-columns: repeat(6, minmax(0,1fr)); }
  .masthead nav { gap: 12px; }
}

/* Lightbox: click any <img data-zoom> to view it larger.
   Uses the page's color tokens when present, with fallbacks. */
img[data-zoom] { cursor: zoom-in; }
img[data-zoom]:focus-visible { outline: 2px solid var(--link, #2450b3); outline-offset: 3px; }
 
.lb {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; grid-template-rows: minmax(0, 1fr) auto; place-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 48px) 16px calc(env(safe-area-inset-bottom, 0px) + 20px);
  background: rgba(10, 12, 16, .92);
  opacity: 0; transition: opacity .18s ease;
}
.lb.open { opacity: 1; }
.lb[hidden] { display: none !important; }
.lb img {
  max-width: min(100%, 1600px); max-height: 100%;
  object-fit: contain; cursor: zoom-out;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
  transform: scale(.97); transition: transform .18s ease;
}
.lb.open img { transform: scale(1); }
.lb-caption {
  max-width: 70ch; text-align: center; color: #d6dbe2;
  font: 400 .9rem/1.5 var(--f-body, system-ui, sans-serif);
}
.lb-count { font: .75rem var(--f-mono, ui-monospace, monospace); color: #8c95a1; margin-left: 8px; }
.lb button {
  position: absolute; background: rgba(255, 255, 255, .1); color: #fff;
  border: 1px solid rgba(255, 255, 255, .2); border-radius: 50%;
  width: 44px; height: 44px; font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.lb button:hover { background: rgba(255, 255, 255, .2); }
.lb button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lb-close { top: calc(env(safe-area-inset-top, 0px) + 12px); right: 16px; }
.lb-prev, .lb-next { top: 50%; transform: translateY(-50%); }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }
.lb.single .lb-prev, .lb.single .lb-next, .lb.single .lb-count { display: none; }
body.lb-lock { overflow: hidden; }
 
@media (prefers-reduced-motion: reduce) {
  .lb, .lb img { transition: none; }
}
@media (max-width: 640px) {
  .lb-prev, .lb-next { top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); transform: none; }
}
/* Side projects: thumbnail on the left, text on the right */
.projects-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 24px; max-width: 760px; }
.project { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 20px; align-items: start; }
.project-thumb { display: block; }
.project-thumb img {
  display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; object-position: center;
  border: 1px solid var(--rule); background: var(--panel); transition: opacity .15s;
}
.project-thumb:hover img { opacity: .85; }
.project-body { min-width: 0; }
.article .project p.project-meta { font: 500 .7rem/1.4 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 4px; }
.article .project h3 { font: 400 1.15rem/1.3 var(--f-display); margin: 0 0 6px; text-wrap: balance; }
.article .project h3 a { color: var(--ink); }
.article .project h3 a:hover { color: var(--link); }
.article .project p { font-size: .94rem; margin: 0 0 6px; }
.article .project-links { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .88rem; }
@media (prefers-reduced-motion: reduce) { .project-thumb img { transition: none; } }
@media (max-width: 640px) {
  .project { grid-template-columns: 96px minmax(0, 1fr); gap: 14px; }
}
