:root {
  --bg: #0f0e0c;
  --ink: #f4efe6;
  --muted: #a39c8f;
  --gold: #c9a45c;
  --line: rgba(244, 239, 230, 0.16);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Noto Sans SC", sans-serif;
  overscroll-behavior: none;
}

[hidden] { display: none !important; }

.view { min-height: 100%; }

/* ---------- 品牌 ---------- */
.brand {
  font-family: "Cormorant Garamond", "Didot", "Bodoni 72", Georgia, "Songti SC", serif;
  font-size: 1.35rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-align: center;
}
.brand span { color: var(--gold); }
.brand.small { font-size: 0.95rem; letter-spacing: 0.18em; }

/* ---------- 首页 ---------- */
#view-home {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: calc(1.5rem + var(--safe-top)) 1.5rem calc(1.5rem + var(--safe-bottom));
  max-width: 30rem;
  margin: 0 auto;
}

.card { width: 100%; text-align: center; margin-top: 0.5rem; }

.poster-wrap {
  width: 100%;
  max-height: 46vh;
  display: flex;
  justify-content: center;
  padding: 10px;
  background: linear-gradient(145deg, #3a2f1e, #1c1710);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(201, 164, 92, 0.35);
}
.poster-wrap img { max-width: 100%; max-height: calc(46vh - 20px); display: block; object-fit: contain; }

h1 {
  font-family: "Cormorant Garamond", Georgia, "Songti SC", serif;
  font-weight: 500;
  font-size: 1.6rem;
  margin: 1.1rem 0 0.2rem;
}
.sub { margin: 0; color: var(--muted); font-size: 0.9rem; letter-spacing: 0.04em; }

.actions { width: 100%; display: flex; flex-direction: column; gap: 0.7rem; margin-top: auto; }

.btn {
  width: 100%;
  padding: 1rem 1.2rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1a1509; font-weight: 600; }
.btn:disabled { opacity: 0.4; }
.btn:active:not(:disabled) { transform: scale(0.985); }

.notice {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(201, 164, 92, 0.5);
  background: rgba(201, 164, 92, 0.08);
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.5;
}
.notice p { margin: 0; }
.link { display: inline-block; margin-top: 0.5rem; color: var(--gold); }

.fine { color: var(--muted); font-size: 0.75rem; text-align: center; margin: 0; line-height: 1.5; }

/* ---------- AR ---------- */
#view-ar, #view-video { position: fixed; inset: 0; background: #000; overflow: hidden; }

#ar-container { position: absolute; inset: 0; overflow: hidden; }

.ar-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(0.7rem + var(--safe-top)) 1rem 1.4rem;
  background: linear-gradient(rgba(0, 0, 0, 0.6), transparent);
}
.ar-top.solid { background: #000; padding-bottom: 0.7rem; }

.icon-btn {
  width: 2.6rem; height: 2.6rem; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.45);
  color: var(--ink); font-size: 1.05rem; cursor: pointer;
}

.ar-stage {
  position: absolute; inset: 0; z-index: 4;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem; padding: 0 2rem; pointer-events: none; text-align: center;
  transition: opacity 0.3s;
}
.ar-stage.quiet { opacity: 0; }

.ar-msg {
  margin: 0; padding: 0.55rem 1rem; border-radius: 999px;
  background: rgba(0, 0, 0, 0.6); font-size: 0.98rem;
}
.ar-msg:empty { display: none; }
.ar-tip { margin: 0; max-width: 22rem; font-size: 0.82rem; line-height: 1.5; color: #e7dfd0; background: rgba(0, 0, 0, 0.55); padding: 0.6rem 0.9rem; border-radius: 12px; }

.frame { position: relative; width: min(62vw, 46vh); aspect-ratio: 4 / 5; animation: breathe 2.4s ease-in-out infinite; }
.frame i { position: absolute; width: 26px; height: 26px; border: 2px solid var(--gold); }
.frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
.frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
.frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
.frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }
@keyframes breathe { 50% { transform: scale(1.04); opacity: 0.7; } }

.spinner {
  width: 2.4rem; height: 2.4rem; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ar-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center; flex-wrap: wrap; gap: 0.6rem;
  padding: 1.6rem 1rem calc(1rem + var(--safe-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
}
.pill {
  padding: 0.6rem 1rem; border-radius: 999px; font-size: 0.9rem; font-family: inherit;
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.5); color: var(--ink); cursor: pointer;
}

.debug {
  position: absolute; left: 8px; top: calc(4rem + var(--safe-top)); z-index: 6; margin: 0;
  font-size: 11px; line-height: 1.4; color: #7CFC9A; background: rgba(0, 0, 0, 0.6); padding: 6px 8px;
  pointer-events: none; white-space: pre-wrap; max-width: 80vw;
}

/* ---------- 备用视频 ---------- */
#fb-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; padding-top: calc(4rem + var(--safe-top)); }

.hidden-video { position: fixed; left: 0; top: 0; width: 2px; height: 2px; opacity: 0.01; pointer-events: none; z-index: -1; }

/* ---------- 定制引擎的显示层 ---------- */
#ar-container .vp-camera,
#ar-container .vp-frame { position: absolute; display: block; max-width: none; }
#ar-container .vp-camera { z-index: 0; }
#ar-container .vp-frame { z-index: 1; }            /* 与贴图同帧的镜头画面 */
#ar-container .vp-overlay {                         /* 作品视频：四角由 matrix3d 钉在画面上 */
  position: absolute; left: 0; top: 0; z-index: 2; max-width: none;
  transform-origin: 0 0; opacity: 0; transition: opacity 0.16s linear;
  pointer-events: none; will-change: transform, opacity; backface-visibility: hidden;
  object-fit: cover; background: transparent;
}
#ar-container .vp-debug { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
