:root {
  --bg: #000;
  --fg: #fff;
  --muted: rgba(255, 255, 255, 0.72);
  --pink: #fe2c55;
  --cyan: #25f4ee;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden; overscroll-behavior: none;
}

button { font: inherit; color: inherit; }
[contenteditable="true"] { outline: none; cursor: text; }
[contenteditable="true"]:focus { background: rgba(255,255,255,0.08); border-radius: 4px; }

#app {
  position: fixed; inset: 0;
  display: flex; justify-content: center;
  background: #000;
}

.stage {
  position: relative;
  width: 100%; max-width: 480px;
  height: 100dvh; background: #000; overflow: hidden;
}

#photo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  background: #0a0a0a;
}

.stage::before, .stage::after {
  content: ""; position: absolute; left: 0; right: 0;
  pointer-events: none; z-index: 2;
}
.stage::before { top: 0; height: 160px; background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(0,0,0,0)); }
.stage::after  { bottom: 0; height: 220px; background: linear-gradient(0deg, rgba(0,0,0,0.6), rgba(0,0,0,0)); }

/* Top bar */
.top {
  position: absolute; top: max(env(safe-area-inset-top), 10px);
  left: 0; right: 0; z-index: 5;
  display: grid; grid-template-columns: 44px 1fr 44px;
  align-items: center; padding: 6px 10px; gap: 8px;
}
.top__icon {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; padding: 0; color: #fff;
}
.top__tabs {
  display: flex; align-items: center; justify-content: center;
  gap: 18px; font-size: 16px; font-weight: 600;
}
.top__tab {
  background: transparent; border: 0; padding: 6px 2px;
  color: rgba(255,255,255,0.7); font-weight: 600; cursor: pointer;
  position: relative;
}
.top__tab--active { color: #fff; }
.top__tab--active::after {
  content: ""; position: absolute; left: 50%; transform: translateX(-50%);
  bottom: -4px; width: 18px; height: 2px; background: #fff; border-radius: 2px;
}

/* Right rail */
.rail {
  position: absolute; right: 8px; bottom: 110px; z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.rail__avatar {
  position: relative;
  width: 48px; height: 48px; border-radius: 50%;
  background: #333 center/cover no-repeat; border: 2px solid #fff;
}
.rail__avatar::after {
  content: "+"; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--pink); color: #fff;
  font-size: 16px; line-height: 18px; text-align: center; font-weight: 700;
}
.rail__btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: transparent; border: 0; padding: 0; cursor: pointer; color: #fff;
}
.rail__btn svg { width: 36px; height: 36px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6)); }
.rail__count {
  font-size: 12px; font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
  min-width: 28px; text-align: center;
}
.rail__disc {
  width: 40px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle at center, #444 0 6px, #111 7px 100%) center/cover;
  border: 2px solid #222;
  animation: spin 6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .rail__disc { animation: none; } }

/* Caption */
.caption {
  position: absolute; left: 12px; right: 86px; bottom: 96px; z-index: 5;
  display: flex; flex-direction: column; gap: 4px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.7);
}
.caption__user { font-weight: 700; font-size: 16px; }
.caption__text { font-size: 14px; line-height: 1.35; }
.caption__music { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-top: 4px; }
.caption__music svg { width: 14px; height: 14px; flex: 0 0 auto; }

/* Bottom nav */
.nav {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  height: calc(56px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #000;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
}
.nav__btn {
  background: transparent; border: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: rgba(255,255,255,0.75);
  font-size: 11px; font-weight: 500;
  padding: 4px 0; cursor: pointer;
}
.nav__btn--active { color: #fff; }
.nav__btn svg { width: 24px; height: 24px; }

.nav__add { position: relative; width: 46px; height: 30px; margin-bottom: 2px; }
.nav__add::before, .nav__add::after {
  content: ""; position: absolute; top: 0;
  width: 46px; height: 30px; border-radius: 8px;
}
.nav__add::before { left: -3px; background: var(--cyan); }
.nav__add::after  { left:  3px; background: var(--pink); }
.nav__add > span {
  position: absolute; inset: 0; z-index: 1;
  background: #fff; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #000; font-size: 22px; font-weight: 700; line-height: 1;
}

/* Floating retake button + parody mark */
.tools {
  position: absolute;
  top: max(env(safe-area-inset-top), 10px);
  right: 56px;
  z-index: 6;
  display: flex; align-items: center; gap: 8px;
}
.tools__btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.15);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff; padding: 0;
}
.tools__btn svg { width: 16px; height: 16px; }
.tools__mark {
  position: absolute;
  top: 38px; right: 0;
  font-size: 10px; color: rgba(255,255,255,0.6);
  background: rgba(0,0,0,0.35);
  padding: 2px 6px; border-radius: 4px;
  white-space: nowrap;
}

/* Status pill */
#status {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  z-index: 6; font-size: 13px; color: #fff;
  background: rgba(0,0,0,0.5);
  padding: 6px 10px; border-radius: 999px;
  backdrop-filter: blur(6px);
  max-width: 90%; text-align: center;
}
#status:empty { display: none; }
#status.error { background: rgba(180,30,30,0.7); }

/* Permission arrow — positioned just under the iOS permission dialog
   (which appears centered on screen) so it visibly points up at "Autoriser". */
.perm-hint {
  position: fixed; left: 0; right: 0;
  top: 64%; z-index: 50;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
.perm-hint__arrow {
  font-size: 56px; line-height: 1; color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.8);
  animation: bounce 1.1s ease-in-out infinite;
}
.perm-hint__text {
  margin: 0; font-size: 13px; color: #fff;
  background: rgba(0,0,0,0.6);
  padding: 5px 10px; border-radius: 999px;
  backdrop-filter: blur(6px);
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
@media (prefers-reduced-motion: reduce) { .perm-hint__arrow { animation: none; } }

/* Consent fallback */
.consent {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(0,0,0,0.85);
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  padding: 24px; text-align: center; gap: 14px;
}
.consent[hidden] { display: none; }
.consent h2 { margin: 0; font-size: 18px; font-weight: 600; }
.consent p  { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.45; }
.consent button {
  appearance: none; border: 0; border-radius: 999px;
  padding: 12px 22px; background: #fff; color: #000;
  font-weight: 600; cursor: pointer;
}

video, canvas { display: none; }
