:root {
  color-scheme: dark;
  --bg-main: #0a0a0c;
  --bg-card: #0f0f12;
  --bg-nav: rgba(10, 10, 12, 0.92);
  --bg-nav-open: rgba(10, 10, 12, 0.98);
  --text-primary: #f2ede7;
  --text-muted: #5e5e68;
  --text-dim: #2e2e36;
  --accent-start: #e63946;
  --accent-end: #f4831f;
  --accent-ghost: rgba(230, 57, 70, 0.08);
  --accent-start-soft: rgba(230, 57, 70, 0.24);
  --accent-end-soft: rgba(244, 131, 31, 0.2);

  --border-subtle: #18181c;
  --border-hover: #2a2a32;
  --border-tag: #222228;

  --overlay-bg: rgba(7, 7, 10, 0.6);
  --overlay-bg-strong: rgba(7, 7, 10, 0.85);
  --halo-primary: rgba(230, 57, 70, 0.065);
  --halo-secondary: rgba(244, 131, 31, 0.05);
  --hero-dot: rgba(255, 255, 255, 0.065);
  --hero-fade-end: 80%;
  --hero-ticker-bg: rgba(10, 10, 12, 0.6);
  --surface-sheen: rgba(255, 255, 255, 0.045);
  --surface-sheen-strong: rgba(255, 255, 255, 0.05);
  --contact-card-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.015));
  --scrollbar-track: rgba(255, 255, 255, 0.04);

  --project-preview-base-start: #0e0e11;
  --project-preview-base-end: #131316;
  --project-preview-base-start-hover: #0f0f13;
  --project-preview-base-end-hover: #141418;
  --project-preview-accent: rgba(230, 57, 70, 0.06);
  --project-preview-accent-hover: rgba(230, 57, 70, 0.1);
  --project-preview-dot: rgba(255, 255, 255, 0.045);
  --project-preview-line: rgba(230, 57, 70, 0.28);
  --project-preview-shadow-1: rgba(255, 255, 255, 0.035);
  --project-preview-shadow-2: rgba(255, 255, 255, 0.02);

  --footer-bg: #121218;
  --footer-muted: #3a3a40;
  --footer-muted-strong: #666670;
  --logo-fill: #f2ede7;
  --cursor-glow-primary: rgba(230, 57, 70, 0.07);
  --cursor-glow-secondary: rgba(244, 131, 31, 0.04);

  --font-heading: 'Syne', sans-serif;
  --font-body: 'Karla', sans-serif;

  --radius-xxs: 2px;
  --radius-sm: 7px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-pill: 999px;

  --radius-button: var(--radius-sm);
  --shadow-subtle: inset 0 1px 0 rgba(255, 255, 255, 0.02);
  --shadow-subtle-strong: inset 0 1px 0 rgba(255, 255, 255, 0.025);
  --surface-bg-default: var(--bg-card);
  --surface-border-default: var(--border-subtle);
  --surface-shadow-default: var(--shadow-subtle);

  --fs-tag: 10px;
  --fs-body: 15px;
  --fs-h3: 17px;
  --fs-h2: 24px;
  --fs-h1: 38px;
  --fs-eyebrow: 12px;
  --fs-link: 14px;

  --nav-h: 54px;
  --stable-vh: 100vh;
  --pad-x: 5%;
  --pad-y: 52px;
  --heading-gap: 24px;
  --cursor-glow-size: 580;
  --hbg-chr-opacity: 0.038;
  --hbg-main-opacity: 0.11;
  --section-intrinsic-size: 900px;
  --about-intrinsic-size: 780px;
  --skills-intrinsic-size: 980px;
  --projects-intrinsic-size: 760px;
  --contact-intrinsic-size: 760px;
}

/* LIGHT THEME — system preference */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg-main: #f6f2ed;
    --bg-card: #fbf8f4;
    --bg-nav: rgba(246, 242, 237, 0.92);
    --bg-nav-open: rgba(246, 242, 237, 0.98);
    --text-primary: #1a1a1f;
    --text-muted: #5d5a56;
    --text-dim: #9b948b;
    --accent-ghost: rgba(230, 57, 70, 0.12);
    --accent-start-soft: rgba(230, 57, 70, 0.18);
    --accent-end-soft: rgba(244, 131, 31, 0.16);

    --border-subtle: #e3ddd6;
    --border-hover: #d3cbc2;
    --border-tag: #e2dcd5;

    --overlay-bg: rgba(10, 10, 14, 0.25);
    --overlay-bg-strong: rgba(10, 10, 14, 0.38);
    --halo-primary: rgba(230, 57, 70, 0.12);
    --halo-secondary: rgba(244, 131, 31, 0.1);
    --hero-dot: rgba(0, 0, 0, 0.22);
    --hero-fade-end: 90%;
    --hero-ticker-bg: rgba(255, 255, 255, 0.7);
    --surface-sheen: rgba(0, 0, 0, 0.045);
    --surface-sheen-strong: rgba(0, 0, 0, 0.04);
    --contact-card-bg: linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.01));
    --scrollbar-track: rgba(0, 0, 0, 0.08);

    --project-preview-base-start: #f7f2ec;
    --project-preview-base-end: #efe7df;
    --project-preview-base-start-hover: #f4eee7;
    --project-preview-base-end-hover: #ebe2d9;
    --project-preview-accent: rgba(230, 57, 70, 0.12);
    --project-preview-accent-hover: rgba(230, 57, 70, 0.16);
    --project-preview-dot: rgba(0, 0, 0, 0.04);
    --project-preview-line: rgba(230, 57, 70, 0.32);
    --project-preview-shadow-1: rgba(0, 0, 0, 0.08);
    --project-preview-shadow-2: rgba(0, 0, 0, 0.05);

    --footer-bg: #efe8e0;
    --footer-muted: #9a9188;
    --footer-muted-strong: #7a736c;
    --logo-fill: #1a1a1f;
    --cursor-glow-primary: rgba(230, 57, 70, 0.14);
    --cursor-glow-secondary: rgba(244, 131, 31, 0.08);

    --shadow-subtle: inset 0 1px 0 rgba(0, 0, 0, 0.05);
    --shadow-subtle-strong: inset 0 1px 0 rgba(0, 0, 0, 0.08);
    --hbg-chr-opacity: 0.07;
    --hbg-main-opacity: 0.18;
  }
}

