:root {
  color-scheme: light;
  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --border: rgba(0, 0, 0, 0.08);
  --text: #1D1D1F;
  --muted: rgba(29, 29, 31, 0.62);
  --accent: #0066CC;
  --btn: #0066CC;
  --accent-dim: rgba(0, 102, 204, 0.10);
  --focus: #0066CC;
  --dot-inactive: #C7C7CC;
  --nav-bg: rgba(245, 245, 247, 0.78);
  --nav-border: rgba(0, 0, 0, 0.08);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #1D1D1F;
  --border: rgba(255, 255, 255, 0.14);
  --text: #F5F5F7;
  --muted: rgba(245, 245, 247, 0.62);
  --accent: #2997FF;
  --btn: #0A6FE0;
  --accent-dim: rgba(41, 151, 255, 0.18);
  --focus: #2997FF;
  --dot-inactive: #48484A;
  --nav-bg: rgba(0, 0, 0, 0.72);
  --nav-border: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

@media (prefers-reduced-motion: reduce) {
  body { transition: none; }
}

a { color: inherit; }

.nav {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  padding: 0 16px;
  pointer-events: none;
}

.nav-inner {
  pointer-events: auto;
  max-width: 640px;
  width: 100%;
  height: 48px;
  margin: 0 auto;
  padding: 0 8px 0 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  background: var(--nav-bg);
  border: 1px solid var(--nav-border);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  box-shadow: 0 8px 28px -12px rgba(0, 0, 0, 0.22);
  transition: box-shadow 0.3s var(--ease), background-color 0.3s var(--ease), border-color 0.3s var(--ease);
}

.nav-brand {
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
  justify-self: start;
  white-space: nowrap;
  transition: opacity 0.2s var(--ease);
}

.nav-brand:hover { opacity: 0.7; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links li { position: relative; }

.nav-links a {
  position: relative;
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 999px;
  transition: color 0.25s var(--ease), background-color 0.25s var(--ease);
}

.nav-links a:hover { color: var(--text); background: var(--accent-dim); }
.nav-links a[aria-current="true"] { color: var(--text); }

.nav-links a::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 2px;
  height: 1.5px;
  background: var(--accent);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.25s var(--ease-out);
}

.nav-links a[aria-current="true"]::after { transform: scaleX(1); }

.nav-links a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 999px;
}

@media (prefers-reduced-motion: reduce) {
  .nav-links a::after { transition: none; }
}

.nav-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  border-radius: 999px;
  padding: 6px;
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
}

.theme-toggle:hover { background: var(--accent-dim); }

.theme-toggle .dot {
  border-radius: 50%;
  transition: background-color 0.3s var(--ease), width 0.3s var(--ease), height 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.theme-toggle .dot-a {
  width: 13px;
  height: 13px;
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--bg);
}

.theme-toggle .dot-b {
  width: 5px;
  height: 5px;
  background: var(--dot-inactive);
}

:root[data-theme="light"] .theme-toggle .dot-a { width: 5px; height: 5px; background: var(--dot-inactive); box-shadow: none; }
:root[data-theme="light"] .theme-toggle .dot-b { width: 13px; height: 13px; background: var(--accent); box-shadow: inset 0 0 0 3px var(--bg); }

.theme-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
  border-radius: 10px;
}

.menu-toggle {
  display: none;
  position: relative;
  background: none;
  border: none;
  border-radius: 999px;
  padding: 6px;
  cursor: pointer;
  color: var(--text);
  transition: background-color 0.2s var(--ease);
}

.menu-toggle:hover { background: var(--accent-dim); }

.menu-toggle svg {
  width: 20px;
  height: 20px;
  grid-area: 1 / 1;
  transition: opacity 0.2s var(--ease), transform 0.3s var(--ease);
}

.menu-toggle #menu-icon-close {
  opacity: 0;
  transform: rotate(-45deg) scale(0.7);
}
.menu-toggle[aria-expanded="true"] #menu-icon-open {
  opacity: 0;
  transform: rotate(45deg) scale(0.7);
}
.menu-toggle[aria-expanded="true"] #menu-icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}
.menu-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}

.nav-panel {
  display: none;
}

@media (max-width: 640px) {
  .nav-inner { grid-template-columns: 1fr auto; }
  .nav-inner > nav { display: none; }
  .nav-links { display: none; }
  .menu-toggle { display: grid; }

  .nav-panel {
    display: flex;
    position: fixed;
    top: calc(16px + env(safe-area-inset-top, 0px) + 56px);
    left: 16px;
    right: 16px;
    z-index: 49;
    max-width: 640px;
    margin: 0 auto;
    background: var(--nav-bg);
    border: 1px solid var(--nav-border);
    border-radius: 20px;
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    box-shadow: 0 8px 28px -12px rgba(0, 0, 0, 0.22);
    padding: 0 18px;
    flex-direction: column;
    gap: 2px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transform: translateY(-6px);
    transition: max-height 0.32s var(--ease), opacity 0.22s var(--ease), transform 0.28s var(--ease), padding 0.32s var(--ease);
  }

  .nav-panel.open {
    max-height: 320px;
    opacity: 1;
    padding: 10px 18px 14px;
    pointer-events: auto;
    transform: translateY(0);
  }

  .nav-panel a {
    padding: 12px 4px;
    font-size: 0.95rem;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    border-radius: 6px;
    transition: color 0.2s var(--ease), padding-left 0.2s var(--ease);
  }

  .nav-panel a:hover,
  .nav-panel a[aria-current="true"] { color: var(--accent); padding-left: 8px; }

  .nav-panel a:last-of-type { border-bottom: none; }
}

