:root {
  --ink: #172027;
  --muted: #60707c;
  --panel: rgba(255, 255, 255, 0.9);
  --line: rgba(255, 255, 255, 0.42);
  --accent: #12a3a8;
  --accent-2: #e4523f;
  --good: #2e9d64;
  --warn: #d98b23;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101820;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
}

.camera-stage {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px),
    #2a3338;
  background-size: 32px 32px;
}

#camera {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

#camera.rear-camera {
  transform: none;
}

#meter {
  position: absolute;
  left: -200px;
  top: -200px;
}

.shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 16, 21, 0.56), rgba(10, 16, 21, 0.05) 36%, rgba(10, 16, 21, 0.72));
  pointer-events: none;
}

.top-bar {
  position: absolute;
  z-index: 4;
  top: max(18px, env(safe-area-inset-top));
  left: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
}

.eyebrow {
  margin: 0 0 3px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
}

h1 {
  font-size: 1.45rem;
}

h2 {
  font-size: 1.35rem;
}

.icon-button,
.primary-action,
.secondary-action,
.settings-panel button,
.download-links a {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.icon-button {
  width: 44px;
  height: 44px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
}

.settings-panel {
  position: absolute;
  z-index: 5;
  top: max(76px, calc(env(safe-area-inset-top) + 76px));
  left: 18px;
  right: 18px;
  padding: 14px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
}

.settings-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(96, 112, 124, 0.22);
}

.setting-row:first-child {
  padding-top: 0;
}

.setting-row span {
  display: grid;
  gap: 3px;
}

.setting-row strong {
  font-size: 0.92rem;
}

.setting-row small {
  color: var(--muted);
  line-height: 1.25;
}

.switch {
  display: inline-flex !important;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  position: relative;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: #c8d1d7;
  transition: background 0.18s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  transition: transform 0.18s ease;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(22px);
}

.settings-panel input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #c8d1d7;
  border-radius: 8px;
}

.settings-panel button {
  margin-top: 10px;
  padding: 10px 14px;
  color: white;
  background: var(--accent);
}

.face-guide {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.face-oval {
  width: min(72vw, 360px);
  aspect-ratio: 0.72;
  border: 3px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.15);
}

.chin-line,
.teeth-target {
  position: absolute;
  left: 50%;
  width: min(42vw, 190px);
  transform: translateX(-50%);
  border-top: 2px dashed rgba(255, 255, 255, 0.72);
}

.chin-line {
  top: 66%;
}

.teeth-target {
  top: 55%;
  border-color: rgba(228, 82, 63, 0.9);
}

.prompt-panel {
  position: absolute;
  z-index: 3;
  left: 18px;
  right: 18px;
  bottom: calc(106px + env(safe-area-inset-bottom));
  padding: 16px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce5e9;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.24s ease;
}

.step-title {
  margin: 13px 0 5px;
  font-size: 1.3rem;
  font-weight: 800;
}

.step-detail,
.quality-hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.38;
}

.quality-hint {
  margin-top: 8px;
  font-size: 0.86rem;
  font-weight: 700;
}

.controls {
  position: absolute;
  z-index: 4;
  left: 18px;
  right: 18px;
  bottom: max(22px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
}

.primary-action,
.secondary-action {
  min-height: 54px;
  padding: 0 18px;
  font-weight: 800;
}

.primary-action {
  color: white;
  background: var(--accent-2);
}

.secondary-action {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.result-panel {
  position: fixed;
  z-index: 8;
  left: 18px;
  right: 18px;
  bottom: 18px;
  padding: 16px;
  border-radius: 8px;
  background: #f8fafb;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.36);
}

.result-panel .eyebrow {
  color: var(--muted);
}

.download-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

.download-links a {
  padding: 10px 12px;
  color: white;
  font-weight: 800;
  text-decoration: none;
  background: var(--accent);
}

@media (min-width: 780px) {
  .camera-stage {
    max-width: 520px;
    min-height: 920px;
    margin: 0 auto;
  }
}