/* LIGHT THEME — manual toggle */
:root[data-theme="light"] {
  color-scheme: light;
  --bg-main: #f6f2ed;
  --bg-card: #fbf8f4;
  --bg-nav: rgba(246, 242, 237, 0.92);
  --bg-nav-open: rgba(246, 242, 237, 0.98);
  --text-primary: #1a1a1f;
  --text-muted: #5d5a56;
  --text-dim: #9b948b;
  --accent-ghost: rgba(230, 57, 70, 0.12);
  --accent-start-soft: rgba(230, 57, 70, 0.18);
  --accent-end-soft: rgba(244, 131, 31, 0.16);

  --border-subtle: #e3ddd6;
  --border-hover: #d3cbc2;
  --border-tag: #e2dcd5;

  --overlay-bg: rgba(10, 10, 14, 0.25);
  --overlay-bg-strong: rgba(10, 10, 14, 0.38);
  --halo-primary: rgba(230, 57, 70, 0.12);
  --halo-secondary: rgba(244, 131, 31, 0.1);
  --hero-dot: rgba(0, 0, 0, 0.22);
  --hero-fade-end: 90%;
  --hero-ticker-bg: rgba(255, 255, 255, 0.7);
  --surface-sheen: rgba(0, 0, 0, 0.045);
  --surface-sheen-strong: rgba(0, 0, 0, 0.04);
  --contact-card-bg: linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.01));
  --scrollbar-track: rgba(0, 0, 0, 0.08);

  --project-preview-base-start: #f7f2ec;
  --project-preview-base-end: #efe7df;
  --project-preview-base-start-hover: #f4eee7;
  --project-preview-base-end-hover: #ebe2d9;
  --project-preview-accent: rgba(230, 57, 70, 0.12);
  --project-preview-accent-hover: rgba(230, 57, 70, 0.16);
  --project-preview-dot: rgba(0, 0, 0, 0.04);
  --project-preview-line: rgba(230, 57, 70, 0.32);
  --project-preview-shadow-1: rgba(0, 0, 0, 0.08);
  --project-preview-shadow-2: rgba(0, 0, 0, 0.05);

  --footer-bg: #efe8e0;
  --footer-muted: #9a9188;
  --footer-muted-strong: #7a736c;
  --logo-fill: #1a1a1f;
  --cursor-glow-primary: rgba(230, 57, 70, 0.14);
  --cursor-glow-secondary: rgba(244, 131, 31, 0.08);

  --shadow-subtle: inset 0 1px 0 rgba(0, 0, 0, 0.05);
  --shadow-subtle-strong: inset 0 1px 0 rgba(0, 0, 0, 0.08);
  --hbg-chr-opacity: 0.07;
  --hbg-main-opacity: 0.18;
}

@supports (height: 100svh) {
  :root {
    --stable-vh: 100svh;
  }
}

@supports (height: 100dvh) {
  :root {
    --stable-vh: 100dvh;
  }
}

*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 9999;
  padding: 8px 16px;
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  text-decoration: none;
  border-bottom: 1px solid var(--border-subtle);
}

.skip-link:focus {
  top: 0;
}

html {
  scroll-behavior: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background-color: var(--bg-main);
}

html.smooth-scroll {
  scroll-behavior: smooth;
}

html::-webkit-scrollbar { display: none; }

body {
  background-color: var(--bg-main);
  font-family: var(--font-body);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

body.nav-open {
  overflow: hidden;
  touch-action: none;
}

/* FIX 1: removed backdrop-filter — overlay is opaque enough at both
   light (0.25) and dark (0.6) alpha; the blur was invisible but costly. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 150;
  pointer-events: none;
}

body.nav-open::after {
  opacity: 1;
  pointer-events: auto;
}

html.lenis,
html.lenis body {
  height: auto;
}

.lenis:not(.lenis-autoToggle).lenis-stopped {
  overflow: clip;
}

.lenis [data-lenis-prevent],
.lenis [data-lenis-prevent-wheel],
.lenis [data-lenis-prevent-touch],
.lenis [data-lenis-prevent-vertical],
.lenis [data-lenis-prevent-horizontal] {
  overscroll-behavior: contain;
}

.lenis.lenis-smooth iframe {
  pointer-events: none;
}

.lenis.lenis-autoToggle {
  transition-property: overflow;
  transition-duration: 1ms;
  transition-behavior: allow-discrete;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 45% at 10% 15%, var(--halo-primary) 0%, transparent 58%),
    radial-gradient(ellipse 45% 55% at 90% 85%, var(--halo-secondary) 0%, transparent 58%);
  pointer-events: none;
  z-index: 0;
  animation: halo-breathe 14s ease-in-out infinite alternate;
  will-change: opacity, transform;
}

/* FIX 3: pause halo animation when hero is offscreen or tab is hidden */
body.halo-paused::before {
  animation-play-state: paused;
}

@keyframes halo-breathe {
  from { opacity: 0.6; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1.04); }
}

