:root {
  color-scheme: dark;
  --bg-top: #060816;
  --bg-bottom: #0f1731;
  --bg-accent-1: rgba(146, 168, 255, 0.18);
  --bg-accent-2: rgba(130, 148, 224, 0.14);
  --panel: rgba(11, 20, 40, 0.76);
  --panel-border: rgba(148, 170, 255, 0.16);
  --text: #edf2ff;
  --muted: #aab6df;
  --accent: #92a8ff;
  --accent-strong: #bfd1ff;
  --link-hover: #ffffff;
  --focus-ring: #bfd1ff;
  --header-bg: rgba(8, 13, 28, 0.72);
  --surface-soft: rgba(255, 255, 255, 0.04);
  --card-bg: rgba(255, 255, 255, 0.025);
  --card-border: rgba(191, 209, 255, 0.1);
  --badge-border: rgba(191, 209, 255, 0.18);
  --badge-bg: rgba(255, 255, 255, 0.04);
  --brand-ring: rgba(191, 209, 255, 0.35);
  --brand-mark-bg: radial-gradient(circle at 30% 30%, rgba(191, 209, 255, 0.18), rgba(12, 22, 46, 0.85));
  --orb: radial-gradient(circle, rgba(146, 168, 255, 0.18), transparent 65%);
  --overlay-bottom: rgba(4, 8, 18, 0.28);
  --button-primary-start: #a0b3ff;
  --button-primary-end: #7590ff;
  --button-primary-text: #07101d;
  --skip-bg: #ffffff;
  --skip-text: #07101d;
  --select-bg: rgba(255, 255, 255, 0.04);
  --select-text: #edf2ff;
  --select-border: rgba(148, 170, 255, 0.16);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --max-width: 1320px;
}

html[data-resolved-theme="light"] {
  color-scheme: light;
  --bg-top: #eef4ff;
  --bg-bottom: #dfe8ff;
  --bg-accent-1: rgba(73, 107, 223, 0.12);
  --bg-accent-2: rgba(93, 124, 219, 0.12);
  --panel: rgba(255, 255, 255, 0.82);
  --panel-border: rgba(73, 107, 223, 0.16);
  --text: #13203d;
  --muted: #425174;
  --accent: #496bdf;
  --accent-strong: #2f54c7;
  --link-hover: #13203d;
  --focus-ring: #2f54c7;
  --header-bg: rgba(255, 255, 255, 0.72);
  --surface-soft: rgba(47, 84, 199, 0.06);
  --card-bg: rgba(255, 255, 255, 0.58);
  --card-border: rgba(47, 84, 199, 0.12);
  --badge-border: rgba(47, 84, 199, 0.18);
  --badge-bg: rgba(47, 84, 199, 0.06);
  --brand-ring: rgba(47, 84, 199, 0.24);
  --brand-mark-bg: radial-gradient(circle at 30% 30%, rgba(98, 128, 223, 0.18), rgba(255, 255, 255, 0.92));
  --orb: radial-gradient(circle, rgba(73, 107, 223, 0.14), transparent 65%);
  --overlay-bottom: rgba(223, 232, 255, 0.2);
  --button-primary-start: #3659d6;
  --button-primary-end: #5f7ff1;
  --button-primary-text: #ffffff;
  --skip-bg: #13203d;
  --skip-text: #ffffff;
  --select-bg: rgba(255, 255, 255, 0.88);
  --select-text: #13203d;
  --select-border: rgba(73, 107, 223, 0.16);
  --shadow: 0 18px 50px rgba(58, 76, 125, 0.16);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Barlow", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, var(--bg-accent-1), transparent 28%),
    radial-gradient(circle at 80% 20%, var(--bg-accent-2), transparent 20%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  line-height: 1.6;
  position: relative;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background-image:
    radial-gradient(2px 2px at 20% 30%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1.5px 1.5px at 75% 18%, rgba(255, 255, 255, 0.55), transparent),
    radial-gradient(1.5px 1.5px at 85% 62%, rgba(255, 255, 255, 0.45), transparent),
    radial-gradient(1px 1px at 40% 70%, rgba(255, 255, 255, 0.45), transparent),
    radial-gradient(1px 1px at 12% 82%, rgba(255, 255, 255, 0.55), transparent);
  opacity: 0.65;
  animation: drift 18s linear infinite;
}

body::after {
  background: linear-gradient(transparent, var(--overlay-bottom));
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover,
a:focus-visible {
  color: var(--link-hover);
}

a:focus-visible,
button:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

img {
  max-width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-shell {
  width: min(calc(100% - 2.5rem), var(--max-width));
  margin: 0 auto;
  padding: 1.25rem 0 2.5rem;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 10;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  background: var(--skip-bg);
  color: var(--skip-text);
  font-weight: 700;
}

.skip-link:focus {
  top: 1rem;
}

.site-header,
.site-footer,
.panel,
.project-card {
  backdrop-filter: blur(12px);
}

.site-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 5rem;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: var(--header-bg);
  box-shadow: var(--shadow);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  color: var(--text);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--brand-ring);
  border-radius: 999px;
  font-family: "Michroma", sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  background: var(--brand-mark-bg);
}

.brand-text,
.site-nav a,
.button,
.eyebrow {
  letter-spacing: 0.04em;
}

.brand-text,
h1,
h2,
h3 {
  margin: 0;
}

.brand-text,
h1,
h2,
h3 {
  font-family: "Michroma", sans-serif;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.theme-switcher {
  position: relative;
  z-index: 6;
  display: inline-flex;
}

.theme-option-input {
  pointer-events: none;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-width: 2.7rem;
  min-height: 2.45rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--select-border);
  border-radius: 999px;
  background: var(--select-bg);
  color: var(--select-text);
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.1);
}

