:root {
  /* Meta + Apple + Linear */
  --bg: #ffffff;
  --bg-soft: #F5F7FA;
  --surface: #ffffff;
  --surface-2: #F5F7FA;
  --border: #E6E8EC;
  --border-strong: #D4D7DC;
  --text: #111111;
  --muted: #666666;
  --faint: #8A8F98;
  --blue: #0866FF;
  --purple: #0866FF;
  --grad: linear-gradient(135deg, #0866FF 0%, #4C8DFF 100%);
  --grad-soft: linear-gradient(135deg, rgba(8,102,255,0.10), rgba(8,102,255,0.04));
  --ring: rgba(8,102,255,0.28);
  --shadow: 0 1px 2px rgba(17,17,17,0.04), 0 8px 24px rgba(17,17,17,0.05);
  --shadow-lg: 0 16px 48px rgba(8,102,255,0.16);
  --font: "Inter", "Geist", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  /* Linear-inspired dark */
  --bg: #08090A;
  --bg-soft: #101113;
  --surface: #131416;
  --surface-2: #1B1C1E;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --text: #F7F8F8;
  --muted: rgba(247,248,248,0.66);
  --faint: rgba(247,248,248,0.42);
  --blue: #4C8DFF;
  --purple: #4C8DFF;
  --grad: linear-gradient(135deg, #4C8DFF 0%, #6BA5FF 100%);
  --grad-soft: linear-gradient(135deg, rgba(76,141,255,0.14), rgba(76,141,255,0.06));
  --ring: rgba(76,141,255,0.35);
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 10px 30px rgba(0,0,0,0.35);
  --shadow-lg: 0 20px 60px rgba(76,141,255,0.20);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  letter-spacing: -0.011em;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background 0.4s ease, color 0.4s ease;
}
::selection { background: var(--purple); color: #fff; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.wrap { max-width: 1140px; margin: 0 auto; padding: 0 28px; }

.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------- Ambient background ---------- */
.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.5; }
.orb-1 { width: 520px; height: 520px; background: radial-gradient(circle, rgba(8,102,255,0.14), transparent 70%); top: -160px; right: -120px; }
.orb-2 { width: 480px; height: 480px; background: radial-gradient(circle, rgba(8,102,255,0.08), transparent 70%); top: 700px; left: -180px; }
[data-theme="dark"] .orb { opacity: 0.4; }

/* ---------- Nav ---------- */
nav {
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(16px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid transparent;
  transition: background 0.3s, border-color 0.3s;
}
nav.scrolled { border-bottom-color: var(--border); }
nav .wrap { display: flex; align-items: center; justify-content: space-between; height: 70px; }
.brand { font-weight: 700; letter-spacing: -0.02em; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--grad); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 15px; box-shadow: var(--shadow); }
.nav-links { display: flex; gap: 30px; align-items: center; }
.nav-links a { font-size: 14px; color: var(--muted); transition: color 0.2s; position: relative; font-weight: 500; }
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-links a.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -8px; height: 2px; background: var(--grad); border-radius: 2px; }
.nav-right { display: flex; align-items: center; gap: 14px; }
.theme-toggle {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; display: flex;
  align-items: center; justify-content: center; transition: all 0.25s;
}
.theme-toggle:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }
.menu-btn { display: none; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; flex-direction: column; align-items: center; justify-content: center; gap: 5px; }
.menu-btn span { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; transition: transform 0.3s, opacity 0.3s; }
.menu-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn.open span:nth-child(2) { opacity: 0; }
.menu-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 860px) {
  .nav-links {
    position: absolute; top: 70px; left: 0; right: 0; flex-direction: column; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--border);
    max-height: 0; overflow: hidden; transition: max-height 0.35s ease;
  }
  .nav-links.open { max-height: 360px; }
  .nav-links a { width: 100%; padding: 15px 28px; border-top: 1px solid var(--border); }
  .nav-links a.active::after { display: none; }
  .menu-btn { display: flex; }
}

