:root,
:root[data-theme="dark"] {
  --bg: #0D100F;
  --surface: #141816;
  --line: #262C29;
  --line2: #3A423E;
  --text: #E6E9E4;
  --body: #C9CFCB;
  --muted: #A3ABA6;
  --faint: #7D8681;
  --accent: #7FDC8F;
  --on-accent: #0D100F;
  --branch: #E8B65A;
  --error: #FF8A7A;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #F6F7F4;
  --surface: #ECEEEA;
  --line: #D9DCD6;
  --line2: #B4B9B2;
  --text: #121513;
  --body: #343A36;
  --muted: #565D58;
  --faint: #6B726D;
  --accent: #1D7A34;
  --on-accent: #FFFFFF;
  --branch: #94600A;
  --error: #B42318;
  color-scheme: light;
}

:root {
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 96px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  transition: background 200ms, color 200ms;
}

[hidden] { display: none !important; }

a { color: inherit; }
img { max-width: 100%; }
button { font: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.accent { color: var(--accent); }

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  flex-direction: column;
}

/* ---------- nav ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  transition: background 200ms;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 14px;
}
.brand { text-decoration: none; font-weight: 700; color: var(--text); }
.nav-links { display: flex; flex-wrap: wrap; align-items: center; gap: 28px; margin-left: auto; }
.nav-links a { text-decoration: none; color: var(--muted); }
.nav-links a:hover { color: var(--text); }
.nav-links a.accent { color: var(--accent); }
.nav-actions { display: flex; align-items: center; gap: 4px; }

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--line2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
}
/* Dark theme shows "switch to light" (sun); light theme shows "switch to dark" (moon). */
.theme-toggle .icon-moon, .theme-toggle .label-dark { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun,
:root[data-theme="light"] .theme-toggle .label-light { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon,
:root[data-theme="light"] .theme-toggle .label-dark { display: inline; }

.menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
}
.menu-toggle .icon-close { display: none; }
.menu-toggle[aria-expanded="true"] .icon-menu { display: none; }
.menu-toggle[aria-expanded="true"] .icon-close { display: block; }

.mobile-menu {
  display: flex;
  flex-direction: column;
  padding: 8px 20px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 20px;
}
.mobile-menu a { text-decoration: none; color: var(--text); padding: 14px 0; border-bottom: 1px solid var(--line); }
.mobile-menu a:last-child { border-bottom: 0; }
.mobile-menu a.accent { color: var(--accent); }
.mobile-menu span { color: var(--muted); }

/* ---------- hero ---------- */

.hero {
  padding: 112px 0 96px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.prompt { font-family: var(--mono); font-size: 14px; color: var(--muted); }
.hero h1 {
  margin: 0;
  font-family: var(--mono);
  font-weight: 800;
  font-size: clamp(44px, 7vw, 84px);
  line-height: 1.02;
  letter-spacing: -0.03em;
}
.cursor { color: var(--accent); animation: cursor-blink 1.1s steps(1) infinite; }
@keyframes cursor-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cursor { animation: none; } }

.lede {
  margin: 0;
  max-width: 680px;
  font-size: 22px;
  line-height: 1.5;
  color: var(--body);
  text-wrap: pretty;
}

.cta { display: flex; flex-wrap: wrap; gap: 12px; }

.btn {
  display: inline-block;
  padding: 12px 20px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  text-decoration: none;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--on-accent); border: 0; font-weight: 700; }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line2); }
.btn-ghost.muted { color: var(--muted); }

.panel {
  position: relative;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-family: var(--mono);
  font-size: 14px;
}
.cv-sent { padding: 20px 24px; gap: 6px; }
.panel-copy { margin: 0; font-family: var(--sans); font-size: 15px; color: var(--body); }
.status-warn { color: var(--branch); font-weight: 700; }
.status-ok { color: var(--accent); font-weight: 700; }

