:root {
  --paper: #f6efe2;       /* Warm vintage aged-paper background */
  --paper-card: #fdfaf2;  /* Slightly lighter warm cream for the card */
  --ink: #2b2827;         /* Soft dark charcoal instead of harsh pure black */
  --muted: #756a5e;       /* Warm taupe/sepia for description texts */
  --line: rgba(43, 40, 39, 0.12); /* Delicate warm-grey line */
  --clay: #a6442e;        /* Beautiful brick red / terracotta for main action button */
  --clay-dark: #843321;   /* Deeper brick red */
  --white: #fffdf9;
  --shadow: 0 16px 40px rgba(90, 78, 65, 0.08); /* Organic warm-shadow */
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background-color: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Noto Serif SC", "Songti SC", "SimSun", Georgia, serif;
  background:
    radial-gradient(circle at 10% 20%, rgba(166, 68, 46, 0.02) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(43, 86, 75, 0.02) 0%, transparent 40%),
    linear-gradient(180deg, #faf6ee 0%, #ede5d7 100%);
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
a {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.hero-panel {
  width: min(100%, 880px);
  min-height: min(680px, calc(100vh - 48px));
  display: grid;
  grid-template-columns: 0.4fr 0.6fr;
  gap: 36px;
  align-items: stretch;
  position: relative;
}

.time-rail {
  position: absolute;
  inset: 16px auto 16px -8px;
  width: 1px;
  display: grid;
  align-content: space-between;
  background: var(--line);
}

.time-rail span {
  width: 9px;
  height: 9px;
  margin-left: -4px;
  border: 1px solid var(--clay);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 2px rgba(166, 68, 46, 0.1);
}

.copy-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px 0 20px 24px;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 5.5vw, 46px);
  line-height: 1.3;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.04em;
  text-shadow: 0.5px 0.5px 0.5px rgba(43, 40, 39, 0.05);
}

.subcopy {
  max-width: 20rem;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 20px;
  min-height: 520px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-card);
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

.preview-wrap {
  position: relative;
  min-height: 320px;
  overflow: hidden;
  border-radius: 4px;
  background: #f1ebd9;
  border: 1px solid rgba(43, 40, 39, 0.08);
  box-shadow: inset 0 2px 8px rgba(90, 78, 65, 0.05);
}

.preview-wrap::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(43, 40, 39, 0.06);
  pointer-events: none;
}

.camera,
.preview-image {
  width: 100%;
  height: 100%;
  min-height: 320px;
  display: block;
  object-fit: cover;
}

.empty-preview,
.loading-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
}

.empty-preview strong,
.loading-layer strong {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

.empty-preview small,
.loading-layer small {
  max-width: 16rem;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.face-mark {
  width: 90px;
  height: 112px;
  border: 1px dashed var(--muted);
  opacity: 0.6;
  border-radius: 50% 50% 45% 45%;
  position: relative;
}

.face-mark::before,
.face-mark::after {
  content: "";
  position: absolute;
  background: var(--line);
}

.face-mark::before {
  top: 45%;
  left: -6px;
  right: -6px;
  height: 1px;
}

.face-mark::after {
  left: 50%;
  top: -6px;
  bottom: -6px;
  width: 1px;
  transform: translateX(-50%);
}

.loading-layer {
  z-index: 2;
  background: rgba(253, 250, 242, 0.9);
  backdrop-filter: blur(4px);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(43, 40, 39, 0.06);
  border-top-color: var(--clay);
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
}

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

.message {
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  font-weight: 500;
}

.controls,
.actions {
  display: grid;
  gap: 10px;
}

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

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

.primary-btn,
.secondary-btn,
.process-btn {
  min-height: 46px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.primary-btn {
  color: var(--white);
  background: var(--ink);
}

.primary-btn:hover {
  background: #3c3836;
  transform: translateY(-1px);
}

.secondary-btn {
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
}

.secondary-btn:hover {
  background: rgba(43, 40, 39, 0.04);
  border-color: var(--ink);
  transform: translateY(-1px);
}

.process-btn {
  color: var(--white);
  background: var(--clay);
  box-shadow: 0 4px 12px rgba(166, 68, 46, 0.15);
}

.process-btn:hover:not(:disabled) {
  background: var(--clay-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(166, 68, 46, 0.25);
}

.primary-btn:active,
.secondary-btn:active,
.process-btn:active {
  transform: translateY(0);
}

.primary-btn:disabled,
.process-btn:disabled,
.secondary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none !important;
  box-shadow: none !important;
}

[hidden] {
  display: none !important;
}

@media (max-width: 768px) {
  .app-shell {
    display: block;
    padding: 16px 12px;
  }

  .hero-panel {
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .time-rail {
    display: none;
  }

  .copy-block {
    padding: 12px 4px 0;
    text-align: center;
    align-items: center;
  }

  h1 {
    max-width: 100%;
    font-size: 30px;
  }

  .subcopy {
    max-width: 100%;
    margin-top: 10px;
    font-size: 14px;
  }

  .stage {
    min-height: auto;
    padding: 20px 16px;
    margin-top: 12px;
  }

  .preview-wrap,
  .camera,
  .preview-image {
    min-height: 280px;
    height: 320px;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
