:root {
  color-scheme: dark;
  --ink: #f5fbf8;
  --muted: #a9bbb5;
  --panel: rgba(7, 23, 20, 0.82);
  --line: rgba(211, 238, 228, 0.18);
  --good: #4de3ac;
  --warn: #ffc857;
  --bad: #ff7168;
  --brand: #28c993;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #06100e;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button { font: inherit; }

.capture-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 20%, rgba(31, 112, 88, 0.22), transparent 44%),
    #06100e;
}

.camera-stage {
  position: relative;
  width: min(100vw, 520px);
  height: 100vh;
  min-height: 580px;
  overflow: hidden;
  background: #030908;
}

#camera,
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#camera {
  object-fit: cover;
  transform: scaleX(-1);
}

#overlay {
  z-index: 2;
  pointer-events: none;
  transform: scaleX(-1);
}

.scan-mask {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  background: none;
}

.face-guide {
  position: absolute;
  left: 50%;
  top: 43%;
  width: min(72vw, 320px);
  aspect-ratio: 0.78;
  translate: -50% -50%;
  border: 1.5px solid rgba(235, 250, 244, 0.48);
  border-radius: 50%;
  transition: border-color 180ms ease;
}

.face-guide.ready {
  border-color: rgba(77, 227, 172, 0.66);
}

.top-bar {
  position: absolute;
  z-index: 5;
  top: calc(16px + env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.privacy-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(2, 12, 10, 0.48);
  color: #d8e8e2;
  font-size: 12px;
  backdrop-filter: blur(12px);
}

.privacy-chip span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 10px var(--good);
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(2, 12, 10, 0.48);
  color: var(--ink);
  font-size: 22px;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.status-panel {
  position: absolute;
  z-index: 5;
  left: 16px;
  right: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(18px);
}

.status-title {
  min-height: 25px;
  margin-bottom: 12px;
  font-size: 17px;
  font-weight: 680;
  letter-spacing: 0.01em;
}

.check-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  color: var(--muted);
  font-size: 13px;
}

.check-dot {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--bad);
  box-shadow: 0 0 0 3px rgba(255, 113, 104, 0.12);
  transition: background 160ms ease, box-shadow 160ms ease;
}

.check-dot.ok {
  background: var(--good);
  box-shadow: 0 0 0 3px rgba(77, 227, 172, 0.13);
}

.progress-track {
  height: 5px;
  margin-top: 15px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(235, 250, 244, 0.12);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2fca99, #7af0c4);
  box-shadow: 0 0 16px rgba(77, 227, 172, 0.6);
  transition: width 100ms linear;
}

.success-panel {
  position: absolute;
  z-index: 12;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
  background: rgba(6, 16, 14, 0.98);
  text-align: center;
}

.success-content {
  width: min(100%, 340px);
}

.success-icon {
  display: grid;
  width: 62px;
  height: 62px;
  margin: 0 auto 20px;
  place-items: center;
  border-radius: 50%;
  background: var(--good);
  color: #03130f;
  font-size: 32px;
  font-weight: 800;
  box-shadow: 0 0 36px rgba(77, 227, 172, 0.24);
}

.success-content h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.35;
}

.success-content p {
  margin: 10px 0 24px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.success-content .secondary-button {
  width: 100%;
}

.modal[hidden] { display: none; }

.modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(1, 7, 6, 0.76);
  backdrop-filter: blur(12px);
}

.confirm-card {
  width: min(100%, 400px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #0b1d19;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.48);
}

.consent-modal {
  z-index: 30;
}

.consent-card {
  width: min(100%, 420px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #0b1d19;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.48);
}

.consent-card h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.4;
}

.consent-intro {
  margin: 14px 0 10px;
  color: #d8e8e2;
  font-size: 14px;
  line-height: 1.65;
}

.consent-copy {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.consent-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  cursor: pointer;
}

.consent-check input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  flex: none;
  accent-color: var(--brand);
}

.consent-check:has(input:disabled) {
  color: var(--muted);
  cursor: wait;
}

.consent-actions {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 10px;
  margin-top: 18px;
}

.preparation-modal {
  z-index: 29;
}

.preparation-card {
  width: min(100%, 420px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #0b1d19;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.48);
}

.preparation-card h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.4;
}

.preparation-summary {
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.preparation-list {
  display: grid;
  gap: 10px;
}

.preparation-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 70px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(3, 14, 12, 0.48);
}

.preparation-item strong,
.preparation-item div > span {
  display: block;
}

.preparation-item strong {
  margin-bottom: 4px;
  font-size: 14px;
}

.preparation-item div > span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.preparation-indicator {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 2px solid rgba(169, 187, 181, 0.28);
  border-radius: 50%;
}

.preparation-item.is-loading .preparation-indicator {
  border-color: rgba(77, 227, 172, 0.22);
  border-top-color: var(--good);
  animation: preparation-spin 800ms linear infinite;
}

.preparation-item.is-ready .preparation-indicator {
  border-color: var(--good);
  background: var(--good);
}

.preparation-item.is-ready .preparation-indicator::after {
  content: "✓";
  color: #03130f;
  font-size: 13px;
  font-weight: 800;
}

.preparation-item.is-error {
  border-color: rgba(255, 113, 104, 0.38);
}

.preparation-item.is-error .preparation-indicator {
  border-color: var(--bad);
}

.preparation-item.is-error .preparation-indicator::after {
  content: "!";
  color: var(--bad);
  font-size: 13px;
  font-weight: 800;
}

.preparation-retry {
  width: 100%;
  margin-top: 16px;
}

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

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--good);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.confirm-card h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.35;
}

.quality-badge {
  flex: none;
  padding: 7px 9px;
  border-radius: 999px;
  background: rgba(77, 227, 172, 0.1);
  color: var(--good);
  font-size: 11px;
}

#cropPreview {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #06100e;
}

.confirm-hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 10px;
  margin-top: 17px;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  border-radius: 12px;
  font-weight: 680;
  cursor: pointer;
}

.primary-button {
  border: 0;
  background: var(--brand);
  color: #03130f;
}

.secondary-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

button:disabled { opacity: 0.55; cursor: wait; }
.has-error .face-guide { border-color: var(--bad); }

@media (min-width: 700px) {
  .capture-shell { padding: 24px; }
  .camera-stage {
    height: min(860px, calc(100vh - 48px));
    border: 1px solid rgba(211, 238, 228, 0.12);
    border-radius: 26px;
    box-shadow: 0 40px 120px rgba(0, 0, 0, 0.35);
  }
}

@media (max-width: 380px) {
  .check-list { grid-template-columns: 1fr; }
}
