:root {
  --bg: #f3f3f3;
  --ink: #1a1a1a;
  --muted: #6b7280;
  --oval: #e11d2e;
  --teal: #1aa3b8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Segoe UI", Tahoma, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: 44px 1fr auto auto;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}
.brand { font-weight: 600; font-size: 15px; }
.icon-btn {
  width: 36px; height: 36px; border: 0; background: transparent;
  font-size: 28px; line-height: 1; cursor: pointer; color: #111;
}

.stage {
  background: #111;
  min-height: 0;
  position: relative;
}
.name-step {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px;
  background: #111;
}
.name-step form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(340px, 100%);
}
.name-step label {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}
.name-step input {
  border: 2px solid #333;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 17px;
  text-align: center;
  background: #1c1c1c;
  color: #fff;
  outline: none;
}
.name-step input:focus { border-color: var(--teal); }
.name-err { color: #ff6b74; font-size: 13px; text-align: center; }
.phone {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111;
}
/* Preview shows EXACTLY the recorded frame: 9:16 center crop. */
.frame {
  position: relative;
  aspect-ratio: 9 / 16;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  background: #000;
}
@supports not (aspect-ratio: 1/1) {
  .frame { width: calc(100% * 9 / 16); }
}
#cam, #overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#cam {
  object-fit: cover;
  object-position: center 35%;
}
#overlay { pointer-events: none; }
.hint {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%);
  background: rgba(32, 32, 32, .86);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 4px;
  text-align: center;
  pointer-events: none;
  z-index: 2;
  max-width: 90%;
}
.hint.pulse {
  animation: pulse 1.1s ease-in-out infinite;
  background: rgba(225, 29, 46, .88);
}
@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.08); }
}

.coach {
  background: #fff;
  padding: 10px 16px 6px;
  text-align: center;
  border-top: 1px solid #eee;
}
.phase {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--teal);
  margin-bottom: 4px;
}
.copy { color: var(--muted); font-size: 14px; line-height: 1.35; min-height: 36px; }
.meter {
  margin: 10px auto 4px;
  height: 6px;
  width: min(320px, 90%);
  background: #ececec;
  border-radius: 99px;
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--teal), var(--oval));
  transition: width .2s linear;
}
.time { font-variant-numeric: tabular-nums; color: #111; font-weight: 600; min-height: 1.2em; font-size: 14px; }

.actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: #fff;
}
button, a.primary {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.primary { background: #111; color: #fff; }
.primary.ghost { background: var(--teal); color: #fff; }
.secondary { background: #eee; color: #111; }
.hidden { display: none !important; }