/* ---------- Reveal ---------- */
.reveal { opacity: 0; transform: translateY(28px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.visible { opacity: 1; transform: none; }
.reveal.d1 { transition-delay: 0.08s; }
.reveal.d2 { transition-delay: 0.16s; }
.reveal.d3 { transition-delay: 0.24s; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  * { scroll-behavior: auto !important; }
}

/* ---------- Section shells ---------- */
section { position: relative; z-index: 1; padding: 100px 0; }
.sec-tag { display: inline-block; font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; padding: 6px 14px; border-radius: 999px; background: var(--grad-soft); color: var(--blue); margin-bottom: 18px; }
.sec-title { font-size: clamp(28px, 5vw, 42px); letter-spacing: -0.03em; font-weight: 700; margin-bottom: 16px; }
.sec-lead { font-size: 17px; color: var(--muted); max-width: 620px; }
.sec-center { text-align: center; }
.sec-center .sec-lead { margin: 0 auto; }

/* ---------- Hero ---------- */
header { position: relative; z-index: 1; padding: 110px 0 90px; }
.hero-badge { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 8px 16px; margin-bottom: 30px; background: var(--surface); }
.hero-badge .pulse { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 0 rgba(34,197,94,0.5); animation: ping 2s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); } 70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
h1.hero-name { font-size: clamp(44px, 8vw, 84px); line-height: 1.02; letter-spacing: -0.04em; font-weight: 800; margin-bottom: 20px; }
.hero-role { font-size: clamp(17px, 2.6vw, 23px); font-weight: 600; color: var(--muted); margin-bottom: 26px; }
.hero-role .sep { color: var(--purple); margin: 0 10px; }
.hero-intro { font-size: 18px; color: var(--muted); max-width: 620px; margin-bottom: 38px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 600; padding: 14px 26px; border-radius: 12px; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, background 0.2s; border: 1px solid transparent; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover { transform: translateY(-2px); border-color: var(--blue); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); transform: translateY(-2px); }

.hero-stats { display: flex; gap: 44px; margin-top: 64px; flex-wrap: wrap; }
.hero-stats .num { font-size: 32px; font-weight: 800; letter-spacing: -0.02em; }
.hero-stats .lbl { font-size: 13.5px; color: var(--faint); margin-top: 2px; }

/* ---------- About ---------- */
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 54px; align-items: start; }
.about-text p { font-size: 17px; color: var(--muted); margin-bottom: 20px; }
.about-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 26px; }
.info-card { border: 1px solid var(--border); border-radius: 14px; padding: 18px; background: var(--surface); box-shadow: var(--shadow); }
.info-card .k { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); margin-bottom: 6px; }
.info-card .v { font-size: 15.5px; font-weight: 600; }
.interests { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.chip { font-size: 13.5px; font-weight: 500; padding: 8px 15px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); transition: all 0.2s; }
.chip:hover { color: var(--text); border-color: var(--blue); transform: translateY(-2px); }
.goal-box { border-left: 3px solid transparent; border-image: var(--grad) 1; background: var(--grad-soft); border-radius: 0 14px 14px 0; padding: 20px 22px; margin-top: 8px; }
.goal-box .k { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--blue); font-weight: 700; margin-bottom: 8px; }
.goal-box p { font-size: 15.5px; color: var(--muted); margin: 0; }
@media (max-width: 860px) { .about-grid { grid-template-columns: 1fr; gap: 36px; } }

/* ---------- Skills ---------- */
.skills-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }
.skill-cat { border: 1px solid var(--border); border-radius: 18px; padding: 26px; background: var(--surface); box-shadow: var(--shadow); transition: transform 0.3s, border-color 0.3s; }
.skill-cat:hover { transform: translateY(-4px); border-color: var(--border-strong); }
.skill-cat h3 { font-size: 17px; font-weight: 700; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.skill-cat h3 .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--grad); }
.skill-row { margin-bottom: 16px; }
.skill-row:last-child { margin-bottom: 0; }
.skill-row .top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 7px; }
.skill-row .top .lvl { color: var(--faint); font-size: 12.5px; }
.bar { height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--grad); transition: width 1.1s cubic-bezier(0.22,1,0.36,1); }
.chips-row { display: flex; flex-wrap: wrap; gap: 9px; }
@media (max-width: 760px) { .skills-grid { grid-template-columns: 1fr; } }

