:root {
  color-scheme: dark;
  --background: #111111;
  --panel: rgba(17, 17, 17, 0.88);
  --text: #f4f4f1;
  --muted: #969690;
  --line: rgba(255, 255, 255, 0.14);
  --header-height: 72px;
  --sidebar-width: 264px;
  font-family: Inter, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--background);
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 72% 12%, rgba(255, 255, 255, 0.045), transparent 26rem),
    var(--background);
  color: var(--text);
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  background: #fff;
  color: #111;
  transform: translateY(-150%);
}

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

.site-header {
  position: fixed;
  z-index: 30;
  inset: 0 0 auto 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.identity {
  display: inline-flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.identity-name {
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.identity-role {
  color: var(--muted);
  font-size: 0.82rem;
}

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

.page-indicator {
  min-width: 62px;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

#current-page {
  color: var(--text);
}

.page-divider {
  display: inline-block;
  padding: 0 6px;
  color: #555;
}

.text-button,
.download-button,
.icon-button {
  border: 0;
  background: none;
  color: var(--text);
  cursor: pointer;
}

.download-button {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.8rem;
  text-decoration: none;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.download-button:hover,
.download-button:focus-visible {
  background: #f4f4f1;
  border-color: #f4f4f1;
  color: #111;
}

.reading-progress {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  overflow: hidden;
}

.reading-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: #f4f4f1;
  transform: scaleX(0.0196);
  transform-origin: left;
  transition: transform 180ms ease;
}

.desktop-index {
  position: fixed;
  z-index: 10;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 38px 24px 24px 28px;
  border-right: 1px solid var(--line);
}

.index-label,
.index-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.index-nav {
  display: grid;
  gap: 4px;
  margin-top: 24px;
}

.index-nav button,
.mobile-nav button {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 44px;
  padding: 9px 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: color 160ms ease, border-color 160ms ease;
}

.index-nav button span:first-child,
.mobile-nav button span:first-child {
  font-size: 0.86rem;
}

.index-nav button span:last-child,
.mobile-nav button span:last-child {
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
}

.index-nav button:hover,
.index-nav button:focus-visible,
.index-nav button.active {
  color: var(--text);
  border-bottom-color: var(--line);
}

.index-nav button.active::before {
  position: absolute;
  left: 0;
  width: 2px;
  height: 25px;
  background: var(--text);
  content: "";
}

.index-note {
  margin-top: auto;
  text-transform: none;
}

.portfolio {
  width: calc(100% - var(--sidebar-width));
  margin-left: var(--sidebar-width);
  padding: calc(var(--header-height) + 32px) clamp(26px, 4vw, 72px) 96px;
}

.portfolio-page {
  position: relative;
  width: min(100%, 1440px);
  margin: 0 auto clamp(56px, 8vh, 112px);
  scroll-margin-top: calc(var(--header-height) + 22px);
}

.page-frame {
  position: relative;
  aspect-ratio: 1.414 / 1;
  overflow: hidden;
  background: #e9e9e6;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.36);
}

.page-frame::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 28%, rgba(255, 255, 255, 0.36) 42%, transparent 56%);
  background-size: 260% 100%;
  content: "";
  animation: loading-sheen 1.25s ease-in-out infinite;
}

.portfolio-page.loaded .page-frame::after {
  display: none;
}

.page-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 240ms ease;
}

.portfolio-project-link {
  position: absolute;
  z-index: 2;
  top: 79.35%;
  left: 4.35%;
  display: inline-flex;
  align-items: center;
  width: 16.9%;
  height: 4.05%;
  padding-top: 0.15%;
  overflow: hidden;
  background: #fff;
  color: #748197;
  font-size: clamp(0.34rem, 1.04vw, 1rem);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.portfolio-project-link::after {
  position: absolute;
  right: 0;
  bottom: 9%;
  left: 0;
  height: 1px;
  background: #8b96a8;
  content: "";
}

.portfolio-project-link:hover,
.portfolio-project-link:focus-visible {
  color: #36445d;
}

.portfolio-project-link:focus-visible {
  outline: 2px solid #36445d;
  outline-offset: 2px;
}

.portfolio-page.loaded img {
  opacity: 1;
}

.page-caption {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.page-caption span:last-child {
  font-variant-numeric: tabular-nums;
}

.page-controls {
  position: fixed;
  z-index: 20;
  right: 22px;
  bottom: 22px;
  display: grid;
  grid-template-columns: repeat(2, 42px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(16px);
}

.page-controls button {
  width: 42px;
  height: 42px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.page-controls button + button {
  border-left: 1px solid var(--line);
}

.page-controls button:hover,
.page-controls button:focus-visible {
  background: rgba(255, 255, 255, 0.12);
}

.mobile-only,
.mobile-menu {
  display: none;
}

.noscript-note {
  position: fixed;
  z-index: 60;
  inset: 50% auto auto 50%;
  width: min(90vw, 560px);
  margin: 0;
  padding: 24px;
  background: #fff;
  color: #111;
  transform: translate(-50%, -50%);
}

.noscript-note a {
  color: inherit;
}

@keyframes loading-sheen {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

@media (max-width: 900px) {
  :root {
    --header-height: 64px;
  }

  .site-header {
    padding: 0 16px;
  }

  .identity-role,
  .desktop-index,
  .page-indicator {
    display: none;
  }

  .mobile-only {
    display: inline-flex;
  }

  .header-actions {
    gap: 12px;
  }

  .text-button {
    min-height: 40px;
    padding: 0 4px;
    font-size: 0.85rem;
  }

  .download-button {
    min-height: 36px;
    padding: 0 13px;
  }

  .portfolio {
    width: 100%;
    margin-left: 0;
    padding: calc(var(--header-height) + 18px) 12px 78px;
  }

  .portfolio-page {
    margin-bottom: 42px;
    scroll-margin-top: calc(var(--header-height) + 14px);
  }

  .page-frame {
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.34);
  }

  .page-caption {
    margin: 10px 4px 0;
  }

  .page-controls {
    right: 14px;
    bottom: 14px;
  }

  .mobile-menu.open {
    position: fixed;
    z-index: 50;
    inset: 0;
    display: block;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(10px);
  }

  .mobile-menu-panel {
    position: absolute;
    inset: auto 0 0;
    max-height: min(82vh, 720px);
    overflow: auto;
    padding: 20px 22px max(26px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    background: #171717;
  }

  .mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
  }

  .mobile-menu-header h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 560;
  }

  .icon-button {
    width: 44px;
    height: 44px;
    font-size: 1.65rem;
    line-height: 1;
  }

  .mobile-nav button {
    min-height: 50px;
    border-bottom-color: var(--line);
  }

  .mobile-nav button.active {
    color: var(--text);
  }
}

@media (max-width: 480px) {
  .identity-name {
    font-size: 0.92rem;
  }

  .download-button {
    font-size: 0.75rem;
  }

  .portfolio {
    padding-inline: 8px;
  }

  .page-caption {
    font-size: 0.67rem;
  }
}

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

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