:root {
  --topbar-height: 72px;
  --hero-gap-top: 20px;
  --hero-gap-bottom: 24px;
  --about-landing-gap: 110px;
  --bg: #efe8db;
  --bg-grad-1: #f6f0e6;
  --bg-grad-2: #e9dbc4;
  --text: #2b2520;
  --muted: #5b4f45;
  --paper: #fff9ef;
  --paper-edge: #e4d4bf;
  --ink: #1b1612;
  --accent: #b34d2b;
  --accent-soft: #ffd2a2;
  --tape: rgba(255, 243, 184, 0.55);
  --line: rgba(36, 30, 24, 0.12);
  --shadow: 0 18px 32px rgba(60, 40, 24, 0.12);
}

body[data-theme="dark"] {
  --bg: #18161d;
  --bg-grad-1: #241f2d;
  --bg-grad-2: #15131a;
  --text: #f4efea;
  --muted: #b6a89f;
  --paper: #24202b;
  --paper-edge: #413846;
  --ink: #f8f2eb;
  --accent: #ff8b60;
  --accent-soft: #3c2b30;
  --tape: rgba(248, 228, 144, 0.2);
  --line: rgba(255, 255, 255, 0.11);
  --shadow: 0 22px 40px rgba(0, 0, 0, 0.35);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Space Grotesk", "PingFang SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 5%, var(--bg-grad-1), transparent 38%),
    radial-gradient(circle at 85% -10%, var(--bg-grad-2), transparent 45%),
    var(--bg);
  min-height: 100vh;
  transition: background 0.35s ease, color 0.35s ease;
  position: relative;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: -20vmax;
  pointer-events: none;
  opacity: 0;
  z-index: 70;
  will-change: transform, opacity;
}

body.theme-transition::before,
body.theme-transition::after {
  opacity: 1;
}

body.theme-transition.theme-to-light::before {
  background:
    radial-gradient(circle at 50% 74%, rgba(255, 201, 118, 0.55) 0 16%, rgba(255, 201, 118, 0.2) 26%, transparent 46%),
    linear-gradient(180deg, rgba(255, 244, 217, 0.34), rgba(255, 250, 239, 0.04));
  animation: sun-rise-screen 740ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

body.theme-transition.theme-to-light::after {
  background: radial-gradient(circle at 50% 28%, rgba(196, 209, 255, 0.42) 0 12%, transparent 34%);
  animation: moon-fall-screen 700ms ease-in both;
}

body.theme-transition.theme-to-dark::before {
  background:
    radial-gradient(circle at 50% 70%, rgba(190, 205, 255, 0.45) 0 15%, rgba(190, 205, 255, 0.16) 25%, transparent 44%),
    linear-gradient(180deg, rgba(44, 52, 82, 0.38), rgba(19, 22, 35, 0.1));
  animation: moon-rise-screen 740ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

body.theme-transition.theme-to-dark::after {
  background: radial-gradient(circle at 50% 30%, rgba(255, 203, 125, 0.46) 0 13%, transparent 34%);
  animation: sun-fall-screen 700ms ease-in both;
}

@keyframes sun-rise-screen {
  0% {
    transform: translateY(36vh) scale(0.8);
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
  100% {
    transform: translateY(-14vh) scale(1.22);
    opacity: 0;
  }
}

@keyframes moon-fall-screen {
  0% {
    transform: translateY(-12vh) scale(1);
    opacity: 0.7;
  }
  100% {
    transform: translateY(34vh) scale(0.8);
    opacity: 0;
  }
}

@keyframes moon-rise-screen {
  0% {
    transform: translateY(36vh) scale(0.8);
    opacity: 0;
  }
  40% {
    opacity: 1;
  }
  100% {
    transform: translateY(-14vh) scale(1.18);
    opacity: 0;
  }
}

@keyframes sun-fall-screen {
  0% {
    transform: translateY(-12vh) scale(1);
    opacity: 0.7;
  }
  100% {
    transform: translateY(34vh) scale(0.8);
    opacity: 0;
  }
}

html.is-damped-scrolling,
body.is-damped-scrolling {
  overscroll-behavior: none;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 30;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--paper-edge);
  border-radius: 10px;
  padding: 0.5rem 0.72rem;
  text-decoration: none;
}

.skip-link:focus-visible {
  left: 10px;
  top: 10px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 5vw;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px dashed var(--line);
  min-height: var(--topbar-height);
}

.brand {
  text-decoration: none;
  color: var(--ink);
  font-family: "Caveat", cursive;
  font-size: 2rem;
}

.theme-toggle {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--text);
  border-radius: 999px;
  min-height: 42px;
  padding: 0.35rem 0.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  background: color-mix(in srgb, var(--accent-soft) 35%, var(--paper));
}

.theme-toggle:active {
  transform: translateY(0);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
}

.menu-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--text);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.menu-toggle:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  background: color-mix(in srgb, var(--accent-soft) 35%, var(--paper));
}

