:root {
  color-scheme: light;
  --ink: #1d2433;
  --muted: #667085;
  --line: #d9dee8;
  --panel: #ffffff;
  --surface: #f3f6f8;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --blue: #2563eb;
  --shadow: 0 24px 80px rgba(26, 35, 54, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 32%),
    linear-gradient(315deg, rgba(37, 99, 235, 0.09), transparent 30%),
    var(--surface);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.hidden {
  display: none !important;
}

.intro-page {
  display: grid;
  gap: clamp(14px, 2.2vh, 24px);
  min-height: calc(100vh - 56px);
  padding: clamp(18px, 4vw, 44px);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(217, 222, 232, 0.85);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.intro-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.intro-copy {
  max-width: 760px;
}

.brand-logo {
  width: clamp(128px, 22vw, 260px);
  height: auto;
  object-fit: contain;
  flex: 0 0 auto;
}

.intro-copy h1 {
  font-size: clamp(1.65rem, 4vw, 3.6rem);
  max-width: 740px;
}

.friendly-subtitle {
  width: fit-content;
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(15, 118, 110, 0.09);
  font-family:
    "Nunito", "Avenir Rounded", "PingFang SC", "Microsoft YaHei", system-ui,
    sans-serif;
  font-size: clamp(0.92rem, 2.2vw, 1.12rem);
  font-weight: 800;
  letter-spacing: 0;
}

.intro-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.example-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 1.6vw, 12px);
  margin-top: clamp(12px, 2vh, 20px);
}

.example-card {
  display: grid;
  gap: 6px;
  padding: clamp(8px, 1.7vw, 12px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.86);
}

.example-card strong {
  font-size: clamp(0.72rem, 1.7vw, 0.92rem);
}

.example-card span {
  color: var(--muted);
  font-size: clamp(0.64rem, 1.5vw, 0.82rem);
}

.example-card.wrong strong {
  color: #dc2626;
}

.example-card.correct strong {
  color: var(--accent);
}

.example-photo {
  position: relative;
  aspect-ratio: 35 / 45;
  overflow: hidden;
  border: 1px solid rgba(102, 112, 133, 0.3);
  border-radius: 6px;
  background: #fff;
}

.example-photo::after {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
  font-size: 0.82rem;
}

.example-card.wrong .example-photo::after {
  content: "!";
  background: #dc2626;
}

.example-card.correct .example-photo::after {
  content: "✓";
  background: var(--accent);
}

.bad-bg {
  background: #dbeafe;
}

.example-head {
  position: absolute;
  left: 50%;
  top: 24%;
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #d69a72;
  transform: translateX(-50%);
}

.example-body {
  position: absolute;
  left: 50%;
  bottom: -5%;
  width: 52%;
  height: 34%;
  border-radius: 999px 999px 0 0;
  background: #315b67;
  transform: translateX(-50%);
}

.bad-position .example-head,
.bad-position .example-body {
  left: 34%;
}

.good-photo::before {
  content: "";
  position: absolute;
  left: 20%;
  top: 11%;
  width: 60%;
  height: 78%;
  border: 2px dashed rgba(15, 118, 110, 0.75);
  border-radius: 50%;
}

.intro-grid.single {
  grid-template-columns: minmax(0, 1fr);
}

.spec-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: rgba(248, 250, 252, 0.86);
}

.spec-card ul {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.55;
}

.intro-actions,
.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.large-action {
  min-width: 180px;
}

.secondary-file {
  color: var(--accent-strong);
  border: 1px solid rgba(15, 118, 110, 0.38);
  background: rgba(15, 118, 110, 0.08);
}

