:root {
  --bg: #0b0d14;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --text: #eef0f6;
  --muted: #9aa1b5;
  --accent: #7c8cff;
  --accent-2: #22c3a6;
  --radius: 18px;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef0f7;
  --border: rgba(20, 24, 40, 0.09);
  --text: #141828;
  --muted: #5d6479;
  --accent: #4f5de0;
  --accent-2: #0f9e86;
  --shadow: 0 20px 40px -24px rgba(30, 40, 90, 0.25);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.15; margin: 0; letter-spacing: -0.02em; }

.bg-glow {
  position: fixed; inset: -20% -10% auto; height: 80vh; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40% 50% at 20% 30%, rgba(124, 140, 255, 0.22), transparent 70%),
    radial-gradient(35% 45% at 80% 20%, rgba(34, 195, 166, 0.16), transparent 70%);
  filter: blur(20px);
}

main, .nav, .footer { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  height: 68px; backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
}
.logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: -0.01em; text-decoration: none;
}
.logo img { display: block; transition: transform 0.35s, filter 0.35s; }
.logo:hover img { transform: rotate(-12deg) scale(1.08); filter: drop-shadow(0 0 10px rgba(90, 168, 255, 0.6)); }
@media (max-width: 480px) { .logo span { display: none; } }
.nav nav { display: flex; gap: 22px; align-items: center; }
.nav nav a { text-decoration: none; color: var(--muted); font-size: 0.95rem; }
.nav nav a:hover { color: var(--text); }
.theme-toggle {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 1rem;
}

/* Hero */
.hero { padding: 90px 0 70px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 48px; align-items: center; }

