:root {
  --bg: #0c0c0e;
  --surface: #141417;
  --surface-2: #1b1b1f;
  --line: #26262b;
  --text: #ededea;
  --muted: #9b9ba3;
  --dim: #64646c;
  --accent: #c8ff4d;
  --accent-ink: #0c0c0e;
  --t-k: #ff7ab8;
  --t-f: #7cc4ff;
  --t-s: #ffd479;
  --t-n: #c8ff4d;
  --t-c: #6b6f7a;
  --max: 1080px;
  --gutter: clamp(16px, 4vw, 40px);
  --font: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.mono { font-family: var(--mono); }
kbd {
  font-family: var(--mono);
  font-size: 0.9em;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
}

/* ---------- Header ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 64px;
  padding: 0 var(--gutter);
  background: rgba(12, 12, 14, 0.92);
  border-bottom: 1px solid var(--line);
}
.logo { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; text-decoration: none; }
.accent { color: var(--accent); }
.top nav { margin-left: auto; }
.nav { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.nav a {
  display: block;
  padding: 6px 12px;
  font-size: 15px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.nav a:hover, .nav a.active { color: var(--text); background: var(--surface-2); }

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.no-js .switch { display: none; }
.switch:hover { border-color: var(--accent); }
.switch-label { font-size: 13px; }
.switch-track {
  position: relative;
  width: 38px; height: 22px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background 0.25s, border-color 0.25s;
}
.switch-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.3s var(--ease), background 0.25s;
}
.switch[aria-checked="true"] .switch-track { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(16px); background: var(--accent-ink); }

/* ---------- Blocks ---------- */
.block {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(64px, 9vw, 112px) var(--gutter) 0;
}
.title {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 0 0 32px;
  font-size: clamp(32px, 4.4vw, 52px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}
.num { font-size: 0.32em; font-weight: 500; color: var(--accent); letter-spacing: 0; }

/* ---------- Hero ---------- */
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: center; gap: 24px; }
.glyphs { width: 100%; height: clamp(320px, 38vw, 480px); cursor: crosshair; touch-action: pan-y; }
html.src .hero-grid { grid-template-columns: 1fr; }
html.src .glyphs { height: 260px; }
.hero { padding-top: clamp(56px, 10vw, 128px); }
.eyebrow { display: flex; align-items: center; gap: 10px; margin: 0 0 22px; font-size: 13px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.name {
  margin: 0;
  font-size: clamp(54px, 10.5vw, 148px);
  font-weight: 750;
  letter-spacing: -0.055em;
  line-height: 0.9;
}
.pitch {
  margin: 14px 0 0;
  font-size: clamp(28px, 4.6vw, 58px);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.05;
  color: var(--muted);
}
.pitch em { font-style: normal; color: var(--accent); }
.intro { max-width: 36em; margin: 26px 0 30px; font-size: clamp(17px, 1.6vw, 20px); color: var(--muted); }
.intro a { color: var(--text); text-underline-offset: 4px; text-decoration-color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hint { margin: 34px 0 0; font-size: 12.5px; color: var(--dim); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  font: 600 15px/1 var(--font);
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.btn:hover { border-color: var(--accent); }
.btn-solid { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.btn-solid:hover { background: #d9ff85; }
#copy-email.copied { color: var(--accent); border-color: var(--accent); }

/* ---------- Project cards (flip to code) ---------- */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.card { perspective: 1400px; }
.card-wide { grid-column: 1 / -1; }
.card-inner {
  display: grid;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.7s var(--ease);
}
.card.flipped .card-inner { transform: rotateY(180deg); }
.face {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: clamp(22px, 3vw, 32px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.face.back { transform: rotateY(180deg); background: #0f0f12; }
.kind { margin: 0 0 6px; font-size: 12px; color: var(--accent); }
.card h3 { margin: 0 0 10px; font-size: clamp(28px, 3.2vw, 38px); font-weight: 700; letter-spacing: -0.04em; line-height: 1.05; }
.face > p { margin: 0 0 16px; color: var(--muted); }
.face > p.small { font-size: 14.5px; line-height: 1.55; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; }
.facts li { padding: 4px 9px; font-size: 12px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; }
.demos { margin: 0 0 16px; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.demos a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: color 0.2s;
}
.demos a span { font-weight: 400; color: var(--dim); font-size: 14px; }
.demos a:hover { color: var(--accent); }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 6px; }
.link { font-weight: 600; font-size: 15px; color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; text-underline-offset: 4px; }
.flip {
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.flip:hover { border-color: var(--accent); color: var(--accent); }
.file { margin: 0 0 12px; font-size: 12.5px; color: var(--text); }
.file span { color: var(--dim); }

/* ---------- Code ---------- */
.code {
  flex: 1;
  margin: 0 0 14px;
  padding: 0;
  overflow: auto;
  font-size: 12.5px;
  line-height: 1.7;
  color: #d4d6dc;
  tab-size: 2;
}
.card-wide .code { max-height: 200px; }
.t-k { color: var(--t-k); }
.t-f { color: var(--t-f); }
.t-s { color: var(--t-s); }
.t-n { color: var(--t-n); }
.t-c { color: var(--t-c); }

/* ---------- Skills graph ---------- */
.graph-wrap { position: relative; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.graph { display: block; width: 100%; height: clamp(380px, 42vw, 500px); cursor: grab; touch-action: pan-y; }
.graph.dragging { cursor: grabbing; }
.graph-hint { position: absolute; right: 16px; top: 12px; margin: 0; font-size: 11.5px; color: var(--dim); pointer-events: none; }

/* ---------- Skills ---------- */
.skills { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.skill { padding: 22px 24px; background: var(--surface); }
.skill h3 { margin: 0 0 6px; font-size: 13px; font-weight: 500; color: var(--accent); }
.skill p { margin: 0; font-size: 16.5px; }

/* ---------- Experience ---------- */
.jobs { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.jobs li { display: grid; grid-template-columns: 110px 1fr; gap: 4px 24px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.when { padding-top: 3px; font-size: 13px; color: var(--accent); }
.jobs h3 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.jobs p { margin: 4px 0 0; color: var(--muted); font-size: 15.5px; }

/* ---------- Contact ---------- */
.big { margin: 0 0 26px; max-width: 18em; font-size: clamp(28px, 4.2vw, 50px); font-weight: 650; letter-spacing: -0.04em; line-height: 1.1; }
.big a { color: var(--accent); text-underline-offset: 6px; }
.footer { max-width: var(--max); margin: 0 auto; padding: 80px var(--gutter) 40px; font-size: 12.5px; color: var(--dim); }

/* ---------- Source mode ---------- */
.src-panel { display: none; }
html.src body { background-image: radial-gradient(rgba(200, 255, 77, 0.07) 1px, transparent 1px); background-size: 22px 22px; }
html.src .block {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
  max-width: 1480px;
  align-items: start;
}
html.src .src-panel {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  background: #0f0f12;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  animation: slide-in 0.45s var(--ease);
}
@keyframes slide-in { from { opacity: 0; transform: translateX(24px); } }
.src-head { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; font-size: 12px; color: var(--muted); background: var(--surface); border-bottom: 1px solid var(--line); }
.src-head b { color: var(--text); font-weight: 500; }
.src-panel .code { margin: 0; padding: 14px 0; font-size: 12px; line-height: 1.65; }
#self-code .ln::before { width: 2.6em; margin-right: 10px; }
.code .ln { display: block; padding: 0 14px 0 0; white-space: pre; }
.code .ln::before {
  counter-increment: ln;
  content: counter(ln);
  display: inline-block;
  width: 3.4em;
  margin-right: 12px;
  padding-right: 8px;
  text-align: right;
  color: var(--dim);
  border-right: 1px solid var(--line);
}
.t-tag { color: var(--t-k); }
.t-attr { color: var(--t-f); }
/* devtools-style outlines on the rendered side */
html.src .content * { outline: 1px dashed rgba(200, 255, 77, 0.16); outline-offset: -1px; }
html.src .content .code * { outline: 0; }
html.src .card.flipped .card-inner { transform: none; }

.inspect {
  position: fixed;
  z-index: 60;
  display: none;
  padding: 4px 8px;
  font-size: 11.5px;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
}
.inspect span { opacity: 0.65; }
html.src .inspect.on { display: block; }

/* ---------- Reveal ---------- */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  html.src .block { grid-template-columns: 1fr; }
  html.src .src-panel { position: static; max-height: 360px; }
}
@media (max-width: 760px) {
  body { font-size: 16px; }
  .top { gap: 12px; height: 58px; }
  .top nav { display: none; }
  .switch { margin-left: auto; }
  .cards, .skills { grid-template-columns: 1fr; }
  .hero-grid { grid-template-columns: 1fr; }
  .glyphs { order: -1; height: 220px; margin-bottom: -8px; }
  .graph { height: 560px; }
  .graph-hint { display: none; }
  .jobs li { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  .reveal { opacity: 1; transform: none; }
}
.no-js .reveal { opacity: 1; transform: none; }
