@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  --ink: #12202e;
  --ink-soft: #3d5166;
  --muted: #6b7f94;
  --line: rgba(18, 32, 46, 0.1);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --bg0: #dbe7f2;
  --bg1: #f3f6fa;
  --accent: #0d9f8a;
  --accent-deep: #087a6a;
  --accent-soft: rgba(13, 159, 138, 0.14);
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --stage: #0a1018;
  --radius: 20px;
  --shadow: 0 18px 50px rgba(18, 32, 46, 0.12);
  --font-display: "Outfit", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(ellipse 90% 60% at 10% -10%, #b8d4e8 0%, transparent 50%),
    radial-gradient(ellipse 70% 50% at 100% 0%, #9fd9c8 0%, transparent 45%),
    radial-gradient(ellipse 60% 40% at 50% 100%, #c5d5e8 0%, transparent 50%),
    linear-gradient(165deg, var(--bg0), var(--bg1) 55%, #eef3f8);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px;
  mix-blend-mode: soft-light;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  margin: 0 auto;
  padding: 1.35rem 1.1rem 2.75rem;
  animation: rise 0.55s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(13, 159, 138, 0.35); }
  50% { box-shadow: 0 0 0 10px rgba(13, 159, 138, 0); }
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  color: var(--accent-deep);
}

.top {
  margin-bottom: 1.15rem;
}

.top .back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
  transition: color 0.2s;
}

.top .back:hover { color: var(--accent-deep); }

h1 {
  font-family: var(--font-display);
  font-weight: 750;
  letter-spacing: -0.03em;
  margin: 0.15rem 0 0.35rem;
  font-size: clamp(1.55rem, 5vw, 1.85rem);
  line-height: 1.15;
  color: var(--ink);
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.hint {
  margin: 0.85rem 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  min-height: 1.35em;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.field input {
  border: 1px solid var(--line);
  background: var(--surface-solid);
  color: var(--ink);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  box-shadow: 0 1px 2px rgba(18, 32, 46, 0.04);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 58vh;
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  background: var(--stage);
  box-shadow: var(--shadow), 0 0 0 1px rgba(18, 32, 46, 0.08);
}

.stage .mirror {
  position: absolute;
  inset: 0;
  transform: scaleX(-1);
}

.stage video,
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stage canvas { pointer-events: none; }

.stage-status {
  position: absolute;
  left: 50%;
  bottom: 1.05rem;
  transform: translateX(-50%);
  z-index: 2;
  background: rgba(10, 16, 24, 0.62);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #f4f7fb;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 0.9rem 0.75rem;
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s, background 0.2s, opacity 0.2s;
}

.btn:active:not(:disabled) { transform: scale(0.97); }

.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(180deg, #12b89f 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(13, 159, 138, 0.28);
}

.btn.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #14c4aa 0%, var(--accent-deep) 100%);
}

.btn.success {
  background: linear-gradient(180deg, #22c55e 0%, var(--good) 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(22, 163, 74, 0.25);
}

.btn.secondary {
  background: var(--surface-solid);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(18, 32, 46, 0.04);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px dashed rgba(18, 32, 46, 0.18);
  grid-column: 1 / -1;
}

.toast {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  font-size: 0.9rem;
  font-weight: 600;
  animation: rise 0.3s ease both;
}

.toast.ok {
  background: rgba(22, 163, 74, 0.1);
  color: #166534;
  border: 1px solid rgba(22, 163, 74, 0.25);
}

.toast.err {
  background: rgba(220, 38, 38, 0.08);
  color: #991b1b;
  border: 1px solid rgba(220, 38, 38, 0.22);
}

.glass {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 8px 32px rgba(18, 32, 46, 0.08);
  border-radius: var(--radius);
}

@media (max-width: 380px) {
  .actions { grid-template-columns: 1fr; }
  .btn.ghost { grid-column: auto; }
}