.menu-icon {
  width: 18px;
  height: 14px;
  position: relative;
  display: block;
}

.menu-icon span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform-origin: center;
  transition: transform 0.22s ease, opacity 0.18s ease, top 0.22s ease, width 0.2s ease;
}

.menu-icon span:nth-child(1) {
  top: 0;
}

.menu-icon span:nth-child(2) {
  top: 6px;
}

.menu-icon span:nth-child(3) {
  top: 12px;
}

.menu-toggle[aria-expanded="true"] .menu-icon span:nth-child(1) {
  top: 6px;
  transform: rotate(45deg);
}

.menu-toggle[aria-expanded="true"] .menu-icon span:nth-child(2) {
  opacity: 0;
  width: 0;
}

.menu-toggle[aria-expanded="true"] .menu-icon span:nth-child(3) {
  top: 6px;
  transform: rotate(-45deg);
}

.mobile-menu {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: max(10px, 5vw);
  left: auto;
  width: min(240px, calc(100vw - 20px));
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  box-shadow: var(--shadow);
  padding: 0.4rem;
  display: grid;
  gap: 0.25rem;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top right;
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    visibility 0s linear 0.22s;
}

.mobile-menu.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    visibility 0s linear 0s;
}

.mobile-menu a {
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  padding: 0.6rem 0.75rem;
  border-radius: 9px;
  border: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.mobile-menu a:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--line) 85%, transparent);
  background: color-mix(in srgb, var(--accent-soft) 38%, transparent);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

.theme-toggle .sun,
.theme-toggle .moon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease;
}

.theme-toggle .theme-icon {
  font-size: 0.92em;
  line-height: 1;
  transform: translateY(-0.5px);
}

body[data-theme="light"] .theme-toggle .sun,
body:not([data-theme]) .theme-toggle .sun,
body[data-theme="dark"] .theme-toggle .moon {
  background: var(--accent-soft);
  color: var(--ink);
}

main {
  width: min(1120px, 92vw);
  margin: 0 auto;
  padding-bottom: 4rem;
}

.hero {
  position: relative;
  height: calc(100svh - var(--topbar-height) - var(--hero-gap-top) - var(--hero-gap-bottom));
  border: 2px dashed var(--line);
  border-radius: 26px;
  margin-top: var(--hero-gap-top);
  margin-bottom: var(--hero-gap-bottom);
  overflow: hidden;
  background:
    linear-gradient(115deg, color-mix(in srgb, var(--paper) 78%, transparent), transparent 55%),
    repeating-linear-gradient(0deg, transparent 0 22px, color-mix(in srgb, var(--line) 18%, transparent) 22px 23px);
}

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-width: 220px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  background: color-mix(in srgb, var(--paper) 95%, transparent);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.46rem 0.82rem;
  font-size: 0.78rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 24px rgba(20, 12, 6, 0.14);
  z-index: 4;
  opacity: 0.98;
  transition: transform 0.18s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.scroll-hint:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  background: color-mix(in srgb, var(--accent-soft) 38%, var(--paper));
  transform: translateX(-50%) translateY(-1px);
  box-shadow: 0 14px 28px rgba(20, 12, 6, 0.18);
}

.hint-icon {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  display: inline-grid;
  place-items: center;
  background: color-mix(in srgb, var(--paper) 85%, transparent);
  flex-shrink: 0;
}

.hint-icon svg {
  width: 16px;
  height: 16px;
  fill: var(--accent);
}

.hint-copy {
  display: grid;
  justify-items: start;
  text-align: left;
  line-height: 1.05;
}

.hint-copy strong {
  font-size: 0.78rem;
  color: var(--text);
  font-weight: 700;
}

.hint-copy em {
  font-style: normal;
  font-size: 0.68rem;
  color: var(--muted);
}

.hint-icon svg,
.hint-copy {
  animation: none;
}

