/* ---------- Tokens ---------- */
:root {
  --bg: #f7f8fa;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --border: #e3e7ed;
  --text: #0f1720;
  --text-2: #4a5565;
  --text-3: #7a8494;
  --accent: #0f9d8a;
  --accent-2: #e8a33d;
  --accent-soft: rgba(15, 157, 138, .1);
  --term-bg: #0d1218;
  --term-text: #d6dde6;
  --shadow: 0 1px 2px rgba(15, 23, 32, .04), 0 8px 24px rgba(15, 23, 32, .06);
  --radius: 14px;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Space Grotesk", var(--font-sans);
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f14;
    --bg-2: #10161d;
    --surface: #121a22;
    --border: #212c38;
    --text: #e8edf3;
    --text-2: #a7b1be;
    --text-3: #6f7b8a;
    --accent: #2dd4bf;
    --accent-2: #f5b54a;
    --accent-soft: rgba(45, 212, 191, .1);
    --term-bg: #070a0e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f14;
  --bg-2: #10161d;
  --surface: #121a22;
  --border: #212c38;
  --text: #e8edf3;
  --text-2: #a7b1be;
  --text-3: #6f7b8a;
  --accent: #2dd4bf;
  --accent-2: #f5b54a;
  --accent-soft: rgba(45, 212, 191, .1);
  --term-bg: #070a0e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; margin: 0; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code { font-family: var(--font-mono); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i-fill { fill: currentColor; stroke: none; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }
.dim { color: var(--text-3); }
.accent { color: var(--accent); }
.nowrap { white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.nav.scrolled { border-bottom-color: var(--border); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-family: var(--font-head); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 14px; letter-spacing: .02em;
}
.nav-links { display: flex; gap: 4px; }
.nav-links a { color: var(--text-2); padding: 8px 12px; border-radius: 8px; font-size: 15px; }
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--accent-soft); text-decoration: none; }
.nav-actions { display: flex; gap: 6px; }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { color: var(--text); }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}
.menu-btn { display: none; }
@media (max-width: 760px) {
  .menu-btn { display: grid; }
  .nav-links {
    position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; padding: 8px 16px 16px;
    background: var(--bg); border-bottom: 1px solid var(--border); display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px; }
}

/* ---------- Buttons ---------- */
.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: 500 15px var(--font-sans); cursor: pointer; transition: transform .15s, border-color .15s, background .15s;
}
.btn:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #04201c; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #04201c; } }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.big { padding: 14px 22px; font-size: 16px; }

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 48px; align-items: center;
  padding-top: 72px; padding-bottom: 72px; min-height: min(calc(100vh - 64px), 820px);
}
@media (max-width: 920px) { .hero { grid-template-columns: minmax(0, 1fr); min-height: 0; padding-top: 48px; gap: 40px; } }
.eyebrow { display: inline-flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 14px; margin-bottom: 20px;
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); animation: pulse 2s infinite; flex: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
.hero h1 { font-size: clamp(40px, 7vw, 68px); font-weight: 700; margin-bottom: 16px; }
.role { font-size: clamp(17px, 2.2vw, 20px); color: var(--text-2); margin-bottom: 16px; }
.role strong { color: var(--text); font-weight: 600; }
.lead { color: var(--text-2); max-width: 56ch; }
.lead b { color: var(--text); }
.cta { display: flex; flex-wrap: wrap; gap: 10px; margin: 28px 0 36px; }
.stats { list-style: none; padding: 0; margin: 0; display: flex; gap: 32px; flex-wrap: wrap; }
.stats li { display: flex; flex-direction: column; }
.stats b { font-family: var(--font-head); font-size: 30px; line-height: 1; }
.stats span { color: var(--text-3); font-size: 13px; margin-top: 6px; }