/* ---------- Projects ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 34px; }
.filter-btn { font-size: 14px; font-weight: 500; padding: 9px 18px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; transition: all 0.2s; }
.filter-btn:hover { color: var(--text); border-color: var(--border-strong); }
.filter-btn.active { background: var(--grad); color: #fff; border-color: transparent; }
.projects-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.project { border: 1px solid var(--border); border-radius: 18px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); transition: transform 0.35s, box-shadow 0.35s, border-color 0.35s, opacity 0.4s; display: flex; flex-direction: column; }
.project:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.project.hide { display: none; }
.project .cover { height: 150px; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.project .cover .glyph { font-size: 46px; position: relative; z-index: 1; filter: drop-shadow(0 6px 14px rgba(0,0,0,0.25)); }
.project .cover .mesh { position: absolute; inset: 0; opacity: 0.18; background-image: linear-gradient(#fff 1px, transparent 1px), linear-gradient(90deg, #fff 1px, transparent 1px); background-size: 26px 26px; mask-image: radial-gradient(circle at 50% 40%, black, transparent 78%); }
.cover-a { background: linear-gradient(135deg, #0866FF, #4C8DFF); }
.cover-b { background: linear-gradient(135deg, #052D8C, #0866FF); }
.cover-c { background: linear-gradient(135deg, #4C8DFF, #6BA5FF); }
.project .content { padding: 22px; display: flex; flex-direction: column; flex: 1; }
.project .cat-label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--blue); margin-bottom: 9px; }
.project h3 { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 9px; }
.project p { font-size: 14px; color: var(--muted); margin-bottom: 16px; flex: 1; }
.project .stack { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.project .stack span { font-size: 11.5px; font-weight: 500; padding: 4px 10px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.project .links { display: flex; gap: 16px; }
.project .links a { font-size: 13.5px; font-weight: 600; color: var(--blue); display: inline-flex; align-items: center; gap: 6px; }
.project .links a svg { width: 15px; height: 15px; }
@media (max-width: 960px) { .projects-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .projects-grid { grid-template-columns: 1fr; } }

/* ---------- Experience ---------- */
.exp-box { border: 1px solid var(--border); border-radius: 20px; padding: 40px; background: var(--surface); box-shadow: var(--shadow); display: flex; gap: 24px; align-items: flex-start; }
.exp-box .ic { flex-shrink: 0; width: 56px; height: 56px; border-radius: 14px; background: var(--grad-soft); color: var(--blue); display: flex; align-items: center; justify-content: center; }
.exp-box .ic svg { width: 26px; height: 26px; }
.exp-box h3 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.exp-box p { font-size: 16px; color: var(--muted); }

