:root {
  --bg: #0e0e10;
  --surface: #1a1a1e;
  --surface-2: #26262c;
  --text: #f5f5f7;
  --muted: #9a9aa3;
  --accent: #eb3434;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: 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(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: #ff8a8a; font-size: 14px; }

#app { position: fixed; inset: 0; }
.screen {
  position: absolute; inset: 0; display: none; flex-direction: column;
  padding-top: var(--safe-t); background: var(--bg);
}
.screen.active { display: flex; }
.screen.dark { background: #000; padding-top: 0; }

/* ---------- Lista ---------- */
.hero { padding: 28px 20px 8px; }
.hero h1 { margin: 0; font-size: 38px; letter-spacing: -1px; font-weight: 800; }
.hero h1 span { color: var(--accent); }
.hero p { margin: 8px 0 0; color: var(--muted); max-width: 34ch; }
.hint { margin: 14px 20px 0; padding: 12px 14px; font-size: 14px; border-radius: 12px; background: var(--surface-2); }
.cards { padding: 16px 16px calc(24px + var(--safe-b)); overflow-y: auto; flex: 1; display: grid; gap: 12px; align-content: start; }
.card {
  display: flex; gap: 14px; align-items: center; text-align: left; width: 100%;
  background: var(--surface); border-radius: 18px; padding: 14px;
}
.card:active { background: var(--surface-2); }
.card .emoji {
  flex: none; width: 56px; height: 56px; display: grid; place-items: center; font-size: 28px;
  background: rgba(235, 52, 52, .16); border-radius: 14px;
}
.card h3 { margin: 0 0 2px; font-size: 17px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.card .meta { margin-top: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- Barras ---------- */
.bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 4px; }
.bar h2 { margin: 0; font-size: 17px; }
.icon-btn { width: 44px; height: 44px; font-size: 32px; line-height: 1; border-radius: 50%; }
.bar-spacer { width: 44px; }

.scroll { flex: 1; overflow-y: auto; padding: 4px 20px 120px; -webkit-overflow-scrolling: touch; }
.slot-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.slot-list li { background: var(--surface); border-radius: 14px; padding: 12px 14px; }
.slot-list .row1 { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.slot-list .row1 span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.slot-list p { margin: 4px 0 6px; color: var(--muted); font-size: 14px; }
.slot-list .tags { font-size: 12px; color: var(--accent); font-weight: 600; }

.sticky-actions {
  position: absolute; left: 0; right: 0; bottom: 0; display: grid; gap: 8px;
  padding: 14px 16px calc(14px + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* ---------- Botões ---------- */
.btn {
  display: block; width: 100%; text-align: center; text-decoration: none; font-weight: 700;
  padding: 15px 18px; border-radius: 999px; font-size: 16px;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.light { background: #fff; color: #000; }
.btn.ghost { color: var(--muted); }
.btn:disabled { opacity: .45; }
.btn:active { filter: brightness(.9); }

/* ---------- Câmera ---------- */
#viewfinder { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
#viewfinder.mirror { transform: scaleX(-1); }
#grid {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to right, transparent calc(33.33% - .5px), rgba(255,255,255,.28) calc(33.33% - .5px) calc(33.33% + .5px), transparent calc(33.33% + .5px) calc(66.66% - .5px), rgba(255,255,255,.28) calc(66.66% - .5px) calc(66.66% + .5px), transparent calc(66.66% + .5px)),
    linear-gradient(to bottom, transparent calc(33.33% - .5px), rgba(255,255,255,.28) calc(33.33% - .5px) calc(33.33% + .5px), transparent calc(33.33% + .5px) calc(66.66% - .5px), rgba(255,255,255,.28) calc(66.66% - .5px) calc(66.66% + .5px), transparent calc(66.66% + .5px));
}
#guide-frame {
  position: absolute; pointer-events: none; border: 1.5px dashed rgba(255,255,255,.55); border-radius: 12px;
  top: var(--ft, 18%); bottom: var(--fb, 34%); left: var(--fl, 6%); right: var(--fl, 6%);
  transition: all .25s ease;
}
#guide-move {
  position: absolute; left: 0; right: 0; top: 40%; display: grid; place-items: center; pointer-events: none;
}
#guide-move span {
  display: grid; place-items: center; width: 66px; height: 66px; border-radius: 50%; font-size: 32px;
  background: rgba(0,0,0,.38); color: #fff;
}
#guide-move.pushIn span { animation: pushIn 1.6s ease-in-out infinite; }
#guide-move.pullOut span { animation: pullOut 1.6s ease-in-out infinite; }
#guide-move.panLeft span { animation: nudgeL 1.4s ease-in-out infinite; }
#guide-move.panRight span { animation: nudgeR 1.4s ease-in-out infinite; }
#guide-move.tiltUp span { animation: nudgeU 1.4s ease-in-out infinite; }
#guide-move.tiltDown span { animation: nudgeD 1.4s ease-in-out infinite; }
#guide-move.handheld span { animation: shake .5s linear infinite; }
@keyframes pushIn { 0%,100% { transform: scale(.8) } 50% { transform: scale(1.25) } }
@keyframes pullOut { 0%,100% { transform: scale(1.25) } 50% { transform: scale(.8) } }
@keyframes nudgeL { 0%,100% { transform: translateX(14px) } 50% { transform: translateX(-14px) } }
@keyframes nudgeR { 0%,100% { transform: translateX(-14px) } 50% { transform: translateX(14px) } }
@keyframes nudgeU { 0%,100% { transform: translateY(14px) } 50% { transform: translateY(-14px) } }
@keyframes nudgeD { 0%,100% { transform: translateY(-14px) } 50% { transform: translateY(14px) } }
@keyframes shake { 0%,100% { transform: translate(0,0) } 25% { transform: translate(2px,-2px) } 75% { transform: translate(-2px,2px) } }

.top { position: absolute; top: 0; left: 0; right: 0; padding: calc(var(--safe-t) + 8px) 14px 0; display: grid; gap: 12px; }
.top-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.glass-btn, .glass-pill { background: rgba(0,0,0,.42); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.glass-btn { width: 42px; height: 42px; border-radius: 50%; font-size: 18px; }
.glass-pill { padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 700; }

.ribbon { display: flex; gap: 4px; height: 14px; align-items: center; }
.ribbon .seg {
  height: 8px; border-radius: 999px; background: rgba(255,255,255,.28); position: relative; min-width: 8px;
}
.ribbon .seg::after { content: ""; position: absolute; inset: -10px -2px; }
.ribbon .seg.done { background: #fff; }
.ribbon .seg.current { box-shadow: 0 0 0 2.5px var(--accent); }

.countdown {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-size: 150px; font-weight: 800; text-shadow: 0 4px 30px rgba(0,0,0,.5);
}
.countdown.pop { animation: pop .9s ease-out; }
@keyframes pop { from { transform: scale(1.6); opacity: 0 } 25% { opacity: 1 } to { transform: scale(.9); opacity: .9 } }

.bottom {
  position: absolute; left: 0; right: 0; bottom: 0; display: grid; gap: 12px;
  padding: 0 14px calc(14px + var(--safe-b));
}
.slot-card { background: rgba(0,0,0,.56); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-radius: 18px; padding: 13px 14px; }
.slot-card .head { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 4px; }
.slot-card p { margin: 0 0 9px; font-size: 14px; color: rgba(255,255,255,.9); }
.chips-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.chip { flex: none; background: rgba(255,255,255,.18); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }

.controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.take-count { font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 600; }
.rec { position: relative; width: 84px; height: 84px; display: grid; place-items: center; }
.rec svg { position: absolute; inset: 0; }
.ring-bg { fill: none; stroke: #fff; stroke-width: 5; }
.ring { fill: none; stroke: var(--accent); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 276.46; stroke-dashoffset: 276.46; }
#rec-core { width: 64px; height: 64px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-size: 26px; font-weight: 800; transition: all .15s; }
#rec-core.retake { background: #f08a24; }
#rec-core.stop { width: 30px; height: 30px; border-radius: 7px; }

/* ---------- Overlay ---------- */
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.72); padding: 24px; z-index: 5; }
.overlay-box { text-align: center; display: grid; gap: 12px; justify-items: center; max-width: 320px; }
.overlay-box h3 { margin: 0; }
.overlay-box p { margin: 0; color: var(--muted); }
.big { font-size: 44px; }
.progress { width: 220px; height: 8px; border-radius: 99px; background: rgba(255,255,255,.2); overflow: hidden; }
.progress div { height: 100%; width: 0; background: #fff; }

/* ---------- Revisão e resultado ---------- */
.stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px 24px; }
#out, #result-video {
  max-width: 100%; max-height: 100%; aspect-ratio: 9 / 16; background: #000; border-radius: 18px; object-fit: contain;
}
.panel { padding: 8px 16px calc(14px + var(--safe-b)); display: grid; gap: 10px; }
.label { font-size: 13px; font-weight: 600; color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; padding: 8px 14px; border-radius: 999px; background: var(--surface-2); font-size: 14px; font-weight: 600; }
.chips button.on { background: var(--accent); color: #fff; }