@media (prefers-reduced-motion: reduce) {
  .nav-panel {
    transition: opacity 0.15s linear;
    transform: none;
  }
  .menu-toggle svg { transition: opacity 0.15s linear; }
  .menu-toggle #menu-icon-close,
  .menu-toggle[aria-expanded="true"] #menu-icon-open { transform: none; }
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 28px 80px;
}

section { scroll-margin-top: calc(env(safe-area-inset-top, 0px) + 84px); }

#about {
  padding-top: calc(env(safe-area-inset-top, 0px) + 104px);
}

.greet {
  font-size: 1.6rem;
  line-height: 1.25;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 2px;
  letter-spacing: -0.02em;
}

.role {
  font-size: 1.02rem;
  color: var(--muted);
  margin: 0 0 36px;
  font-weight: 400;
}

.tagline {
  font-size: 1.06rem;
  color: var(--text);
  line-height: 1.6;
  max-width: 40ch;
  margin: 0 0 44px;
  opacity: 0.9;
  font-weight: 400;
}

.links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0 32px;
}

.section-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
  margin: 0 0 18px;
}

.about-toggle {
  display: inline-flex;
  padding: 6px 4px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  border-radius: 6px;
  margin-bottom: 2px;
  transition: opacity 0.2s var(--ease);
}

.about-toggle:hover { text-decoration: underline; text-underline-offset: 3px; opacity: 0.8; }

.about-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.about-text {
  max-width: 42ch;
  font-size: 0.94rem;
  line-height: 1.6;
  color: var(--muted);
  margin: 2px 4px 12px;
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  opacity: 0;
  transition: grid-template-rows 0.35s var(--ease), opacity 0.3s var(--ease);
}

.about-text.open {
  grid-template-rows: 1fr;
  opacity: 1;
}

.about-text > span { min-height: 0; overflow: hidden; display: block; }

@media (prefers-reduced-motion: reduce) {
  .about-text { transition: opacity 0.15s linear; }
}

.links a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 4px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.96rem;
  border-radius: 6px;
  width: fit-content;
  transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
}

.links a:hover { text-decoration: underline; text-underline-offset: 3px; transform: translateX(2px); }

.links a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.links svg { width: 17px; height: 17px; flex-shrink: 0; transition: transform 0.2s var(--ease); }

.links a.resume-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  background: var(--btn);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  width: fit-content;
  transition: opacity 0.25s var(--ease), transform 0.2s var(--ease), box-shadow 0.25s var(--ease);
}

.links a.resume-btn:hover {
  opacity: 0.92;
  text-decoration: none;
  transform: translateX(0) translateY(-1px);
  box-shadow: 0 6px 16px -6px var(--accent-dim);
}
.links a.resume-btn:active { transform: translateY(0) scale(0.98); box-shadow: none; }
.links a.resume-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.links a.resume-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

@media (prefers-reduced-motion: reduce) {
  .links a:hover { transform: none; }
  .links a.resume-btn:hover,
  .links a.resume-btn:active { transform: none; }
}

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

.stack-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--text);
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease), background-color 0.2s var(--ease);
}

.stack-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--accent);
  transition: transform 0.25s var(--ease-out);
}

.projects {
  display: flex;
  flex-direction: column;
}

.project {
  display: flex;
  flex-direction: column;
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}

.project:first-child { padding-top: 0; }
.project:last-child { border-bottom: none; padding-bottom: 0; }

.project h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.project p {
  margin: 0 0 14px;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--muted);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.tags li {
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 4px 10px;
  border-radius: 999px;
}

.project-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  margin-top: auto;
  padding-top: 16px;
  transition: gap 0.2s var(--ease);
}

.project-link:hover { text-decoration: underline; text-underline-offset: 3px; gap: 6px; }

.project-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

.project-link svg { width: 15px; height: 15px; transition: transform 0.25s var(--ease-out); }
.project-link:hover svg { transform: translateX(3px); }

@media (prefers-reduced-motion: reduce) {
  .project-link:hover svg { transform: none; }
  .project-link:hover { gap: 3px; }
}

.contact {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
}

.contact-note {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
}

.send-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  border: none;
  border-radius: 999px;
  background: var(--btn);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 12px 24px;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.25s var(--ease), transform 0.2s var(--ease), box-shadow 0.25s var(--ease);
}

.send-btn:hover { opacity: 0.92; transform: translateY(-1px); box-shadow: 0 6px 16px -6px var(--accent-dim); }
.send-btn:active { transform: translateY(0) scale(0.98); box-shadow: none; }
.send-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .send-btn:hover,
  .send-btn:active { transform: none; }
}

footer {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 28px 48px;
  text-align: center;
}

footer p {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
}

@media (max-width: 520px) {
  .nav-brand { font-size: 0.84rem; }
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 8px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--btn);
  color: #fff;
  font-size: 0.9rem;
  text-decoration: none;
  transition: top 0.25s var(--ease-out);
}

.skip-link:focus { top: 8px; }

@media (prefers-reduced-motion: reduce) {
  .skip-link { transition: none; }
}

@media (max-width: 520px) {
  .wrap { padding-left: 20px; padding-right: 20px; }
}

::selection { background: var(--accent-dim); color: var(--text); }

.stack-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 14px -8px var(--accent-dim);
}
.stack-item:hover svg { transform: scale(1.08); }

.js-reveal .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}
.js-reveal .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .js-reveal .reveal { opacity: 1; transform: none; transition: none; }
  .stack-item:hover { transform: none; box-shadow: none; }
  .stack-item:hover svg { transform: none; }
}

@media print {
  .nav, .nav-panel, .skip-link, .theme-toggle, .contact { display: none !important; }
  body { background: #fff; color: #000; }
  #about { padding-top: 0; }
}
