:root {
  --bg: #050307;
  --glass: rgba(20, 12, 24, 0.68);
  --glass-border: rgba(246, 202, 160, 0.28);
  --pink: #ffc7e4;
  --pink-strong: #ff8dc7;
  --gold: #f6d194;
  --text: #fdf4f9;
  --muted: rgba(246, 224, 236, 0.72);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#gl-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#gl-canvas:active {
  cursor: grabbing;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.greeting-header {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: clamp(18px, 6.2vw, 88px);
  z-index: 10;
  pointer-events: none;
}

.greeting-title {
  margin: 0;
  font-family: "Snell Roundhand", "Brush Script MT", "Segoe Script", Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(26px, 3.8vw, 52px);
  line-height: 1.15;
  background: linear-gradient(95deg, #fff6fb 0%, #ffc4e4 55%, #f8d89c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px rgba(255, 178, 220, 0.42));
  letter-spacing: 0.02em;
}

.mode-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

.gesture-hud {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.gesture-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  font-size: 12.5px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.gesture-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}

.gesture-pill.is-active .dot {
  background: #6ee7b7;
  box-shadow: 0 0 10px #6ee7b7;
}

.gesture-pill.is-loading .dot {
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
}

.gesture-pill.is-error .dot {
  background: #fda4af;
}

.webcam-pip {
  width: 174px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(14, 9, 18, 0.82);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

.webcam-pip canvas {
  display: block;
  width: 100%;
  height: auto;
}

.pip-hint {
  padding: 5px 8px;
  font-size: 11px;
  text-align: center;
  color: var(--pink);
  border-top: 1px solid rgba(255, 200, 228, 0.14);
}

.focus-bar {
  position: fixed;
  bottom: calc(78px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 680px);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(18, 10, 22, 0.88);
  border: 1px solid rgba(247, 208, 152, 0.45);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}

.focus-caption {
  font-size: 13px;
  color: #ffe8f3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.pill-btn {
  border: 1px solid rgba(255, 204, 232, 0.25);
  background: rgba(255, 190, 225, 0.12);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.pill-btn:hover {
  background: rgba(255, 190, 225, 0.24);
}

.pill-btn.subtle {
  color: var(--gold);
  border-color: rgba(246, 209, 148, 0.35);
}

.dock {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 5px;
  width: max-content;
  max-width: calc(100vw - 24px);
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.52);
}

.dock-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  justify-content: center;
}

.dock-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 220, 238, 0.18);
  margin: 0 2px;
}

.dock-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
  white-space: nowrap;
}

.dock-btn:hover {
  color: var(--text);
  background: rgba(255, 196, 228, 0.12);
}

.dock-btn.active {
  color: #180c16;
  background: linear-gradient(135deg, #ffd1e8 0%, #f8d89c 100%);
  font-weight: 600;
}

.dock-btn.accent {
  color: var(--pink);
  border-color: rgba(255, 168, 214, 0.36);
  background: rgba(255, 141, 199, 0.12);
}

.dock-btn.accent.active {
  color: #180c16;
  background: linear-gradient(135deg, #a7f3d0 0%, #fde68a 100%);
}

.studio-dialog {
  margin: auto;
  width: min(94vw, 680px);
  max-height: 86vh;
  padding: 0;
  border-radius: 20px;
  border: 1px solid rgba(246, 209, 148, 0.35);
  background: rgba(16, 10, 20, 0.94);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75);
}

.studio-dialog::backdrop {
  background: rgba(4, 2, 6, 0.72);
  backdrop-filter: blur(6px);
}

.dialog-shell {
  padding: 20px 22px 24px;
  overflow-y: auto;
  max-height: 86vh;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 214, 236, 0.14);
}

.dialog-head h2 {
  margin: 0;
  font-size: 18px;
  color: var(--pink);
}

.dialog-desc {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.icon-close {
  border: 1px solid rgba(255, 214, 236, 0.22);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
}

.dialog-section {
  margin-top: 16px;
}

.upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.upload-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 9px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ffb6dc 0%, #f7d294 100%);
  color: #190d17;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.upload-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.ghost-btn {
  border: 1px solid rgba(255, 208, 232, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 13px;
  font-size: 12.5px;
  cursor: pointer;
}

.ghost-btn:hover {
  background: rgba(255, 208, 232, 0.16);
}

.photo-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 10px;
}

.photo-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(246, 209, 148, 0.22);
}

.photo-item img {
  display: block;
  width: 100%;
  height: 108px;
  object-fit: cover;
  cursor: pointer;
}

.photo-item-meta {
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.photo-item-name {
  font-size: 11.5px;
  color: var(--pink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-del-btn {
  border: none;
  background: rgba(255, 110, 140, 0.18);
  color: #fecdd3;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.field input[type="text"],
.field select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 210, 235, 0.22);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}

.field select option {
  background: #170e1c;
  color: var(--text);
}

.field input[type="range"] {
  accent-color: #f9a8d4;
}

.inline-row {
  display: flex;
  gap: 8px;
}

.inline-row input {
  flex: 1;
  min-width: 0;
}

.legend h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--gold);
}

.legend ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--muted);
}

.dialog-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(22, 12, 26, 0.9);
  border: 1px solid rgba(246, 209, 148, 0.45);
  color: var(--pink);
  font-size: 13px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  .greeting-header {
    left: 16px;
    top: max(12px, env(safe-area-inset-top));
  }
  .mode-subtitle {
    display: none;
  }
  .webcam-pip {
    width: 126px;
  }
  .dock {
    width: auto;
    flex-wrap: wrap;
    border-radius: 18px;
    padding: 6px 8px;
  }
  .dock-group {
    flex-wrap: wrap;
  }
  .dock-divider {
    display: none;
  }
  .dock-btn {
    padding: 6px 9px;
    font-size: 12px;
  }
  .focus-bar {
    bottom: calc(114px + env(safe-area-inset-bottom));
    padding: 6px 10px;
    gap: 6px;
  }
  .focus-caption {
    max-width: 120px;
  }
}
