:root {
  color-scheme: light;
  --background: #fbfaf7;
  --surface: #ffffff;
  --text: #111111;
  --muted: #5e5b57;
  --line: #dedbd5;
  --accent: #7a1f1f;
  --accent-hover: #521414;
  --header-background: rgba(251, 250, 247, 0.94);
  --focus: #2457a7;
  --content-width: 930px;
  --reading-width: 620px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --background: #111212;
  --surface: #171818;
  --text: #f3f1ec;
  --muted: #aaa7a1;
  --line: #343535;
  --accent: #e0a2a2;
  --accent-hover: #f1c5c5;
  --header-background: rgba(17, 18, 18, 0.94);
  --focus: #8eb4ff;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 18px;
  line-height: 1.34;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-hover);
}

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

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1000;
  transform: translateY(-150%);
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid transparent;
  background: var(--header-background);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.site-header.is-scrolled {
  border-bottom-color: var(--line);
}

.header-inner {
  width: min(calc(100% - 48px), var(--content-width));
  min-height: 78px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-name {
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.015em;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 18px;
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

.desktop-nav a,
.mobile-nav a {
  color: var(--text);
  text-decoration: none;
}

.desktop-nav a:hover,
.desktop-nav a[aria-current="page"],
.mobile-nav a:hover,
.mobile-nav a[aria-current="page"] {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 6px;
}

.icon-button,
.menu-button {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
}

.icon-button:hover,
.menu-button:hover {
  background: var(--surface);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-icon {
  display: none;
}

.icon-button[data-current-theme="light"] .theme-moon,
.icon-button[data-current-theme="dark"] .theme-sun {
  display: block;
}

.menu-button {
  display: none;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 5px;
  font-size: 16px;
}

.menu-button svg {
  width: 15px;
  height: 15px;
  transition: transform 180ms ease;
}

.menu-button[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.mobile-nav-wrap {
  display: none;
}

.mobile-nav {
  width: min(calc(100% - 48px), var(--content-width));
  margin: 0 auto;
  padding: 0 0 18px;
  border-top: 1px solid var(--line);
}

.mobile-nav[hidden] {
  display: none;
}

.mobile-nav a {
  display: block;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

main {
  width: min(calc(100% - 48px), var(--content-width));
  margin: 0 auto;
}

.home-main {
  padding: 72px 0 96px;
}

.reading-column {
  max-width: var(--reading-width);
}

h1 {
  margin: 0 0 28px;
  font-size: clamp(38px, 4vw, 43px);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.home-copy p {
  margin: 0 0 22px;
  font-size: 18px;
  line-height: 1.36;
  letter-spacing: -0.004em;
}

.home-copy p:last-child {
  margin-bottom: 0;
}

.page-main {
  padding: 64px 0 92px;
}

.page-title {
  margin-bottom: 42px;
  font-size: clamp(36px, 4vw, 43px);
}

.project-list {
  max-width: 780px;
  border-top: 1px solid var(--line);
}

.project-item {
  padding: 22px 0 24px;
  border-bottom: 1px solid var(--line);
}

.project-item h2 {
  margin: 0 0 7px;
  font-size: 23px;
  line-height: 1.2;
}

.project-item h2 a {
  color: var(--text);
  text-decoration-color: var(--accent);
}

.project-item p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.45;
}

.resume-list {
  max-width: 690px;
  border-top: 1px solid var(--line);
}

.resume-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.resume-item h2 {
  margin: 0 0 5px;
  font-size: 22px;
}

.resume-item p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.resume-link {
  white-space: nowrap;
}

.empty-page {
  min-height: 58vh;
}

.site-footer {
  width: min(calc(100% - 48px), var(--content-width));
  margin: 0 auto;
  padding: 26px 0 34px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 760px) {
  body {
    font-size: 17px;
  }

  .header-inner,
  .mobile-nav,
  main,
  .site-footer {
    width: min(calc(100% - 36px), var(--content-width));
  }

  .header-inner {
    min-height: 68px;
    gap: 10px;
  }

  .site-name {
    font-size: 18px;
  }

  .desktop-nav {
    display: none;
  }

  .header-actions {
    gap: 4px;
  }

  .menu-button {
    display: inline-flex;
  }

  .mobile-nav-wrap {
    display: block;
  }

  .home-main {
    padding: 52px 0 72px;
  }

  h1 {
    margin-bottom: 25px;
    font-size: clamp(36px, 11vw, 42px);
  }

  .home-copy p {
    margin-bottom: 22px;
    font-size: 18px;
    line-height: 1.45;
  }

  .page-main {
    padding: 48px 0 72px;
  }

  .page-title {
    margin-bottom: 32px;
  }

  .project-item {
    padding: 19px 0 21px;
  }

  .project-item h2 {
    font-size: 21px;
  }

  .project-item p {
    font-size: 16px;
  }

  .resume-item {
    grid-template-columns: 1fr;
    gap: 9px;
  }
}

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

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Subtle interaction polish */
body,
.site-header,
.icon-button,
.menu-button,
.project-item,
.resume-item,
.site-footer {
  transition:
    background-color 220ms ease,
    color 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease;
}

a {
  transition: color 160ms ease, text-decoration-color 160ms ease;
}

.site-header {
  transition:
    background-color 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease;
}

.site-header.is-scrolled {
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.035);
}

html[data-theme="dark"] .site-header.is-scrolled {
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.18);
}

.desktop-nav a {
  position: relative;
  padding: 8px 0;
  text-decoration: none;
}

.desktop-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 190ms cubic-bezier(0.22, 1, 0.36, 1);
}

.desktop-nav a:hover,
.desktop-nav a[aria-current="page"] {
  color: var(--accent);
  text-decoration: none;
}

.desktop-nav a:hover::after,
.desktop-nav a[aria-current="page"]::after {
  transform: scaleX(1);
}

.icon-button,
.menu-button {
  transition:
    background-color 170ms ease,
    color 170ms ease,
    transform 170ms cubic-bezier(0.22, 1, 0.36, 1);
}

.icon-button:active,
.menu-button:active {
  transform: scale(0.96);
}

.icon-button {
  position: relative;
}

.icon-button .theme-icon {
  display: block;
  position: absolute;
  opacity: 0;
  transform: rotate(-18deg) scale(0.78);
  transition:
    opacity 170ms ease,
    transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.icon-button[data-current-theme="light"] .theme-moon,
.icon-button[data-current-theme="dark"] .theme-sun {
  display: block;
  opacity: 1;
  transform: rotate(0) scale(1);
}

main {
  animation: page-enter 270ms cubic-bezier(0.22, 1, 0.36, 1) both;
  transition:
    opacity 150ms ease,
    transform 150ms ease;
}

html.is-leaving main {
  opacity: 0;
  transform: translateY(5px);
}

@keyframes page-enter {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.project-item h2 a,
.resume-link {
  display: inline-block;
  transition:
    color 160ms ease,
    transform 190ms cubic-bezier(0.22, 1, 0.36, 1),
    text-decoration-color 160ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .project-item:hover h2 a,
  .resume-item:hover .resume-link {
    transform: translateX(3px);
  }
}

@media (max-width: 760px) {
  .mobile-nav-wrap {
    display: block;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-4px);
    transition:
      max-height 260ms cubic-bezier(0.22, 1, 0.36, 1),
      opacity 170ms ease,
      transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .mobile-nav-wrap.is-open {
    max-height: 280px;
    opacity: 1;
    transform: translateY(0);
  }

  .mobile-nav {
    transform: translateY(-5px);
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .mobile-nav-wrap.is-open .mobile-nav {
    transform: translateY(0);
  }

  .mobile-nav a {
    transition:
      color 160ms ease,
      padding-left 190ms cubic-bezier(0.22, 1, 0.36, 1),
      border-color 220ms ease;
  }

  .mobile-nav a:hover,
  .mobile-nav a[aria-current="page"] {
    padding-left: 4px;
    text-decoration: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  main {
    animation: none;
  }

  html.is-leaving main {
    opacity: 1;
    transform: none;
  }
}
