:root {
  --bg: #0b0b0f;
  --panel: #14141a;
  --card: rgba(255, 255, 255, .05);
  --line: rgba(255, 255, 255, .09);
  --text: #f3f1f6;
  --muted: #8f8a9c;
  --accent: #ff6f9c;
  --accent2: #9b6bff;
  --good: #5fe0a5;
  --warn: #ffc15e;
  --grad: linear-gradient(120deg, var(--accent), var(--accent2));
  --r: 16px;
  --top: 52px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 "Vazirmatn", system-ui, -apple-system, "Segoe UI", sans-serif;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- top bar ---------- */
.top {
  height: var(--top); display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; padding-top: env(safe-area-inset-top); position: relative; z-index: 5;
}
.brand { font-weight: 700; letter-spacing: .4px; font-size: 17px; }
.logo { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.top-end { display: flex; align-items: center; gap: 8px; }
.lang { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; font: inherit; font-size: 13px; }
.lang option { color: #111; }
.credits { font-size: 12px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 11px 18px; border-radius: 999px; font: inherit; font-size: 14px; cursor: pointer; transition: .15s;
}
.btn:hover { background: rgba(255, 255, 255, .1); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad); border: 0; color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.btn.small { padding: 7px 14px; font-size: 13px; }
.btn[disabled] { opacity: .6; cursor: progress; }
.link { color: var(--muted); font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.ib {
  width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .45); color: #fff;
  backdrop-filter: blur(8px); font-size: 20px; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.ib.sm { width: 30px; height: 30px; font-size: 18px; background: var(--card); }
.mini-sel { background: rgba(0, 0, 0, .45); color: #fff; border: 0; border-radius: 999px; padding: 7px 10px; font: inherit; font-size: 12px; backdrop-filter: blur(8px); }
.mini-sel option { color: #111; }

main { height: calc(100dvh - var(--top) - env(safe-area-inset-top)); }

/* ---------- start ---------- */
.start { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 0 24px 40px; text-align: center; }
.start h1 { margin: 0; font-size: clamp(26px, 6vw, 40px); font-weight: 600; letter-spacing: -.5px; }
.sub { margin: 0; color: var(--muted); max-width: 380px; }
.picks { display: flex; gap: 14px; margin-top: 10px; width: min(100%, 420px); }
.pick {
  flex: 1; aspect-ratio: 1 / 1.05; border: 1px solid var(--line); border-radius: 22px; background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; cursor: pointer; transition: .18s;
}
.pick:hover, .pick.over { border-color: var(--accent); background: rgba(255, 111, 156, .08); transform: translateY(-2px); }
.pick-ic { font-size: 38px; }
.pick-t { font-size: 16px; font-weight: 500; }
.privacy { font-size: 12px; color: var(--muted); max-width: 340px; margin: 6px 0 0; }

/* ---------- work layout ---------- */
.work { height: 100%; display: flex; flex-direction: column; position: relative; }
.stage { position: relative; flex: 1; min-height: 0; background: #000; overflow: hidden; touch-action: none; }
.stage img, .stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.overlay { position: absolute; pointer-events: none; }
.overlay .fbox {
  position: absolute; border: 3px solid #fff; border-radius: 22%; pointer-events: auto; cursor: pointer;
  transition: .2s; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}
.overlay .fbox.dim { opacity: .45; border-width: 2px; }
.overlay .fbox.sel { border-color: var(--accent); box-shadow: 0 0 22px rgba(255, 111, 156, .7); }
.overlay .fbox b { position: absolute; top: -13px; left: 50%; transform: translateX(-50%); background: #fff; color: #111; border-radius: 999px; min-width: 26px; height: 26px; display: grid; place-items: center; font-size: 13px; }
.overlay .fbox.sel b { background: var(--accent); color: #fff; }
.overlay.ghosted .fbox { pointer-events: none; }
.bar { position: absolute; left: 10px; right: 10px; top: 10px; display: flex; align-items: center; gap: 8px; z-index: 3; }
.grow { flex: 1; }
.tag { position: absolute; left: 12px; bottom: 12px; background: rgba(0, 0, 0, .6); padding: 3px 10px; border-radius: 999px; font-size: 12px; }
.busy { position: absolute; right: 12px; bottom: 12px; width: 22px; height: 22px; opacity: 0; transition: .2s; }
.busy.on { opacity: 1; }
.busy span { display: block; width: 100%; height: 100%; border: 2px solid rgba(255, 255, 255, .25); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* matrix scan */
#matrix { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; transition: opacity .5s; }
#matrix.on { opacity: 1; }
.scan-text { position: absolute; left: 0; right: 0; bottom: 18px; margin: 0; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; color: #6bff9e; letter-spacing: 1.5px; font-size: 13px; text-shadow: 0 0 8px rgba(107, 255, 158, .7); opacity: 0; transition: opacity .3s; }
.scan-text.on { opacity: 1; }

/* ---------- bottom sheet ---------- */
.sheet {
  background: var(--panel); border-radius: 22px 22px 0 0; border-top: 1px solid var(--line);
  max-height: 46dvh; overflow: hidden; display: flex; flex-direction: column; transition: max-height .28s ease;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.tall { max-height: 78dvh; }
.sheet.low { max-height: max(26dvh, 232px); }
.grab { appearance: none; border: 0; background: transparent; padding: 10px 0 6px; cursor: grab; touch-action: none; }
.grab i { display: block; width: 40px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .22); margin: 0 auto; }
.pane { padding: 4px 16px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pane h2 { margin: 2px 0 6px; font-size: 18px; font-weight: 600; }

.res-head { display: flex; flex-direction: column; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 3px 11px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--muted); }
.findings { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 8px; }
.findings li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.findings .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--muted); }
.findings .ok .dot { background: var(--good); }
.findings .warn .dot { background: var(--warn); }
.findings b { display: block; font-weight: 500; }
.findings span { color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }

.gender { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; margin: 8px 0 2px; }
.gender button { appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; padding: 5px 14px; border-radius: 999px; cursor: pointer; }
.gender button.on { background: var(--grad); color: #fff; }
.who { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.faces { display: flex; gap: 8px; }
.faces button { appearance: none; padding: 0; width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--line); overflow: hidden; background: #222; cursor: pointer; }
.faces button.on { border-color: var(--accent); }
.faces canvas { width: 100%; height: 100%; display: block; }

/* categories (FaceApp-like grid) */
.cats { display: flex; gap: 10px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.sheet.tall .cats { display: grid; grid-template-columns: repeat(4, 1fr); overflow: visible; gap: 12px 8px; }
.cat { appearance: none; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 72px; cursor: pointer; }
.cat .ci { width: 58px; height: 58px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; font-size: 24px; transition: .15s; }
.cat:hover .ci { border-color: var(--accent); }
.cat .nm { color: var(--muted); }
.cat-head { display: flex; align-items: center; gap: 10px; margin: 8px 0 10px; }
.cat-head b { font-weight: 600; font-size: 16px; }

/* sliders */
.slider { display: block; margin: 12px 0; }
.slider .lbl { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.slider .lbl b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .15); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .5); }
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border: 0; border-radius: 50%; background: #fff; }
.shades { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.shade { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.shade.on { border-color: #fff; }
.note { font-size: 13px; color: var(--muted); background: var(--card); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }

/* presets */
.styles { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.style { appearance: none; border: 0; background: transparent; color: var(--text); font: inherit; padding: 0; cursor: pointer; text-align: center; }
.style .thumb { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; border: 2px solid transparent; background: #222; }
.style.sel .thumb { border-color: var(--accent); }
.style .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.style .sw { position: absolute; inset: 0; transition: opacity .3s; }
.style .badge { position: absolute; top: 4px; left: 4px; background: var(--accent); color: #fff; font-size: 10px; padding: 1px 7px; border-radius: 999px; }
.style .nm { font-size: 12px; margin-top: 5px; color: var(--muted); }
.why { font-size: 13px; color: var(--muted); margin: 10px 0 0; min-height: 18px; }
.ai-note { background: var(--card); border-radius: 12px; padding: 10px 12px; margin: 8px 0; font-size: 13px; white-space: pre-wrap; }
.row-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tgl { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 8px 0; }

/* ---------- misc ---------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 30px); background: #24202c; border: 1px solid var(--line); padding: 8px 20px; border-radius: 999px; opacity: 0; pointer-events: none; transition: .25s; z-index: 30; max-width: 90vw; font-size: 14px; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.dlg { background: #1a1722; color: var(--text); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; width: min(92vw, 380px); }
.dlg::backdrop { background: rgba(5, 5, 8, .75); backdrop-filter: blur(3px); }
.dlg h2 { margin: 0 0 6px; font-size: 20px; }
.fld { display: block; margin: 12px 0; font-size: 13px; color: var(--muted); }
.fld input { display: block; width: 100%; margin-top: 5px; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .07); color: var(--text); font: inherit; font-size: 16px; }
.err { color: #ff8a9a; font-size: 13px; margin: 6px 0 0; }
.dlg .btn.wide { margin-top: 8px; }

/* ---------- desktop: stage left, sheet right ---------- */
@media (min-width: 900px) {
  .work { flex-direction: row; }
  .sheet { width: 400px; max-height: none !important; border-radius: 0; border-top: 0; border-left: 1px solid var(--line); }
  .grab { display: none; }
  .cats, .sheet .cats { display: grid; grid-template-columns: repeat(4, 1fr); overflow: visible; }
  .pane { padding-top: 16px; }
}
@media (max-width: 520px) { #authBtn { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }
[dir=rtl] .overlay .fbox b { left: 50%; }

/* ---- face scan ---- */
.pin { position: absolute; transform: translate(-50%, -50%) scale(.6); background: rgba(255, 255, 255, .92); color: #111; font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap; opacity: 0; transition: .35s; box-shadow: 0 2px 10px rgba(0, 0, 0, .35); pointer-events: none; }
.pin.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.scan-text { color: #fff; text-shadow: 0 1px 8px rgba(0, 0, 0, .8); font-family: inherit; letter-spacing: .5px; font-size: 15px; font-weight: 500; }

/* ---- FaceBAF brand ---- */
.brand { display: flex; align-items: center; gap: 9px; }
.brand img { border-radius: 8px; display: block; }
.wm { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.wm b { font-weight: 700; background: linear-gradient(90deg, #ff6fb1, #8f7bff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-logo { border-radius: 26px; box-shadow: 0 10px 50px rgba(155, 107, 255, .35); margin-bottom: 4px; }

.pick-ic { width: 64px; height: 64px; object-fit: contain; opacity: .92; transition: .18s; }
.pick:hover .pick-ic { opacity: 1; transform: scale(1.06); }

.selfie { display: inline-flex; flex-direction: row; align-items: center; gap: 9px; cursor: pointer; margin-top: 4px;
  padding: 8px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); transition: .15s; }
.selfie:hover { border-color: var(--accent); background: rgba(255, 255, 255, .09); }
.selfie-ic { width: 22px; height: 22px; border-radius: 6px; display: block; }
.selfie-t { font-size: 13px; color: var(--text); }

/* ---- look score ---- */
.score { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; margin: 10px 0 4px; }
.ring { --p: 80; flex: none; width: 66px; height: 66px; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), rgba(255, 255, 255, .1) 0); }
.ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--panel); }
.ring b, .ring small { position: relative; line-height: 1; }
.ring b { font-size: 20px; font-weight: 700; }
.ring small { position: absolute; bottom: 12px; font-size: 9px; color: var(--muted); }
.ring.great { background: conic-gradient(var(--good) calc(var(--p) * 1%), rgba(255, 255, 255, .1) 0); }
.score-txt { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.score-txt b { font-size: 15px; font-weight: 600; }
.score-txt span { color: var(--muted); }
.two.single { grid-template-columns: 1fr; }

.privacy { display: flex; align-items: center; justify-content: center; gap: 8px; }
.warn-ic { width: 18px; height: 18px; flex: none; display: block; }

/* ---- floating analysis tags (random positions on the picture) ---- */
.floats { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.ftag { position: absolute; display: flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 8px; font-size: 13px; font-weight: 500;
  color: #fff; background: rgba(8, 8, 14, .62); border: 1px solid rgba(255, 255, 255, .35); backdrop-filter: blur(4px); white-space: nowrap;
  opacity: 0; transform: translateY(6px) scale(.96); transition: opacity .35s, transform .35s; }
.ftag.on { opacity: 1; transform: none; }
.ftag i { width: 7px; height: 7px; border-radius: 50%; background: #fff; box-shadow: 0 0 8px #fff; animation: blink 1s infinite; flex: none; }
.ftag.big { font-size: 15px; font-weight: 700; letter-spacing: .6px; padding: 8px 18px; }
@keyframes blink { 50% { opacity: .25; } }

/* ---- editor top bar: back | undo redo | ... save ---- */
.pill { display: flex; align-items: center; background: rgba(0, 0, 0, .5); border: 1px solid rgba(255, 255, 255, .12); border-radius: 999px; backdrop-filter: blur(8px); padding: 0 4px; height: 38px; }
.pb { width: 44px; height: 36px; border: 0; background: transparent; color: #fff; font-size: 21px; cursor: pointer; padding: 0; border-radius: 999px; }
.pb[disabled] { opacity: .32; cursor: default; }
.ib.more span { position: relative; width: 22px; height: 22px; border: 2px solid #fff; border-radius: 50%; display: block; }
.ib.more span::before { content: ""; position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; margin: -1.5px 0 0 -1.5px; border-radius: 50%; background: #fff; box-shadow: -5.5px 0 #fff, 5.5px 0 #fff; }
.menu { position: absolute; right: 10px; top: 56px; z-index: 6; background: #1c1a24; border: 1px solid var(--line); border-radius: 14px; padding: 6px; min-width: 230px; box-shadow: 0 14px 40px rgba(0, 0, 0, .55); }
.mi { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; background: none; border: 0; color: var(--text); font: inherit; font-size: 14px; border-radius: 10px; cursor: pointer; text-align: start; }
.mi:hover { background: rgba(255, 255, 255, .07); }
.mi-ic { width: 20px; text-align: center; color: var(--muted); font-size: 16px; }
.mi select { margin-inline-start: auto; background: #2a2733; color: #fff; border: 0; border-radius: 8px; padding: 4px 6px; font: inherit; font-size: 12px; }
.mi-hint { margin: 4px 12px 8px; font-size: 12px; color: var(--muted); }

.toast.warn { background: #3a1820; border-color: #ff6f80; color: #fff; white-space: normal; text-align: center; max-width: min(92vw, 420px); border-radius: 14px; }
/* ---- video trim ---- */
.trim-vid { width: 100%; max-height: 22dvh; border-radius: 12px; background: #000; display: block; margin-bottom: 8px; }
.trim-sel { font-size: 13px; color: var(--text); text-align: center; margin: 4px 0 10px; font-variant-numeric: tabular-nums; direction: ltr; }
