:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --bg: #0b1020;
  --bg-alt: #0e1428;
  --surface: #141b31;
  --surface-2: #1a223c;
  --border: rgba(148, 163, 184, 0.14);
  --text: #e6ebf5;
  --muted: #96a1b8;
  --accent: #818cf8;
  --accent-2: #c084fc;
  --accent-glow: rgba(129, 140, 248, 0.35);
  --header-bg: rgba(11, 16, 32, 0.72);
  --shadow: 0 20px 50px rgba(2, 6, 23, 0.5);
  --radius: 18px;
  --maxw: 1120px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html[data-theme="light"] {
  --bg: #f5f6fb;
  --bg-alt: #eef0f8;
  --surface: #ffffff;
  --surface-2: #f1f3fa;
  --border: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --muted: #526078;
  --accent: #5457e5;
  --accent-2: #9333ea;
  --accent-glow: rgba(84, 87, 229, 0.18);
  --header-bg: rgba(245, 246, 251, 0.8);
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
ul { list-style: none; margin: 0; padding: 0; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ---------- Header / Nav ---------- */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease);
}

.nav { display: flex; align-items: center; justify-content: space-between; height: 68px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.02em; }
.brand-mark {
  font-family: var(--font-mono);
  font-size: 15px;
  padding: 6px 9px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 20px var(--accent-glow);
}
.brand-name { font-size: 18px; }

.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-links li a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 13px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.nav-links li a:hover { color: var(--text); background: var(--surface-2); }
.nav-links .nav-gh { color: var(--text); }
.nav-links .nav-gh svg { width: 16px; height: 16px; fill: currentColor; }
.nav-divider { width: 1px; height: 22px; background: var(--border); margin: 0 8px; }

.nav-toggle {
  display: none;
  flex-direction: column; gap: 5px;
  width: 42px; height: 42px;
  align-items: center; justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.nav-toggle span { width: 18px; height: 2px; background: var(--text); border-radius: 2px; transition: transform 0.25s var(--ease), opacity 0.2s; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 120px 0 90px;
  overflow: hidden;
}
.hero-bg { position: absolute; inset: 0; z-index: 0; }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5; }
.blob-1 { width: 480px; height: 480px; background: var(--accent); top: -120px; right: -80px; }
.blob-2 { width: 420px; height: 420px; background: var(--accent-2); bottom: -160px; left: -120px; opacity: 0.4; }
.grid-overlay {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--border) 1px, transparent 1px),
                    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 0%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 0%, transparent 75%);
  opacity: 0.5;
}
.hero-inner { position: relative; z-index: 1; }

.hero-card { max-width: 680px; }
.avatar-wrap { position: relative; width: 112px; height: 112px; margin-bottom: 26px; }
.avatar {
  width: 112px; height: 112px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 6px var(--accent-glow), var(--shadow);
  object-fit: cover;
}
.status-dot {
  position: absolute; right: 4px; bottom: 8px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #22c55e;
  border: 3px solid var(--bg);
}

.eyebrow { font-family: var(--font-mono); font-size: 15px; color: var(--accent); margin: 0 0 8px; }
.hero-name {
  font-size: clamp(48px, 8vw, 80px);
  line-height: 1.02;
  letter-spacing: -0.04em;
  margin: 0 0 8px;
  background: linear-gradient(120deg, var(--text) 0%, var(--accent) 55%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-role { font-size: 20px; font-weight: 600; margin: 0 0 18px; color: var(--text); }
.hero-role .sep { color: var(--accent); margin: 0 6px; }
.hero-bio { font-size: 17px; color: var(--muted); max-width: 560px; margin: 0 0 24px; }

.hero-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 30px; }
.meta-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 500;
  padding: 8px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}
.meta-chip svg { width: 15px; height: 15px; fill: none; stroke: var(--accent); stroke-width: 1.8; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 12px 28px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 34px var(--accent-glow); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); transform: translateY(-2px); }
.btn-small { padding: 9px 16px; font-size: 13.5px; }

.scroll-hint {
  position: absolute; left: 50%; bottom: 26px;
  transform: translateX(-50%);
  color: var(--muted);
  animation: float 2.2s ease-in-out infinite;
}
.scroll-hint svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@keyframes float { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, 8px); } }