nav, section, footer {
  position: relative;
  z-index: 1;
}

/* Utilities */
.gradient-text {
  background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.btn {
  display: inline-block;
  padding: 11px 28px;
  border: 1px solid var(--accent-start);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-button);
  letter-spacing: 0.4px;
  transition: background-color 0.2s, transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, var(--surface-sheen) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
  pointer-events: none;
}

.btn:hover::after { transform: translateX(100%); }

.btn:hover {
  background-color: var(--accent-ghost);
  transform: translateY(-2px);
  box-shadow: 0 4px 24px rgba(230, 57, 70, 0.18);
}

:where(.stat-chip, .skill-tags span, .project-tags span, .contact-links a, .error-link) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--pill-pad, 4px 12px);
  border-radius: var(--radius-pill);
  border: 1px solid var(--pill-border, var(--border-tag));
  background: var(--pill-bg, rgba(255, 255, 255, 0.02));
  color: var(--pill-color, var(--text-muted));
  font-size: var(--pill-size, var(--fs-tag));
  font-weight: 600;
  letter-spacing: var(--pill-tracking, 0.14em);
  text-transform: var(--pill-case, uppercase);
  text-decoration: none;
  box-shadow: 0 0 0 0 transparent;
  transition: border-color 0.2s, color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

:where(.highlight-card, .skill-card, .project-card, .contact-card, .error-card) {
  background: var(--surface-bg, var(--surface-bg-default));
  border: 1px solid var(--surface-border, var(--surface-border-default));
  border-radius: var(--surface-radius, var(--radius-lg));
  box-shadow: var(--surface-shadow, var(--surface-shadow-default));
}

@media (hover: none) and (pointer: coarse) {
  a,
  button,
  [role="button"] {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
  }

  .btn:active,
  .nav-toggle:active,
  .theme-toggle:active,
  .contact-links a:active,
  .error-link:active {
    transform: translateY(1px) scale(var(--press-scale, 0.98));
    opacity: 0.85;
    background-color: var(--accent-ghost);
    border-color: var(--accent-start);
  }

  nav a:active,
  .project-header a:active,
  .footer-links a:active,
  .footer-socials a:active {
    opacity: 0.7;
  }
}

/* ─── 404 / error page ─────────────────────────────────────────────────────── */

.error-page-main {
  min-height: calc(var(--stable-vh) - var(--nav-h));
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: left;
  padding: calc(var(--nav-h) + 20px) var(--pad-x) calc(var(--pad-y) + 20px);
  position: relative;
  z-index: 1;
}

.error-card {
  width: min(720px, 100%);
  padding: 48px 44px;
  position: relative;
  overflow: hidden;
  text-align: left;
  --surface-radius: var(--radius-xl);
}

.error-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--surface-sheen-strong), transparent 60%);
  opacity: 0.5;
  pointer-events: none;
}

.error-card > * {
  position: relative;
  z-index: 1;
}

.error-eyebrow {
  display: inline-block;
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 18px;
}

.error-code {
  font-family: var(--font-heading);
  font-size: clamp(72px, 18vw, 140px);
  line-height: 0.9;
  margin-bottom: 12px;
  letter-spacing: -0.04em;
}

.error-title {
  font-family: var(--font-heading);
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 700;
  margin-bottom: 12px;
}

.error-text {
  font-size: var(--fs-body);
  color: var(--text-muted);
  line-height: 1.7;
  margin: 0 auto 28px;
  max-width: 420px;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 14px;
}

.error-link {
  --pill-pad: 8px 18px;
  --pill-size: var(--fs-link);
  --pill-case: none;
  --pill-tracking: 0.03em;
}

.contact-links a:hover,
.contact-links a:focus-visible,
.error-link:hover,
.error-link:focus-visible {
  color: var(--text-primary);
  background-color: var(--accent-ghost);
  border-color: var(--accent-start);
  box-shadow: 0 0 0 2px var(--accent-start);
  outline: none;
}

@media (forced-colors: active) {
  .error-link:focus-visible,
  .contact-links a:focus-visible {
    outline: 2px solid CanvasText;
    outline-offset: 2px;
    box-shadow: none;
  }
}

.scrollbar {
  position: fixed;
  top: calc(var(--nav-h) + 8px);
  bottom: 56px;
  right: 5px;
  width: 3px;
  pointer-events: none;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 9999;
}

.scrollbar.visible {
  opacity: 1;
  transform: translateX(0);
}

.scrollbar-track {
  position: absolute; inset: 0;
  border-radius: var(--radius-pill);
  background: var(--scrollbar-track);
}

.scrollbar-thumb {
  position: absolute;
  left: 0; width: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--accent-start), var(--accent-end));
}

section {
  min-height: var(--stable-vh);
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  padding: calc(var(--nav-h) + 20px) var(--pad-x) calc(var(--pad-y) + 20px);
  border-bottom: 1px solid var(--border-subtle);
}

