:root {
  --bg: #06040a;
  --ink: #f6ecf6;
  --ink-dim: rgba(246, 236, 246, 0.55);
  --pink: #ff4f9e;
  --gold: #ffd48a;
  --glass: rgba(20, 12, 24, 0.55);
  --stroke: rgba(255, 200, 230, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

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

/* ---------- 氛围层 ---------- */
.glow-bg {
  position: absolute;
  inset: -20%;
  pointer-events: none;
  background:
    radial-gradient(38% 34% at 50% 46%, rgba(255, 82, 158, 0.20), transparent 70%),
    radial-gradient(30% 28% at 22% 76%, rgba(126, 84, 255, 0.16), transparent 72%),
    radial-gradient(26% 26% at 80% 22%, rgba(255, 196, 120, 0.12), transparent 70%);
  filter: blur(18px);
  mix-blend-mode: screen;
  animation: drift 24s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-1.5%, 1%, 0) scale(1.0); }
  to   { transform: translate3d(1.5%, -1.5%, 0) scale(1.06); }
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 42%, rgba(0, 0, 0, 0.55) 100%);
}

.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.045;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/></filter><rect width='120' height='120' filter='url(%23n)'/></svg>");
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 22px 26px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  pointer-events: none;
}

.brand { display: flex; align-items: center; gap: 12px; }

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #6b5a70;
  box-shadow: 0 0 0 0 rgba(255, 79, 158, 0.5);
  transition: background 0.35s ease;
  flex: 0 0 auto;
}
.dot.live {
  background: var(--pink);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 79, 158, 0.45); }
  70%  { box-shadow: 0 0 0 12px rgba(255, 79, 158, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 79, 158, 0); }
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.16em;
}
.brand-text .sub {
  display: block;
  margin-top: 4px;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: var(--ink-dim);
}

/* 作者署名：斜体英文 */
.brand-text .by {
  display: block;
  margin-top: 6px;
  font-family: "Cormorant Garamond", "Baskerville", Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: rgba(246, 236, 246, 0.38);
}
.brand-text .by em {
  font-style: italic;
  font-size: 15px;
  background: linear-gradient(135deg, #ffd9a3, #ff6fb2 55%, #c07bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* 启动页署名 */
.credit {
  margin: 20px 0 0 !important;
  font-family: "Cormorant Garamond", "Baskerville", Georgia, "Times New Roman", serif;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: rgba(246, 236, 246, 0.34) !important;
}
.credit em {
  font-style: italic;
  font-size: 20px;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #ffd9a3, #ff6fb2 55%, #c07bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.meters {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  min-width: 200px;
}

.meter { width: 200px; }
.meter label {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--ink-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
}
.meter label b { color: var(--ink); font-weight: 600; letter-spacing: 0.04em; }

.bar {
  height: 3px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, #ffd48a, #ff4f9e 60%, #b06bff);
  box-shadow: 0 0 12px rgba(255, 79, 158, 0.7);
  transition: width 0.08s linear;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
  padding: 5px 9px;
  border-radius: 99px;
  border: 1px solid var(--stroke);
  background: var(--glass);
  backdrop-filter: blur(8px);
  white-space: nowrap;
}
.chip b { color: var(--ink); font-weight: 600; }
.chip.mono {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  letter-spacing: 0;
  color: rgba(246, 236, 246, 0.4);
}

/* ---------- 摄像头预览 ---------- */
.preview {
  position: absolute;
  right: 26px;
  bottom: 26px;
  width: 208px;
  height: 156px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--stroke);
  background: rgba(10, 6, 14, 0.7);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), inset 0 0 40px rgba(255, 79, 158, 0.06);
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}
.preview.on { opacity: 1; transform: none; }

.preview video,
.preview canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* 镜像，符合照镜子直觉 */
}

.preview video { filter: saturate(0.55) contrast(1.05) brightness(0.72); }

.preview .tag {
  position: absolute;
  left: 8px;
  top: 8px;
  font-size: 8.5px;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(0, 0, 0, 0.4);
  padding: 3px 6px;
  border-radius: 4px;
  transform: none;
}