.theme-toggle[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--surface-soft);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.14);
}

.theme-toggle-caret {
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  transition: transform 160ms ease;
}

.theme-toggle[aria-expanded="true"] .theme-toggle-caret {
  transform: rotate(-135deg) translateY(-1px);
}

.theme-menu {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  z-index: 12;
  min-width: 10.5rem;
  margin: 0;
  padding: 0.4rem;
  border: 1px solid var(--select-border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  transform-origin: top right;
  animation: theme-menu-enter 160ms ease;
}

.theme-menu[hidden] {
  display: none;
}

.theme-option {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.55rem 0.8rem;
  border-radius: 14px;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  transition: transform 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.theme-option:hover {
  transform: translateY(-1px);
  background: var(--surface-soft);
  color: var(--text);
}

.theme-option-input:checked + .theme-option {
  background: linear-gradient(135deg, var(--button-primary-start), var(--button-primary-end));
  color: var(--button-primary-text);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

.theme-option-input:checked + .theme-option::after {
  content: "";
  position: absolute;
  right: 0.8rem;
  width: 0.42rem;
  height: 0.8rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.theme-option-input:focus-visible + .theme-option {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.theme-icon {
  width: 1.1rem;
  height: 1.1rem;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.site-nav a {
  position: relative;
  padding-bottom: 0.18rem;
  color: var(--muted);
}

.site-nav a.is-active,
.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--text);
}

.site-nav a.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.2rem;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-strong), transparent);
}

.menu-toggle {
  display: none;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0.5rem;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 1.1rem;
  height: 2px;
  margin: 0.2rem 0;
  background: currentColor;
}

main {
  display: grid;
  gap: 1.5rem;
}

.panel,
.project-card {
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 1.6rem;
}

.hero {
  padding: 4rem 1.8rem;
  min-height: 24rem;
  overflow: hidden;
  position: relative;
}

.hero::after,
.page-hero::after {
  content: "";
  position: absolute;
  inset: auto -10% -45% auto;
  width: 20rem;
  height: 20rem;
  border-radius: 999px;
  background: var(--orb);
  filter: blur(8px);
  pointer-events: none;
}

.page-hero {
  min-height: 17rem;
  position: relative;
  overflow: hidden;
}

.article-hero h1 {
  max-width: 32ch;
  font-size: clamp(2.4rem, 5.4vw, 4.6rem);
  line-height: 1.08;
  text-wrap: balance;
}

.eyebrow {
  margin: 0 0 0.85rem;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 600;
}

h1 {
  font-size: clamp(2.2rem, 4.8vw, 4.4rem);
  line-height: 1.08;
  max-width: none;
  text-wrap: balance;
}

.hero h1,
.page-hero h1 {
  max-width: 16ch;
}

.article-hero h1 {
  max-width: 32ch;
}

h2 {
  font-size: clamp(1.15rem, 2.1vw, 1.6rem);
  line-height: 1.35;
}

h3 {
  font-size: 1rem;
  line-height: 1.45;
}

p,
li {
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-copy,
.page-hero p {
  max-width: 52rem;
  text-wrap: pretty;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin: 1.4rem 0;
}

.hero-meta span,
.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--badge-border);
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--accent-strong);
  font-size: 0.86rem;
}