.scroll-hint {
  animation: hintPaperFloat 2.4s ease-in-out infinite;
}

@keyframes hintPaperFloat {
  0% {
    transform: translateX(-50%) translateY(0);
    box-shadow: 0 10px 24px rgba(20, 12, 6, 0.14);
  }
  50% {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 14px 28px rgba(20, 12, 6, 0.18);
  }
  100% {
    transform: translateX(-50%) translateY(0);
    box-shadow: 0 10px 24px rgba(20, 12, 6, 0.14);
  }
}

#heroCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-board {
  position: absolute;
  inset: 0;
}

.note {
  position: absolute;
  width: min(34vw, 340px);
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--paper-edge);
  border-radius: 10px;
  padding: 1rem;
  box-shadow: var(--shadow);
  transform: rotate(var(--r)) translate3d(0, 0, 0);
  left: var(--x);
  top: var(--y);
  cursor: grab;
  user-select: none;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.note:active {
  cursor: grabbing;
}

.note.large {
  width: min(54vw, 560px);
}

.note h1,
.note h2 {
  font-family: "Caveat", cursive;
  line-height: 1;
  margin-bottom: 0.4rem;
}

.note h1 {
  font-size: clamp(2rem, 4.2vw, 3.4rem);
}

.note h2 {
  font-size: 2rem;
}

.note p {
  color: color-mix(in srgb, var(--ink) 78%, transparent);
  line-height: 1.5;
}

.note.sticky {
  background: #ffe9a9;
}

body[data-theme="dark"] .note.sticky {
  background: #4b3f22;
  color: #fff5db;
}

.note.tape::before {
  content: "";
  position: absolute;
  top: -11px;
  left: 24px;
  width: 86px;
  height: 22px;
  background: var(--tape);
  border: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  transform: rotate(-4deg);
}

.section {
  margin-top: 3.4rem;
}

section[id] {
  scroll-margin-top: 88px;
}

#about {
  scroll-margin-top: calc(var(--about-landing-gap) + 4px);
}

.about-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1rem;
  align-items: center;
}

.about-copy p {
  margin-top: 0.65rem;
}

.about-avatar {
  display: grid;
  gap: 0.55rem;
  justify-items: center;
  align-content: start;
  padding-top: 0.3rem;
}

.avatar-photo {
  width: min(176px, 44vw);
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 50%;
  border: 2px dashed color-mix(in srgb, var(--accent) 40%, var(--paper-edge));
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  display: block;
  box-shadow: var(--shadow);
}

.avatar-role {
  text-align: center;
  color: var(--muted);
  max-width: 200px;
  font-size: 0.92rem;
}

.tag {
  font-family: "Caveat", cursive;
  color: var(--accent);
  font-size: 1.3rem;
}

.section h2 {
  font-family: "Caveat", cursive;
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 0.2rem 0 0.7rem;
}

.section p {
  color: var(--muted);
  max-width: 760px;
  line-height: 1.65;
}

.paper {
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.skills-grid,
.works-list,
.toolbox-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.skill-card {
  position: relative;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--paper) 94%, transparent), color-mix(in srgb, var(--paper-edge) 12%, transparent));
}

.skill-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.skill-head h3 {
  margin: 0;
  font-family: "Caveat", cursive;
  font-size: 1.95rem;
  line-height: 1;
}

.skill-stamp {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px dashed color-mix(in srgb, var(--line) 84%, transparent);
  background: color-mix(in srgb, var(--accent-soft) 42%, var(--paper));
  display: inline-grid;
  place-items: center;
  font-size: 1.02rem;
  transform: rotate(-4deg);
  box-shadow: 0 3px 8px rgba(20, 12, 6, 0.08);
}

.skill-stamp img {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
  filter: saturate(0.9) contrast(1.05);
}

/* Unified override for icons with built-in transparent padding. */
#toolbox .skill-stamp img.tool-icon-padded {
  width: 22px;
  height: 22px;
}

#toolbox .tool-card[data-brand="vscode"] .skill-stamp,
#toolbox .tool-card[data-brand="xcode"] .skill-stamp,
#toolbox .tool-card[data-brand="androidstudio"] .skill-stamp,
#toolbox .tool-card[data-brand="ghostty"] .skill-stamp {
  border-style: solid;
}

#toolbox .tool-card[data-brand="vscode"] .skill-stamp {
  background: #f3f8ff;
  border-color: #9ccaff;
}

