/* StyleMirror — warm salon-editorial theme */
:root {
  --bg: #faf6ef;
  --bg-soft: #f3ecdf;
  --ink: #241d15;
  --ink-soft: #6f6355;
  --card: #ffffff;
  --copper: #b4642d;
  --gold: #c8873a;
  --line: #e7ddcc;
  --shadow: 0 10px 34px rgba(66, 45, 22, 0.12);
  --shadow-lg: 0 22px 70px rgba(66, 45, 22, 0.22);
  --radius: 20px;
  --sans: "Inter", -apple-system, system-ui, sans-serif;
  --serif: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

.screen { display: none; min-height: 100dvh; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- Gallery ---------- */
.masthead { padding: max(20px, env(safe-area-inset-top)) 22px 6px; text-align: center; }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--copper));
  color: #fff; font-size: 19px; transform: rotate(-18deg);
  box-shadow: var(--shadow);
}
.brand h1 {
  font-family: var(--serif); font-weight: 600; font-size: 1.9rem;
  letter-spacing: 0.01em; margin: 0;
}
.tagline { color: var(--ink-soft); font-size: 0.85rem; margin: 6px 0 0; letter-spacing: 0.02em; }

.chips {
  display: flex; gap: 8px; padding: 16px 22px 4px;
  overflow-x: auto; scrollbar-width: none; justify-content: safe center;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--card);
  color: var(--ink-soft); font: 500 0.83rem var(--sans);
  padding: 9px 18px; border-radius: 999px; cursor: pointer;
  transition: all 0.18s ease;
}
.chip.active {
  background: var(--ink); border-color: var(--ink); color: var(--bg);
}

.grid {
  display: grid; gap: 16px; padding: 18px 22px 28px;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  max-width: 1060px; margin: 0 auto; width: 100%;
}
.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); cursor: pointer; border: 0; padding: 0;
  text-align: left; transition: transform 0.22s ease, box-shadow 0.22s ease;
  animation: rise 0.5s ease backwards;
}
.card:active { transform: scale(0.97); }
@media (hover: hover) {
  .card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
}
.card-img {
  width: 100%; aspect-ratio: 2 / 3; object-fit: cover; display: block;
  background: linear-gradient(160deg, var(--bg-soft), #e9dcc6);
}
.card-body { padding: 12px 14px 14px; }
.card-name { font-family: var(--serif); font-weight: 500; font-size: 1.02rem; margin: 0; }
.card-tags { color: var(--ink-soft); font-size: 0.72rem; margin: 3px 0 0; letter-spacing: 0.03em; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.foot { text-align: center; padding: 4px 26px calc(20px + env(safe-area-inset-bottom)); margin-top: auto; }
.foot p { color: var(--ink-soft); font-size: 0.72rem; }

/* ---------- Buttons ---------- */
.ghost-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: 500 0.9rem var(--sans); padding: 12px 20px; border-radius: 999px;
  cursor: pointer; transition: background 0.15s;
}
.ghost-btn:active { background: var(--bg-soft); }
.primary-btn {
  border: 0; background: linear-gradient(135deg, var(--gold), var(--copper));
  color: #fff; font: 600 0.95rem var(--sans); padding: 14px 26px;
  border-radius: 999px; cursor: pointer; box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.primary-btn:active { transform: scale(0.97); }

/* ---------- Camera ---------- */
.cam-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) 18px 10px;
}
.cam-style-tag {
  font-family: var(--serif); font-size: 1rem; color: var(--ink-soft);
  padding-right: 4px;
}
.cam-stage {
  position: relative; margin: 4px auto 0; width: min(92vw, 420px);
  aspect-ratio: 4 / 5; border-radius: 26px; overflow: hidden;
  background: #1c1712; box-shadow: var(--shadow-lg);
}
#cam-video, #cam-still {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
#cam-video { transform: scaleX(-1); }
#cam-still.mirrored { transform: scaleX(-1); }
.cam-mask { position: absolute; inset: 0; pointer-events: none; }
.cam-oval {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%);
  width: 62%; aspect-ratio: 3 / 4; border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.65);
  box-shadow: 0 0 0 200vmax rgba(20, 15, 10, 0.34);
}
.cam-hint {
  position: absolute; left: 0; right: 0; bottom: 10px; text-align: center;
  color: rgba(255, 255, 255, 0.92); font-size: 0.78rem; letter-spacing: 0.02em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); margin: 0; padding: 0 16px;
}
.cam-controls {
  display: flex; align-items: center; justify-content: center; gap: 26px;
  padding: 22px 26px 6px;
}
.upload-btn { display: inline-flex; align-items: center; }
.ghost-spacer { width: 86px; }
.shutter {
  width: 76px; height: 76px; border-radius: 50%; cursor: pointer;
  border: 4px solid var(--ink); background: transparent; padding: 5px;
}
.shutter span {
  display: block; width: 100%; height: 100%; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--copper));
  transition: transform 0.12s;
}
.shutter:active span { transform: scale(0.86); }
.privacy-line {
  text-align: center; color: var(--ink-soft); font-size: 0.72rem;
  padding: 10px 26px calc(18px + env(safe-area-inset-bottom)); margin: auto 0 0;
}