section[id] {
  scroll-margin-top: var(--nav-h);
}

section:not(#hero) {
  content-visibility: auto;
  contain-intrinsic-size: 1px var(--section-intrinsic-size);
}

#about {
  --section-intrinsic-size: var(--about-intrinsic-size);
}

#skills {
  --section-intrinsic-size: var(--skills-intrinsic-size);
}

#projects {
  --section-intrinsic-size: var(--projects-intrinsic-size);
}

#contact {
  --section-intrinsic-size: var(--contact-intrinsic-size);
}

section h2 {
  font-family: var(--font-heading);
  font-size: var(--fs-h2);
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.15;
  margin-bottom: var(--heading-gap);
}

nav {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--nav-h);
  padding: 0 var(--pad-x);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-nav);
  /* FIX 1: this is the single backdrop-filter kept — nav frosted glass is the
     only one doing visible work; ticker and overlay versions are removed. */
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
}

nav.menu-open {
  background: var(--bg-nav-open);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-menu {
  list-style: none;
  display: flex;
  gap: 28px;
}

nav a {
  position: relative;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

nav a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
  border-radius: var(--radius-xxs);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

nav a:hover, nav a.active {
  color: var(--text-primary);
}

nav a:hover::after, nav a.active::after {
  transform: scaleX(1);
  transform-origin: left;
}

.nav-toggle {
  --press-scale: 1;
  display: none;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  cursor: pointer;
  color: var(--text-primary);
  transition: background 0.2s ease, border-color 0.2s ease, width 0.25s ease, transform 0.25s ease;
}

.nav-toggle-icon {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
}

.nav-toggle-label {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: inherit;
  white-space: nowrap;
}

.nav-toggle-label.is-animating {
  animation: nav-label-swap 0.24s ease;
}

@keyframes nav-label-swap {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.nav-toggle-icon span {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: var(--radius-xxs);
  transition: transform 0.2s ease, opacity 0.2s ease;
  transform-origin: center;
}

.nav-toggle:hover {
  border-color: var(--border-hover);
}

.nav-toggle.active {
  background: rgba(230, 57, 70, 0.12);
  border-color: rgba(230, 57, 70, 0.45);
}

.nav-toggle.active .nav-toggle-icon span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.nav-toggle.active .nav-toggle-icon span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.nav-toggle.active .nav-toggle-icon span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.theme-toggle-label {
  color: var(--text-dim);
}

.theme-toggle-state {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-ghost);
  color: var(--text-primary);
  font-size: 9px;
  letter-spacing: 0.22em;
}

.theme-toggle:hover {
  border-color: var(--border-hover);
  background-color: var(--accent-ghost);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent-start);
  outline-offset: 2px;
}

#hero {
  position: relative;
  overflow: clip;
  min-height: calc(var(--stable-vh) - var(--nav-h));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: var(--pad-y) var(--pad-x);
  padding-bottom: calc(var(--pad-y) + 40px);
  gap: 0;
  text-align: left;
}

#hero::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, var(--hero-dot) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

#hero::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 85% 75% at 50% 50%, transparent 15%, var(--bg-main) var(--hero-fade-end, 80%));
  pointer-events: none;
  z-index: 1;
}

/* ─── Hero Solar System ──────────────────────────────────────────────────────── */

.hero-solar {
  position: absolute;
  right: 3%;
  top: 50%;
  transform: translateY(-52%);
  width: 660px;
  height: 660px;
  pointer-events: none;
  user-select: none;
  z-index: 2;
  opacity: 0;
  animation: hero-fade-in 1.4s ease 0.3s forwards;
  perspective: 900px;
  perspective-origin: 50% 35%;
}

.solar-system {
  position: relative;
  width: 100%;
  height: 100%;
  transform: rotateX(65deg);
  transform-style: preserve-3d;
}

/* Orbital rings */
.solar-ring {
  position: absolute;
  width: calc(var(--rr) * 2);
  height: calc(var(--rr) * 2);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid var(--solar-ring-color, rgba(255, 255, 255, 0.046));
}

/* Core radiance behind the star */
.solar-core-glow {
  position: absolute;
  width: 160px;
  height: 160px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(230, 57, 70, 0.18) 0%, rgba(244, 131, 31, 0.1) 38%, transparent 72%);
  animation: solar-core-pulse 4.5s ease-in-out infinite;
  z-index: 1;
}

@keyframes solar-core-pulse {
  0%, 100% { opacity: 0.55; transform: translate(-50%, -50%) rotateX(-65deg) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) rotateX(-65deg) scale(1.4); }
}

/* Center star (the logo) */
.solar-star {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotateX(-65deg);
  width: 58px;
  height: 58px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.solar-star svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 9px rgba(230, 57, 70, 0.5)) drop-shadow(0 0 20px rgba(244, 131, 31, 0.25));
  animation: solar-star-pulse 4.5s ease-in-out infinite;
}

@keyframes solar-star-pulse {
  0%, 100% { filter: drop-shadow(0 0 7px rgba(230, 57, 70, 0.38)) drop-shadow(0 0 16px rgba(244, 131, 31, 0.18)); }
  50% { filter: drop-shadow(0 0 15px rgba(230, 57, 70, 0.68)) drop-shadow(0 0 30px rgba(244, 131, 31, 0.36)); }
}

