:root {
  --bg: #e7ecef;
  --paper: #f8fafb;
  --paper-2: #edf3f6;
  --text: #142126;
  --muted: #4e5d66;
  --line: #b9c7d0;
  --accent: #c56f42;
  --accent-soft: #f2e2d8;
  --radius: 16px;
  --shadow: 0 10px 32px rgba(35, 61, 74, 0.14);
  --shadow-soft: 0 5px 14px rgba(39, 65, 79, 0.09);
  --shadow-hover: 0 12px 26px rgba(31, 58, 73, 0.16);
  --topbar-bg: rgba(231, 236, 239, 0.9);
  --topbar-line: rgba(74, 96, 108, 0.26);
  --brand-bg: #f2f6f8;
  --hero-bg: linear-gradient(145deg, rgba(250, 252, 253, 0.97), rgba(240, 245, 248, 0.94));
  --tag-bg: #eef4f7;
  --surface: #f3f7f9;
  --surface-hover: #eef4f7;
  --surface-border-hover: #9eb2be;
  --body-grad-1: #bcd1dc;
  --body-grad-2: #e8c4a5;
  --body-fx-1: rgba(232, 196, 165, 0.42);
  --body-fx-2: rgba(188, 209, 220, 0.5);
  --body-fx-3: rgba(204, 218, 226, 0.34);
  --subtle-strong: #2a2a2a;
  --subtle-copy: #2f2f2f;
  --subtle-card: #313131;
  --subtle-timeline: #333;
  --subtle-patent: #303030;
  --footer-line: rgba(130, 130, 130, 0.25);
  --btn-solid-bg: #142126;
  --btn-solid-fg: #ffffff;
}

html[data-theme="dark"] {
  --bg: #0f1519;
  --paper: #1a242c;
  --paper-2: #172128;
  --text: #edf4f8;
  --muted: #9fb1bc;
  --line: #314553;
  --accent: #e59466;
  --accent-soft: #3b2a22;
  --shadow: 0 12px 36px rgba(2, 7, 10, 0.45);
  --shadow-soft: 0 8px 20px rgba(3, 9, 13, 0.35);
  --shadow-hover: 0 14px 30px rgba(1, 7, 12, 0.52);
  --topbar-bg: rgba(13, 20, 25, 0.84);
  --topbar-line: rgba(81, 109, 125, 0.28);
  --brand-bg: #18222a;
  --hero-bg: linear-gradient(145deg, rgba(28, 39, 47, 0.96), rgba(21, 30, 37, 0.97));
  --tag-bg: #1b2b36;
  --surface: #172129;
  --surface-hover: #1d2a33;
  --surface-border-hover: #4b6678;
  --body-grad-1: #223a4a;
  --body-grad-2: #4f3225;
  --body-fx-1: rgba(166, 110, 77, 0.18);
  --body-fx-2: rgba(82, 121, 145, 0.2);
  --body-fx-3: rgba(72, 103, 123, 0.14);
  --subtle-strong: #d8e6ee;
  --subtle-copy: #c5d5de;
  --subtle-card: #d1e0e8;
  --subtle-timeline: #cddde6;
  --subtle-patent: #d3e3eb;
  --footer-line: rgba(93, 121, 137, 0.28);
  --btn-solid-bg: #e59466;
  --btn-solid-fg: #0f1519;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 84% 10%, var(--body-grad-1) 0, transparent 36%),
    radial-gradient(circle at 16% 18%, var(--body-grad-2) 0, transparent 32%),
    var(--bg);
  line-height: 1.6;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: -24% -16%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 26%, var(--body-fx-1) 0, rgba(232, 196, 165, 0) 38%),
    radial-gradient(circle at 87% 13%, var(--body-fx-2) 0, rgba(188, 209, 220, 0) 41%),
    radial-gradient(circle at 60% 80%, var(--body-fx-3) 0, rgba(204, 218, 226, 0) 36%);
  filter: blur(12px);
  animation: bgFloat 16s ease-in-out infinite alternate;
}

a {
  color: inherit;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 520ms ease, transform 520ms ease;
}

.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  backdrop-filter: blur(10px);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-line);
  transition: background-color 220ms ease, border-color 220ms ease;
}

.brand {
  font-family: "IBM Plex Mono", monospace;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  background: var(--brand-bg);
}

.menu {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.menu a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 180ms ease, transform 180ms ease;
}