/* ---------- Result / compare ---------- */
.compare {
  position: relative; margin: 4px auto 0; width: min(92vw, 420px);
  aspect-ratio: 2 / 3; border-radius: 26px; overflow: hidden;
  box-shadow: var(--shadow-lg); background: var(--bg-soft);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.compare img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; pointer-events: none;
}
.compare-after { position: absolute; inset: 0; overflow: hidden; clip-path: inset(0 0 0 50%); }
.compare-handle {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 3px;
  background: rgba(255, 255, 255, 0.95); cursor: ew-resize;
  box-shadow: 0 0 14px rgba(0, 0, 0, 0.35);
}
.handle-knob {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 46px; height: 46px; border-radius: 50%; background: #fff;
  display: grid; place-items: center; font-size: 1.05rem; color: var(--copper);
  box-shadow: var(--shadow);
}
.compare-label {
  position: absolute; top: 14px; font: 600 0.68rem var(--sans);
  letter-spacing: 0.09em; text-transform: uppercase; color: #fff;
  background: rgba(20, 15, 10, 0.45); padding: 6px 12px; border-radius: 999px;
  backdrop-filter: blur(6px);
}
.label-before { left: 14px; }
.label-after { right: 14px; }

.result-actions {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 22px 26px calc(22px + env(safe-area-inset-bottom));
}
.result-row { display: flex; gap: 12px; }
.quota { color: var(--ink-soft); font-size: 0.72rem; margin: 0; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 30px;
  background: rgba(24, 18, 12, 0.93); color: #f6efe4;
  backdrop-filter: blur(8px);
}
.overlay h2 { font-family: var(--serif); font-weight: 500; font-size: 1.5rem; margin: 26px 0 6px; }
.overlay p { color: #cdbca4; font-size: 0.88rem; margin: 0; min-height: 1.4em; transition: opacity 0.4s; }
.busy-ring {
  width: 74px; height: 74px; border-radius: 50%;
  border: 3px solid rgba(200, 135, 58, 0.25); border-top-color: var(--gold);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.overlay-light { background: rgba(250, 246, 239, 0.96); color: var(--ink); }
.qr-card {
  background: var(--card); border-radius: 24px; box-shadow: var(--shadow-lg);
  padding: 30px 34px; display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.qr-card h2 { font-family: var(--serif); font-weight: 500; font-size: 1.3rem; margin: 0; }
.qr-card p { color: var(--ink-soft); font-size: 0.78rem; margin: 0; }
#qr-box img, #qr-box canvas { border-radius: 10px; }

.toast {
  position: fixed; left: 50%; bottom: calc(30px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 60; max-width: min(88vw, 420px);
  background: var(--ink); color: var(--bg); font-size: 0.85rem; line-height: 1.45;
  padding: 14px 20px; border-radius: 16px; box-shadow: var(--shadow-lg);
  animation: rise 0.3s ease;
}

.kiosk-reset {
  position: fixed; top: max(14px, env(safe-area-inset-top)); right: 14px; z-index: 30;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  font: 500 0.8rem var(--sans); padding: 9px 16px; border-radius: 999px; cursor: pointer;
  box-shadow: var(--shadow);
}

@media (min-width: 760px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
  .brand h1 { font-size: 2.2rem; }
}
