:root {
  --bg: #fcfcfa;
  --bg-glow: none;
  --surface: #f3f2ee;
  --surface-hover: #ecebe5;
  --frame-screen: #ffffff;
  --frame-glint: rgba(255, 255, 255, 0.55);
  --border-glint: rgba(17, 17, 17, 0.22);
  --ink: #111111;
  --body: #3f3f46;
  --muted: #71717a;
  --line: #e6e5e0;
  --line-strong: #cfcec7;
  --rim: none;
  --img-shadow: 0 10px 26px rgba(0, 0, 0, 0.07);
  --grain-opacity: 0.032;
  --toast-bg: #111111;
  --toast-ink: #ffffff;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0c0c0f;
  --bg-glow: radial-gradient(ellipse 75% 42% at 50% -10%, rgba(255, 255, 255, 0.055), transparent 72%);
  --surface: #131318;
  --surface-hover: #18181f;
  --frame-screen: #0b0b0e;
  --frame-glint: rgba(255, 255, 255, 0.08);
  --border-glint: rgba(255, 255, 255, 0.42);
  --ink: #f4f4f5;
  --body: #a1a1aa;
  --muted: #787882;
  --line: rgba(255, 255, 255, 0.085);
  --line-strong: rgba(255, 255, 255, 0.2);
  --rim: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --img-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  --grain-opacity: 0.04;
  --toast-bg: #f4f4f5;
  --toast-ink: #09090b;
}

/* Radial Theme Transition Root Reset */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-new(root) {
  z-index: 9999;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  position: relative;
  background-color: var(--bg);
  background-image: var(--bg-glow);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle Matte Material Grain (Inline SVG, Zero CDN) */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* Choreographed Entrance */
@keyframes revealUp {
  from {
    opacity: 0;
    transform: translateY(8px);
    filter: blur(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

.reveal {
  animation: revealUp 0.48s var(--ease-out) both;
  animation-delay: var(--d, 0ms);
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    animation: none !important;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}

.ambient-field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.page {
  position: relative;
  z-index: 1;
  width: min(960px, calc(100% - 48px));
  margin: 0 auto;
  padding: 36px 0 84px;
}

/* Top Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 40px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.brand-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.email-link {
  background: none;
  border: none;
  padding: 2px 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--line-strong);
  transition: color 0.16s ease, border-color 0.16s ease;
  white-space: nowrap;
}

.email-link:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--rim);
  font-size: 12px;
  color: var(--body);
  will-change: transform;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.28s var(--ease-out);
  white-space: nowrap;
}

.theme-toggle:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
  color: var(--ink);
}

.theme-icon {
  width: 13px;
  height: 13px;
  display: inline-block;
  flex-shrink: 0;
}

[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

/* Vertical Identity Band + Tactile Capsule Pills */
.intro-band {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 32px;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--line);
}

.intro-copy {
  max-width: 860px;
}

.intro-copy p.intro-headline {
  margin: 0 0 8px;
  font-size: clamp(17px, 2vw, 19.5px);
  font-weight: 560;
  letter-spacing: -0.025em;
  line-height: 1.55;
  color: var(--ink);
}

.intro-copy p.intro-sub {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--muted);
}

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

.scope-item {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--rim);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--body);
  will-change: transform;
  transition: border-color 0.18s ease, color 0.18s ease, background-color 0.18s ease, transform 0.28s var(--ease-out);
  white-space: nowrap;
}

.scope-item:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
  color: var(--ink);
}

/* Quiet Section Header */
.section-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--muted);
}

.section-bar-mono {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
}

.works-section {
  scroll-margin-top: 28px;
}

/* 2-Column Showcase Grid */
.showcase-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px;
}

.work-card {
  display: flex;
  flex-direction: column;
  transition: opacity 0.24s var(--ease-out);
}

.showcase-grid:has(.work-card:hover) .work-card:not(:hover) {
  opacity: 0.68;
}

.work-frame {
  position: relative;
  aspect-ratio: 16 / 10;
  padding: 14px 14px 0;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--rim);
  overflow: hidden;
  margin-bottom: 16px;
  will-change: transform;
  transform-style: preserve-3d;
  transition: border-color 0.22s ease, background-color 0.22s ease, transform 0.36s var(--ease-out);
}

.work-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(
    220px circle at var(--bx, -300px) var(--by, -300px),
    var(--border-glint),
    transparent 70%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  opacity: var(--border-on, 0);
  transition: opacity 0.28s ease;
}

.work-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(
    240px circle at var(--mx, 50%) var(--my, 50%),
    var(--frame-glint),
    transparent 68%
  );
  opacity: 0;
  transition: opacity 0.25s ease;
}

.work-card:hover .work-frame::after {
  opacity: 1;
}

.work-frame img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  background: var(--frame-screen);
  box-shadow: var(--img-shadow);
  transition: transform 0.4s var(--ease-out);
}

.work-card:hover .work-frame {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.work-card:hover .work-frame img {
  transform: scale(1.015);
}

.work-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.work-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.work-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.18s ease;
}

.work-card:hover .work-tag {
  color: var(--ink);
}

.arrow-roll {
  position: relative;
  display: inline-block;
  width: 1.05em;
  height: 1.15em;
  overflow: hidden;
  vertical-align: -0.15em;
}

.arrow-roll span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.26s var(--ease-out);
}

.arrow-roll span:last-child {
  transform: translate(-100%, 100%);
}

.work-card:hover .arrow-roll span:first-child {
  transform: translate(100%, -100%);
}

.work-card:hover .arrow-roll span:last-child {
  transform: translate(0, 0);
}

.work-summary {
  margin: 0;
  font-size: 14px;
  line-height: 1.68;
  color: var(--body);
}

/* About Section (First-Person Narrative + Minimal 3-Row Timeline) */
.about-section {
  margin-top: 68px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 28px;
}

.about-prose {
  max-width: 740px;
  margin-bottom: 44px;
}

.about-prose p {
  margin: 0 0 18px;
  font-size: 15px;
  line-height: 1.88;
  color: var(--body);
}

.about-prose p:last-child {
  margin-bottom: 0;
}

.career-list {
  border-top: 1px solid var(--line);
}

.career-row {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  align-items: baseline;
  gap: 8px 28px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.career-date {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}

.career-detail {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
}

.career-detail strong {
  font-size: 15px;
  font-weight: 580;
  color: var(--ink);
}

.career-detail span {
  font-size: 14px;
  color: var(--muted);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 14px);
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: 12.5px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 1000;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Mobile Responsive */
@media (max-width: 760px) {
  .page {
    width: calc(100% - 32px);
    padding: 24px 0 60px;
  }

  .topbar {
    padding-bottom: 18px;
    margin-bottom: 28px;
  }

  .intro-band {
    gap: 18px;
    padding-bottom: 26px;
    margin-bottom: 24px;
  }

  .scope-grid {
    gap: 8px;
  }

  .scope-item {
    font-size: 12.5px;
    padding: 5px 12px;
  }

  .showcase-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .about-section {
    margin-top: 52px;
    padding-top: 26px;
  }

  .about-prose {
    margin-bottom: 32px;
  }

  .career-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 15px 0;
  }
}

/* Print Stylesheet */
@media print {
  @page {
    size: A4;
    margin: 14mm 16mm;
  }

  html,
  body {
    background: #ffffff !important;
    background-image: none !important;
    color: #000000 !important;
  }

  body::after,
  .ambient-field,
  .topbar,
  .toast {
    display: none !important;
  }

  .page {
    width: 100%;
    padding: 0;
  }
}