/* ============================================================
   图片圣诞树 · 手势相册
   ============================================================ */

:root {
  --bg: #05070f;
  --ink: #f2f6ff;
  --ink-dim: #9aa7c2;
  --line: rgba(255, 255, 255, 0.12);
  --glass: rgba(12, 17, 32, 0.62);
  --glass-2: rgba(18, 24, 42, 0.86);
  --red: #ff4d5e;
  --green: #35d07f;
  --gold: #ffcf5c;
  --blue: #5aa9ff;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui,
    -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; }

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#scene:active { cursor: grabbing; }

.hidden { display: none !important; }

/* ---------------- 通用按钮 ---------------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--ink);
  font: 600 13px/1 var(--font);
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform 0.15s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
  user-select: none;
}
.btn:hover { background: rgba(40, 52, 84, 0.8); border-color: rgba(255, 255, 255, 0.26); }
.btn:active { transform: scale(0.96); }
.btn.on {
  background: linear-gradient(135deg, rgba(255, 77, 94, 0.9), rgba(255, 122, 89, 0.72));
  border-color: rgba(255, 175, 175, 0.5);
  box-shadow: 0 6px 22px rgba(255, 77, 94, 0.32);
}
.btn-primary {
  background: linear-gradient(135deg, #ff4d5e, #ff8a5b);
  border-color: rgba(255, 190, 160, 0.45);
  color: #fff;
  box-shadow: 0 8px 26px rgba(255, 77, 94, 0.34);
}
.btn-primary:hover { background: linear-gradient(135deg, #ff5f6f, #ff9a6c); }
.btn-ghost { background: rgba(255, 255, 255, 0.05); padding: 9px 13px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------------- 加载层 ---------------- */
#loader {
  position: absolute;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 42%, #0d1630 0%, #05070f 68%);
  transition: opacity 0.6s ease, visibility 0.6s;
}
#loader.done { opacity: 0; visibility: hidden; }
.loader-inner { text-align: center; width: 280px; }
.loader-star {
  width: 54px;
  height: 54px;
  margin: 0 auto 18px;
  background: var(--gold);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  filter: drop-shadow(0 0 22px rgba(255, 207, 92, 0.85));
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 0.9; } 50% { transform: scale(1.16); opacity: 1; } }
.loader-title { font-size: 15px; letter-spacing: 3px; margin: 0 0 14px; color: #dfe7ff; }
.loader-bar { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.loader-bar i { display: block; height: 100%; width: 0%; border-radius: 4px; background: linear-gradient(90deg, var(--green), var(--gold)); transition: width 0.3s ease; }
.loader-tip { font-size: 12px; color: var(--ink-dim); margin: 12px 0 0; }

/* ---------------- 顶栏 ---------------- */
#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 16px 20px;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; justify-self: start; }
.brand-icon { font-size: 26px; filter: drop-shadow(0 0 14px rgba(53, 208, 127, 0.7)); }
.brand-text h1 { margin: 0; font-size: 15px; letter-spacing: 1px; font-weight: 700; color: rgba(242, 246, 255, 0.7); }

.xmas-title { text-align: center; justify-self: center; }
.xmas-title h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
  font-size: clamp(20px, 3.4vw, 34px);
  font-weight: 400;
  letter-spacing: 6px;
  text-transform: none;
  background: linear-gradient(180deg, #fff8e6 8%, #ffdf9a 55%, #d9a441 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 18px rgba(255, 205, 110, 0.35));
}
.xmas-title p {
  margin: 5px 0 0;
  font-size: 10.5px;
  letter-spacing: 5px;
  color: rgba(190, 205, 235, 0.55);
}
.top-actions { display: flex; gap: 8px; justify-self: end; }

/* ---------------- 底部控制条 ---------------- */
#dock {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  max-width: calc(100vw - 24px);
}
.dock-row {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}
.dock-row::-webkit-scrollbar { display: none; }
.dock-row-2 { flex-wrap: wrap; justify-content: center; }

.chip {
  appearance: none;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-dim);
  font: 600 12.5px/1 var(--font);
  padding: 9px 13px;
  border-radius: 11px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s;
}
.chip:hover { color: var(--ink); background: rgba(255, 255, 255, 0.1); }
.chip.active {
  color: #061108;
  background: linear-gradient(135deg, #4fe08d, #a8f0c0);
  box-shadow: 0 5px 18px rgba(53, 208, 127, 0.34);
}
.dock-sep { width: 1px; background: var(--line); margin: 0 4px; align-self: stretch; }
.dock-stat { font-size: 12px; color: var(--ink-dim); align-self: center; padding-right: 6px; }

/* ---------------- 摄像头 HUD ---------------- */
#cam {
  position: absolute;
  right: 18px;
  bottom: 132px;
  z-index: 34;
  width: 232px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--glass-2);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  animation: pop 0.28s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.96); } }
