/* ---------- Theme ---------- */
:root {
  --bg: #f7f8fa;
  --bg-alt: #eef1f5;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #526077;
  --border: #dde3ea;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #d8f0ec;
  --on-accent: #ffffff;
  --chip: #eef2f6;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 20px rgba(15, 23, 42, .06);
  --term-bg: #0b1220;
  --term-text: #d6e2f0;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
:root[data-theme="dark"] {
  --bg: #0b1017;
  --bg-alt: #0f161f;
  --surface: #141c27;
  --text: #e6edf5;
  --muted: #9aa8bb;
  --border: #243142;
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --accent-soft: #123b39;
  --on-accent: #062522;
  --chip: #1b2533;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --term-bg: #060a10;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1017;
    --bg-alt: #0f161f;
    --surface: #141c27;
    --text: #e6edf5;
    --muted: #9aa8bb;
    --border: #243142;
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --accent-soft: #123b39;
    --on-accent: #062522;
    --chip: #1b2533;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --term-bg: #060a10;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h2 { font-size: clamp(1.6rem, 3vw, 2rem); letter-spacing: -.01em; }
h2::after {
  content: ""; display: block; width: 44px; height: 4px; margin-top: .45em;
  background: var(--accent); border-radius: 4px;
}
h3 { font-size: 1.12rem; }
p { margin: 0 0 1em; }
ul { padding-left: 1.2em; }
.container { width: min(1120px, 100% - 40px); margin-inline: auto; }
.narrow > p, .narrow > .timeline, .contact > .contact-links { max-width: 820px; }
.muted { color: var(--muted); }
.small-text { font-size: .9rem; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip-link:focus { left: 8px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 20px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); color: var(--on-accent); font-size: .85rem; letter-spacing: .02em;
}
.nav { display: flex; gap: 22px; margin-left: auto; }
.nav a { color: var(--muted); text-decoration: none; font-size: .95rem; font-weight: 500; }
.nav a:hover { color: var(--text); }
.theme-toggle {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ---------- Buttons, chips, cards ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: .95rem;
  text-decoration: none; transition: transform .12s ease, border-color .12s ease;
}
.btn:hover { color: var(--text); border-color: var(--accent); transform: translateY(-1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { color: var(--on-accent); background: var(--accent-strong); }
.btn-small { padding: 7px 12px; font-size: .88rem; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { background: var(--chip); border: 1px solid var(--border); padding: 5px 11px; border-radius: 999px; font-size: .9rem; }
.chips.small li { font-size: .8rem; padding: 3px 9px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}

/* ---------- Hero ---------- */
.hero { padding: 76px 0 64px; }
.hero-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 48px; align-items: center; }
.avatar { display: block; margin-bottom: 22px; }
.avatar img {
  display: block; width: 168px; height: 168px; border-radius: 50%; object-fit: cover;
  border: 4px solid var(--surface); box-shadow: 0 0 0 2px var(--accent), var(--shadow);
}
.eyebrow { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; font-size: .92rem; margin-bottom: 14px; }
.hero h1 { font-size: clamp(2.3rem, 6vw, 3.6rem); letter-spacing: -.025em; margin-bottom: .15em; }
.headline { font-size: clamp(1.15rem, 2.4vw, 1.45rem); font-weight: 600; color: var(--muted); margin-bottom: .9em; }
.lead { font-size: 1.08rem; max-width: 38em; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 26px 0 18px; }
.social { list-style: none; padding: 0; margin: 0; display: flex; gap: 20px; }
.social a { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); text-decoration: none; font-weight: 500; }
.social a:hover { color: var(--text); }

.terminal {
  background: var(--term-bg); color: var(--term-text); border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(2, 8, 23, .25); overflow: hidden; border: 1px solid #1e293b;
}
.terminal-bar { display: flex; align-items: center; gap: 7px; padding: 12px 14px; background: rgba(255,255,255,.04); }
.terminal-bar span { width: 11px; height: 11px; border-radius: 50%; background: #ef4444; }
.terminal-bar span:nth-child(2) { background: #f59e0b; }
.terminal-bar span:nth-child(3) { background: #22c55e; }
.terminal-bar em { margin-left: auto; font-style: normal; font-family: var(--mono); font-size: .75rem; color: #8193aa; }
.terminal pre { margin: 0; padding: 18px 20px 8px; font-family: var(--mono); font-size: .86rem; line-height: 1.65; overflow-x: auto; }
.t-prompt { color: #2dd4bf; }
.terminal-link { display: block; padding: 6px 20px 16px; font-family: var(--mono); font-size: .82rem; color: #5eead4; }
.terminal-link:hover { color: #99f6e4; }

/* ---------- Sections ---------- */
.section { padding: 68px 0; }
.section.alt { background: var(--bg-alt); border-block: 1px solid var(--border); }
.section .narrow > p { font-size: 1.05rem; }

.skills-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.skill-card h3 { color: var(--accent); font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 14px; }

.projects-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
.project-card { display: flex; flex-direction: column; }
.project-card > p { color: var(--muted); }
.project-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.project-head h3 { margin-bottom: .3em; }
.badge {
  flex-shrink: 0; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 4px 9px; border-radius: 999px; background: var(--chip); color: var(--muted); border: 1px solid var(--border);
}
.badge-public { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.period { color: var(--muted); font-size: .88rem; font-weight: 500; margin-bottom: .6em; }
.ticks { list-style: none; padding: 0; margin: 0 0 18px; }
.ticks li { position: relative; padding-left: 22px; margin-bottom: 6px; font-size: .95rem; }
.ticks li::before { content: ""; position: absolute; left: 2px; top: .6em; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }
.project-foot { margin-top: auto; padding-top: 18px; }

.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--border); }
.timeline > li { position: relative; padding: 0 0 26px 26px; }
.timeline > li::before {
  content: ""; position: absolute; left: -8px; top: 6px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent);
}
.timeline > li:last-child { padding-bottom: 0; }
.timeline .period { margin: 0 0 .2em; color: var(--accent); font-weight: 600; }
.timeline h3 { margin-bottom: .25em; }
.at { color: var(--muted); font-weight: 500; }
.timeline ul { margin: .3em 0 0; color: var(--muted); }
.timeline ul li { margin-bottom: 4px; }

.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 40px; }
.school { font-weight: 500; margin-bottom: .2em; }
.edu-card.has-photo { display: grid; grid-template-columns: minmax(150px, 210px) 1fr; gap: 24px; align-items: start; }
.edu-photo { display: block; margin: 0; }
.edu-photo img {
  display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover;
  border-radius: calc(var(--radius) - 4px); border: 1px solid var(--border); background: var(--chip);
}
.edu-body > :last-child { margin-bottom: 0; }
.lang-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.lang-list li { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; }

.contact-links { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }

.site-footer { padding: 30px 0; border-top: 1px solid var(--border); font-size: .9rem; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px; }
.footer-inner p { margin: 0; }
.not-found { text-align: center; padding: 60px 0; }
.not-found h2::after { margin-inline: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; gap: 36px; }
  .skills-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .nav { display: none; }
  .theme-toggle { margin-left: auto; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .edu-card.has-photo { grid-template-columns: 1fr; gap: 18px; }
  .edu-photo { max-width: 300px; width: 100%; margin: 0 auto; }
  body { font-size: 16px; }
  .hero { padding: 44px 0 40px; }
  .section { padding: 48px 0; }
  .skills-grid { grid-template-columns: 1fr; }
  .projects-grid { grid-template-columns: 1fr; }
  .card { padding: 18px; }
  .project-head { flex-direction: column-reverse; gap: 8px; }
  .terminal pre { font-size: .78rem; }
  .actions .btn { flex: 1 1 auto; justify-content: center; }
  .contact-links .btn { width: 100%; justify-content: center; }
  .brand-name { font-size: .95rem; }
  .avatar img { width: 132px; height: 132px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn { transition: none; }
}