/* ---------- Timeline ---------- */
.timeline { position: relative; max-width: 760px; margin: 0 auto; padding-left: 8px; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--grad); opacity: 0.5; }
.tl-item { position: relative; padding: 0 0 26px 48px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item .node { position: absolute; left: 6px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--bg); border: 3px solid var(--blue); z-index: 1; transition: transform 0.3s; }
.tl-item:hover .node { transform: scale(1.2); }
.tl-item.done .node { background: var(--grad); border-color: transparent; }
.tl-item .step { font-size: 12px; font-weight: 600; color: var(--faint); letter-spacing: 0.05em; }
.tl-item .label { font-size: 17px; font-weight: 600; margin-top: 2px; }
.tl-item .tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; margin-top: 6px; }
.tag-done { background: rgba(34,197,94,0.14); color: #16a34a; }
[data-theme="dark"] .tag-done { background: rgba(110,231,160,0.15); color: #6ee7a0; }
.tag-now { background: var(--grad-soft); color: var(--blue); }
.tag-next { background: var(--surface-2); color: var(--faint); }

/* ---------- Achievements ---------- */
.ach-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.ach-card { border: 1px solid var(--border); border-radius: 16px; padding: 26px; background: var(--surface); box-shadow: var(--shadow); display: flex; gap: 16px; align-items: flex-start; transition: transform 0.3s, border-color 0.3s; }
.ach-card:hover { transform: translateY(-4px); border-color: var(--border-strong); }
.ach-card .ic { flex-shrink: 0; width: 46px; height: 46px; border-radius: 12px; background: var(--grad-soft); color: var(--blue); display: flex; align-items: center; justify-content: center; }
.ach-card .ic svg { width: 22px; height: 22px; }
.ach-card p { font-size: 15px; color: var(--muted); }
@media (max-width: 700px) { .ach-grid { grid-template-columns: 1fr; } }

/* ---------- Contact ---------- */
.contact-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 44px; align-items: start; }
.contact-info h3 { font-size: 22px; font-weight: 700; margin-bottom: 14px; }
.contact-info p { font-size: 16px; color: var(--muted); margin-bottom: 28px; }
.contact-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 30px; }
.contact-list a { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); transition: all 0.25s; }
.contact-list a:hover { border-color: var(--blue); transform: translateX(4px); }
.contact-list a .ic { width: 40px; height: 40px; border-radius: 10px; background: var(--grad-soft); color: var(--blue); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.contact-list a .ic svg { width: 20px; height: 20px; }
.contact-list a .k { font-size: 12px; color: var(--faint); }
.contact-list a .v { font-size: 14.5px; font-weight: 600; }
.socials { display: flex; gap: 12px; }
.socials a { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); display: flex; align-items: center; justify-content: center; color: var(--text); transition: all 0.25s; }
.socials a:hover { background: var(--grad); color: #fff; border-color: transparent; transform: translateY(-3px); }
.socials a svg { width: 20px; height: 20px; }

form.contact-form { border: 1px solid var(--border); border-radius: 20px; padding: 30px; background: var(--surface); box-shadow: var(--shadow); }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 8px; }
.field input, .field textarea { width: 100%; font-family: var(--font); font-size: 15px; color: var(--text); background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 13px 15px; transition: border-color 0.2s, box-shadow 0.2s; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--ring); }
.field textarea { resize: vertical; min-height: 120px; }
.field .err { display: none; font-size: 12.5px; color: #ef4444; margin-top: 6px; }
.field.invalid input, .field.invalid textarea { border-color: #ef4444; }
.field.invalid .err { display: block; }
.form-note { font-size: 13.5px; margin-top: 14px; text-align: center; min-height: 20px; }
.form-note.ok { color: #16a34a; }
.contact-form .btn-primary { width: 100%; justify-content: center; }
@media (max-width: 860px) { .contact-grid { grid-template-columns: 1fr; gap: 32px; } }

/* ---------- Footer ---------- */
footer { border-top: 1px solid var(--border); padding: 40px 0; position: relative; z-index: 1; text-align: center; }
footer .quote { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 12px; }
footer .copy { font-size: 14px; color: var(--faint); }

/* Back to top */
.to-top { position: fixed; right: 24px; bottom: 24px; z-index: 90; width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); opacity: 0; visibility: hidden; transform: translateY(10px); transition: all 0.3s; }
.to-top.show { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { background: var(--grad); color: #fff; border-color: transparent; }
.to-top svg { width: 20px; height: 20px; }

/* ---------- Hero photo ---------- */
.hero-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 50px; align-items: center; }
.hero-content { min-width: 0; }
.hero-photo { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.photo-frame { position: relative; width: 310px; max-width: 100%; aspect-ratio: 4 / 5; border-radius: 24px; overflow: hidden; border: 1px solid var(--border-strong); background: var(--grad-soft); box-shadow: var(--shadow-lg); }
.photo-frame::after { content: ""; position: absolute; inset: 0; border-radius: 24px; padding: 1.5px; background: var(--grad); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; opacity: 0.65; pointer-events: none; }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-fallback { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; font-size: 130px; font-weight: 800; letter-spacing: -0.04em; color: rgba(8,102,255,0.35); background: var(--grad-soft); }
[data-theme="dark"] .photo-fallback { color: rgba(76,141,255,0.45); }
.photo-frame.no-img .photo-fallback { display: flex; }
.photo-caption { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 500; }
.photo-caption .cap-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--grad); }
@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; gap: 36px; }
  .hero-photo { order: -1; }
  .photo-frame { width: 240px; }
}
