:root {
  --crimson: #920932;
  --pastel-orange: #eecc8c;
  --light-orange: #fcf6f2;
  --text: #000000;
  --muted: rgba(0, 0, 0, 0.62);
  --on-crimson: #fcf6f2;
  --surface: #fffef9;
  --bar: rgba(252, 246, 242, 0.96);
  --shadow: 0 8px 28px -12px rgba(146, 9, 50, 0.35);
  --radius: 16px;
  --radius-sm: 12px;
  --space: 20px;
  --space-sm: 14px;
  --gap: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse 90% 50% at 50% -10%, rgba(238, 204, 140, 0.45), transparent 50%),
    linear-gradient(165deg, var(--light-orange), #fdf0e2 45%, var(--light-orange));
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.web-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(100%, 420px);
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(146, 9, 50, 0.08);
  border: 1px solid rgba(146, 9, 50, 0.18);
  color: var(--text);
  text-decoration: none;
  font-size: 0.72rem;
  line-height: 1.4;
}

.web-banner-link {
  flex-shrink: 0;
  font-weight: 700;
  color: var(--crimson);
}

.phone {
  width: min(100%, 420px);
  min-height: min(88vh, 820px);
  background: var(--surface);
  border-radius: 22px;
  border: 1px solid rgba(146, 9, 50, 0.18);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 10px 14px 6px;
  background: var(--crimson);
  color: var(--on-crimson);
}

.app-bar h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.icon-btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }

.lang {
  display: flex;
  justify-content: flex-end;
  padding: 10px var(--space) 6px;
  gap: 8px;
}

.lang-inline { justify-content: flex-start; padding: 0; }

.lang button {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(146, 9, 50, 0.3);
  background: #fff;
  cursor: pointer;
}

.lang button.is-on {
  background: var(--crimson);
  color: var(--on-crimson);
  border-color: var(--crimson);
}

.content {
  flex: 1;
  padding: var(--space);
  padding-bottom: calc(var(--space) + 8px);
  overflow-y: auto;
}

.screen { display: none; }
.screen.is-visible { display: block; }

.panel {
  background: var(--surface);
  border: 1px solid rgba(146, 9, 50, 0.14);
  border-radius: var(--radius);
  padding: var(--space);
  margin-bottom: var(--gap);
}

.panel-muted { background: rgba(252, 246, 242, 0.9); }
.panel-accent { background: rgba(238, 204, 140, 0.35); border-color: rgba(146, 9, 50, 0.18); }

.pill-info {
  background: rgba(238, 204, 140, 0.42);
  border: 1px solid rgba(146, 9, 50, 0.18);
  border-radius: var(--radius);
  padding: var(--space);
  margin-bottom: var(--gap);
}

.pill-info strong {
  display: block;
  font-size: 1rem;
  color: var(--crimson);
  margin-bottom: 8px;
}

.lead {
  margin: 0 0 var(--space-sm);
  font-size: 0.95rem;
  line-height: 1.55;
}

.lead.center { text-align: center; }
.lead.strong { font-weight: 600; }

.headline {
  margin: 0 0 8px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--crimson);
  text-align: center;
}

.sub {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
}

.sub.meta { margin-top: 8px; font-size: 0.75rem; color: var(--muted); }
.sub.muted { color: var(--muted); font-size: 0.8rem; }

.label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
}

.field { margin-bottom: var(--space-sm); }

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(146, 9, 50, 0.28);
  font: inherit;
  background: #fff;
}

.field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(146, 9, 50, 0.28);
  font: inherit;
  background: #fff;
}

.age-preview {
  margin: 0 0 var(--space-sm);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(238, 204, 140, 0.35);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--crimson);
}

.steps {
  display: none;
  gap: 8px;
  padding: 8px var(--space) 0;
}

.steps.is-visible { display: flex; }

.step-pill {
  flex: 1;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 8px 4px;
  border-radius: 999px;
  background: rgba(238, 204, 140, 0.45);
  color: var(--muted);
  border: 1px solid rgba(146, 9, 50, 0.12);
}

