:root {
  --bg: #fbfaf7; --fg: #1c1d21; --muted: #5d606b; --line: #e4e1da;
  --card: #ffffff; --accent: #990000; --accent-fg: #ffffff; --brand-bar: #990000;
  --serif: "Times New Roman", Times, "Liberation Serif", serif;
  --max: 1080px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
/* Dark theme: follows the system unless the visitor picked one (data-theme on <html>) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #131417; --fg: #ececef; --muted: #a0a3ad; --line: #2a2c33;
          --card: #1b1d22; --accent: #e03a3a; --accent-fg: #ffffff; --brand-bar: #e03a3a; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #131417; --fg: #ececef; --muted: #a0a3ad; --line: #2a2c33;
          --card: #1b1d22; --accent: #e03a3a; --accent-fg: #ffffff; --brand-bar: #e03a3a; color-scheme: dark; }

/* Theme toggle: shows a moon in light mode and a sun in dark mode */
.theme-toggle { vertical-align: middle; background: none; border: 0; padding: 4px; margin-left: 16px; color: var(--muted); cursor: pointer; line-height: 0; border-radius: 6px; }
.theme-toggle:hover { color: var(--fg); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: inline; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}
:root[data-theme="dark"] .theme-toggle .sun { display: inline; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--fg); line-height: 1.6; font-size: 17px; }
a { color: var(--accent); }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }

header.top { border-bottom: 1px solid var(--line); }
header.top .wrap { display: flex; justify-content: space-between; align-items: flex-end; min-height: 72px; padding-bottom: 8px; gap: 16px; }
.brand { font-family: var(--serif); font-weight: 900; font-size: 34px; line-height: 1; color: var(--fg); text-decoration: none; border-bottom: 5px solid var(--brand-bar); padding-bottom: 4px; }
nav { display: flex; align-items: center; flex-wrap: nowrap; }
@media (max-width: 480px) { .brand { font-size: 22px; } header.top .wrap { gap: 8px; padding: 0 16px 8px; } nav a { margin-left: 10px; } .theme-toggle { margin-left: 6px; } }
nav a { color: var(--muted); text-decoration: none; margin-left: 20px; font-size: 15px; }
nav a:hover, nav a[aria-current="page"] { color: var(--fg); }
@media (max-width: 860px) { nav a:not(.cta) { display: none; } }
.brand, nav a { white-space: nowrap; }

.hero { padding-top: 88px; padding-bottom: 64px; }
.hero h1 { font-family: var(--serif); font-weight: 800; font-size: clamp(32px, 5vw, 50px); line-height: 1.12; margin: 0 0 20px; max-width: 24ch; }
.hero p.lede { font-size: 20px; color: var(--muted); max-width: 60ch; margin: 0 0 32px; }
.btn { display: inline-block; padding: 12px 22px; border-radius: 8px; text-decoration: none; font-weight: 600; margin: 0 10px 10px 0; }
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.ghost { border: 1px solid var(--line); color: var(--fg); }
.proof { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; margin-top: 56px; padding-top: 32px; border-top: 1px solid var(--line); }
.proof b { display: block; font-size: 26px; letter-spacing: -.01em; }
.proof span { color: var(--muted); font-size: 15px; }

section { padding: 64px 0; border-top: 1px solid var(--line); }
section h2 { font-size: 28px; letter-spacing: -.01em; margin: 0 0 8px; }
section .sub { color: var(--muted); margin: 0 0 36px; max-width: 65ch; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.card h3 { margin: 0 0 8px; font-size: 19px; }
.card p { margin: 0 0 12px; color: var(--muted); font-size: 16px; }
.tags { font-size: 13px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.work { display: grid; gap: 0; }
.work article { display: grid; grid-template-columns: 220px 1fr; gap: 24px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.work article:last-child { border-bottom: 0; }
.work .who b { display: block; }
.work .who span { color: var(--muted); font-size: 14px; }
.work p { margin: 0; }
@media (max-width: 640px) { .work article { grid-template-columns: 1fr; gap: 6px; } }
.also { color: var(--muted); font-size: 15px; margin-top: 20px; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } }
ul.plain { padding-left: 18px; margin: 0; }
ul.plain li { margin-bottom: 8px; }

.contact { text-align: left; }
.contact .big { font-size: 22px; font-weight: 600; }
footer { border-top: 1px solid var(--line); padding: 28px 0 48px; color: var(--muted); font-size: 14px; }
footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

/* CV page */
.cv { max-width: 820px; margin: 0 auto; padding: 48px 20px 80px; }
.cv h1 { margin-bottom: 4px; }
.cv h2 { border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-top: 40px; font-size: 22px; }
.cv h3 { margin-bottom: 4px; font-size: 18px; }
.cv .meta { color: var(--muted); }
@media print {
  header.top, footer, .noprint { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .cv { padding: 0; }
  a { color: #000; text-decoration: none; }
}

/* Image placeholders: replace each <figure class="ph"> with <img src="img/..." alt="..."> */
figure.ph { margin: 0 0 14px; border: 2px dashed var(--line); border-radius: 10px; display: flex;
  align-items: center; justify-content: center; text-align: center; color: var(--muted);
  font-size: 14px; padding: 12px; background: var(--card); max-width: 520px; }
figure.ph code { font-size: 12px; }
figure.ph.headshot { max-width: 180px; border-radius: 50%; float: right; margin: 0 0 12px 16px; }
.work .who a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.work .who a:hover { color: var(--accent); }
.work img { width: 100%; height: auto; max-width: 520px; border-radius: 10px; border: 1px solid var(--line); margin-bottom: 14px; display: block; }
img.headshot { width: 180px; height: 180px; object-fit: cover; border-radius: 50%; float: right; margin: 0 0 12px 16px; }
ol.steps { padding-left: 22px; margin: 0 0 20px; }
ol.steps li { margin-bottom: 12px; }
ul.facts { color: var(--muted); font-size: 15px; }
#about::after { content: ""; display: block; clear: both; }
.faq details { border-bottom: 1px solid var(--line); padding: 14px 0; }
.faq summary { cursor: pointer; font-weight: 600; font-size: 18px; }
.faq details p { color: var(--muted); margin: 10px 0 0; max-width: 70ch; }
