:root {
    color-scheme: light;
    --bg: #ffffff;
    --surface: #fff;
    --text: #171717;
    --muted: #606060;
    --accent: #171717;
    --accent-hover: #404040;
    --border: #dddddd;
    --tint: #f5f5f5;
    --visual: #f7f7f7;
    --diagram-label: #e5e5e5;
    --diagram-node-bg: #ffffff;
    --diagram-warm: #666666;
    --diagram-reference: #999999;
    --nav-bg: rgb(255 255 255 / 94%);
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
html.dark {
    color-scheme: dark;
    --bg: #111111;
    --surface: #181818;
    --text: #eeeeee;
    --muted: #bbbbbb;
    --accent: #eeeeee;
    --accent-hover: #cccccc;
    --border: #363636;
    --tint: #202020;
    --visual: #202020;
    --diagram-label: #383838;
    --diagram-node-bg: #181818;
    --diagram-warm: #bbbbbb;
    --diagram-reference: #888888;
    --nav-bg: rgb(17 17 17 / 94%);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 100px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.7; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
img, svg { max-width: 100%; }
img { display: block; }
h1, h2, h3, h4, p, figure { margin: 0; }
button, input { border-radius: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 5px; }
::selection { background: var(--accent); color: var(--bg); }
[hidden] { display: none !important; }
.container { max-width: 1160px; width: calc(100% - 96px); margin-inline: auto; }
.skip-link { position: fixed; top: -100px; left: 20px; padding: 12px 20px; background: var(--surface); z-index: 2000; }
.skip-link:focus { top: 12px; }
.site-header { position: sticky; top: 0; z-index: 1000; border-bottom: 1px solid var(--border); background: var(--nav-bg); backdrop-filter: blur(16px); }
nav { display: flex; align-items: center; height: 84px; gap: 32px; }
.logo { font-size: 33px; font-weight: 750; letter-spacing: -1px; line-height: 1; }
.logo span { color: var(--accent); }
.nav-menu { display: flex; align-items: center; list-style: none; margin: 0 0 0 auto; padding: 0; gap: 32px; }
.nav-menu a { font-size: 14px; color: var(--muted); display: block; padding: 12px 0; position: relative; }
.nav-menu a:hover, .nav-menu a.active { color: var(--accent); }
.nav-menu a.active::after { content: ""; height: 3px; width: 3px; background: var(--accent); border-radius: 50%; position: absolute; bottom: 3px; left: 50%; }
.nav-controls { display: flex; align-items: center; gap: 8px; }
.icon-button { display: grid; place-content: center; width: 42px; height: 42px; border: 1px solid var(--border); border-radius: 50%; background: transparent; }
.icon-button:hover { background: var(--tint); }
.sun, html.dark .moon { display: none; }
html.dark .sun { display: block; }
.nav-toggle { display: none; }
#hero { padding: 64px 0; border-bottom: 1px solid var(--border); }
.hero-content { display: grid; grid-template-columns: 1fr 320px; gap: 72px; align-items: center; }
.eyebrow, .small-label { font-family: var(--mono); font-size: 11px; font-weight: 500; line-height: 1.6; letter-spacing: 1.6px; }
.eyebrow { color: var(--accent); margin-bottom: 24px; }
h1 { font-size: clamp(40px, 4.5vw, 62px); font-weight: 550; line-height: 1.1; letter-spacing: -3px; }
.hero-description { max-width: 465px; color: var(--muted); margin-top: 24px; line-height: 1.85; }
.hero-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; max-width: 360px; gap: 12px; margin-top: 28px; }
.resume-download { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 12px 18px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--text); font-size: 14px; font-weight: 500; line-height: 1.4; transition: background .15s, color .15s, border-color .15s; }
.resume-download svg { flex-shrink: 0; }
.resume-download:hover { background: var(--text); border-color: var(--text); color: var(--bg); }
.resume-download:active { background: var(--muted); border-color: var(--muted); color: var(--bg); }
.btn { display: inline-flex; align-items: center; gap: 28px; padding: 12px 21px; font-size: 13px; font-weight: 500; border-radius: 5px; }
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover { background: var(--accent-hover); }
.text-link { display: inline-flex; align-items: center; gap: 12px; font-size: 13px; font-weight: 550; padding: 8px 0; border: 0; background: transparent; }
.text-link:hover { color: var(--accent); }
.hero-portrait { width: 100%; }
.portrait-frame { position: relative; overflow: hidden; border-radius: 3px; }
.portrait-frame img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; }
.section { padding: 64px 0; border-bottom: 1px solid var(--border); }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 28px; margin-bottom: 32px; }
h2 { font-size: clamp(27px, 3vw, 36px); font-weight: 500; line-height: 1.2; letter-spacing: -1.25px; }
.project { display: grid; grid-template-columns: 1.28fr 1fr; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; background: var(--surface); }
.project + .project { margin-top: 24px; }
.project-copy { padding: 32px; min-width: 0; }
.project-meta { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; font: 11px var(--mono); color: var(--muted); margin-bottom: 23px; }
.status-label { background: var(--tint); color: var(--accent); padding: 5px 8px; border-radius: 3px; }
h3 { font-size: 28px; font-weight: 550; letter-spacing: -.8px; line-height: 1.2; }
.project-subtitle { color: var(--text) !important; font-size: 16px; margin: 8px 0 14px; }
.project-copy > p, .project-details p { color: var(--muted); font-size: 14px; line-height: 1.85; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 20px; }
.tags span { font: 11px var(--mono); color: var(--muted); border: 1px solid var(--border); padding: 5px 7px; border-radius: 3px; }
.project-actions { margin-top: 14px; }
.project-details { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
.project-details summary { cursor: pointer; font-size: 13px; color: var(--muted); list-style: none; display: flex; justify-content: space-between; }
summary::-webkit-details-marker { display: none; }
.project-details summary span { font-size: 18px; line-height: 1; }
.project-details[open] summary span { transform: rotate(45deg); }
.project-details p { margin-top: 12px; font-size: 13px; }
.project-visual { margin: 0; background: var(--visual); padding: 24px; display: flex; flex-direction: column; justify-content: center; gap: 16px; min-width: 0; border-left: 1px solid var(--border); }
.figure-title { color: var(--text); font-size: 14px; font-weight: 550; }
.figure-note { color: var(--muted); font-size: 11px; line-height: 1.6; }
.project-diagram { width: 100%; height: auto; display: block; overflow: visible; }
.sav-diagram { max-height: 460px; }
.diagram-node { fill: var(--diagram-node-bg); stroke: var(--border); stroke-width: 1; }
.diagram-heading { fill: var(--text); font-size: 14px; font-weight: 500; }
.diagram-note { fill: var(--muted); font-size: 12px; }
.diagram-state { fill: none; stroke: var(--border); }
.looplens-visual { background: var(--tint); gap: 12px; }
.figure-pipeline { display: flex; align-items: center; justify-content: space-between; list-style: none; padding: 0; margin: 0; gap: 8px; font-size: 12px; color: var(--muted); }
.figure-pipeline li:not(:last-child)::after { content: "→"; margin-left: 16px; color: var(--accent); }
.plot-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin-top: 2px; }
.plot-legend span { display: inline-flex; align-items: center; gap: 5px; }
.plot-legend span::before { content: ""; width: 15px; height: 0; border-top: 2px solid var(--accent); }
.plot-legend .legend-truth::before { border-color: var(--diagram-reference); border-top-style: dotted; }
.plot-legend .legend-before::before { border-color: var(--diagram-warm); border-top-style: dashed; }
.trajectory-diagram { max-height: 350px; }
.figure-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.figure-metrics strong { font-size: 27px; font-weight: 500; line-height: 1.3; color: var(--accent); }
.figure-metrics small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.figure-metrics p { font-size: 11px; color: var(--muted); margin-top: 5px; }
.about-layout { display: grid; grid-template-columns: 1fr 1.05fr; gap: 100px; }
.about-intro > p:not(.eyebrow) { color: var(--muted); font-size: 14px; margin-top: 18px; max-width: 420px; }
.education > h3 { color: var(--muted); margin-bottom: 20px; }
.education-item { display: flex; align-items: center; gap: 18px; padding: 21px 0; border-bottom: 1px solid var(--border); }
.education-item:last-child { border: 0; }
.education-logo { width: 65px; height: 58px; display: flex; justify-content: center; align-items: center; background: #fff; border-radius: 4px; flex-shrink: 0; }
.education-logo img { object-fit: contain; padding: 3px; }
.year { font: 11px var(--mono); color: var(--accent); }
.education h4 { font-size: 15px; font-weight: 550; margin-top: 5px; }
.education-item p { font-size: 13px; color: var(--muted); }
.skills-grid { display: grid; grid-template-columns: .8fr 1fr 1.5fr; gap: 30px; border-top: 1px solid var(--border); padding-top: 30px; margin-top: 45px; scroll-margin-top: 120px; }
.skills-grid .small-label { color: var(--accent); font-size: 10px; letter-spacing: 1px; }
.skills-grid p { font-size: 13px; color: var(--muted); margin-top: 12px; line-height: 1.9; }
.gallery { min-width: 0; }
.gallery-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 16px; }
#gallery-position { font: 11px var(--mono); color: var(--muted); }
.gallery-arrows { display: flex; gap: 8px; }
.gallery-arrows .icon-button { width: 34px; height: 34px; font-size: 16px; }
.gallery-arrows button:disabled { opacity: .3; }
.photo-journal { display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 36px) / 3); gap: 18px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scrollbar-width: none; }
.photo-journal::-webkit-scrollbar { display: none; }
.photo-journal > .photo-card { scroll-snap-align: start; min-width: 0; }
.photo-journal > .photo-card:focus-visible { outline-offset: -4px; }
.photo-card { position: relative; padding: 0; border: 0; overflow: hidden; background: var(--tint); border-radius: 5px; text-align: left; }
.photo-card img { width: 100%; height: 210px; object-fit: cover; transition: transform .4s; }
.photo-card:hover img { transform: scale(1.035); }
.photo-card::after { content: ""; position: absolute; inset: 30% 0 0; background: linear-gradient(transparent, rgb(0 0 0 / 65%)); pointer-events: none; }
.photo-card-label { position: absolute; bottom: 17px; left: 19px; right: 19px; color: #fff; z-index: 1; display: flex; align-items: end; justify-content: space-between; font-size: 16px; }
.photo-card-label small { display: block; font: 10px var(--mono); opacity: .85; margin-top: 4px; }
.map-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 24px 0 12px; }
.travel-stats { color: var(--muted); font: 11px var(--mono); }
.travel-stats strong { font-family: inherit; color: var(--text); font-size: 16px; font-weight: 500; }
#map { height: 350px; border: 1px solid var(--border); border-radius: 5px; background: var(--tint); position: relative; isolation: isolate; }
.map-status { height: 100%; display: grid; place-content: center; font-size: 13px; color: var(--muted); padding: 25px; text-align: center; }
.city-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin: 20px 0 14px; }
.search-box { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); color: var(--muted); padding: 4px 0; }
.search-box input { width: 240px; min-width: 0; background: transparent; border: 0; color: var(--text); font-size: 13px; padding: 8px 4px; }
.search-box input::placeholder { color: var(--muted); }
#search-status { color: var(--muted); font: 11px var(--mono); }
#city-list { display: grid; grid-template-columns: repeat(4, 1fr); column-gap: 20px; align-items: start; }
.country-group { border-bottom: 1px solid var(--border); }
.country-group summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 10px 0; font-size: 13px; }
.country-flag { width: 20px; height: 15px; object-fit: cover; flex-shrink: 0; border-radius: 2px; box-shadow: 0 0 0 1px rgb(0 0 0 / 6%); }
.country-group summary .country-count { margin-left: auto; color: var(--muted); font: 10px var(--mono); }
.country-group summary::after { content: "+"; color: var(--muted); width: 12px; text-align: center; }
.country-group[open] summary::after { content: "−"; }
.city-buttons { display: flex; flex-wrap: wrap; gap: 5px; padding-bottom: 12px; }
.city-button { border: 1px solid var(--border); border-radius: 3px; padding: 5px 8px; font-size: 12px; background: var(--surface); text-align: left; }
.city-button:hover { border-color: var(--accent); color: var(--accent); }
.city-button small { color: var(--muted); }
.city-marker { border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px #00000030; }
.leaflet-container { font-family: inherit; }
#map .leaflet-tile-pane { filter: grayscale(1); }
html.dark #map .leaflet-tile-pane { filter: grayscale(1) invert(1) brightness(.8); }
.map-notice { position: absolute; z-index: 600; top: 10px; right: 10px; max-width: 220px; padding: 8px 12px; border-radius: 4px; background: var(--surface); color: var(--muted); box-shadow: 0 2px 8px #0002; font-size: 11px; pointer-events: none; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); }
.city-photo-popup .leaflet-popup-content { margin: 10px; width: 210px !important; }
.city-photo-popup img { width: 210px; height: 140px; object-fit: cover; border-radius: 3px; }
.popup-label { font-size: 12px; font-weight: 600; padding-top: 7px; }
.popup-note { display: block; font-weight: 400; color: var(--muted); margin-top: 3px; }
.no-script-note { padding: 20px 0; color: var(--muted); }
#contact { padding-bottom: 65px; }
.contact-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin-top: 24px; }
.contact-links a { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; padding: 14px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.contact-links a:hover { border-color: var(--text); }
.contact-links a span { flex-shrink: 0; }

footer { display: flex; justify-content: space-between; gap: 20px; font: 11px var(--mono); color: var(--muted); padding-block: 25px; }
dialog { width: min(900px, calc(100% - 40px)); max-height: 90dvh; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / 80%); backdrop-filter: blur(6px); }
#dialog-image { width: 100%; max-height: 72dvh; object-fit: contain; border-radius: 4px; background: var(--tint); }
.dialog-close { position: absolute; top: 20px; right: 20px; background: var(--surface); font-size: 25px; z-index: 1; }
.dialog-caption { padding: 16px 8px 4px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-caption h2 { font-size: 20px; letter-spacing: -.3px; }
.dialog-caption p { font-size: 13px; color: var(--muted); }
.dialog-nav { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.dialog-nav[hidden] { display: none; }
.dialog-nav span { font: 11px var(--mono); color: var(--muted); margin-right: 6px; }
.dialog-nav .icon-button { width: 38px; height: 38px; font-size: 16px; }

@media (max-width: 1000px) {
    .container { width: calc(100% - 64px); }
    .hero-content { gap: 40px; grid-template-columns: 1fr 280px; }
    .project-copy { padding: 25px; }
    .about-layout { gap: 45px; }
    #city-list { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
    .container { width: calc(100% - 40px); }
    nav { height: 68px; gap: 20px; flex-wrap: wrap; }
    .nav-controls { margin-left: auto; }
    .nav-toggle { display: grid; gap: 5px; }
    .nav-toggle span { width: 15px; height: 1px; background: currentColor; }
    .nav-menu { display: none; position: absolute; top: 68px; left: 0; right: 0; background: var(--bg); padding: 12px 24px 20px; border-bottom: 1px solid var(--border); }
    .nav-menu.open { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
    .nav-menu a { padding: 12px 0; font-size: 15px; }
    .nav-menu a.active::after { display: none; }
    #hero { padding: 40px 0; }
    .hero-content { grid-template-columns: 1fr; gap: 36px; }
    .hero-text .eyebrow { margin-bottom: 20px; }
    h1 { font-size: 47px; letter-spacing: -2px; }
    .hero-description { max-width: 480px; font-size: 14px; margin-top: 20px; }
    .resume-download { min-height: 48px; padding: 12px 14px; }
    .btn { padding: 12px 16px; gap: 18px; }
    .hero-portrait { width: min(260px, 100%); justify-self: start; }
    .section { padding: 52px 0; }
    .section-heading { align-items: start; flex-direction: column; gap: 12px; margin-bottom: 25px; }
    .eyebrow { font-size: 10px; letter-spacing: 1.1px; }
    h2 { font-size: 29px; }
    .project { grid-template-columns: 1fr; }
    .project-copy { padding: 24px; }
    .project-visual { padding: 20px 14px; border-top: 1px solid var(--border); border-left: 0; }
    .figure-pipeline { font-size: 11px; }
    .figure-pipeline li:not(:last-child)::after { margin-left: 8px; }
    .plot-legend { gap: 12px; }
    .about-layout { grid-template-columns: 1fr; gap: 35px; }
    .about-intro > p:not(.eyebrow) { max-width: none; }
    .skills-grid { grid-template-columns: 1fr 1fr; gap: 25px; margin-top: 28px; }
    .skills-grid > div:last-child { grid-column: 1 / -1; }
    .photo-journal { grid-auto-columns: 86%; gap: 12px; }
    .photo-card img { height: 220px; }
    .photo-card-label { left: 16px; right: 16px; bottom: 16px; font-size: 16px; }
    .photo-card-label small { font-size: 11px; }
    #map { height: 300px; }
    #city-list { grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
    .search-box { flex: 1; min-width: 0; }
    .search-box input { width: 100%; font-size: 16px; } /* 16px stops iOS zooming on focus. */
    #search-status { font-size: 10px; flex-shrink: 0; }
    .contact-links { grid-template-columns: 1fr; gap: 8px; }
    footer { font-size: 10px; flex-wrap: wrap; gap: 12px; }
}
@media (max-width: 380px) {
    h1 { font-size: 40px; }
    .btn { font-size: 12px; padding: 12px; gap: 12px; }
    .travel-stats { font-size: 10px; }
    .travel-stats strong { font-size: 13px; }
    .project-meta { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
.not-found { min-height: calc(100dvh - 160px); display: grid; align-content: center; gap: 20px; padding: 64px 0; }
.not-found p:not(.eyebrow) { color: var(--muted); max-width: 420px; }