.terminal { background: var(--term-bg); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid #1e2833; overflow: hidden; min-width: 0; }
.term-bar { display: flex; align-items: center; gap: 7px; padding: 12px 14px; border-bottom: 1px solid #1a232d; }
.term-bar i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.term-bar i:nth-child(2) { background: #febc2e; }
.term-bar i:nth-child(3) { background: #28c840; }
.term-bar span { margin-left: 8px; color: #6b7684; font: 12px var(--font-mono); }
.term-body { margin: 0; padding: 20px 22px 24px; color: var(--term-text); font: 13.5px/1.75 var(--font-mono); overflow-x: auto; }
@media (max-width: 480px) { .term-body { font-size: 11.5px; padding: 16px; } }
.term-body .p { color: #2dd4bf; }
.term-body .o { color: #f5b54a; }
.term-body .k { color: #8ab4ff; }
.caret { display: inline-block; width: 8px; height: 1.1em; background: #2dd4bf; vertical-align: text-bottom; margin-left: 2px; animation: blink 1s steps(1) infinite; }
#loopWord { color: #f5b54a; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Sections ---------- */
.section { padding-top: 88px; padding-bottom: 32px; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 36px; }
.section-head .num { font: 500 14px var(--font-mono); color: var(--accent); }
.section-head h2 { font-size: clamp(28px, 4vw, 38px); }
.section-head::after { content: ""; flex: 1; height: 1px; background: var(--border); align-self: center; margin-left: 8px; }

/* About */
.about-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 48px; }
@media (max-width: 860px) { .about-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; } }
.about-text p { color: var(--text-2); font-size: 17px; }
.about-text strong { color: var(--text); font-weight: 600; }
.motto code { display: inline-block; padding: 8px 14px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 14px; }
.focus { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.focus li { display: flex; gap: 14px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.focus-ico { font-size: 22px; line-height: 1.3; }
.focus h3 { font-size: 16px; margin-bottom: 4px; }
.focus p { margin: 0; color: var(--text-2); font-size: 14.5px; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 190px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.timeline > li { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 40px; margin-bottom: 24px; position: relative; }
.timeline > li::before {
  content: ""; position: absolute; left: 184px; top: 22px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--text-3);
}
.timeline > li.current::before { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.tl-meta { text-align: right; padding-top: 16px; display: flex; flex-direction: column; }
.tl-meta .date { font: 500 13.5px var(--font-mono); color: var(--text); }
.tl-meta .place { font-size: 13px; color: var(--text-3); }
.tl-card { padding: 20px 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.tl-card h3 { font-size: 19px; }
.tl-card .company { color: var(--accent); font-weight: 500; margin: 4px 0 12px; }
.tl-card p, .tl-card li { color: var(--text-2); font-size: 15px; }
.tl-card ul { padding-left: 18px; margin: 0 0 14px; }
.tl-card li { margin-bottom: 6px; }
.tl-card li b { color: var(--text); font-weight: 600; }
@media (max-width: 720px) {
  .timeline::before { left: 6px; }
  .timeline > li { grid-template-columns: minmax(0, 1fr); gap: 8px; padding-left: 30px; }
  .timeline > li::before { left: 0; top: 4px; }
  .tl-meta { text-align: left; padding-top: 0; flex-direction: row; gap: 10px; flex-wrap: wrap; }
  .tl-card { padding: 18px; }
}
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { font: 12px var(--font-mono); padding: 4px 9px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }

.edu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 40px; }
@media (max-width: 860px) { .edu { grid-template-columns: 1fr; } }
.edu-card { display: flex; gap: 14px; padding: 16px 18px; border: 1px dashed var(--border); border-radius: var(--radius); }
.edu-ico { font-size: 22px; }
.edu-card h3 { font-size: 15.5px; margin-bottom: 4px; }
.edu-card p { margin: 0; color: var(--text-3); font-size: 13.5px; }

/* Projects */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.chip {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font: 500 14px var(--font-sans); cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.projects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 980px) { .projects { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .projects { grid-template-columns: 1fr; } }
.card {
  display: flex; flex-direction: column; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); transition: transform .2s, border-color .2s, box-shadow .2s; min-width: 0;
}
.card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); box-shadow: var(--shadow); }
.card.feature { grid-column: span 1; background: linear-gradient(160deg, var(--accent-soft), var(--surface) 55%); }
@media (min-width: 981px) { .card.feature { grid-column: span 1; } .projects .card.feature:first-child { grid-column: span 2; } }
.card[hidden] { display: none; }
.card-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 12px; font: 12.5px var(--font-mono); }
.card-top .kind { color: var(--accent); }
.card-top .year { color: var(--text-3); }
.card h3 { font-size: 19px; margin-bottom: 10px; }
.card p { color: var(--text-2); font-size: 14.5px; flex: 1; }
.card p b { color: var(--text); font-weight: 600; }
.card .links { display: flex; gap: 16px; margin-top: 14px; font-weight: 500; font-size: 14.5px; }

.live { margin-top: 40px; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-2); }
.live-title { display: flex; align-items: center; gap: 10px; font-size: 16px; margin-bottom: 14px; }
.live-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 860px) { .live-list { grid-template-columns: 1fr; } }
.live-list a { display: block; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); min-width: 0; }
.live-list a:hover { border-color: var(--accent); text-decoration: none; }
.live-list .rn { font: 500 14px var(--font-mono); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-list .rm { font-size: 12.5px; color: var(--text-3); }

/* Skills */
.skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 860px) { .skills { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .skills { grid-template-columns: 1fr; } }
.skill-group { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.skill-group h3 { font-size: 15px; margin-bottom: 14px; color: var(--text-2); font-family: var(--font-mono); font-weight: 500; }
.skill-group ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.skill-group li { padding: 5px 11px; border-radius: 8px; border: 1px solid var(--border); font-size: 14px; background: var(--bg); }

/* Contact */
.contact { padding: 48px 0 24px; }
.contact-lead { font-size: 18px; color: var(--text-2); max-width: 52ch; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0; }
.contact-actions .big { word-break: break-all; }
.socials { list-style: none; padding: 0; margin: 0; display: flex; gap: 20px; flex-wrap: wrap; }
.socials a { color: var(--text-2); font-weight: 500; }
.socials a:hover { color: var(--accent); }

/* Footer */
.footer { border-top: 1px solid var(--border); margin-top: 64px; padding: 28px 0; font-size: 14px; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.footer p { margin: 0; color: var(--text-2); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; transition: .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .pulse, .caret { animation: none; }
}
