:root {
  --bg: #ffffff;
  --surface: #f6f7f9;
  --text: #0f172a;
  --body: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #1d4ed8;
  --accent-soft: #eff4ff;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111a2e;
    --text: #e2e8f0;
    --body: #a3b1c6;
    --muted: #7d8ba1;
    --line: #1e293b;
    --accent: #7aa2ff;
    --accent-soft: rgba(122, 162, 255, .1);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
strong { color: var(--text); font-weight: 500; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 16px; z-index: 10; background: var(--bg); padding: 8px 12px; }

/* ---------- Layout ---------- */
.layout {
  max-width: 1160px; margin: 0 auto; padding: 0 48px;
  display: grid; grid-template-columns: 1fr 1.15fr; gap: 64px;
}
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 96px 0 64px;
}
.content { padding: 96px 0 64px; }

/* ---------- Sidebar ---------- */
.name { font-size: 44px; font-weight: 700; color: var(--text); letter-spacing: -.03em; line-height: 1.1; }
.title { margin-top: 12px; font-size: 19px; font-weight: 500; color: var(--text); }
.title a { color: var(--accent); }
.tagline { margin-top: 16px; max-width: 340px; color: var(--muted); }

.nav { margin-top: 64px; }
.nav a {
  display: inline-flex; align-items: center; gap: 16px; padding: 10px 0;
  font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.nav a::before { content: ""; width: 32px; height: 1px; background: currentColor; transition: width .2s, background .2s; }
.nav a:hover, .nav a.active { color: var(--text); }
.nav a:hover::before, .nav a.active::before { width: 64px; }

.sidebar-foot { display: flex; align-items: center; gap: 28px; }
.resume, .btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); font-size: 14px; font-weight: 500; color: var(--text);
}
.resume:hover, .btn:hover { border-color: var(--accent); color: var(--accent); }
.socials { display: flex; align-items: center; gap: 20px; }
.socials a { color: var(--muted); display: inline-flex; }
.socials a:hover { color: var(--text); }
.socials svg { width: 22px; height: 22px; }

/* ---------- Sections ---------- */
section { margin-bottom: 112px; scroll-margin-top: 96px; }
section:last-of-type { margin-bottom: 64px; }
.section-title {
  font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--text);
  margin-bottom: 24px; display: none;
}
#about p + p { margin-top: 16px; }
#about a { color: var(--text); font-weight: 500; border-bottom: 1px solid var(--line); }
#about a:hover { color: var(--accent); border-color: var(--accent); }