/* Orbit wrapper — zero-size point at the solar system center that spins */
.solar-orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  animation: solar-spin var(--dur, 12s) linear infinite;
  animation-delay: var(--od, 0s);
  transform-style: preserve-3d;
}

/* Static arm that places the orb at radius --r above the center */
.solar-orb-track {
  position: absolute;
  top: calc(-1 * var(--r) - 14px);
  left: 0;
  transform: translateX(-50%);
  transform-style: preserve-3d;
}

/* Orb content — counter-rotates so labels stay upright */
.solar-orb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  animation: solar-counter-spin var(--dur, 12s) linear infinite;
  animation-delay: var(--od, 0s);
  transform-style: preserve-3d;
}

.solar-orb-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--oc, #f2ede7);
  box-shadow:
    0 0 6px var(--og, rgba(242, 237, 231, 0.4)),
    0 0 14px var(--og, rgba(242, 237, 231, 0.22));
  flex-shrink: 0;
}

.solar-orb-label {
  font-family: var(--font-body);
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--oc, #f2ede7);
  opacity: 0.68;
  white-space: nowrap;
  line-height: 1;
  transform: rotateX(-65deg);
}

@keyframes solar-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes solar-counter-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-360deg); }
}

/* Light theme ring tint */
:root[data-theme="light"] .solar-ring {
  --solar-ring-color: rgba(0, 0, 0, 0.07);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .solar-ring {
    --solar-ring-color: rgba(0, 0, 0, 0.07);
  }
}

/* Responsive scaling */
@media (max-width: 1280px) {
  .hero-solar { right: 1%; transform: translateY(-52%) scale(0.84); transform-origin: center center; }
}
@media (max-width: 1024px) {
  .hero-solar {
    right: 50%;
    top: 50%;
    transform: translate(50%, -50%) scale(0.68);
    transform-origin: center center;
    opacity: 0;
    animation: hero-fade-in 1.4s ease 0.3s forwards;
  }
}
@media (max-width: 640px) {
  .hero-solar {
    right: 50%;
    top: 48%;
    transform: translate(50%, -50%) scale(0.46);
    opacity: 0;
    animation: hero-solar-mobile-in 1.4s ease 0.3s forwards;
  }
}

@keyframes hero-solar-mobile-in {
  from { opacity: 0; }
  to   { opacity: 0.22; }
}

@media (prefers-reduced-motion: reduce) {
  .solar-orbit,
  .solar-orb,
  .solar-core-glow,
  .solar-star svg {
    animation: none !important;
  }
  .hero-solar { opacity: 0.5; }
}

.hero-content {
  position: relative;
  z-index: 3;
}

#hero h1 {
  font-family: var(--font-heading);
  font-size: var(--fs-h1);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  margin-bottom: 18px;
  opacity: 0;
  animation: hero-up 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.93s forwards;
}

#hero h1 span { letter-spacing: 0.005em; }

#hero p.subtitle {
  font-size: var(--fs-body);
  color: var(--text-muted);
  line-height: 1.65;
  max-width: 300px;
  margin: 0 0 30px;
  opacity: 0;
  animation: hero-up 0.9s cubic-bezier(0.16, 1, 0.3, 1) 1.06s forwards;
}

#hero .btn {
  opacity: 0;
  animation: hero-up 0.9s cubic-bezier(0.16, 1, 0.3, 1) 1.2s forwards;
}

@keyframes hero-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-side-label {
  display: none;
  position: absolute;
  bottom: calc(40px + 32px);
  left: 0;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  padding: 0 14px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
  z-index: 4;
  opacity: 0;
  animation: hero-fade-in 0.8s ease 1.45s forwards;
}

.hero-badge {
  position: absolute;
  bottom: calc(40px + 26px);
  right: var(--pad-x);
  width: 82px;
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  cursor: default;
  opacity: 0;
  animation: hero-fade-in 0.7s ease 1.5s forwards;
}

.hero-badge text {
  fill: var(--text-muted);
}

@keyframes hero-fade-in { to { opacity: 1; } }

.hero-badge-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  animation: badge-spin 22s linear infinite;
  overflow: visible;
}

@keyframes badge-spin { to { transform: rotate(360deg); } }

.hero-badge-arrow {
  font-size: 18px;
  color: var(--text-muted);
  z-index: 1;
  user-select: none;
  transition: color 0.25s, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.hero-badge:hover .hero-badge-arrow {
  color: var(--text-primary);
  transform: rotate(45deg) scale(1.15);
}

.hero-badge:hover .hero-badge-ring { animation-play-state: paused; }

/* FIX 1: removed backdrop-filter: blur(10px) — the ticker sits over an opaque
   hero background so the blur has no visible effect but creates a compositor layer. */
.hero-ticker {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border-top: 1px solid var(--border-subtle);
  background: var(--hero-ticker-bg);
  z-index: 5;
  opacity: 0;
  animation: hero-fade-in 0.6s ease 1.7s forwards;
}

.hero-ticker-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  white-space: nowrap;
  animation: ticker-scroll 28s linear infinite;
}

.hero-ticker.paused .hero-ticker-inner {
  animation-play-state: paused;
}

.hero-ticker-inner span {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ht-sep {
  color: var(--accent-start) !important;
  font-size: 13px !important;
  letter-spacing: 0 !important;
}

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-1 * var(--ticker-offset))); }
}