.hero-actions,
.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.hero-actions {
  margin-top: 1.8rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.8rem;
  padding: 0.75rem 1.15rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
}

.button-primary {
  background: linear-gradient(135deg, var(--button-primary-start), var(--button-primary-end));
  color: var(--button-primary-text);
}

.button-secondary {
  border-color: var(--badge-border);
  background: var(--surface-soft);
  color: var(--text);
}

.two-column,
.resume-layout {
  display: grid;
  gap: 1.5rem;
}

.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card-grid,
.project-grid,
.resume-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card-grid,
.project-grid {
  display: grid;
  gap: 1.2rem;
}

.card {
  padding: 1.2rem;
  border-radius: 20px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
}

.project-card {
  padding: 1.6rem;
}

.detail-list,
.link-list {
  padding-left: 1.1rem;
  margin: 1rem 0 0;
}

.link-list li + li,
.detail-list li + li {
  margin-top: 0.55rem;
}

.text-link {
  font-weight: 600;
}

.card-meta {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.resume-actions {
  margin-top: 1.3rem;
}

.resume-document {
  padding: 1.8rem;
}

.resume-document-header {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: start;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--card-border);
}

.resume-identity {
  min-width: 0;
}

.resume-role {
  margin: 0.45rem 0 0;
  color: var(--accent-strong);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.resume-summary {
  margin-top: 0.85rem;
  max-width: 64ch;
}

.resume-contact-block {
  display: grid;
  gap: 0.45rem;
  justify-items: end;
  text-align: right;
  min-width: 16rem;
}

.resume-contact-block a,
.resume-contact-block span {
  color: var(--muted);
  font-size: 0.98rem;
}

.resume-inline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1rem;
}

.resume-inline-meta span {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--badge-border);
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--accent-strong);
  font-size: 0.86rem;
}

.resume-document-grid {
  display: grid;
  grid-template-columns: minmax(16rem, 0.78fr) minmax(0, 1.45fr);
  gap: 1.35rem;
  margin-top: 1.4rem;
}

.resume-column {
  display: grid;
  gap: 1rem;
  align-content: start;
}

.resume-section {
  padding: 1rem 1.05rem;
  border: 1px solid var(--card-border);
  border-radius: 18px;
  background: var(--card-bg);
}

.resume-section h3 {
  margin-top: 0;
  margin-bottom: 0.65rem;
  font-size: 1rem;
}

.resume-section p {
  margin: 0.5rem 0 0;
  max-width: none;
}

.resume-dense-list {
  margin: 0.55rem 0 0;
  padding-left: 1rem;
}

.resume-dense-list li + li {
  margin-top: 0.42rem;
}

.resume-course-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.article-layout {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(0, 1.8fr) minmax(16rem, 0.9fr);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1rem;
}