/* ---------- Sections ---------- */
.section { padding: 96px 0; position: relative; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-title { font-size: clamp(28px, 4vw, 38px); letter-spacing: -0.03em; margin: 0 0 10px; }
.section-title .num { font-family: var(--font-mono); font-size: 0.72em; color: var(--accent); margin-right: 8px; font-weight: 500; }
.section-sub { color: var(--muted); margin: 0 0 36px; max-width: 560px; }
.section-head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---------- About ---------- */
.about-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 40px; align-items: start; }
.about-text p { color: var(--muted); font-size: 16px; margin: 0 0 16px; }
.about-facts { margin-top: 28px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.about-facts li { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.about-facts span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.about-facts strong, .about-facts a { font-size: 15px; font-weight: 600; }
.about-facts a { color: var(--accent); }
.about-facts a:hover { text-decoration: underline; }

.about-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.about-card-top { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot.red { background: #ff5f57; }
.dot.yellow { background: #febc2e; }
.dot.green { background: #28c840; }
.about-card-file { margin-left: 8px; font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }
.about-card-code { margin: 0; padding: 22px 20px; font-family: var(--font-mono); font-size: 13.5px; line-height: 1.75; color: var(--text); overflow-x: auto; }

/* ---------- Skills ---------- */
.skills-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.skill-card {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 24px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: transform 0.25s var(--ease), border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.skill-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 14px 30px var(--accent-glow); }
.skill-logo {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 800;
  border-radius: 12px;
  color: #fff;
}
.skill-name { font-size: 14px; font-weight: 600; }

/* ---------- Projects ---------- */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.loading { color: var(--muted); font-size: 15px; grid-column: 1 / -1; }
.project-card {
  display: flex; flex-direction: column;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform 0.25s var(--ease), border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.project-card:hover { transform: translateY(-5px); border-color: var(--accent); box-shadow: 0 18px 40px var(--accent-glow); }
.project-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.project-folder { color: var(--accent); flex-shrink: 0; }
.project-folder svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.project-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.project-name a:hover { color: var(--accent); }
.project-desc { color: var(--muted); font-size: 14px; margin: 0 0 18px; flex-grow: 1; }
.project-foot { display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: var(--muted); font-family: var(--font-mono); }
.project-foot .lang { display: inline-flex; align-items: center; gap: 6px; }
.lang-dot { width: 10px; height: 10px; border-radius: 50%; }
.project-foot .star { display: inline-flex; align-items: center; gap: 4px; }
.project-foot svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* ---------- Stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 26px; }
.stat-card {
  text-align: center;
  padding: 28px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-value {
  display: block;
  font-size: clamp(32px, 5vw, 44px);
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat-label { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.lang-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.lang-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; font-size: 14px; font-weight: 600; }
.lang-muted { color: var(--muted); font-weight: 400; font-size: 13px; }
.lang-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-2); margin-bottom: 16px; }
.lang-bar span { height: 100%; }
.lang-legend { display: flex; flex-wrap: wrap; gap: 16px; }
.lang-legend li { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.lang-legend .lang-dot { width: 11px; height: 11px; }

/* ---------- Contact ---------- */
.contact-inner { text-align: center; max-width: 680px; }
.contact-title { font-size: clamp(30px, 5vw, 46px); letter-spacing: -0.03em; margin: 0 0 16px; }
.contact-text { color: var(--muted); font-size: 16px; margin: 0 auto 30px; max-width: 520px; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 26px 0; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer-inner p { margin: 0; color: var(--muted); font-size: 14px; }
.footer-links { display: flex; gap: 20px; }
.footer-links a { color: var(--muted); font-size: 14px; }
.footer-links a:hover { color: var(--accent); }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  position: fixed; right: 22px; bottom: 22px; z-index: 90;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: grid; place-items: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease);
}
.theme-toggle:hover { transform: rotate(12deg); border-color: var(--accent); }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
html[data-theme="dark"] .icon-sun { display: block; }
html[data-theme="dark"] .icon-moon { display: none; }
html[data-theme="light"] .icon-sun { display: none; }
html[data-theme="light"] .icon-moon { display: block; }

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

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute; top: 68px; left: 0; right: 0;
    flex-direction: column; align-items: stretch;
    gap: 4px;
    padding: 16px 20px 22px;
    background: var(--header-bg);
    backdrop-filter: saturate(140%) blur(14px);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
    border-bottom: 1px solid var(--border);
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s var(--ease), opacity 0.2s;
  }
  .nav-links.open { transform: none; opacity: 1; pointer-events: auto; }
  .nav-links li a { padding: 12px 14px; font-size: 16px; }
  .nav-divider { display: none; }
  .about-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .container { padding: 0 18px; }
  .hero { padding-top: 100px; }
  .about-facts { grid-template-columns: 1fr; }
  .skills-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-inner { justify-content: center; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}
