:root, [data-theme="dark"] {
  --bg: #0B0C0E; --surface: #131418; --text: #F4F4F5; --muted: #A1A1AA; --faint: #83838C;
  --line: rgba(255,255,255,.09); --dot: rgba(255,255,255,.07);
  --btn-bg: #F4F4F5; --btn-text: #0B0C0E; --accent: #4ADE80;
  --nav-bg: rgba(19,20,24,.78);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #FAFAF9; --surface: #FFFFFF; --text: #18181B; --muted: #52525B; --faint: #71717A;
  --line: rgba(0,0,0,.09); --dot: rgba(0,0,0,.08);
  --btn-bg: #18181B; --btn-text: #FAFAF9; --accent: #16A34A;
  --nav-bg: rgba(255,255,255,.8);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: auto; }
body {
  margin: 0; color: var(--text); font: 400 16px/1.6 'Inter', system-ui, sans-serif; -webkit-font-smoothing: antialiased;
  background: radial-gradient(var(--dot) 1px, transparent 1.5px) 0 0 / 28px 28px fixed, var(--bg);
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
ul, ol { margin: 0; padding: 0; list-style: none; }
figure { margin: 0; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

/* ---------- Nav ---------- */
.nav {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 10;
  display: flex; align-items: center; gap: 2px; padding: 5px;
  background: var(--nav-bg); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.nav a, .theme-toggle { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 9px; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.nav a:hover, .theme-toggle:hover { color: var(--text); background: var(--line); }
.nav svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.theme-toggle { background: none; border: 0; cursor: pointer; padding: 7px; }
[data-theme="dark"] .icon-moon, [data-theme="light"] .icon-sun { display: none; }

/* ---------- Hero ---------- */
.hero { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 120px 16px 48px; }
.status { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 28px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 99px; font-size: 13px; color: var(--muted); background: var(--surface); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.hero h1 { font-size: clamp(40px, 6.4vw, 76px); font-weight: 700; line-height: 1.06; max-width: 13ch; }
.hero-intro { max-width: 560px; margin: 28px 0 0; color: var(--muted); font-size: 17px; }
.hero-intro-next { margin-top: 14px; }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 36px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 22px; border-radius: 99px; border: 1px solid var(--line); font-size: 14px; font-weight: 600; background: var(--surface); }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--btn-bg); color: var(--btn-text); border-color: var(--btn-bg); }
.btn-primary:hover { opacity: .88; }
.facts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; margin-top: 64px; width: min(1040px, 100%); background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; text-align: left; }
.facts li { background: var(--surface); padding: 16px 18px; font-size: 13px; color: var(--muted); }
.facts strong { display: block; color: var(--text); font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.scroll-cue { margin: 48px 0 0; font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.scroll-cue span { width: 1px; height: 28px; background: var(--faint); }

/* ---------- Sections ---------- */
.section { max-width: 1040px; margin: 0 auto; padding: 96px 16px; border-top: 1px solid var(--line); scroll-margin-top: 40px; }
@media (min-width: 640px) { .section { padding-inline: 32px; } }
.kicker { margin: 0 0 12px; font-size: 12px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); }
.section > h2 { font-size: clamp(28px, 3.6vw, 40px); font-weight: 700; line-height: 1.15; max-width: 24ch; margin-bottom: 40px; }
.prose { max-width: 680px; color: var(--muted); }
.prose p { margin: 0 0 16px; }
.link { display: inline-block; margin-top: 14px; font-size: 14px; font-weight: 600; border-bottom: 1px solid var(--line); }
.link:hover { border-color: var(--text); }

/* ---------- Projects ---------- */
.project { padding: 32px 0 48px; }
.project + .project { border-top: 1px dashed var(--line); padding-top: 48px; }
.project-text { max-width: 720px; }
.project-no { margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--faint); font-variant-numeric: tabular-nums; }
.project h3 { font-size: 24px; font-weight: 700; margin-bottom: 12px; }
.project-text > p { color: var(--muted); margin: 0 0 16px; }
.stats { display: flex; flex-wrap: wrap; gap: 12px; margin: 20px 0; }
.stats div { flex: 1 1 220px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.stats dt { font-size: 22px; font-weight: 700; }
.stats dd { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.project .tags { font-size: 13px; color: var(--faint); margin: 0; }
.shots, .gallery { display: grid; gap: 12px; margin-top: 28px; }
.shots img, .gallery img { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); width: 100%; }
.demo-video { display: block; width: 100%; aspect-ratio: 16 / 9; border: 1px solid var(--line); border-radius: 10px; background: #0B0C0E; }
.shots-3 { grid-template-columns: 1fr 1fr 1.3fr; align-items: start; }
.shots-phones { grid-template-columns: repeat(3, minmax(0, 200px)); }
.shots-phones img { border-radius: 18px; }
.gallery { grid-template-columns: repeat(3, 1fr); }
.gallery figcaption { margin-top: 8px; font-size: 12.5px; line-height: 1.5; color: var(--faint); }
.more { margin-top: 16px; }
.more summary { cursor: pointer; padding: 8px 0; font-size: 14px; font-weight: 600; color: var(--muted); width: max-content; }
.more summary:hover { color: var(--text); }

/* ---------- Timeline ---------- */
.timeline > li { display: grid; grid-template-columns: 180px 1fr; gap: 24px; padding: 28px 0; border-top: 1px solid var(--line); }
.timeline > li:first-child { border-top: 0; padding-top: 0; }
.timeline > li:last-child { padding-bottom: 0; }
.when { margin: 2px 0 0; font-size: 14px; font-weight: 600; }
.when span { display: block; font-weight: 400; color: var(--faint); }
.timeline h3 { font-size: 19px; font-weight: 700; }
.org { margin: 2px 0 12px; color: var(--muted); }
.timeline ul { display: grid; gap: 8px; color: var(--muted); font-size: 15px; }
.timeline ul li { position: relative; padding-left: 18px; }
.timeline ul li::before { content: ''; position: absolute; left: 2px; top: .7em; width: 5px; height: 5px; border-radius: 50%; background: var(--faint); }
.timeline > li > div > p:not(.org) { color: var(--muted); margin: 8px 0 0; }

/* ---------- Skills ---------- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.card { padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.card h3 { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.card p { margin: 0; font-size: 14px; color: var(--muted); }

/* ---------- Contact ---------- */
.contact { text-align: center; }
.contact > h2 { margin: 0 auto 12px; }
.contact-note { color: var(--muted); margin: 0 0 20px; }
.contact-email { font-size: clamp(22px, 3vw, 32px); font-weight: 700; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.contact-email:hover { border-color: var(--text); }
.contact .hero-actions { margin-top: 32px; }
.section > h2:has(+ .section-note) { margin-bottom: 12px; }
.section-note { margin: 0 0 32px; color: var(--muted); max-width: 60ch; }
.gallery-2 { grid-template-columns: 1fr 1fr; }
.project-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 20px; }
.project-actions .link { margin-top: 0; }
.project-meta { font-size: 13px; color: var(--faint); }
.soon { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 16px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 99px; font-size: 13px; font-weight: 500; color: var(--muted); background: var(--surface); }

/* ---------- Image viewer ---------- */
.zoomable { cursor: zoom-in; transition: opacity .2s; }
.zoomable:hover { opacity: .9; }
.zoomable:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.lb { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; color: #F4F4F5; visibility: hidden; touch-action: none; overscroll-behavior: contain; transition: visibility 0s .34s; }
.lb.is-open { visibility: visible; transition: none; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(8,9,11,.94); opacity: 0; transition: opacity .3s ease; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.lb.is-open .lb-backdrop { opacity: 1; }
.lb-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 64px 16px 12px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.lb-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; transform-origin: 0 0; will-change: transform; -webkit-user-drag: none; cursor: zoom-in; }
.lb-img.is-zoomed { cursor: grab; }
.lb-anim { transition: transform .32s cubic-bezier(.2,.8,.2,1), opacity .25s ease; }
.lb-ui { position: relative; opacity: 0; transition: opacity .25s ease; }
.lb.is-open .lb-ui { opacity: 1; }
.lb-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 0 20px; z-index: 2; font-size: 13px; font-weight: 600; color: #A1A1AA; font-variant-numeric: tabular-nums; }
.lb-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 99px; border: 1px solid rgba(255,255,255,.12); background: rgba(19,20,24,.7); color: #F4F4F5; cursor: pointer; font-size: 18px; line-height: 1; transition: background .2s, opacity .2s; }
.lb-btn:hover { background: rgba(255,255,255,.14); }
.lb-btn:disabled { opacity: 0; pointer-events: none; }
.lb-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lb-prev, .lb-next { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; }
.lb-prev { left: 16px; } .lb-next { right: 16px; }
.lb-cap { margin: 0 auto; max-width: 720px; padding: 4px 20px calc(20px + env(safe-area-inset-bottom)); font-size: 14px; line-height: 1.5; color: #D4D4D8; text-align: center; min-height: 1.5em; }
@media (hover: none), (max-width: 640px) { .lb-prev, .lb-next { display: none; } }
@media (prefers-reduced-motion: reduce) { .lb-anim, .lb-backdrop, .lb-ui { transition-duration: .01s; } }

/* ---------- Footer ---------- */
.footer { max-width: 1040px; margin: 0 auto; padding: 28px 16px 40px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; font-size: 13px; color: var(--faint); }
.footer a:hover { color: var(--text); }

/* ---------- Smaller screens ---------- */
@media (max-width: 860px) {
  .facts, .cards { grid-template-columns: 1fr 1fr; }
  .facts li:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .gallery { grid-template-columns: 1fr 1fr; }
  .timeline > li { grid-template-columns: 1fr; gap: 8px; }
}
/* The full nav (icons + Home) is 623px wide, so switch to the compact one below 660px */
@media (max-width: 660px) {
  .nav { top: 10px; }
  .nav svg, .nav .nav-home { display: none; }
  .nav a { padding: 7px 8px; font-size: 12.5px; }
  .theme-toggle svg { display: block; }
  .nav-sep { margin: 0 2px; }
}
@media (max-width: 560px) {
  .hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 400px; margin-inline: auto; }
  .hero-actions > :first-child:nth-last-child(odd) { grid-column: 1 / -1; }
  .hero-actions .btn { padding-inline: 12px; }
  .facts, .cards, .gallery { grid-template-columns: 1fr; }
  .shots-3 { grid-template-columns: 1fr 1fr; }
  .shots-3 img:last-child { grid-column: 1 / -1; }
  .section { padding-block: 72px; }
  .status { flex-wrap: wrap; justify-content: center; column-gap: 8px; row-gap: 0; border-radius: 18px; padding: 8px 16px; }
  .status-sep { display: none; }
  .status-loc { flex-basis: 100%; }
}
@media (max-width: 430px) {
  .nav { padding-inline: 4px; gap: 0; }
  .nav a { padding: 7px 6px; font-size: 12px; }
  .nav-sep { display: none; }
  .theme-toggle { padding: 7px 6px; }
}
@media (max-width: 360px) {
  .nav a { padding: 7px 4px; font-size: 11px; }
}
