:root {
  --bg: #0b0d10;
  --panel: #14181d;
  --panel-2: #1c2129;
  --line: #262d36;
  --text: #e7ecf2;
  --muted: #8b97a6;
  --accent: #6ee7ff;
  --accent-dim: #1f6b7d;
  --peek: #ffd166;
  --topbar-h: 52px;
  --controls-h: 108px;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr auto;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
  overflow: hidden;
  /* 长按按钮时不要弹出系统选择/放大镜 */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar__left,
.topbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.topbar__right {
  margin-left: auto;
}

.brand {
  margin: 0 4px 0 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.brand span {
  color: var(--muted);
  font-weight: 500;
}

.select {
  display: flex;
  align-items: center;
  gap: 6px;
}

.select__label {
  color: var(--muted);
  font-size: 12px;
}

select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* 视角切换 */

.scenes {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 4px;
}

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

.scene-chip {
  flex: 0 0 auto;
  min-width: 34px;
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.scene-chip:hover {
  color: var(--text);
  border-color: #3a4552;
}

.scene-chip[aria-current="true"] {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #eafcff;
  font-weight: 600;
}

.icon-btn {
  height: 30px;
  min-width: 30px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover {
  border-color: #3a4552;
  background: #232a33;
}

.icon-btn--wide {
  font-size: 12px;
  letter-spacing: 0.2px;
}

.zoom-readout {
  min-width: 52px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 舞台 ---------- */

.stage {
  position: relative;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
}

.stage.is-panning {
  cursor: grabbing;
}

.canvas {
  position: relative;
  flex: 0 0 auto;
  transform-origin: center center;
  will-change: transform;
}

.canvas img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  /* 放大后保留原始像素块，方便看清 DLSS 的重建细节 */
  image-rendering: pixelated;
  pointer-events: none;
  -webkit-user-drag: none;
}

.canvas img.is-active {
  opacity: 1;
}

/* 缩放 ≤100% 时用平滑采样，避免缩略时出现锯齿伪影 */
.canvas.is-downscaled img {
  image-rendering: auto;
}

/* HUD */

.hud {
  position: absolute;
  pointer-events: none;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(8, 10, 13, 0.72);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hud--topleft {
  top: 12px;
  left: 12px;
}

.hud--topright {
  top: 12px;
  right: 12px;
  color: var(--muted);
  font-size: 12px;
}

.now {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.now-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.stage.is-peeking .now {
  color: var(--peek);
}

.stage.is-peeking .now-sub {
  color: var(--peek);
  opacity: 0.85;
}

/* 长按时的边框提示 */

.peek-ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 0 solid var(--peek);
  transition: border-width 0.09s ease-out;
}

.stage.is-peeking .peek-ring {
  border-width: 3px;
}

/* 加载进度 */

.loading {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  width: min(360px, 60vw);
  pointer-events: none;
  text-align: center;
}

.loading__bar {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.loading__bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.18s ease-out;
}

.loading__text {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  text-shadow: 0 1px 3px #000;
}

/* ---------- 底部配置按钮 ---------- */

.controls {
  padding: 10px 12px 14px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 9px;
}

.hint b {
  color: var(--text);
  font-weight: 600;
}

.configs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  max-width: 1100px;
  margin: 0 auto;
}

.config-btn {
  position: relative;
  height: 56px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  touch-action: none;
  transition: transform 0.07s, border-color 0.12s, background 0.12s;
}

.config-btn__label {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.config-btn__meta {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.config-btn:hover {
  border-color: #3a4552;
}

/* 基准图 */
.config-btn.is-base {
  border-color: var(--accent);
  background: linear-gradient(180deg, #1b3a44, #16242b);
}

.config-btn.is-base .config-btn__meta {
  color: var(--accent);
}

/* 正在长按预览 */
.config-btn.is-peeking {
  border-color: var(--peek);
  background: linear-gradient(180deg, #3a3220, #241f14);
  transform: scale(0.985);
}

.config-btn.is-peeking .config-btn__meta {
  color: var(--peek);
}

/* 该配置的图还没加载完 */
.config-btn.is-loading::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: sweep 1.1s linear infinite;
}

@keyframes sweep {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

/* ---------- 帮助弹窗 ---------- */

.help {
  width: min(560px, 92vw);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  padding: 22px 24px;
}

.help::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.help h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.help dl {
  margin: 0 0 18px;
}

.help dt {
  font-weight: 600;
  margin-top: 12px;
}

.help dd {
  margin: 3px 0 0;
  color: var(--muted);
}

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  margin: 0 1px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--panel-2);
  font: inherit;
  font-size: 11px;
  text-align: center;
  color: var(--text);
}

.btn-primary {
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  color: #eafcff;
  font: inherit;
  cursor: pointer;
}

@media (max-width: 720px) {
  .brand span,
  .select__label,
  .icon-btn--wide {
    display: none;
  }
  .configs {
    gap: 6px;
  }
  .config-btn {
    height: 50px;
  }
  .config-btn__label {
    font-size: 13px;
  }
}