.step-pill.is-active {
  background: var(--crimson);
  color: var(--on-crimson);
  border-color: var(--crimson);
}

.consent-copy {
  font-size: 0.82rem;
  line-height: 1.55;
  max-height: 160px;
  overflow-y: auto;
}

.consent-check {
  align-items: flex-start;
  margin: var(--space-sm) 0;
  font-size: 0.82rem;
  line-height: 1.45;
}

.consent-check input {
  margin-top: 4px;
  flex-shrink: 0;
}

.signature-wrap {
  border: 1px solid rgba(146, 9, 50, 0.28);
  border-radius: var(--radius-sm);
  background: #fff;
  overflow: hidden;
  margin-bottom: 10px;
  touch-action: none;
}

#signaturePad {
  display: block;
  width: 100%;
  height: 140px;
  cursor: crosshair;
}

.btn-sm {
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: var(--space-sm);
}


.hint {
  margin: 12px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.error {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: #b91c1c;
}

.disclaimer {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 var(--gap);
  line-height: 1.45;
}

.hero-logo {
  text-align: center;
  margin-bottom: var(--space-sm);
}

.hero-logo img {
  max-width: 72%;
  height: auto;
}

.badge-ai {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--crimson);
}

.row {
  display: flex;
  gap: 10px;
  margin-top: var(--space-sm);
  flex-wrap: wrap;
}

.btn {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.btn:active { transform: scale(0.98); }

.btn-filled {
  background: var(--crimson);
  color: var(--on-crimson);
  box-shadow: 0 4px 14px -4px rgba(146, 9, 50, 0.45);
}

.btn-filled:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-tonal {
  background: var(--pastel-orange);
  color: var(--text);
  border: 1px solid rgba(146, 9, 50, 0.35);
}

.status {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 0.88rem;
  cursor: pointer;
}

.toggle-row:last-child { margin-bottom: 0; }

.aptm-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 320 / 220;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(146, 9, 50, 0.16);
  background: #fff;
}

.aptm-stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.aptm-marker {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  opacity: 0.72;
}

.aptm-marker.is-active {
  background: var(--crimson);
  color: var(--on-crimson);
  opacity: 1;
  animation: aptm-blink 0.55s ease-in-out infinite alternate;
}

@keyframes aptm-blink {
  from { opacity: 0.45; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1.05); }
}

.aptm-marker[data-letter="A"] { left: 35%; top: 35%; }
.aptm-marker[data-letter="P"] { left: 58%; top: 28%; }
.aptm-marker[data-letter="T"] { left: 56%; top: 56%; }
.aptm-marker[data-letter="M"] { left: 74%; top: 62%; }

#waveCanvas {
  width: 100%;
  height: 96px;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(238, 204, 140, 0.35), rgba(252, 246, 242, 0.95));
  border: 1px solid rgba(146, 9, 50, 0.12);
}

.quality-badge {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 0.88rem;
  font-weight: 500;
}

.quality-badge.ok {
  background: rgba(238, 204, 140, 0.45);
  border: 1px solid rgba(146, 9, 50, 0.12);
}

.seg-line {
  margin: 0 0 6px;
  font-size: 0.88rem;
}

.result-card {
  background: rgba(238, 204, 140, 0.5);
  border-color: rgba(146, 9, 50, 0.2);
}

.center { text-align: center; }

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 16px;
  border: 3px solid rgba(146, 9, 50, 0.15);
  border-top-color: var(--crimson);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.progress-track {
  height: 6px;
  background: rgba(146, 9, 50, 0.12);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 16px;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--crimson);
  border-radius: 999px;
  transition: width 0.05s linear;
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid rgba(146, 9, 50, 0.1);
  font-size: 0.92rem;
}

.admin-row:last-child { border-bottom: none; }

.admin-row-btn {
  width: 100%;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}

.admin-row-btn:hover { background: rgba(238, 204, 140, 0.25); }

.admin-row-static { cursor: default; }

.chev { color: var(--muted); }

.rest-panel {
  background: rgba(252, 246, 242, 0.95);
}

@media (min-width: 480px) {
  body { padding-top: 20px; }
}