/* Entries (experience + projects) */
.entries { display: flex; flex-direction: column; gap: 8px; }
.entry {
  position: relative; display: grid; grid-template-columns: 140px 1fr; gap: 16px;
  padding: 20px; margin: 0 -20px; border-radius: 10px; transition: background .2s;
}
.entry:hover { background: var(--surface); }
.entries:hover .entry:not(:hover) { opacity: .6; }
.entry .when {
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); padding-top: 3px;
}
.entry h3 { font-size: 16px; font-weight: 500; color: var(--text); line-height: 1.4; }
.entry h3 a::after { content: ""; position: absolute; inset: 0; border-radius: 10px; }
.entry:hover h3 { color: var(--accent); }
.entry h3 .arrow { display: inline-block; margin-left: 4px; transition: transform .2s; }
.entry:hover h3 .arrow { transform: translate(2px, -2px); }
.entry .role-sub { color: var(--muted); font-size: 15px; }
.entry p { margin-top: 8px; font-size: 15px; }
.stars { display: inline-flex; align-items: center; gap: 4px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.stars svg { width: 14px; height: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chips li {
  font-size: 12px; font-weight: 500; line-height: 1; padding: 6px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}

.more { display: inline-flex; align-items: center; gap: 6px; margin-top: 24px; font-weight: 500; color: var(--text); }
.more:hover { color: var(--accent); }
.more span { transition: transform .2s; }
.more:hover span { transform: translateX(3px); }

.footnote { font-size: 14px; color: var(--muted); max-width: 440px; }

/* ---------- Article (archived posts) ---------- */
.article-wrap { max-width: 680px; margin: 0 auto; padding: 72px 24px 32px; }
.article .back { font-size: 14px; font-weight: 500; color: var(--muted); }
.article .back:hover { color: var(--accent); }
.article h1 { font-size: 32px; color: var(--text); letter-spacing: -.02em; line-height: 1.25; margin: 32px 0 8px; }
.article .meta { font-size: 14px; color: var(--muted); margin-bottom: 32px; }
.article .note { font-size: 14px; color: var(--muted); border-left: 2px solid var(--line); padding-left: 12px; margin-bottom: 32px; }
.article p { margin-bottom: 1.1em; font-size: 17px; }
.article p a { color: var(--accent); }
.article img { max-width: 100%; display: block; margin: 28px 0; border-radius: 8px; }
.article ul { list-style: disc; padding-left: 22px; margin-bottom: 1.1em; }
.article li { margin-bottom: 6px; font-size: 17px; }
.article-footer { max-width: 680px; margin: 0 auto; padding: 32px 24px 48px; font-size: 14px; color: var(--muted); }

/* ---------- Pages ---------- */
.detail { margin-bottom: 64px; }
.name a:hover { color: var(--accent); }
.detail .back { display: inline-block; margin-bottom: 32px; font-size: 14px; font-weight: 500; color: var(--muted); }
.detail .back:hover { color: var(--accent); }
.detail-head { margin-bottom: 40px; }
.detail-head h1 { font-size: 32px; font-weight: 700; color: var(--text); letter-spacing: -.02em; line-height: 1.2; }
.detail-meta {
  margin-bottom: 8px; font-size: 12px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.detail-summary { margin-top: 12px; font-size: 17px; }
.prose > * + * { margin-top: 1em; }
.prose h2 {
  margin-top: 2.5em; font-size: 12px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text);
}
.prose ul { list-style: disc; padding-left: 22px; }
.prose li + li { margin-top: 6px; }
.prose a { color: var(--accent); }
.prose img { max-width: 100%; height: auto; border-radius: 8px; }
.prose code { font-size: .9em; padding: 2px 6px; border-radius: 4px; background: var(--surface); }
.detail-head .stars { display: flex; width: max-content; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.detail-cover { display: block; width: 100%; height: auto; margin-bottom: 40px; border-radius: 10px; border: 1px solid var(--line); }

/* ---------- 3D ---------- */
.tag { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.tag-model { color: var(--accent); }
/* Photos are transparent WebP files (scripts/prepare_photos.sh). The tile gives the background. */
.gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 40px; padding: 0; list-style: none; }
.tile {
  position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
}
.tile img, .tile video { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.tile:hover img, .tile:hover video { transform: scale(1.04); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile-video::after {
  content: "▶"; position: absolute; left: 8px; bottom: 8px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; color: #fff; background: rgba(15, 23, 42, .6);
}
.lightbox {
  width: min(960px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text);
}
.lightbox::backdrop { background: rgba(2, 6, 23, .75); }
.lightbox figure { margin: 0; }
.lightbox img, .lightbox video { display: block; width: 100%; max-height: calc(100vh - 100px); object-fit: contain; }
.lightbox-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.lightbox-bar span { margin-right: auto; }
.lightbox button {
  font: inherit; font-size: 13px; padding: 4px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.lightbox button:hover { border-color: var(--accent); color: var(--accent); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin-bottom: 32px; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; color: var(--text); }
.detail > .actions { margin: 0 0 32px; }
.viewer { margin-bottom: 40px; }
.viewer model-viewer {
  display: block; width: 100%; height: auto; aspect-ratio: 4 / 3;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
}
.viewer .more { margin-top: 12px; }

/* ---------- Wide pages (Uses) ---------- */
.topbar-inner, .wide-main { max-width: 1160px; margin: 0 auto; padding-left: 48px; padding-right: 48px; }
.topbar { border-bottom: 1px solid var(--line); }
.topbar-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 32px;
  padding-top: 32px; padding-bottom: 24px;
}
.topbar-name { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: -.02em; }
.topbar-name:hover { color: var(--accent); }
.topbar-nav ul { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.topbar-nav a {
  display: inline-block; padding: 4px 0; font-size: 12px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
}
.topbar-nav a:hover, .topbar-nav a.active { color: var(--text); }
.wide-main { padding-top: 64px; padding-bottom: 64px; }
.wide-head { margin-bottom: 56px; }
.wide-head h1 { font-size: 40px; font-weight: 700; color: var(--text); letter-spacing: -.03em; line-height: 1.1; }
/* Desk photo with a spot on each device. The tip shows on hover, on keyboard focus, or after a tap (.is-open). */
.desk { position: relative; margin: 0 0 64px; border-radius: 12px; background: #000; }
.desk img { display: block; width: 100%; height: auto; border-radius: inherit; transition: filter .3s; }
.desk:has(.desk-spot:hover, .desk-spot:focus-visible, .desk-spot.is-open) img { filter: brightness(.7); }
.desk-spot {
  position: absolute; left: var(--x); top: var(--y); width: 32px; height: 32px; margin: -16px 0 0 -16px;
  padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.desk-spot::before, .desk-spot::after {
  content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #fff;
}
.desk-spot::before { box-shadow: 0 0 0 4px rgba(255, 255, 255, .25), 0 2px 8px rgba(0, 0, 0, .5); }
.desk-spot::after { animation: desk-pulse 2.4s ease-out infinite; }
.desk-spot:hover::before, .desk-spot:focus-visible::before, .desk-spot.is-open::before, .desk-spot.is-linked::before {
  background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent), 0 2px 8px rgba(0, 0, 0, .5);
}
.desk-spot:focus-visible { outline: 2px solid #fff; outline-offset: 0; border-radius: 50%; }
@keyframes desk-pulse { from { opacity: .6; transform: scale(1); } to { opacity: 0; transform: scale(2.6); } }
.desk-tip {
  position: absolute; bottom: calc(100% + 6px); left: 50%; z-index: 1; width: max-content; max-width: 220px;
  padding: 8px 12px; border-radius: 8px; background: rgba(15, 23, 42, .92); backdrop-filter: blur(6px);
  color: #e2e8f0; font-size: 13px; line-height: 1.4; text-align: left; white-space: normal;
  opacity: 0; transform: translate(-50%, 4px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.desk-tip strong { display: block; color: #fff; font-size: 14px; font-weight: 600; }
.desk-tip span { color: #94a3b8; }
.desk-tip em { display: block; margin-top: 4px; font-style: normal; }
.desk-spot[data-below] .desk-tip { top: calc(100% + 6px); bottom: auto; }
.desk-spot[data-align="start"] .desk-tip { left: 0; transform: translate(0, 4px); }
.desk-spot[data-align="end"] .desk-tip { left: auto; right: 0; transform: translate(0, 4px); }
.desk-spot:hover .desk-tip, .desk-spot:focus-visible .desk-tip, .desk-spot.is-open .desk-tip, .desk-spot.is-linked .desk-tip {
  opacity: 1; transform: translate(-50%, 0);
}
.desk-spot[data-align]:is(:hover, :focus-visible, .is-open, .is-linked) .desk-tip { transform: none; }
.desk-spot:is(:hover, :focus-visible, .is-open, .is-linked) { z-index: 2; }
.use-card.is-linked { border-color: var(--accent); }
.use-section { margin-bottom: 64px; }
.use-section-title {
  margin-bottom: 20px; font-size: 12px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--text);
}
.use-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.use-card { border: 1px solid var(--line); border-radius: 12px; transition: border-color .2s; }
.use-card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.use-inner { display: block; padding: 16px; }
.use-media {
  position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; margin-bottom: 16px;
  overflow: hidden; border-radius: 8px; background: var(--surface); color: var(--muted);
}
.use-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.use-icon { width: 56px; height: 56px; }
.use-name { font-size: 16px; font-weight: 500; color: var(--text); line-height: 1.4; }
a.use-inner:hover .use-name { color: var(--accent); }
.use-kind { margin-top: 2px; font-size: 13px; color: var(--muted); }
.use-note { margin-top: 8px; font-size: 15px; }
/* Uses page: a small icon next to the text, because the desk photo shows the devices. */
.use-grid.compact { gap: 12px; }
.compact .use-inner { display: flex; align-items: center; gap: 14px; height: 100%; padding: 14px; }
.compact .use-media { flex: none; width: 44px; height: 44px; aspect-ratio: auto; margin: 0; }
.compact .use-icon { width: 24px; height: 24px; }
.compact .use-text { min-width: 0; }
.compact .use-name { font-size: 15px; }
.compact a.use-inner .use-name::after { content: " →"; color: var(--muted); }
.compact a.use-inner:hover .use-name::after { color: inherit; }

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
  .topbar-inner, .wide-main { padding-left: 24px; padding-right: 24px; }
  .use-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout { display: block; padding: 0 24px; max-width: 720px; }
  .sidebar { position: static; height: auto; padding: 64px 0 0; }
  .nav { margin-top: 28px; }
  .nav ul { display: flex; flex-wrap: wrap; gap: 0 20px; }
  .nav a { padding: 6px 0; }
  .nav a::before { display: none; }
  .sidebar-foot { margin-top: 28px; justify-content: flex-start; }
  .content { padding-top: 56px; }
  section { margin-bottom: 72px; }
  .section-title {
    display: block; position: sticky; top: 0; z-index: 2;
    margin: 0 -24px 16px; padding: 16px 24px;
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  }
  .name { font-size: 36px; }
}
@media (max-width: 600px) {
  .topbar-inner, .wide-main { padding-left: 16px; padding-right: 16px; }
  .wide-main { padding-top: 40px; }
  .wide-head h1 { font-size: 32px; }
  .use-grid { grid-template-columns: 1fr; }
  .desk { margin-bottom: 48px; }
  .desk-spot { width: 24px; height: 24px; margin: -12px 0 0 -12px; }
  .desk-spot::before, .desk-spot::after { inset: 7px; }
  .desk-tip { max-width: 180px; padding: 6px 10px; font-size: 12px; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout { padding: 0 16px; }
  .section-title { margin: 0 -16px 12px; padding: 14px 16px; }
  .entry { grid-template-columns: 1fr; gap: 6px; padding: 16px; margin: 0 -16px; }
  .entry .when br { display: none; }
  .entries:hover .entry:not(:hover) { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
  .desk-spot::after { animation: none; opacity: 0; }
}
