:root {
  --bg: #111214;
  --fg: #f2f2f3;
  --muted: rgba(242, 242, 243, 0.46);
  --line: rgba(242, 242, 243, 0.18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.gallery {
  position: fixed;
  inset: 0;
  background: var(--bg);
}

/* 图片区域：为上下信息栏留出空间，图片完整显示、不裁切、不拉伸 */
.viewport {
  position: absolute;
  top: calc(var(--safe-top) + 58px);
  bottom: calc(var(--safe-bottom) + 82px);
  left: calc(var(--safe-left) + 18px);
  right: calc(var(--safe-right) + 18px);
  overflow: hidden;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

.slide {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform, opacity;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* 顶部：品牌 + 作品集进度 */
.topbar {
  position: absolute;
  top: calc(var(--safe-top) + 20px);
  left: calc(var(--safe-left) + 20px);
  right: calc(var(--safe-right) + 20px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.brand { display: flex; flex-direction: column; gap: 5px; }

.brand-cn {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.28em;
  line-height: 1;
}

.brand-en {
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.36em;
  color: var(--muted);
  line-height: 1;
}

.work-counter {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.2em;
  color: var(--muted);
  line-height: 1.4;
  padding-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* 底部：作品名 + 图序 + 进度条 */
.bottombar {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 22px);
  left: calc(var(--safe-left) + 20px);
  right: calc(var(--safe-right) + 20px);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  pointer-events: none;
}

.work-title {
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.14em;
  line-height: 1.3;
}

.image-counter {
  margin-top: 7px;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.22em;
  color: var(--muted);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.progress { width: 76px; flex: none; padding-bottom: 2px; }

.progress-track {
  height: 1px;
  width: 100%;
  background: var(--line);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--fg);
  transition: width 260ms ease;
}

/* 桌面端左右按钮 */
.nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: color 180ms ease, opacity 180ms ease;
  z-index: 5;
}

.nav:hover { color: var(--fg); }
.nav:focus-visible { outline: 1px solid var(--muted); outline-offset: -4px; }
.nav-prev { left: calc(var(--safe-left) + 6px); }
.nav-next { right: calc(var(--safe-right) + 6px); }

/* 滑动提示 */
.hint {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 4px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  letter-spacing: 0.28em;
  color: var(--muted);
  opacity: 1;
  transition: opacity 700ms ease;
  pointer-events: none;
  white-space: nowrap;
}

/* 触屏设备隐藏箭头，保持界面干净 */
@media (hover: none), (pointer: coarse) {
  .nav { display: none; }
}

/* 桌面 / 平板：放大留白与字号 */
@media (min-width: 768px) {
  .viewport {
    top: calc(var(--safe-top) + 76px);
    bottom: calc(var(--safe-bottom) + 100px);
    left: calc(var(--safe-left) + 72px);
    right: calc(var(--safe-right) + 72px);
  }
  .topbar {
    top: calc(var(--safe-top) + 30px);
    left: calc(var(--safe-left) + 40px);
    right: calc(var(--safe-right) + 40px);
  }
  .bottombar {
    bottom: calc(var(--safe-bottom) + 32px);
    left: calc(var(--safe-left) + 40px);
    right: calc(var(--safe-right) + 40px);
  }
  .brand-cn { font-size: 14px; letter-spacing: 0.32em; }
  .brand-en { font-size: 10px; }
  .work-title { font-size: 15px; }
  .image-counter { font-size: 11px; }
  .work-counter { font-size: 12px; }
  .progress { width: 110px; }
  .nav-prev { left: calc(var(--safe-left) + 14px); }
  .nav-next { right: calc(var(--safe-right) + 14px); }
}

/* 横屏矮屏：压缩留白，给图片更多空间 */
@media (max-height: 480px) {
  .viewport {
    top: calc(var(--safe-top) + 40px);
    bottom: calc(var(--safe-bottom) + 46px);
  }
  .topbar { top: calc(var(--safe-top) + 10px); }
  .bottombar { bottom: calc(var(--safe-bottom) + 10px); }
  .brand-en { display: none; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .slide, .progress-fill, .hint, .nav { transition-duration: 1ms !important; }
}
