:root {
  color-scheme: dark;
  --zoom: 1;
  --page-max: min(94vw, 1320px);
  --surface: #181b22;
  --text: #f6f2ea;
  --muted: #9aa4b2;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #d9b46c;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-user-select: none;
  user-select: none;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #0f1115;
  color: var(--text);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px
    max(14px, env(safe-area-inset-left));
  background: rgba(15, 17, 21, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
  text-decoration: none;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #222733;
  color: var(--text);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.icon-button:hover {
  border-color: rgba(217, 180, 108, 0.55);
  background: #2b3140;
}

.zoom-label {
  min-width: 48px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.viewer {
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 3vw, 34px);
  align-items: center;
  padding: clamp(16px, 3vw, 38px) 0 clamp(40px, 8vw, 92px);
  overflow-x: auto;
}

.loading-state,
.error {
  margin: 12vh auto;
  color: var(--muted);
  font-size: 15px;
}

.sheet {
  width: calc(var(--page-max) * var(--zoom));
  max-width: calc(100vw * var(--zoom));
  margin: 0;
  padding: 0;
  scroll-margin-top: 72px;
}

.sheet.single {
  width: calc(min(94vw, 980px) * var(--zoom));
}

.page-frame {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
}

.sheet img {
  display: block;
  width: 100%;
  aspect-ratio: var(--ratio);
  height: auto;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    var(--surface);
  object-fit: contain;
  pointer-events: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  user-select: none;
}

.watermark-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  align-content: space-around;
  gap: clamp(34px, 6vw, 90px);
  padding: clamp(18px, 4vw, 56px);
  color: rgba(18, 20, 24, 0.085);
  font-size: clamp(12px, 1.55vw, 24px);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.2;
  pointer-events: none;
  text-align: center;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.18);
  transform: rotate(-18deg) scale(1.06);
  transform-origin: center;
  mix-blend-mode: multiply;
}

.watermark-layer span {
  white-space: nowrap;
}

.sheet:not(.ready) img {
  filter: blur(4px);
}

figcaption {
  padding-top: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.back-top {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 11;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #222733;
  color: var(--text);
  font-size: 20px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.back-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

@media (max-width: 700px) {
  .topbar {
    min-height: 54px;
  }

  .brand {
    font-size: 14px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .viewer {
    align-items: flex-start;
  }

  .sheet,
  .sheet.single {
    width: calc(100vw * var(--zoom));
  }

  .sheet img {
    border-radius: 0;
  }

  .page-frame {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .watermark-layer {
    grid-template-columns: repeat(3, minmax(128px, 1fr));
    gap: 30px;
    padding: 24px;
    font-size: 12px;
  }
}

@media print {
  body > * {
    display: none !important;
  }

  body::before {
    display: block;
    padding: 48px;
    color: #111;
    content: "此作品集页面禁止打印或保存。";
    font: 18px/1.5 system-ui, sans-serif;
  }
}