#toolbox .tool-card[data-brand="xcode"] .skill-stamp {
  background: #eef5ff;
  border-color: #9ec0ff;
}

#toolbox .tool-card[data-brand="androidstudio"] .skill-stamp {
  background: #effcf4;
  border-color: #97e4b8;
}

#toolbox .tool-card[data-brand="ghostty"] .skill-stamp {
  background: #f0efff;
  border-color: #b8b5ff;
}

#toolbox .tool-card[data-brand="vscode"] .skill-stamp img,
#toolbox .tool-card[data-brand="xcode"] .skill-stamp img,
#toolbox .tool-card[data-brand="androidstudio"] .skill-stamp img,
#toolbox .tool-card[data-brand="ghostty"] .skill-stamp img {
  filter: none;
}

#toolbox .tool-card .skill-stamp img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.skill-card p {
  margin-top: 0.3rem;
  margin-bottom: 0;
}

.contact-layout {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.9rem;
  grid-template-columns: 1fr;
}

.contact-links-card h2 {
  margin-bottom: 0.7rem;
}

.contact-links {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
}

.contact-links a {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.68rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  text-decoration: none;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.contact-links a:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  background: color-mix(in srgb, var(--accent-soft) 30%, transparent);
}

.contact-links a:focus-visible {
  transform: translateY(-2px);
}

.icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--paper-edge);
  display: inline-grid;
  place-items: center;
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  flex-shrink: 0;
}

.icon svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
  color: var(--accent);
}

.meta {
  display: grid;
  gap: 0.02rem;
}

.meta strong {
  font-size: 0.96rem;
  color: var(--text);
}

.meta em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.88rem;
}

body[data-theme="dark"] .contact-links a {
  background: color-mix(in srgb, #201a26 70%, transparent);
}

.footer {
  width: min(1120px, 92vw);
  margin: 0 auto 2rem;
  padding-top: 1.2rem;
  border-top: 1px dashed var(--line);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  color: var(--muted);
}

.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.reveal.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 860px) {
  :root {
    --topbar-height: 64px;
    --hero-gap-top: 16px;
    --hero-gap-bottom: 18px;
    --about-landing-gap: 96px;
  }

  .topbar {
    gap: 0.55rem;
    padding: 0.7rem 20px;
  }

  .brand {
    font-size: 1.65rem;
  }

  .theme-toggle {
    min-height: 38px;
    padding: 0.28rem 0.5rem;
    font-size: 0.82rem;
  }

  .menu-toggle {
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }

  .hero {
    margin-top: var(--hero-gap-top);
  }

  main,
  .footer {
    width: calc(100vw - 40px);
  }

  .about-layout {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .about-avatar {
    justify-self: center;
    justify-items: center;
  }

  .contact-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  body::before,
  body::after {
    animation: none !important;
    opacity: 0 !important;
  }

  .hint-icon svg,
  .hint-copy {
    animation: none;
  }

  .scroll-hint {
    animation: none;
  }

}

@media (max-width: 620px) {
  :root {
    --topbar-height: 58px;
    --hero-gap-top: 12px;
    --hero-gap-bottom: 14px;
    --about-landing-gap: 88px;
  }

  .topbar {
    padding: 0.65rem 24px;
  }

  .brand {
    font-size: 1.45rem;
  }

  main {
    width: calc(100vw - 48px);
  }

  .footer {
    width: calc(100vw - 48px);
  }

  .mobile-menu {
    right: 24px;
    width: min(240px, calc(100vw - 48px));
  }

  .hero {
    margin-top: var(--hero-gap-top);
  }

  .scroll-hint {
    min-width: 188px;
    padding: 0.34rem 0.56rem;
    bottom: 8px;
    gap: 0.42rem;
  }

  .hint-icon {
    width: 22px;
    height: 22px;
  }

  .hint-icon svg {
    width: 14px;
    height: 14px;
  }

  .hint-copy strong {
    font-size: 0.72rem;
  }

  .hint-copy em {
    font-size: 0.62rem;
  }

  .section {
    margin-top: 2.4rem;
  }

  .section h2 {
    font-size: 2.2rem;
  }

  .paper {
    padding: 1rem;
  }

  .contact-layout {
    grid-template-columns: 1fr;
  }

  .contact-links {
    grid-template-columns: 1fr;
  }
}
