:root[data-theme="dark"] {
  --bg: #0a0a0a; --text: #f2f2f2; --dim: #a3a3a3; --faint: #6b6b6b;
  --line: #232323; --card: #141414; --accent: #ff2390; --accent-ink: #ffffff;
}
:root[data-theme="light"] {
  --bg: #fafaf7; --text: #141414; --dim: #52525b; --faint: #a1a1aa;
  --line: #e4e4e0; --card: #ffffff; --accent: #be185d; --accent-ink: #ffffff;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--text);
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  line-height: 1.65; -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
h1, h2, .display { font-family: "Clash Display", ui-monospace, monospace; }
a { color: inherit; text-decoration: none; }
main, .nav, .foot { max-width: 1000px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }

.nav {
  position: sticky; top: 12px; z-index: 10; display: flex; justify-content: space-between;
  overflow: hidden;
  align-items: center; margin-top: 14px; padding: 10px 20px; border-radius: 16px;
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
}
.nav { max-width: 952px; }
@media (max-width: 1000px) { .nav { margin-left: 12px; margin-right: 12px; } }
.wordmark { font-size: 14px; font-weight: 700; letter-spacing: .5px; }
.nav-right { display: flex; align-items: center; gap: 22px; }
.nav-link { font-size: 13px; color: var(--dim); }
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--accent); }
#nav-progress {
  position: absolute; left: 0; bottom: 0; height: 2px; width: 0;
  background: var(--accent); border-radius: 2px;
}
.kbd-hint { color: var(--faint); }
#theme-toggle {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: none; color: var(--text); cursor: pointer;
}
#theme-toggle:hover { border-color: var(--faint); }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: none; }

section { padding: 88px 0 0; }
.label { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--faint); margin-bottom: 28px; }
.label::before { content: "// "; color: var(--accent); }

@media (max-width: 640px) {
  .nav-link { display: none; }
  section { padding-top: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 40px;
  padding-top: 96px; min-height: 62vh;
}
.kicker { font-size: 13px; color: var(--accent); letter-spacing: 1.5px; margin-bottom: 18px; }
.headline { font-size: clamp(32px, 7.5vw, 76px); font-weight: 600; line-height: 1.05; letter-spacing: -1px; }
.hl-line { display: block; overflow: hidden; }
.hl-line span { display: inline-block; transform: translateY(110%); animation: rise .7s cubic-bezier(.2,.7,.2,1) forwards; }
.hl-line:nth-child(2) span { animation-delay: .12s; }
@keyframes rise { to { transform: translateY(0); } }
.hero-sub { color: var(--dim); font-size: 15px; margin-top: 22px; max-width: 480px; }
.accent-link { color: var(--accent); border-bottom: 1px solid transparent; }
.accent-link:hover { border-bottom-color: var(--accent); }
.hero-links { display: flex; align-items: center; gap: 12px; margin-top: 32px; flex-wrap: wrap; }
.icon-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); color: var(--dim);
  transition: color .2s ease, border-color .2s ease, transform .2s ease;
}
.icon-link:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px); }
.cta {
  display: inline-flex; align-items: center; gap: 8px; margin-left: 8px;
  padding: 9px 18px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--accent); color: var(--accent);
  transition: background .2s ease, color .2s ease;
}
.cta:hover { background: var(--accent); color: var(--accent-ink); }
.ic { width: 16px; height: 16px; fill: currentColor; }
.ic-s { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cta .ic { width: 14px; height: 14px; }

.portrait { position: relative; flex: 0 0 auto; width: 260px; height: 260px; display: grid; place-items: center; }
.portrait img { width: 200px; height: 200px; border-radius: 50%; object-fit: cover; display: block; }
.orbit { position: absolute; inset: 0; width: 100%; height: 100%; animation: spin 22s linear infinite; }
.orbit text { font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; letter-spacing: 2.5px; fill: var(--faint); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .hero { flex-direction: column-reverse; align-items: flex-start; gap: 28px; padding-top: 48px; min-height: 0; }
  .portrait { width: 170px; height: 170px; }
  .portrait img { width: 128px; height: 128px; }
}

.work { list-style: none; }
.row {
  display: flex; align-items: center; gap: 20px; padding: 30px 4px;
  border-top: 1px solid var(--line); transition: padding-left .25s ease;
}
.work li:last-child .row { border-bottom: 1px solid var(--line); }
.row h2 { font-size: clamp(26px, 4vw, 42px); font-weight: 600; letter-spacing: -.5px; }
.row p { color: var(--dim); font-size: 14px; max-width: 560px; margin-top: 6px; }
.row .tags { font-size: 12px; color: var(--faint); margin-top: 10px; }
.sub-link { color: var(--faint); text-decoration: underline; }
.sub-link:hover { color: var(--accent); }
.arrow { margin-left: auto; font-size: 22px; color: var(--faint); transition: transform .25s ease, color .25s ease; }
.row-thumb {
  display: block; width: 300px; height: auto; flex: 0 0 auto;
  border-radius: 10px; border: 1px solid var(--line);
  transition: border-color .25s ease;
}
@media (hover: hover) and (pointer: fine) {
  .row:hover { padding-left: 14px; }
  .row:hover h2 { color: var(--accent); }
  .row:hover .arrow { color: var(--accent); transform: translate(3px,-3px); }
  .row:hover .row-thumb { border-color: var(--accent); }
}
@media (max-width: 760px) {
  .row { flex-direction: column; align-items: flex-start; }
  .row-thumb { width: 100%; }
  .arrow { display: none; }
}

.about-text { font-size: 16px; max-width: 640px; color: var(--text); }
.skills { margin-top: 24px; font-size: 12.5px; color: var(--faint); letter-spacing: .3px; }

.contact-head { font-size: clamp(28px, 5.4vw, 54px); font-weight: 600; letter-spacing: -1px; }
.contact-links { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 30px; }

.foot { margin-top: 120px; padding-top: 26px; padding-bottom: 36px; border-top: 1px solid var(--line); }
.foot-meta {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex-wrap: wrap; font-size: 12px; color: var(--faint);
}
.counter {
  font-variant-numeric: tabular-nums; border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 14px;
}
.counter::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin-right: 8px; vertical-align: 1px;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .3; } }
.top-link:hover { color: var(--text); }