.cv-form label { display: flex; flex-direction: column; gap: 6px; }
.field-label { color: var(--muted); }
.cv-form input,
.cv-form textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line2);
  border-radius: 0;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
}
.cv-form textarea { resize: vertical; }
.cv-form input[aria-invalid="true"] { border-color: var(--error); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.turnstile { min-height: 65px; }
.form-error { margin: 0; color: var(--error); }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

/* ---------- sections ---------- */

.section {
  padding: 72px 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.section h2 {
  margin: 0;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

/* career log */

.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; font-family: var(--mono); }
.commit { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 20px; padding-bottom: 36px; }
.commit.is-root { padding-bottom: 0; }
.rail { display: flex; flex-direction: column; align-items: center; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--faint); margin-top: 8px; }
.is-head .dot { border: 0; background: var(--accent); }
.rail .line { flex: 1; width: 2px; background: var(--line); margin-top: 6px; }
.entry { display: flex; flex-direction: column; gap: 8px; }
.when { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--muted); }
.branch { color: var(--branch); }
.entry h3 { margin: 0; font-size: 20px; font-weight: 700; line-height: 1.4; }
.entry p { margin: 0; max-width: 720px; font-family: var(--sans); color: var(--body); }
.entry p.strong-body { color: var(--text); }
.entry strong { font-weight: 700; color: var(--accent); }

/* skills */

.skills {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 32px;
  font-family: var(--mono);
  font-size: 15px;
  line-height: 2;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 16px 48px;
}
.skills > div { display: flex; flex-direction: column; }

/* projects */

.projects { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 20px; }
.project {
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.project img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border: 1px solid var(--line);
}
.project-name { font-family: var(--mono); font-size: 20px; font-weight: 700; }
.project p { margin: 0; color: var(--body); font-size: 15px; }

/* links */

.links { display: flex; flex-direction: column; font-family: var(--mono); font-size: 18px; }
.links a {
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.link-name { font-weight: 700; min-width: 110px; }
.exit { font-family: var(--mono); font-size: 12px; color: var(--faint); padding-top: 48px; }

/* ---------- mobile ---------- */

@media (max-width: 640px) {
  html { scroll-padding-top: 72px; }
  body { font-size: 16px; }
  .wrap { padding: 0; }

  .nav { flex-wrap: nowrap; padding: 8px 12px 8px 20px; }
  .nav-links { display: none; }
  .theme-toggle { width: 44px; padding: 0; justify-content: center; border: none; }
  .theme-toggle svg { width: 20px; height: 20px; }
  .theme-toggle .label-light,
  .theme-toggle .label-dark,
  :root[data-theme="light"] .theme-toggle .label-dark { display: none; }
  .menu-toggle { display: flex; }

  .hero { padding: 64px 20px 56px; gap: 20px; }
  .prompt { font-size: 13px; }
  .hero h1 { font-size: 52px; line-height: 1; }
  .lede { font-size: 19px; }
  .cta { flex-direction: column; gap: 10px; padding-top: 4px; }
  .cta .btn { padding: 14px 20px; text-align: center; }

  .panel { max-width: none; padding: 18px; gap: 14px; font-size: 13px; }
  .cv-form input, .cv-form textarea { font-size: 16px; }
  .form-actions { flex-direction: column; gap: 12px; }
  .form-actions .btn { padding: 14px 20px; }
  .meta { flex-direction: column; gap: 4px; padding-top: 8px; }

  .section { padding: 48px 20px; gap: 28px; }
  .section h2 { font-size: 13px; }

  .commit { grid-template-columns: 16px minmax(0, 1fr); gap: 16px; padding-bottom: 32px; }
  .dot { margin-top: 6px; }
  .entry { gap: 6px; }
  .when { gap: 4px 10px; font-size: 12px; }
  .entry h3 { font-size: 17px; line-height: 1.35; }
  .entry p { font-size: 15px; }

  .skills { padding: 20px; font-size: 14px; line-height: 1.9; }
  .projects { gap: 16px; }
  .project { padding: 20px; gap: 12px; }
  .project-name { font-size: 18px; }

  .links { font-size: 15px; }
  .links a { display: block; padding: 14px 0; }
  .link-name { min-width: 0; }
  .links a .muted { margin-left: 0.6em; }
  .links a .accent { display: block; margin-top: 2px; }
  .exit { padding-top: 32px; }
}

@media (min-width: 641px) {
  .mobile-menu { display: none !important; }
}