/* ---------- 提示 ---------- */
.hint {
  position: absolute;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: rgba(246, 236, 246, 0.42);
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.hint .sep { opacity: 0.4; }
.hint.fade { opacity: 0.18; }

/* ---------- 调参面板 ---------- */
.tweak {
  position: absolute;
  left: 26px;
  bottom: 26px;
  width: 264px;
  max-height: min(72vh, 620px);
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(16, 9, 20, 0.82);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  font-size: 11px;
  color: rgba(246, 236, 246, 0.78);
  z-index: 15;
  overflow: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.tweak.tw-off {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.tw-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 200, 230, 0.1);
  background: rgba(255, 79, 158, 0.06);
}
.tw-title { font-size: 11px; letter-spacing: 0.18em; color: var(--ink); }
.tw-key {
  flex: 1;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: rgba(246, 236, 246, 0.32);
}
.tw-x {
  border: none;
  background: transparent;
  color: rgba(246, 236, 246, 0.5);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.tw-x:hover { color: var(--pink); }

.tw-body {
  overflow-y: auto;
  padding: 4px 12px 12px;
  scrollbar-width: thin;
}
.tw-body::-webkit-scrollbar { width: 4px; }
.tw-body::-webkit-scrollbar-thumb {
  background: rgba(255, 120, 190, 0.3);
  border-radius: 99px;
}

.tw-group { padding: 10px 0 4px; border-bottom: 1px dashed rgba(255, 255, 255, 0.07); }
.tw-group:last-of-type { border-bottom: none; }

.tw-gh { display: flex; align-items: baseline; gap: 6px; margin-bottom: 8px; }
.tw-gh h4 {
  margin: 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: rgba(255, 200, 230, 0.9);
}
.tw-hint { font-size: 8.5px; color: rgba(246, 236, 246, 0.3); }

.tw-row { display: block; margin-bottom: 7px; }
.tw-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.tw-name { font-size: 10px; color: rgba(246, 236, 246, 0.6); }
.tw-val {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 10px;
  color: var(--gold);
}

.tw-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  background: transparent;
  cursor: ew-resize;
  margin: 0;
}
.tw-range::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
}
.tw-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  margin-top: -4px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd9a3, #ff6fb2);
  box-shadow: 0 0 8px rgba(255, 79, 158, 0.7);
}
.tw-range::-moz-range-track {
  height: 3px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
}
.tw-range::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: none;
  border-radius: 50%;
  background: #ff6fb2;
}

.tw-actions { display: flex; gap: 6px; padding-top: 10px; }
.tw-btn {
  flex: 1;
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 200, 230, 0.18);
  background: rgba(255, 79, 158, 0.12);
  color: rgba(246, 236, 246, 0.85);
  cursor: pointer;
}
.tw-btn:hover { background: rgba(255, 79, 158, 0.24); }
.tw-btn-ghost { background: rgba(255, 255, 255, 0.04); }

body.hide-hud .hud,
body.hide-hud .hint,
body.hide-hud .preview { opacity: 0; pointer-events: none; transition: opacity 0.3s; }

@media (max-width: 720px) {
  .tweak { left: 12px; bottom: 12px; width: 218px; max-height: 52vh; }
}

/* ---------- 启动页 ---------- */
.boot {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(60% 60% at 50% 45%, rgba(24, 10, 26, 0.86), rgba(4, 2, 8, 0.96));
  backdrop-filter: blur(14px);
  z-index: 20;
  transition: opacity 0.7s ease, visibility 0.7s;
}
.boot.hidden { opacity: 0; visibility: hidden; }

.boot-card {
  width: min(420px, calc(100vw - 48px));
  padding: 34px 32px 28px;
  border-radius: 20px;
  text-align: center;
  border: 1px solid var(--stroke);
  background: linear-gradient(160deg, rgba(38, 20, 40, 0.75), rgba(14, 8, 18, 0.85));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.boot-mark {
  font-size: 34px;
  line-height: 1;
  color: var(--pink);
  text-shadow: 0 0 24px rgba(255, 79, 158, 0.8);
  animation: float 3.6s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(6deg); }
}

.boot-card h2 {
  margin: 16px 0 10px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.2em;
}

.boot-card p {
  margin: 0 0 20px;
  font-size: 12.5px;
  line-height: 1.85;
  color: rgba(246, 236, 246, 0.6);
}
.boot-card p b { color: var(--ink); font-weight: 600; }

.boot-actions { display: flex; gap: 10px; justify-content: center; }

button {
  font: inherit;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  padding: 11px 20px;
  border-radius: 99px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.25s ease, background 0.25s ease, opacity 0.2s;
}
button:active { transform: scale(0.97); }

button.primary {
  color: #1a0510;
  background: linear-gradient(135deg, #ffd9a3, #ff6fb2 55%, #c07bff);
  box-shadow: 0 10px 30px rgba(255, 79, 158, 0.35);
  font-weight: 600;
}
button.primary:hover { box-shadow: 0 14px 40px rgba(255, 79, 158, 0.5); }

button.ghost {
  color: rgba(246, 236, 246, 0.8);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--stroke);
}
button.ghost:hover { background: rgba(255, 255, 255, 0.09); }

.boot-note {
  margin: 18px 0 0 !important;
  font-size: 10.5px !important;
  letter-spacing: 0.02em;
  color: rgba(246, 236, 246, 0.34) !important;
}
.boot-note code {
  font-family: ui-monospace, Consolas, monospace;
  background: rgba(255, 255, 255, 0.07);
  padding: 1px 5px;
  border-radius: 4px;
}

@media (max-width: 720px) {
  .hud { padding: 16px 18px; flex-direction: column; gap: 14px; }
  .meters { align-items: flex-start; width: 100%; }
  .chips { justify-content: flex-start; }
  .preview { width: 132px; height: 100px; right: 16px; bottom: 16px; }
  .hint { display: none; }
}