.cam-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; font-size: 12px; color: var(--ink-dim);
  border-bottom: 1px solid var(--line);
}
.cam-head button {
  background: none; border: 0; color: var(--ink-dim);
  font-size: 19px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.cam-head button:hover { color: #fff; }
.cam-stage { position: relative; aspect-ratio: 4 / 3; background: #000; }
#cam-video, #cam-canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#cam-video { transform: scaleX(-1); }
#cam-canvas { transform: scaleX(-1); }
.cam-foot { padding: 9px 12px 11px; }
.gesture-name {
  font-size: 13px; font-weight: 700; color: var(--gold);
  display: flex; align-items: center; gap: 6px; min-height: 18px;
}
.gesture-bars { display: flex; gap: 10px; margin-top: 8px; }
.gbar { flex: 1; }
.gbar i {
  display: block; height: 4px; border-radius: 4px; width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--gold));
  transition: width 0.12s linear;
}
.gbar em { display: block; font-size: 10px; color: var(--ink-dim); font-style: normal; margin-top: 4px; }
.cam-debug {
  display: none;
  margin-top: 8px;
  font-size: 10px;
  line-height: 1.5;
  color: #7f8db0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  word-break: break-all;
}
.cam-debug.show { display: block; }

/* ---------------- 相册面板 ---------------- */
#panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  z-index: 60;
  width: 340px;
  max-width: 88vw;
  display: flex;
  flex-direction: column;
  background: var(--glass-2);
  border-left: 1px solid var(--line);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.55);
  animation: slidein 0.26s ease;
}
@keyframes slidein { from { transform: translateX(100%); } }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 14px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-head em { color: var(--ink-dim); font-style: normal; font-size: 12px; margin-left: 6px; }
.panel-head button { background: none; border: 0; color: var(--ink-dim); font-size: 24px; cursor: pointer; line-height: 1; }
.panel-head button:hover { color: #fff; }
.panel-body { flex: 1; overflow-y: auto; padding: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; align-content: start; }
.panel-body::-webkit-scrollbar { width: 6px; }
.panel-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 3px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #10162a; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px;
  border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.65); color: #fff;
  font-size: 13px; line-height: 20px; padding: 0; cursor: pointer; opacity: 0;
  transition: opacity 0.2s;
}
.thumb:hover button { opacity: 1; }
.thumb button:hover { background: var(--red); }
.panel-empty { grid-column: 1 / -1; text-align: center; color: var(--ink-dim); font-size: 13px; padding: 44px 12px; line-height: 1.8; }
.panel-foot { padding: 14px; border-top: 1px solid var(--line); }
.panel-note { margin: 10px 0 0; font-size: 11px; color: var(--ink-dim); text-align: center; line-height: 1.6; }

/* ---------------- 灯箱 ---------------- */
#lightbox {
  position: absolute; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: rgba(3, 5, 12, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadein 0.22s ease;
}
@keyframes fadein { from { opacity: 0; } }
#lb-img {
  max-width: 82vw; max-height: 78vh;
  border-radius: 12px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.14);
  object-fit: contain;
}
#lightbox button {
  position: absolute;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  width: 44px; height: 44px;
  font-size: 24px;
  line-height: 1;
  transition: background 0.2s;
}
#lightbox button:hover { background: rgba(255, 255, 255, 0.2); }
#lb-close { top: 22px; right: 22px; }
#lb-prev { left: 22px; top: 50%; transform: translateY(-50%); }
#lb-next { right: 22px; top: 50%; transform: translateY(-50%); }
#lb-name { position: absolute; bottom: 30px; left: 0; right: 0; text-align: center; color: var(--ink-dim); font-size: 12.5px; margin: 0; }