.menu a:hover {
  color: var(--text);
  transform: translateY(-1px);
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

section {
  margin-top: 2.8rem;
}

.hero {
  margin-top: 1.5rem;
  background: var(--hero-bg);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  padding: 2rem;
  box-shadow: var(--shadow);
  animation: heroFade 620ms ease;
  position: relative;
}

.hero-layout {
  display: grid;
  grid-template-columns: minmax(210px, 270px) 1fr;
  gap: 1.3rem;
  align-items: start;
}

.hero-media {
  padding-top: 0.35rem;
  perspective: 1200px;
}

.profile-photo {
  width: 100%;
  max-width: 270px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  display: block;
  background: var(--surface);
  backface-visibility: hidden;
  transform-style: preserve-3d;
}

.profile-photo.is-flipping {
  animation: profileCoinFlip 620ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.hero-tag {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--tag-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
}

h1 {
  margin: 0.4rem 0 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1.05;
}

.role {
  margin: 0.5rem 0 1rem;
  font-size: 1.1rem;
  color: var(--subtle-strong);
}

.intro {
  margin: 0;
  color: var(--subtle-copy);
  font-size: 1.05rem;
  max-width: 70ch;
}

.intro + .intro {
  margin-top: 0.35rem;
}

.hero-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 1.2rem;
  align-items: center;
}

.btn-primary,
.btn-ghost {
  text-decoration: none;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--btn-solid-bg);
  color: var(--btn-solid-fg);
  transition: transform 170ms ease, box-shadow 170ms ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.16);
}

.btn-ghost {
  border: 1px solid var(--line);
  background: var(--surface);
  transition: background-color 170ms ease, border-color 170ms ease;
}

.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: var(--surface-border-hover);
}

.copy-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, color 150ms ease, background-color 150ms ease;
}

.copy-icon:hover {
  transform: translateY(-1px);
  border-color: var(--surface-border-hover);
  color: var(--text);
}

.copy-icon.is-copied {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.socials {
  margin-top: 1rem;
  display: flex;
  gap: 0.65rem;
}

.socials a {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 170ms ease, border-color 170ms ease;
}

.socials a:hover {
  transform: translateY(-2px);
  border-color: var(--surface-border-hover);
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, color 160ms ease, background-color 160ms ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  border-color: var(--surface-border-hover);
  color: var(--text);
  background: var(--surface-hover);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.section-head h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2.6vw, 2.2rem);
}

.section-icon {
  margin-right: 0.48rem;
  color: var(--accent);
  font-size: 0.82em;
}

.card-icon {
  margin-right: 0.42rem;
  color: var(--accent);
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.card {
  background: linear-gradient(180deg, var(--paper), var(--paper-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-soft);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: #96aeba;
  box-shadow: var(--shadow-hover);
}

.card h3 {
  margin: 0;
  font-size: 1.08rem;
}

.card p {
  margin: 0.55rem 0 0;
  color: var(--subtle-card);
  font-size: 0.95rem;
}

.timeline {
  display: grid;
  gap: 0.8rem;
}

.timeline-item {
  background: linear-gradient(180deg, var(--paper), var(--paper-2));
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-soft);
  transition: border-color 180ms ease, transform 180ms ease;
}

.timeline-item:hover {
  border-color: #96aeba;
  transform: translateX(2px);
}

.timeline-item span {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  color: var(--muted);
}

.timeline-item h3 {
  margin: 0.2rem 0 0;
  font-size: 1rem;
}

.timeline-item p {
  margin: 0.15rem 0 0;
  color: var(--subtle-timeline);
}

.skill-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.skill-groups > div {
  background: linear-gradient(180deg, var(--paper), var(--paper-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.95rem;
  box-shadow: var(--shadow-soft);
}

.skill-groups h3 {
  margin: 0;
  font-size: 1rem;
}

.skill-groups p {
  margin: 0.45rem 0 0;
  color: var(--subtle-card);
  font-size: 0.94rem;
}

.patents-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.patent {
  text-decoration: none;
  background: linear-gradient(180deg, var(--paper), var(--paper-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-soft);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.patent:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: #96aeba;
}

.patent h3 {
  margin: 0;
  font-size: 1.02rem;
}

.patent p {
  margin: 0.4rem 0 0;
  color: var(--subtle-patent);
  font-size: 0.92rem;
}

.note {
  background: var(--paper);
  border-left: 6px solid var(--accent);
}

.footer {
  margin: 2rem 0 0;
  border-top: 1px solid var(--footer-line);
  padding: 1rem 1.25rem 1.8rem;
}

.footer p {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.87rem;
}

@media (max-width: 920px) {
  .menu {
    display: none;
  }

  .hero-layout {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }

  .hero-media {
    padding-top: 0;
  }

  .profile-photo {
    max-width: 240px;
    margin: 0 auto;
  }

  .cards,
  .skill-groups,
  .patents-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .topbar {
    padding: 0.8rem;
  }

  .page {
    padding: 1rem 0.85rem 3rem;
  }

  .hero {
    padding: 1.25rem;
  }

  .profile-photo {
    max-width: 210px;
    border-radius: 18px;
  }

  .hero-tag {
    position: static;
    display: inline-block;
    margin-bottom: 0.65rem;
  }

  .section-head {
    display: block;
  }

  .section-head p {
    margin-top: 0.2rem;
  }
}

@keyframes heroFade {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bgFloat {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(-3.4%, 2.8%, 0) scale(1.06);
  }
  100% {
    transform: translate3d(3.1%, -2.5%, 0) scale(1.08);
  }
}

@keyframes profileCoinFlip {
  0% {
    transform: rotateY(0deg) scale(1);
  }
  48% {
    transform: rotateY(88deg) scale(0.9);
  }
  52% {
    transform: rotateY(-88deg) scale(0.9);
  }
  100% {
    transform: rotateY(0deg) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