@media (prefers-reduced-motion: reduce) {
  html.smooth-scroll {
    scroll-behavior: auto;
  }

  .hero-ticker-inner { animation: none; }
}

.dict-block {
  margin-bottom: 32px;
  padding-left: 16px;
  border-left: 2px solid var(--accent-start);
  opacity: 0;
  animation: hero-up 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.8s forwards;
  max-width: 400px;
}

.dict-word {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 800;
  margin-right: 8px;
}

.dict-phonetic { font-size: 14px; color: var(--text-muted); margin-right: 8px; }
.dict-pos { font-size: 13px; font-style: italic; color: var(--accent-start); }

.dict-def {
  margin-top: 8px;
  padding-left: 18px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

.dict-def li { margin-bottom: 4px; }
.dict-def li::marker { color: var(--text-dim); font-weight: 600; }

#about {
  align-items: center;
  text-align: center;
  gap: 28px;
}

#about img {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--border-hover);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.35s, box-shadow 0.5s;
}

#about img:hover {
  transform: scale(1.045) rotate(-1.5deg);
  border-color: var(--accent-start);
  box-shadow: 0 0 40px rgba(230, 57, 70, 0.18);
}

.about-text p {
  font-size: var(--fs-body);
  color: var(--text-muted);
  line-height: 1.78;
}

.about-text p + p { margin-top: 12px; }

.about-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

.stat-chip:hover {
  border-color: rgba(230, 57, 70, 0.35);
  color: var(--text-primary);
}

#skills { gap: 24px; }

.skills-header {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.skills-heading {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skills-sub {
  font-size: var(--fs-body);
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 520px;
}

.skills-highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.highlight-card {
  padding: 16px;
  color: var(--text-muted);
  position: relative;
  overflow: hidden;
  transition: border-color 0.22s, transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.32s;
}

.highlight-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 40%, var(--surface-sheen) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
  pointer-events: none;
}

.highlight-card:hover::after { transform: translateX(100%); }

.highlight-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(230, 57, 70, 0.08);
}

.highlight-label {
  display: inline-block;
  font-size: var(--fs-tag);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.highlight-card p {
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--text-muted);
}

.skills-kicker {
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 6px;
}

.skills-carousel {
  --carousel-card-width: clamp(180px, 62vw, 260px);
  --carousel-gap: 12px;
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 0 12px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-x pan-y;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.skills-carousel.is-dragging { cursor: grabbing; }
.skills-carousel.is-animated {
  overflow: hidden;
  scroll-snap-type: none;
  touch-action: pan-y;
}
.skills-carousel::-webkit-scrollbar { display: none; }

.skills-track {
  display: flex;
  align-items: stretch;
  gap: var(--carousel-gap);
  width: max-content;
  min-width: 100%;
  will-change: transform;
}

.skills-track .skill-card {
  flex: 0 0 var(--carousel-card-width);
  scroll-snap-align: start;
}
.skills-carousel .skill-card {
  opacity: 1;
  transform: none;
}

.skill-card {
  padding: 20px 18px 18px;
  color: var(--text-primary);
  font-size: var(--fs-body);
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.22s, color 0.22s, background-color 0.22s, transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.32s;
  --surface-radius: var(--radius-md);
  --surface-shadow: var(--shadow-subtle-strong);
}

.skill-card::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, var(--surface-sheen) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.48s ease;
  pointer-events: none;
}

.skill-card:hover::after { transform: translateX(100%); }

.skill-card:hover {
  border-color: var(--accent-start);
  color: var(--text-primary);
  background-color: var(--accent-ghost);
  transform: translateY(-3px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 8px 28px rgba(230, 57, 70, 0.09);
}

.skill-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.skill-card-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.skill-name {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.skill-role {
  font-size: var(--fs-tag);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.skill-desc {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.6;
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.skill-tags span {
  --pill-size: var(--fs-tag);
}

.skill-card:hover .skill-tags span {
  border-color: var(--border-hover);
  color: var(--text-muted);
}

.skill-icon {
  width: 26px;
  height: 26px;
  color: var(--accent-start);
  opacity: 0.65;
  flex-shrink: 0;
  transition: opacity 0.22s, color 0.22s;
}

.skill-card:hover .skill-icon { opacity: 1; }

.projects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.project-card {
  display: flex;
  flex-direction: column;
  clip-path: inset(0 round var(--surface-radius));
  transform-style: preserve-3d;
  transition: border-color 0.25s, box-shadow 0.25s;
  --surface-radius: var(--radius-lg);
}

.project-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 10px 52px rgba(230, 57, 70, 0.09);
}

.project-preview {
  width: 100%;
  height: 130px;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse 65% 80% at 25% 60%, var(--project-preview-accent) 0%, transparent 60%), linear-gradient(145deg, var(--project-preview-base-start) 0%, var(--project-preview-base-end) 100%);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  transition: background 0.3s;
}

.project-preview::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, var(--project-preview-dot) 1px, transparent 1px);
  background-size: 18px 18px;
}

.project-preview::after {
  content: '';
  position: absolute;
  left: 20px; right: 20px;
  bottom: 24px;
  height: 1.5px;
  background: linear-gradient(90deg, var(--project-preview-line), transparent 70%);
  border-radius: 1px;
  box-shadow: 0 -10px 0 var(--project-preview-shadow-1), 0 -20px 0 var(--project-preview-shadow-2);
}

.project-card:hover .project-preview {
  background: radial-gradient(ellipse 65% 80% at 25% 60%, var(--project-preview-accent-hover) 0%, transparent 60%), linear-gradient(145deg, var(--project-preview-base-start-hover) 0%, var(--project-preview-base-end-hover) 100%);
}

.project-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 22px 22px 0;
}

.project-header h3 {
  font-family: var(--font-heading);
  font-size: var(--fs-h3);
  font-weight: 700;
  line-height: 1.3;
}

.project-header a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 16px;
  flex-shrink: 0;
  transition: color 0.2s, transform 0.2s;
  display: inline-block;
}

.project-header a:hover {
  color: var(--accent-end);
  transform: translate(2px, -2px);
}

.project-card > p {
  font-size: var(--fs-body);
  color: var(--text-muted);
  line-height: 1.75;
  padding: 10px 22px 0;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 22px 22px;
}

.project-tags span {
  --pill-size: var(--fs-tag);
}

.project-card:hover .project-tags span {
  border-color: var(--border-hover);
  color: var(--text-muted);
}

#contact {
  align-items: stretch;
  gap: 26px;
}

.contact-sub {
  font-size: var(--fs-body);
  color: var(--text-muted);
  line-height: 1.75;
  max-width: 520px;
  margin: 0;
}

.contact-grid {
  display: grid;
  gap: 18px;
}

.contact-card {
  --surface-bg: var(--contact-card-bg);
  --surface-radius: var(--radius-2xl);
  --surface-shadow: none;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.contact-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
}

.contact-value {
  color: var(--text-primary);
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.contact-card p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.7;
  font-size: var(--fs-body);
}

.contact-actions {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.contact-links a {
  --pill-pad: 9px 14px;
  --pill-size: var(--fs-link);
  --pill-case: none;
  --pill-tracking: 0.03em;
}

footer {
  border-top: 1px solid var(--border-subtle);
  margin-top: 18px;
  padding: 30px var(--pad-x) calc(24px + env(safe-area-inset-bottom));
  background-color: var(--footer-bg);
  text-align: left;
  font-size: 12px;
  color: var(--footer-muted);
}

.footer-grid {
  display: grid;
  gap: 20px;
}

.footer-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.footer-brand p {
  margin: 0;
  color: var(--footer-muted-strong);
  font-size: 13px;
  line-height: 1.65;
}

.footer-links,
.footer-socials {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 14px;
}

.footer-links a,
.footer-socials a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.2px;
  transition: color 0.2s;
}

.footer-links a:hover,
.footer-socials a:hover {
  color: var(--text-primary);
}

.footer-brand span { color: var(--accent-end); }