.workspace {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(217, 222, 232, 0.85);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.complete-page {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  padding: clamp(28px, 6vw, 72px);
  text-align: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(217, 222, 232, 0.85);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.complete-page .brand-logo {
  width: clamp(150px, 34vw, 320px);
}

.complete-page h1 {
  max-width: 760px;
  font-size: clamp(1.7rem, 4vw, 3.4rem);
}

.crop-page {
  min-height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  gap: 18px;
  padding: clamp(18px, 4vw, 36px);
  background:
    linear-gradient(rgba(29, 36, 51, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 36, 51, 0.05) 1px, transparent 1px),
    rgba(255, 255, 255, 0.92);
  background-size: 22px 22px;
  border: 1px solid rgba(217, 222, 232, 0.85);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.crop-preview {
  align-self: center;
  width: min(68vw, 420px);
  aspect-ratio: 35 / 45;
  overflow: hidden;
  border-radius: 6px;
  background: #eef2f7;
  box-shadow: 0 18px 50px rgba(17, 24, 39, 0.18);
}

.crop-controls {
  width: min(720px, 100%);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
}

.editor-logo {
  width: clamp(118px, 18vw, 220px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1.1;
}

h2 {
  font-size: 0.98rem;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 0;
  min-height: 680px;
}

.preview-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(rgba(29, 36, 51, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 36, 51, 0.05) 1px, transparent 1px);
  background-size: 22px 22px;
}

.photo-stage {
  position: relative;
  width: min(68vw, 430px);
  aspect-ratio: 35 / 45;
  max-height: 72vh;
  background: #eef2f7;
  border-radius: 6px;
  box-shadow: 0 18px 50px rgba(17, 24, 39, 0.18);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  touch-action: none;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}

.empty-state strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.empty-state.hidden {
  display: none;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.control-group {
  display: grid;
  gap: 14px;
}

.control-group.compact {
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.file-button,
.primary-action,
.secondary-action,
.ghost-action {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 750;
}

.file-button,
.primary-action {
  color: #fff;
  background: var(--accent);
}

.file-button:hover,
.primary-action:hover {
  background: var(--accent-strong);
}

.secondary-action {
  color: var(--accent-strong);
  border: 1px solid rgba(15, 118, 110, 0.38);
  background: rgba(15, 118, 110, 0.08);
}

.ghost-action {
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.camera-frame {
  position: relative;
  width: min(68vw, 430px);
  aspect-ratio: 35 / 45;
  display: none;
  justify-self: center;
  overflow: hidden;
  border: 1px solid rgba(29, 36, 51, 0.28);
  border-radius: 6px;
  background: #111827;
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.16);
}

.camera-frame.active {
  display: block;
}

video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transform: scaleX(-1);
}

.live-guides {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.9);
}

.face-mask {
  position: absolute;
  left: 19%;
  top: 10%;
  width: 62%;
  height: 80%;
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(17, 24, 39, 0.38);
}

.face-frame {
  position: absolute;
  left: 19%;
  top: 10%;
  width: 62%;
  height: 80%;
  border: 3px solid rgba(255, 255, 255, 0.96);
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(29, 36, 51, 0.48),
    0 0 22px rgba(0, 0, 0, 0.18);
}

.guide-line {
  position: absolute;
  left: 15%;
  right: 15%;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  text-shadow:
    0 1px 2px rgba(255, 255, 255, 0.95),
    0 -1px 2px rgba(255, 255, 255, 0.95);
}

.guide-head,
.guide-chin {
  color: #dc2626;
  border-top: 2px dashed rgba(220, 38, 38, 0.98);
}

.guide-head-min,
.guide-chin-min {
  color: var(--accent);
  border-top: 2px dashed rgba(15, 118, 110, 0.98);
}

.guide-head {
  top: 10%;
}

.guide-head-min {
  top: 14.444%;
}

.guide-chin-min {
  top: 85.556%;
}

.guide-chin {
  top: 90%;
}

.center-line {
  position: absolute;
  top: 8%;
  bottom: 8%;
  left: 50%;
  border-left: 1px solid rgba(255, 255, 255, 0.82);
}

.quality-panel {
  padding-top: 4px;
}

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

.quality-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.quality-item span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.quality-item strong {
  font-size: 0.88rem;
}

.quality-item.pass {
  border-color: rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.08);
}

.quality-item.warn {
  border-color: rgba(220, 38, 38, 0.32);
  background: rgba(220, 38, 38, 0.07);
}

.quality-item.pending {
  background: #f8fafc;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.46);
}

.modal-panel {
  width: min(440px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  display: grid;
  gap: 16px;
  padding: 22px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

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

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.submit-photo-action {
  margin-top: 2px;
}

.camera-actions,
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stage-actions {
  display: none;
  width: min(68vw, 430px);
  margin-top: 16px;
  grid-template-columns: 1fr;
}

.capture-action {
  min-height: 52px;
  background: var(--accent);
  box-shadow: 0 12px 26px rgba(15, 118, 110, 0.24);
}

.capture-action:hover {
  background: var(--accent-strong);
}

.camera-frame.active + .stage-actions {
  display: grid;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

@media (max-width: 880px) {
  .app-shell {
    width: min(100vw - 20px, 560px);
    padding: 10px 0;
  }

  .intro-page {
    gap: 12px;
    min-height: calc(100vh - 20px);
    padding: 16px;
  }

  .intro-header {
    align-items: flex-start;
    gap: 10px;
  }

  .brand-logo {
    width: clamp(96px, 31vw, 150px);
  }

  .intro-copy h1 {
    font-size: clamp(1.45rem, 7vw, 2rem);
  }

  .topbar {
    align-items: center;
    flex-direction: row;
    padding: 18px;
  }

  .editor-logo {
    width: clamp(92px, 30vw, 140px);
  }

  .intro-grid {
    grid-template-columns: 1fr;
  }

  .example-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    margin-top: 12px;
  }

  .example-card {
    padding: 7px;
  }

  .example-photo::after {
    right: 4px;
    bottom: 4px;
    width: 16px;
    height: 16px;
    font-size: 0.68rem;
  }

  .spec-card {
    padding: 12px;
  }

  .spec-card ul {
    gap: 6px;
    margin-top: 8px;
    font-size: 0.86rem;
    line-height: 1.35;
  }

  .large-action {
    min-width: 0;
  }

  .intro-actions,
  .topbar-actions {
    display: grid;
  }

  .editor-grid {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    padding: 18px 14px;
  }

  .photo-stage {
    width: min(82vw, 390px);
    max-height: 68vh;
  }

  .camera-frame {
    width: min(82vw, 390px);
    max-height: 68vh;
  }

  .stage-actions {
    width: min(82vw, 390px);
  }

  .crop-page {
    min-height: calc(100vh - 20px);
    gap: 14px;
    padding: 14px;
  }

  .crop-preview {
    width: min(82vw, 390px);
    max-height: 56vh;
  }

  .crop-controls {
    padding: 16px;
  }

  .controls {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