/* ---------------- 说明 ---------------- */
#help {
  position: absolute; inset: 0; z-index: 85;
  display: grid; place-items: center;
  background: rgba(3, 5, 12, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadein 0.22s ease;
  padding: 20px;
}
.help-card {
  position: relative;
  width: min(520px, 100%);
  max-height: 84vh;
  overflow-y: auto;
  background: linear-gradient(160deg, #131c33, #0a1020);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 30px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}
.help-card h2 { margin: 0 0 18px; font-size: 18px; }
.help-card h3 { margin: 20px 0 10px; font-size: 13.5px; color: var(--gold); letter-spacing: 0.5px; }
.help-card ul { margin: 0; padding-left: 18px; }
.help-card li { font-size: 12.8px; line-height: 1.9; color: #cfd9f2; }
.help-gestures li { list-style: none; margin-left: -14px; display: flex; gap: 10px; }
.help-gestures b { min-width: 118px; color: #fff; }
.help-gestures span { color: var(--ink-dim); }
.help-card kbd {
  background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 6px; font-size: 11px; font-family: inherit;
}
.help-foot { margin: 24px 0 0; text-align: center; font-size: 12px; color: var(--green); }
#help-close, #lb-close { }
#help-close {
  position: absolute; top: 16px; right: 18px;
  background: none; border: 0; color: var(--ink-dim);
  font-size: 26px; cursor: pointer; line-height: 1;
}
#help-close:hover { color: #fff; }

/* ---------------- 上传密码锁 ---------------- */
#lock {
  position: absolute; inset: 0; z-index: 88;
  display: grid; place-items: center;
  background: rgba(3, 5, 12, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fadein 0.2s ease;
  padding: 20px;
}
.lock-card {
  position: relative;
  width: min(360px, 100%);
  background: linear-gradient(160deg, #16203a, #0a1020);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px 26px 24px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
  animation: pop 0.24s ease;
}
.lock-icon { font-size: 34px; margin-bottom: 10px; filter: drop-shadow(0 0 16px rgba(255, 207, 92, 0.5)); }
.lock-card h2 { margin: 0 0 6px; font-size: 16px; }
.lock-sub { margin: 0 0 18px; font-size: 12px; color: var(--ink-dim); }
.lock-card input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font: 600 14px/1 var(--font);
  text-align: center;
  letter-spacing: 2px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.lock-card input[type="password"] + input[type="password"] { margin-top: 9px; }
.lock-card input[type="password"]:focus {
  border-color: rgba(255, 175, 175, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 77, 94, 0.15);
}
.lock-card input.hidden { display: none; }
.lock-err {
  min-height: 17px; margin: 10px 0 4px;
  font-size: 12px; color: #ff8a9a;
}
.lock-card .btn-block { margin-top: 6px; padding: 12px; justify-content: center; font-size: 14px; }
.lock-tip { margin: 14px 0 0; font-size: 11px; color: #6f7d9c; line-height: 1.6; }
#lock-close {
  position: absolute; top: 12px; right: 14px;
  background: none; border: 0; color: var(--ink-dim);
  font-size: 24px; line-height: 1; cursor: pointer;
}
#lock-close:hover { color: #fff; }
.lock-card.shake { animation: shake 0.32s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(4px); }
}

/* ---------------- Toast ---------------- */
#toast {
  position: absolute;
  left: 50%; top: 82px;
  transform: translateX(-50%) translateY(-12px);
  z-index: 95;
  padding: 11px 20px;
  border-radius: 12px;
  background: var(--glass-2);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  max-width: 86vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- 移动端 ---------------- */
@media (max-width: 760px) {
  .brand-text h1 { display: none; }
  .xmas-title h1 { letter-spacing: 3px; }
  .xmas-title p { letter-spacing: 3px; }
  #topbar { padding: 12px 14px; grid-template-columns: auto 1fr auto; gap: 8px; }
  .btn { padding: 9px 11px; font-size: 12px; }
  #dock { bottom: 12px; width: calc(100vw - 20px); }
  .dock-row { width: 100%; justify-content: flex-start; }
  .dock-row-2 { justify-content: center; }
  .dock-stat { display: none; }
  .dock-sep { display: none; }
  #cam { width: 168px; right: 12px; bottom: 148px; }
  #panel { width: 100%; }
  .help-card { padding: 24px 20px; }
  .help-gestures li { flex-direction: column; gap: 0; }
  .help-gestures b { margin-bottom: -6px; }
  #lb-prev { left: 10px; } #lb-next { right: 10px; }
}