@media (max-width: 639px) {
  :root {
    --nav-h: 60px;
  }

  nav {
    background: var(--bg-main);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  nav.menu-open {
    background: var(--bg-main);
    box-shadow: none;
  }

  body::after {
    background: var(--overlay-bg-strong);
  }

  .nav-toggle { display: flex; }

  .nav-actions { gap: 10px; }

  .theme-toggle {
    height: 34px;
    padding: 0 10px;
  }

  .theme-toggle-label { display: none; }

  .theme-toggle-state { letter-spacing: 0.18em; }

  .nav-menu {
    position: fixed;
    inset: var(--nav-h) 0 0 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 20px var(--pad-x) 24px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-subtle);
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 210;
  }

  .nav-menu.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  .nav-menu li {
    width: 100%;
    border-bottom: 1px solid var(--border-subtle);
  }

  .nav-menu li:last-child { border-bottom: none; }

  .nav-menu a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: var(--text-primary);
    transition: color 0.2s ease;
  }

  .nav-menu a:hover {
    color: var(--accent-end, #f4831f);
    background: none;
    transform: none;
  }

  .nav-menu a.active {
    color: var(--accent-end, #f4831f);
    background: none;
    transform: none;
  }

  @supports ((-webkit-background-clip: text) or (background-clip: text)) {
    .nav-menu a.active {
      background: linear-gradient(90deg, var(--accent-start, #e63946), var(--accent-end, #f4831f));
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent;
      -webkit-text-fill-color: transparent;
    }
  }

  .nav-menu a::after { display: none; }

  .skills-carousel { --carousel-card-width: clamp(190px, 74vw, 240px); --carousel-gap: 10px; }
  .error-card { padding: 36px 24px; }
  .error-actions { flex-direction: column; }
  .error-eyebrow { letter-spacing: 0.1em; }
}

@media (min-width: 640px) {
  :root {
    --fs-tag: 11px;
    --fs-body: 16px;
    --fs-h3: 19px;
    --fs-h2: 32px;
    --fs-h1: 56px;
    --pad-x: 8%;
    --pad-y: 80px;
    --heading-gap: 36px;
    --nav-h: 64px;
    --radius-button: var(--radius-md);
  }

  #about { flex-direction: row; text-align: left; align-items: center; gap: 48px; }
  #about img { width: 180px; height: 180px; }
  .about-stats { justify-content: flex-start; }
  .skills-header {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 1.4fr;
    align-items: start;
    gap: 32px;
  }
  .skills-carousel { --carousel-card-width: clamp(200px, 40vw, 250px); --carousel-gap: 12px; }
  .projects-grid { grid-template-columns: 1fr; gap: 16px; }
  #hero { min-height: calc(var(--stable-vh) - var(--nav-h)); justify-content: center; }
  #hero p.subtitle, .contact-sub { max-width: 380px; }

  .hero-badge { width: 90px; height: 90px; bottom: calc(40px + 28px); }
  .hero-badge-arrow { font-size: 20px; }

  .btn { padding: 13px 32px; font-size: 14px; }

  nav .logo { font-size: 20px; }
  nav a { font-size: 15px; }
  .nav-menu { gap: 32px; }
}

@media (min-width: 1024px) {
  :root {
    --fs-tag: 12px;
    --fs-body: 17px;
    --fs-h3: 22px;
    --fs-h2: 44px;
    --fs-h1: 88px;
    --pad-x: 10%;
    --pad-y: 120px;
    --heading-gap: 52px;
    --nav-h: 70px;
  }

  #hero { flex-direction: column; text-align: left; align-items: flex-start; justify-content: center; min-height: calc(var(--stable-vh) - var(--nav-h)); }

  .dict-block { margin-bottom: 42px; max-width: 500px; }
  .dict-word { font-size: 28px; }
  .dict-phonetic { font-size: 16px; }
  .dict-pos, .dict-def { font-size: 15px; }
  .hero-side-label { display: block; }
  .hero-badge { width: 96px; height: 96px; bottom: calc(40px + 30px); right: 3%; }
  .hero-badge-arrow { font-size: 22px; }
  #hero h1 { letter-spacing: -4px; margin-bottom: 20px; }

  #hero p.subtitle { max-width: 420px; font-size: 18px; margin: 0 0 32px; }
  .btn { padding: 14px 40px; font-size: 15px; }

  #about { gap: 80px; }
  #about img { width: 260px; height: 260px; }

  .skills-carousel { --carousel-card-width: clamp(220px, 28vw, 280px); --carousel-gap: 14px; }
  .skill-card { padding: 24px 20px; gap: 14px; }
  .skill-icon { width: 30px; height: 30px; }

  .projects-grid { grid-template-columns: repeat(2, 1fr); gap: 22px; }
  .project-preview { height: 150px; }

  .contact-grid { grid-template-columns: 1.1fr 1fr; gap: 22px; }
  .contact-sub { max-width: 600px; font-size: 18px; }
  .footer-grid {
    grid-template-columns: 1.4fr auto auto;
    align-items: start;
    gap: 22px;
  }

  nav .logo { font-size: 22px; }
  nav a { font-size: 16px; }
  .nav-menu { gap: 40px; }
  footer { padding: 26px var(--pad-x) 22px; font-size: 13px; }
}

@media (min-width: 1440px) {
  :root { --fs-h1: 108px; --fs-h2: 56px; --fs-h3: 26px; --fs-body: 18px; --pad-x: 13%; }
  #hero h1 { letter-spacing: -5px; }
  #about img { width: 300px; height: 300px; }
  #about { gap: 100px; }
  .hero-badge { width: 110px; height: 110px; }
  .hero-badge-arrow { font-size: 24px; }
  #hero p.subtitle, .contact-sub { max-width: 560px; }
  .skills-carousel { --carousel-card-width: 260px; --carousel-gap: 14px; }
  .project-preview { height: 170px; }
}

.grain-overlay {
  position: fixed;
  inset: -40px;
  pointer-events: none;
  z-index: 9997;
  opacity: 0.04;
  contain: strict;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 160px 160px;
  animation: grain-shift 0.55s steps(1) infinite;
  will-change: transform;
}

/* Pause grain while the page is scrolling */
body.is-scrolling .grain-overlay { animation-play-state: paused; }

/* FIX 3: pause grain when tab is hidden (set by JS visibilitychange handler) */
.grain-overlay.hidden-tab { animation-play-state: paused; }

@keyframes grain-shift {
  0%   { transform: translate(0px, 0px); }
  11%  { transform: translate(-5px, -10px); }
  22%  { transform: translate(-15px, 5px); }
  33%  { transform: translate(7px, -25px); }
  44%  { transform: translate(-5px, 25px); }
  55%  { transform: translate(-15px, 10px); }
  66%  { transform: translate(15px, 0px); }
  77%  { transform: translate(0px, 15px); }
  88%  { transform: translate(3px, 35px); }
  100% { transform: translate(-10px, 10px); }
}

.cursor-glow {
  position: fixed;
  width: calc(var(--cursor-glow-size) * 1px);
  height: calc(var(--cursor-glow-size) * 1px);
  border-radius: 50%;
  background: radial-gradient(circle, var(--cursor-glow-primary) 0%, var(--cursor-glow-secondary) 35%, transparent 70%);
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 2;
  top: 0;
  left: 0;
}

.reveal {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 0.75s cubic-bezier(0.16, 1, 0.3, 1), transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-left {
  opacity: 0;
  transform: translateX(-36px);
  transition: opacity 0.85s cubic-bezier(0.16, 1, 0.3, 1), transform 0.85s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.visible, .reveal-left.visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal-left {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .error-link {
    transition: none;
  }
}

.nav-logo-svg .base-star, .nav-logo-svg .star-top {
  fill: var(--logo-fill);
  transition: fill 0.3s ease;
}

.nav-logo-svg .star-top-gradient {
  opacity: 0;
  transition: opacity 0.4s ease;
}

nav.at-hero .nav-logo-svg .star-top-gradient {
  opacity: 1;
}