#dither {
  position: absolute; top: 0; left: 0; width: 100%; height: min(92vh, 860px);
  z-index: -1; opacity: .48; pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 45%, transparent 100%);
}
:root[data-theme="light"] #dither { opacity: .34; }
:root[data-theme="dark"] .hero-text { text-shadow: 0 2px 24px rgba(0,0,0,.5); }

#cat {
  position: fixed; bottom: -2px; left: 0; z-index: 30;
  pointer-events: none; will-change: transform;
}
#cat .cat-flip { transition: transform .25s ease; }
#cat canvas { display: block; image-rendering: pixelated; }
@media (hover: none), (max-width: 760px) { #cat { display: none; } }

#palette, #term {
  position: fixed; inset: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; justify-content: center; align-items: flex-start; padding: 14vh 20px 0;
}
#palette[hidden], #term[hidden] { display: none; }
.pal-box {
  width: 100%; max-width: 520px; border-radius: 14px; overflow: hidden;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.6);
}
#pal-input {
  width: 100%; padding: 16px 18px; font: inherit; font-size: 15px;
  background: none; border: none; border-bottom: 1px solid var(--line);
  color: var(--text); outline: none;
}
#pal-list { list-style: none; max-height: 320px; overflow-y: auto; padding: 6px; }
#pal-list li {
  padding: 10px 12px; border-radius: 8px; font-size: 13.5px; color: var(--dim);
  cursor: pointer; display: flex; justify-content: space-between; align-items: center;
}
#pal-list li .hint { font-size: 11px; color: var(--faint); }
#pal-list li.sel { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text); }
.term-box {
  width: 100%; max-width: 640px; border-radius: 12px; overflow: hidden;
  background: #0c0c0c; border: 1px solid #262626; color: #d8d8d8;
  font-size: 13px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.7);
}
.term-head {
  padding: 9px 14px; font-size: 11px; color: #737373; background: #161616;
  display: flex; align-items: center; gap: 7px;
}
.term-head span { width: 10px; height: 10px; border-radius: 50%; background: #333; }
.term-head span:first-child { background: #ff5f57; }
.term-head span:nth-child(2) { background: #febc2e; }
.term-head span:nth-child(3) { background: #28c840; }
#term-out { padding: 14px 16px 4px; max-height: 300px; overflow-y: auto; white-space: pre-wrap; line-height: 1.55; }
#term-out .t-accent { color: #ff2390; }
.term-line { display: flex; align-items: center; padding: 4px 16px 14px; color: #ff2390; }
#term-input {
  flex: 1; background: none; border: none; outline: none; color: #d8d8d8;
  font: inherit; caret-color: #ff2390;
}
@media (max-width: 640px) { .kbd-hint { display: none; } }

.reveal { opacity: 0; transform: translateY(12px); transition: opacity .5s ease, transform .5s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } }
