:root {
  --bg: #0A0B0D;
  --bg-soft: #131417;
  --text: #F4F5F7;
  --muted: #8A8F98;
  --line: rgba(255, 255, 255, 0.10);
  --panel: rgba(18, 20, 24, 0.72);
  --radius: 16px;
  --radius-full: 999px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "SF Pro Text", system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  color-scheme: dark;
}

body.is-locked {
  overflow: hidden;
}

/* 顶部栏 */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 20px 8px;
  background: linear-gradient(180deg, rgba(10, 11, 13, 0.92) 0%, rgba(10, 11, 13, 0.55) 60%, rgba(10, 11, 13, 0) 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08);
}

.brand-text {
  min-width: 0;
}

.brand-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  margin: 1px 0 0;
  font-size: 11px;
  line-height: 15px;
  color: var(--muted);
  white-space: nowrap;
}

.qr-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  line-height: 16px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.qr-btn:active {
  background: rgba(255, 255, 255, 0.12);
}

/* 横滑容器 */
.gallery {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.gallery::-webkit-scrollbar {
  display: none;
}

.slide {
  position: relative;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 64px) 20px calc(env(safe-area-inset-bottom) + 56px);
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--bg-soft);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.08);
  -webkit-user-select: none;
  user-select: none;
}

.meta {
  flex: 0 0 auto;
  padding-top: 18px;
}

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

.meta h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 24px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag {
  flex: 0 0 auto;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  font-size: 10px;
  line-height: 14px;
  color: var(--muted);
}

.desc {
  margin: 7px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/* 进度条 */
.pager {
  position: fixed;
  left: 20px;
  right: 20px;
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.counter {
  flex: 0 0 58px;
  font-size: 11px;
  line-height: 16px;
  letter-spacing: 0.06em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.counter-ghost {
  text-align: right;
  color: var(--muted);
}

.dots {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  pointer-events: auto;
}

.dots.is-bar {
  justify-content: stretch;
}

.progress {
  flex: 1 1 auto;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 4%;
  border-radius: 2px;
  background: var(--text);
  transition: width 0.22s ease;
}

.dots button {
  width: 6px;
  height: 6px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.24);
  cursor: pointer;
  transition: width 0.22s ease, background 0.22s ease;
}

.dots button[aria-current="true"] {
  width: 18px;
  background: var(--text);
}

/* 保存与提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 58px);
  z-index: 40;
  transform: translate(-50%, 8px);
  max-width: 86vw;
  padding: 9px 14px;
  border-radius: var(--radius-full);
  background: rgba(28, 30, 35, 0.96);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  line-height: 17px;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

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

.save-btn {
  margin-left: auto;
  flex: 0 0 auto;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  line-height: 15px;
  cursor: pointer;
}

.save-btn:active {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.28);
}

/* 小程序码弹层 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(4px);
  animation: fade-in 0.2s ease both;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 22px 20px calc(env(safe-area-inset-bottom) + 18px);
  border-radius: 20px 20px 0 0;
  background: #16181C;
  border-top: 1px solid var(--line);
  text-align: center;
  animation: sheet-up 0.26s cubic-bezier(0.22, 0.9, 0.32, 1) both;
}

.modal-eyebrow {
  margin: 0;
  font-size: 11px;
  line-height: 16px;
  color: var(--muted);
}

.modal-title {
  margin: 4px 0 0;
  font-size: 17px;
  line-height: 24px;
  font-weight: 600;
}

.qr-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 200px;
  margin: 16px auto 0;
  padding: 10px;
  border-radius: var(--radius);
  background: #fff;
}

.qr-box img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-box img[hidden] {
  display: none;
}

.qr-fallback {
  margin: 0;
  color: #5a5f68;
  font-size: 11px;
  line-height: 1.7;
}

.qr-fallback code {
  font-size: 10.5px;
  color: #23262b;
}

.modal-desc {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 18px;
  color: var(--muted);
}

.modal-close {
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  cursor: pointer;
}

.modal-close:active {
  background: rgba(255, 255, 255, 0.12);
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheet-up {
  from { transform: translateY(18px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* 矮屏微调 */
@media (max-height: 680px) {
  .slide {
    padding-top: calc(env(safe-area-inset-top) + 58px);
    padding-bottom: calc(env(safe-area-inset-bottom) + 48px);
  }
  .meta {
    padding-top: 12px;
  }
  .meta h2 {
    font-size: 16px;
    line-height: 22px;
  }
  .desc {
    margin-top: 5px;
    -webkit-line-clamp: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal-backdrop,
  .modal-card,
  .toast,
  .dots button {
    animation: none;
    transition: none;
  }
}