/* Portrait */
.portrait { position: relative; margin: 0; width: clamp(240px, 28vw, 340px); }
.portrait[hidden] { display: none; }
.portrait::before {
  content: ""; position: absolute; inset: -12%; border-radius: 50%; z-index: -1;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 35%, transparent), transparent);
  filter: blur(10px);
}
.portrait-ring {
  aspect-ratio: 1; border-radius: 50%; padding: 6px;
  background: conic-gradient(from 210deg, #8b7cff, #5aa8ff, #22e0b4, #8b7cff);
  box-shadow: var(--shadow); animation: float 6s ease-in-out infinite;
}
.portrait-ring img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block;
  border: 5px solid var(--bg); background: var(--surface-2);
}
.portrait-badge {
  position: absolute; left: -6%; bottom: 12%;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px; font-size: 0.85rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.portrait-badge i {
  width: 9px; height: 9px; border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 0 4px color-mix(in srgb, #22c55e 25%, transparent);
}
@keyframes float { 50% { transform: translateY(-10px); } }
.eyebrow {
  font-family: "JetBrains Mono", monospace; color: var(--accent-2);
  font-size: 0.9rem; margin: 0 0 14px;
}
.hero h1 {
  font-size: clamp(2.6rem, 7vw, 5rem); font-weight: 800;
  background: linear-gradient(120deg, var(--text) 30%, var(--accent) 70%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lead { max-width: 680px; color: var(--muted); font-size: 1.15rem; margin: 20px 0 32px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; font-weight: 600; text-decoration: none;
  border: 1px solid var(--border); transition: transform 0.2s, background 0.2s;
}
.btn:hover { transform: translateY(-2px); }
.btn.primary { background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: #fff; border: 0; }
.btn.ghost { background: var(--surface); }

.stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px;
  margin-top: 56px; max-width: 760px;
}
.stat { padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.stat b { display: block; font-size: 1.9rem; font-weight: 800; }
.stat span { color: var(--muted); font-size: 0.85rem; }

/* Work */
.work { padding: 40px 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.section-head h2, .skills h2, .contact h2 { font-size: clamp(1.8rem, 4vw, 2.4rem); }
.view-switch {
  display: inline-flex; padding: 4px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
}
.view-switch button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600;
  padding: 8px 18px; border-radius: 999px; cursor: pointer;
}
.view-switch button[aria-selected="true"] { background: var(--surface-2); color: var(--text); }

.toolbar { margin: 26px 0 10px; display: grid; gap: 14px; }
#search {
  width: 100%; padding: 14px 18px; border-radius: 14px; font: inherit;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); outline: none;
}
#search:focus { border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-size: 0.85rem; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent); color: #fff; border-color: transparent; }
.chip .n { opacity: 0.6; margin-left: 4px; }

.group { margin-top: 48px; }
.group-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.group-icon {
  flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  font-size: 1.3rem; background: var(--surface-2); border: 1px solid var(--border);
}
.group-head h3 { font-size: 1.35rem; }
.group-head .meta { font-size: 0.85rem; color: var(--muted); font-family: "JetBrains Mono", monospace; }
.group-head p { color: var(--muted); margin: 4px 0 0; max-width: 760px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.card {
  position: relative; text-align: left; font: inherit; color: inherit; cursor: pointer;
  display: flex; flex-direction: column; padding: 0; overflow: hidden;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
  opacity: 0; transform: translateY(12px); animation: rise 0.5s forwards;
}
.card:hover { transform: translateY(-6px); border-color: color-mix(in srgb, var(--brand, var(--accent)) 50%, transparent); box-shadow: var(--shadow); }
.card-body { position: relative; flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 20px 22px 22px; }
.card .company { font-size: 0.78rem; font-family: "JetBrains Mono", monospace; color: var(--brand, var(--accent)); padding-right: 76px; }
.card h4 { margin: 0; font-size: 1.12rem; letter-spacing: -0.01em; }
.card p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.card .badge {
  position: absolute; top: 18px; right: 18px; font-size: 0.7rem; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, var(--accent-2) 20%, transparent); color: var(--accent-2);
}

/* Card previews */
.preview {
  position: relative; aspect-ratio: 16 / 10; overflow: hidden;
  background:
    radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--brand, var(--accent)) 38%, transparent), transparent 60%),
    radial-gradient(90% 90% at 100% 100%, color-mix(in srgb, var(--accent-2) 26%, transparent), transparent 60%),
    var(--surface-2);
}
.browser, .editor {
  position: absolute; left: 7%; top: 11%; width: 80%;
  border-radius: 10px; overflow: hidden; background: #fff;
  box-shadow: 0 18px 40px -12px rgba(10, 14, 40, 0.45);
  transition: transform 0.4s;
}
.browser-bar {
  display: flex; align-items: center; gap: 5px; height: 20px; padding: 0 9px; background: #eceef4;
}
.browser-bar i { width: 7px; height: 7px; border-radius: 50%; background: #ff5f57; }
.browser-bar i:nth-child(2) { background: #febc2e; }
.browser-bar i:nth-child(3) { background: #28c840; }
.browser-bar span { margin-left: 8px; font: 500 0.62rem "JetBrains Mono", monospace; color: #6b7280; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.browser img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top; }

.phone {
  position: absolute; right: 6%; bottom: -14%; width: 23%; aspect-ratio: 9 / 19;
  padding: 4px; border-radius: 18px; background: #11131c;
  box-shadow: 0 16px 36px -10px rgba(10, 14, 40, 0.55);
  transition: transform 0.4s;
}
.phone img { width: 100%; height: 100%; object-fit: cover; object-position: top; border-radius: 14px; display: block; }
.card:hover .browser { transform: translateY(-4px) scale(1.02); }
.card:hover .phone { transform: translateY(-10px) rotate(-3deg); }

.phone.big { right: auto; left: 50%; bottom: -30%; width: 34%; transform: translateX(-50%); }
.card:hover .phone.big { transform: translateX(-50%) translateY(-12px); }
.app-screen {
  height: 100%; border-radius: 14px; display: flex; flex-direction: column; align-items: center;
  padding-top: 26%; gap: 8px; text-align: center; color: #fff;
  background: linear-gradient(160deg, var(--brand, var(--accent)), #1b1f3a 85%);
}
.phone .app-screen img { width: 42%; height: auto; object-fit: contain; aspect-ratio: 1; background: #fff; border-radius: 22%; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35); }
.app-screen b { font-size: 0.62rem; line-height: 1.25; padding: 0 8px; }
.app-screen small { font-size: 0.55rem; opacity: 0.75; }

.editor { background: #151a2e; }
.editor .browser-bar { background: #1e2440; }
.editor .browser-bar span { color: #8b93b8; }
.editor pre {
  margin: 0; padding: 12px 14px 16px; font: 500 0.68rem/1.7 "JetBrains Mono", monospace;
  color: #d7dcf5; white-space: pre-wrap; word-break: break-word;
}
.editor .k { color: #c792ea; }
.editor .s { color: #7fe0c3; }
.card:hover .editor { transform: translateY(-4px) scale(1.02); }

.btn.pass { font: inherit; font-weight: 600; color: var(--text); cursor: pointer; }
.btn.pass code { font-family: "JetBrains Mono", monospace; color: var(--accent); }
.btn.pass span { font-size: 0.78rem; color: var(--muted); }

/* Modal gallery */
.gallery { margin: -32px -32px 22px; background: var(--surface-2); }
.gallery .preview { border-radius: 0; }
.gallery-main { display: grid; place-items: center; padding: 18px 18px 10px; }
.gallery-main img { max-width: 100%; max-height: 52vh; border-radius: 10px; box-shadow: var(--shadow); display: block; }
.gallery-main img.mobile { max-height: 52vh; border-radius: 22px; border: 5px solid #11131c; }
.thumbs { display: flex; gap: 8px; justify-content: center; padding: 0 18px 16px; }
.thumb {
  padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer;
  background: none; opacity: 0.6; height: 54px;
}
.thumb.active { border-color: var(--accent); opacity: 1; }
.thumb img { height: 100%; display: block; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.tag {
  font-size: 0.75rem; padding: 3px 9px; border-radius: 8px;
  background: var(--surface-2); color: var(--muted);
}
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

@keyframes rise { to { opacity: 1; transform: none; } }

/* Skills */
.skills { padding: 80px 0 40px; }
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 26px; }
.skill-card { padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.skill-card h3 { font-size: 1.05rem; margin-bottom: 12px; display: flex; gap: 8px; align-items: center; }

/* GitHub activity */
.activity { padding: 60px 0 20px; }
.activity h2 { font-size: clamp(1.8rem, 4vw, 2.4rem); }
.section-sub { color: var(--muted); margin: 8px 0 26px; }
.section-sub a { color: var(--accent); font-weight: 600; text-decoration: none; margin-left: 6px; white-space: nowrap; }
.section-sub a:hover { text-decoration: underline; }
.activity-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; }
.activity-hero, .year-bars, .heatmap-wrap {
  padding: 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
}
.activity-hero { display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.activity-hero b { display: block; font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; }
.activity-hero b.big {
  font-size: clamp(2.8rem, 6vw, 3.8rem); line-height: 1;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.activity-hero span { color: var(--muted); font-size: 0.9rem; }

.year-bars { display: flex; align-items: flex-end; gap: 14px; min-height: 240px; }
.year-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; }
.year-bar .val { font-weight: 700; font-size: 0.95rem; }
.year-bar .track { flex: 1; width: 100%; max-width: 64px; display: flex; align-items: flex-end; }
.year-bar .fill {
  width: 100%; height: var(--h); min-height: 6px; border-radius: 10px 10px 4px 4px;
  background: color-mix(in srgb, var(--accent) 45%, var(--surface-2));
  transform-origin: bottom; animation: grow 0.9s cubic-bezier(.2,.8,.2,1) both;
}
.year-bar.current .fill { background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
.year-bar .lbl { font: 500 0.78rem "JetBrains Mono", monospace; color: var(--muted); white-space: nowrap; }
@keyframes grow { from { transform: scaleY(0); } }

.heatmap-wrap { margin-top: 16px; overflow-x: auto; }
.heatmap { display: grid; grid-template-rows: repeat(7, 11px); grid-auto-flow: column; grid-auto-columns: 11px; gap: 3px; }
.heatmap i, .heatmap-legend i { width: 11px; height: 11px; border-radius: 3px; background: var(--surface-2); display: inline-block; }
.heatmap .l1, .heatmap-legend .l1 { background: color-mix(in srgb, var(--accent-2) 30%, var(--surface-2)); }
.heatmap .l2, .heatmap-legend .l2 { background: color-mix(in srgb, var(--accent-2) 55%, var(--surface-2)); }
.heatmap .l3, .heatmap-legend .l3 { background: color-mix(in srgb, var(--accent-2) 80%, var(--surface-2)); }
.heatmap .l4, .heatmap-legend .l4 { background: var(--accent-2); }
.heatmap-legend { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 10px; font-size: 0.78rem; color: var(--muted); }

@media (max-width: 760px) {
  .activity-grid { grid-template-columns: 1fr; }
  .year-bars { min-height: 200px; }
}

/* Contact */
.contact {
  margin: 60px 0; padding: 56px 32px; text-align: center; border-radius: 28px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), color-mix(in srgb, var(--accent-2) 14%, transparent));
  border: 1px solid var(--border);
}
.contact p { color: var(--muted); margin: 10px 0 26px; }
.contact .hero-actions { justify-content: center; }

.footer { padding: 30px 24px 50px; color: var(--muted); font-size: 0.85rem; text-align: center; }
.footer p { margin: 12px 0 0; }
.views {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
}
.views[hidden] { display: none; }
.views b { color: var(--text); font-weight: 700; }
.views i {
  width: 8px; height: 8px; border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 0 3px color-mix(in srgb, #22c55e 25%, transparent);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, #22c55e 0%, transparent); } }

/* Modal */
.modal {
  width: min(780px, calc(100vw - 32px)); max-height: 90vh; padding: 0;
  border: 1px solid var(--border); border-radius: 22px;
  background: var(--bg); color: var(--text); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(5, 7, 12, 0.6); backdrop-filter: blur(4px); }
.modal-close { z-index: 2;
  position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.modal h3 { font-size: 1.6rem; margin: 6px 0 12px; padding-right: 30px; }
.modal p { color: var(--muted); }
.modal ul { padding-left: 20px; margin: 0 0 20px; }
.modal li { margin-bottom: 6px; }
.modal h5 { margin: 20px 0 10px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

@media (max-width: 640px) {
  main, .nav, .footer { padding: 0 16px; }
  .nav nav { gap: 14px; }
  .hero { padding: 40px 0 40px; grid-template-columns: 1fr; gap: 28px; }
  .portrait { order: -1; width: 180px; }
  .portrait-badge { left: auto; right: -30%; bottom: 6%; font-size: 0.75rem; padding: 6px 12px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: 1fr; }
  .contact { padding: 40px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .card { opacity: 1; transform: none; }
}

#modalBody { padding: 32px; }
