:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --card: #ffffff;
  --line: #dde3ec;
  --soft: #eef2f8;           /* buttons, the image frames, the bar track */
  --text: #1a2230;
  --muted: #5f6b7c;
  --accent: #2563eb;         /* blue */
  --accent-2: #1d4ed8;
  --accent-rgb: 37, 99, 235;
  --danger: #dc2626;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}

header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { margin: 0; display: flex; align-items: center; }
.brand img { height: 58px; display: block; }
.partner { height: 46px; display: block; }
header { box-shadow: 0 1px 4px rgba(15,23,42,.06); }

main { flex: 1; display: grid; grid-template-columns: 1fr 320px; min-height: 0; }

/* ---------- stage ---------- */
.stage { position: relative; padding: 16px; min-height: 0; display: flex; }
.dropzone {
  flex: 1; border: 2px dashed #b9c6d8; border-radius: var(--radius); background: #fff;
  display: grid; place-items: center; cursor: pointer; transition: .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: rgba(var(--accent-rgb),.05); }
.dz-inner { text-align: center; }
.dz-icon { font-size: 42px; color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.viewer { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.toolbar { display: flex; justify-content: center; margin-bottom: 10px; }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.seg button {
  width: auto; margin: 0; background: none; border: 0; color: var(--muted);
  padding: 5px 14px; border-radius: 6px; font-size: 13px;
}
.seg button.active { background: rgba(var(--accent-rgb),.12); color: var(--accent); font-weight: 600; }

.pair { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pair.wipe { grid-template-columns: 1fr; }
.pair.wipe #beforeFig { display: none; }
.pair figure { margin: 0; display: flex; flex-direction: column; min-height: 0; }
.pair figcaption {
  font-size: 12px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase;
  letter-spacing: .06em; text-align: center;
}
.pair.wipe figcaption { visibility: hidden; height: 0; margin: 0; }
.frame {
  position: relative; flex: 1; min-height: 0; background: var(--soft); border-radius: var(--radius);
  overflow: hidden; touch-action: none;
}
.frame img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  display: block; pointer-events: none;
}
#imgAfter { clip-path: inset(0 0 0 50%); }
#overlay { position: absolute; touch-action: none; }
.viewer .hint { margin: 8px 0 0; text-align: center; }

.divider {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: #fff;
  transform: translateX(-1px); cursor: ew-resize; pointer-events: none;
}
.divider span {
  position: absolute; top: 50%; left: 50%; width: 34px; height: 34px; border-radius: 50%;
  transform: translate(-50%, -50%); background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.divider span::before {
  content: "\2039 \203A"; color: #222; font-weight: 700; position: absolute; inset: 0;
  display: grid; place-items: center; white-space: pre;
}
.tag {
  position: absolute; top: 10px; padding: 3px 8px; background: rgba(15,23,42,.6);
  color: #fff; border-radius: 6px; font-size: 12px; pointer-events: none;
}
.tag-l { left: 10px; } .tag-r { right: 10px; }

/* ---------- loading ---------- */
.loader {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; min-height: 0;
}
.loader-photo {
  position: relative; border-radius: var(--radius); overflow: hidden; max-width: 100%;
  box-shadow: 0 10px 34px rgba(15,23,42,.18), 0 0 0 1px var(--line);
  animation: breathe 2.6s ease-in-out infinite;
}
.loader-photo img {
  display: block; max-width: 100%; max-height: 55vh; filter: brightness(.75) saturate(.85);
}
@keyframes breathe { 50% { box-shadow: 0 10px 34px rgba(15,23,42,.18), 0 0 0 1px var(--accent), 0 0 28px rgba(var(--accent-rgb),.3); } }

/* a band of light sweeping down over the photo */
.scan {
  position: absolute; left: 0; right: 0; height: 30%; top: -30%; pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(var(--accent-rgb),.25) 70%, rgba(var(--accent-rgb),.5));
  animation: scan 2.2s cubic-bezier(.45,.05,.55,.95) infinite;
}
.scan::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--accent); box-shadow: 0 0 12px 2px var(--accent);
}
@keyframes scan { 0% { top: -30%; } 100% { top: 100%; } }

.steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 26px; flex-wrap: wrap; justify-content: center; }
.steps li { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; transition: color .3s; }
.steps li::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; box-sizing: border-box;
  border: 2px solid var(--line); transition: .3s;
}
.steps li.active { color: var(--text); }
.steps li.active::before {
  border-color: rgba(var(--accent-rgb),.2); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
.steps li.done { color: var(--accent); }
.steps li.done::before { background: var(--accent); border-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

.loader-bar { width: min(420px, 80%); height: 4px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.loader-bar div {
  height: 100%; width: 0; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

/* the same light over the new smile while another version is made */
.regen {
  position: absolute; inset: 0; overflow: hidden; display: grid; place-items: end center;
  background: rgba(255,255,255,.2); pointer-events: none;
}
.regen span {
  margin-bottom: 18px; padding: 6px 14px; border-radius: 20px; font-size: 13px;
  background: rgba(15,23,42,.75); color: #fff;
}

.loupe {
  position: fixed; z-index: 50; pointer-events: none; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 6px 20px rgba(15,23,42,.35);
  background: #000;
}

/* ---------- panel ---------- */
.panel { background: var(--bg); border-left: 1px solid var(--line); padding: 14px; overflow-y: auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(15,23,42,.05); }
.card h2 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.info { font-size: 12px; color: var(--muted); }
.info b { color: var(--text); }

.slider { margin-bottom: 14px; }
.slider .row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.slider .val { font-variant-numeric: tabular-nums; color: var(--accent); min-width: 42px; text-align: right; font-weight: 600; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }

button, .download {
  font: inherit; color: var(--text); background: var(--soft); border: 1px solid transparent;
  border-radius: 8px; padding: 8px 12px; cursor: pointer; transition: .15s; width: 100%;
  margin-top: 8px;
}
button:hover:not(:disabled), .download:hover { filter: brightness(.95); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: #fff; border-color: var(--line); }
label.check { display: flex; align-items: center; gap: 6px; color: var(--muted); margin-bottom: 6px; }

.download { display: block; text-align: center; background: var(--accent-2); color: #fff; font-weight: 600; text-decoration: none; }


.toast {
  position: sticky; bottom: 0; background: #fef2f2; border: 1px solid var(--danger);
  color: #991b1b; padding: 10px 12px; border-radius: 8px; font-size: 13px;
}
.hidden { display: none !important; }

/* ---------- header: user menu ---------- */
.header-right { display: flex; align-items: center; gap: 22px; }
.user-menu { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.user-menu .user-name { font-weight: 600; }
.user-menu a { color: var(--accent); text-decoration: none; font-weight: 600; }
.user-menu form { margin: 0; }
button.link {
  width: auto; margin: 0; padding: 4px 10px; background: none; border: 1px solid var(--line);
  color: var(--muted); font-size: 13px;
}
button.link:hover { color: var(--danger); border-color: var(--danger); filter: none; }
a { color: var(--accent); }

/* ---------- login / register / admin pages ---------- */
body.page { height: auto; min-height: 100%; }
.auth { flex: 1; display: grid; place-items: center; padding: 40px 16px; }
.auth-card { width: min(420px, 100%); padding: 28px 28px 22px; }
.auth-card h2 { font-size: 20px; text-transform: none; letter-spacing: 0; color: var(--text); margin-bottom: 14px; }
.auth-card .primary { margin-top: 14px; padding: 10px; }
.field { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 0; }
.field input, .field textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit; font-weight: 400;
  color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 8px;
}
.field input:focus, .field textarea:focus, .admin select:focus, .admin input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .15);
}
.field textarea { resize: vertical; }
.center { text-align: center; }
.big-check {
  width: 54px; height: 54px; margin: 4px auto 10px; border-radius: 50%; display: grid; place-items: center;
  font-size: 28px; color: #fff; background: var(--accent);
}
a.button {
  display: block; text-align: center; text-decoration: none; padding: 10px; border-radius: 8px; margin-top: 16px;
}
a.button.primary { background: var(--accent); color: #fff; font-weight: 600; }
.notice { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin: 0 0 10px; border: 1px solid; }
.notice-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.notice-ok { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }

.admin { padding: 20px; max-width: 1280px; width: 100%; margin: 0 auto; }
.admin .card { padding: 18px 20px; margin-bottom: 18px; overflow-x: auto; }
.admin h2 { display: flex; align-items: center; gap: 8px; }
.count {
  background: rgba(var(--accent-rgb), .12); color: var(--accent); border-radius: 10px;
  padding: 1px 8px; font-size: 12px; letter-spacing: 0;
}
.admin table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.admin td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin tr:last-child td { border-bottom: 0; }
.admin .msg { max-width: 280px; white-space: pre-wrap; }
.admin .nowrap { white-space: nowrap; }
.admin .actions { min-width: 360px; }
.admin form.inline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 6px; }
.admin select, .admin input[type=date] {
  font: inherit; font-size: 13px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text);
}
.small-btn { width: auto; margin: 0; padding: 5px 12px; font-size: 13px; }
button.danger { background: var(--danger); color: #fff; font-weight: 600; }
button.danger-ghost { background: #fff; color: var(--danger); border-color: #fecaca; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-expired { background: #fef3c7; color: #92400e; }
.badge-blocked { background: #fee2e2; color: #991b1b; }
.badge-rejected { background: #eef2f8; color: var(--muted); }


@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
  .stage { min-height: 60vh; }
  .pair { grid-template-columns: 1fr; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
}