.article-hero-image {
  width: 100%;
  margin: 1.35rem 0 0;
  border: 1px solid var(--card-border);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.article-hero-image img,
.blog-card-media img {
  display: block;
  width: 100%;
  height: auto;
}

.article-content,
.article-sidebar {
  display: grid;
  gap: 1.1rem;
}

.article-sidebar {
  align-content: start;
  gap: 0.85rem;
}

.article-sidebar-section {
  padding-top: 0.15rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--card-border);
}

.article-sidebar-section + .detail-list {
  margin-top: 0;
}

.article-content h2 {
  margin-top: 0.4rem;
}

.article-content blockquote {
  margin: 0;
  padding: 1rem 1.1rem;
  border-left: 3px solid var(--accent);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 1.1rem;
}

.article-content p,
.article-content li,
.article-sidebar p,
.article-sidebar li {
  max-width: 68ch;
}

.article-content ul,
.article-sidebar ul {
  margin: 0;
}

.article-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
}

.article-back-link::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.blog-card-media {
  margin: 1rem 0 0;
  border: 1px solid var(--card-border);
  border-radius: 18px;
  overflow: hidden;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  padding: 1rem 0.25rem 0;
}

.site-footer p {
  margin: 0;
  font-size: 0.96rem;
}

.footer-copy {
  text-align: right;
}

@keyframes drift {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes theme-menu-enter {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 800px) {
  .menu-toggle {
    display: inline-block;
  }

  .site-header {
    flex-wrap: wrap;
  }

  .header-controls {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .site-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    padding-top: 0.4rem;
    order: 3;
  }

  .theme-switcher {
    margin-left: auto;
  }

  .site-nav.is-open {
    display: flex;
  }

  .two-column,
  .card-grid,
  .project-grid,
  .resume-layout,
  .article-layout,
  .resume-document-grid,
  .resume-course-grid {
    grid-template-columns: 1fr;
  }

  .resume-document-header {
    flex-direction: column;
  }

  .resume-contact-block {
    justify-items: start;
    text-align: left;
    min-width: 0;
  }

  .site-footer {
    flex-direction: column;
  }

  .footer-copy {
    text-align: left;
  }

  .article-hero h1 {
    max-width: 20ch;
    font-size: clamp(2rem, 7vw, 3.5rem);
  }

  .hero h1,
  .page-hero h1 {
    max-width: 14ch;
  }
}

@media (max-width: 640px) {
  .site-shell {
    width: min(calc(100% - 1rem), var(--max-width));
    padding-top: 0.5rem;
  }

  .site-header,
  .panel,
  .project-card {
    border-radius: 20px;
  }

  .site-header {
    padding: 0.8rem 0.9rem;
    min-height: auto;
  }

  .brand {
    gap: 0.65rem;
  }

  .brand-text {
    font-size: 0.96rem;
  }

  .theme-menu {
    right: 0;
    min-width: 9.5rem;
  }

  .hero,
  .page-hero,
  .panel,
  .project-card {
    padding: 1.2rem;
  }

  .hero,
  .page-hero {
    min-height: auto;
  }

  h1 {
    font-size: clamp(1.6rem, 11vw, 2.6rem);
    max-width: none;
  }

  .article-hero h1 {
    max-width: none;
    font-size: clamp(1.95rem, 9vw, 2.9rem);
    line-height: 1.1;
  }

  h2 {
    font-size: 1.1rem;
  }

  p,
  li {
    font-size: 1rem;
  }
}

@media (min-width: 1400px) {
  .site-shell {
    width: min(calc(100% - 4rem), 1440px);
  }

  .hero h1,
  .page-hero h1 {
    max-width: 18ch;
  }

  .article-hero h1 {
    max-width: 34ch;
  }

  .hero-copy,
  .page-hero p {
    max-width: 56rem;
  }

  .two-column,
  .card-grid,
  .project-grid,
  .resume-layout,
  .article-layout {
    gap: 1.5rem;
  }

  .panel,
  .project-card {
    padding: 1.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
