/* ============ FaceFind theme ============ */
:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f3efe9;
  --text: #1a1714;
  --muted: #7a736b;
  --border: #ebe6df;
  --ink: #1a1714;          /* primary button */
  --ink-text: #ffffff;
  --accent: #b07a52;       /* champagne / terracotta */
  --accent-soft: #f4e9df;
  --danger: #c0392b;
  --ok: #2e7d4f;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(26, 23, 20, .04), 0 8px 30px rgba(26, 23, 20, .06);
  --shadow-lg: 0 20px 60px rgba(26, 23, 20, .18);
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110;
    --surface: #1b1a18;
    --surface-2: #24221f;
    --text: #f3efe9;
    --muted: #a39c92;
    --border: #2e2b27;
    --ink: #f3efe9;
    --ink-text: #121110;
    --accent: #d9a77f;
    --accent-soft: #2c241d;
    --danger: #ff7a6b;
    --ok: #5fcf8e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .35em; letter-spacing: -.015em; font-weight: 600; }
.serif { font-family: var(--serif); font-weight: 500; letter-spacing: -.02em; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .wrap { padding: 0 28px; } }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.hidden { display: none !important; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

/* ---------- buttons & inputs ---------- */
button, .btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 10px 18px; border-radius: 999px; font: 600 14px/1.2 var(--sans); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  transition: transform .12s ease, background .15s, border-color .15s, opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
button:hover, .btn:hover { border-color: var(--muted); }
button:active, .btn:active { transform: scale(.97); }
button:disabled { opacity: .5; cursor: default; transform: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.btn-primary:hover { border-color: var(--ink); opacity: .9; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-lg { padding: 15px 24px; font-size: 16px; }
.btn-icon { width: 42px; height: 42px; padding: 0; }
.btn svg, button svg { width: 18px; height: 18px; flex: none; }

input[type=text], input[type=password], input[type=date] {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: 15px var(--sans); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label { font-size: 13px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 6px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
@media (min-width: 768px) { .card { padding: 24px; } }

.status { padding: 11px 14px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; display: flex; gap: 10px; align-items: center; }
.status.error { color: var(--danger); }
.status.ok { color: var(--ok); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .25s; }

/* ---------- top nav ---------- */
.nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 64px; }
.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; text-decoration: none; letter-spacing: -.01em; }
.logo-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--ink); color: var(--ink-text); display: grid; place-items: center; }
.logo-mark svg { width: 18px; height: 18px; }

/* ---------- masonry gallery ---------- */
.masonry { column-count: 2; column-gap: 8px; }
@media (min-width: 640px) { .masonry { column-count: 3; column-gap: 10px; } }
@media (min-width: 1024px) { .masonry { column-count: 4; column-gap: 12px; } }
.masonry .tile { break-inside: avoid; margin-bottom: 8px; }
@media (min-width: 640px) { .masonry .tile { margin-bottom: 10px; } }
@media (min-width: 1024px) { .masonry .tile { margin-bottom: 12px; } }

.tile {
  position: relative; display: block; width: 100%; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); cursor: zoom-in; padding: 0; border: 0;
}
.tile img { width: 100%; height: 100%; display: block; object-fit: cover; opacity: 0; transition: opacity .4s, transform .5s ease; }
.tile img.loaded { opacity: 1; }
@media (hover: hover) { .tile:hover img { transform: scale(1.03); } }
.tile .badge {
  position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.55); color: #fff; backdrop-filter: blur(6px);
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 99px;
}
.tile .del {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; padding: 0; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; border: 0; backdrop-filter: blur(6px); opacity: 0; transition: opacity .15s;
}
.tile:hover .del, .tile:focus-within .del { opacity: 1; }
@media (hover: none) { .tile .del { opacity: 1; } }

.square-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
@media (min-width: 640px) { .square-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }
.square-grid .tile { aspect-ratio: 1; }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty svg { width: 36px; height: 36px; margin-bottom: 8px; opacity: .6; }

/* ---------- modals (camera, lightbox) ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 9, 8, .94);
  display: flex; flex-direction: column; color: #fff;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; }
.modal-bar button, .modal-bar .btn { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; }
.modal-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; position: relative; padding: 0 12px; }
.modal-body img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; user-select: none; -webkit-user-drag: none; }
.modal-foot { display: flex; justify-content: center; gap: 10px; padding: 14px 16px 18px; }
.nav-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; padding: 0;
  background: rgba(255,255,255,.12); border: 0; color: #fff; border-radius: 50%;
}
.nav-arrow:active { transform: translateY(-50%) scale(.95); }
.nav-arrow.prev { left: 16px; } .nav-arrow.next { right: 16px; }
@media (max-width: 640px) { .nav-arrow { display: none; } }

.camera-frame { position: relative; width: min(100%, 520px); aspect-ratio: 3 / 4; max-height: 100%; border-radius: 22px; overflow: hidden; background: #000; }
.camera-frame video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.face-guide {
  position: absolute; left: 50%; top: 46%; width: 62%; aspect-ratio: 3 / 4; transform: translate(-50%, -50%);
  border-radius: 50%; border: 3px solid rgba(255,255,255,.85); box-shadow: 0 0 0 9999px rgba(0,0,0,.35);
}
.shutter { width: 74px; height: 74px; border-radius: 50%; padding: 0; background: #fff; border: 5px solid rgba(255,255,255,.35); background-clip: padding-box; }
