:root {
  --ink: #15171c; --ink-2: #3a3e48; --muted: #6b6f7a; --line: #e6e2d9;
  --paper: #faf8f4; --card: #fff; --sand: #f2eee5;
  --accent: #0d6b5e; --accent-ink: #094c43; --accent-soft: #e2f0ec; --gold: #f2b84b; --gold-ink: #7a5300;
  --danger: #b4322c; --ok: #1f7a4d;
  --r: 12px; --r-lg: 18px; --shadow: 0 1px 2px rgba(21,23,28,.06), 0 8px 24px rgba(21,23,28,.06);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.5 Onest, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: var(--ink);
  background: var(--paper); -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
a { color: var(--accent); }
img { max-width: 100%; display: block; }
button { font: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 19px; font-weight: 700; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.bar {
  position: sticky; top: 0; z-index: 5; height: 56px; padding: 0 16px; display: flex; align-items: center;
  background: rgba(250,248,244,.92); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 17px; }
.brand small { display: block; font-size: 11px; font-weight: 600; color: var(--accent); letter-spacing: .02em; margin-top: -3px; }
.brand span { line-height: 1.15; }

main { max-width: 560px; margin: 0 auto; padding: 20px 16px calc(32px + var(--safe-b)); }

/* кнопки */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 52px; padding: 12px 18px;
  border-radius: 14px; border: 1px solid transparent; font-weight: 700; font-size: 16px; text-decoration: none; cursor: pointer;
  transition: background-color .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-gold { background: var(--gold); color: #231a00; }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn:focus-visible, .chip:focus-visible, .cand:focus-visible, .handle:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.stack { display: grid; gap: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* головна */
.hero { padding: 8px 0 20px; }
.hero h1 { font-size: 28px; }
.hero p { color: var(--ink-2); }
.steps { display: grid; gap: 10px; margin: 22px 0 6px; padding: 0; list-style: none; counter-reset: s; }
.steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; color: var(--ink-2); }
.steps li::before {
  counter-increment: s; content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: 13px;
}
.section { margin-top: 28px; }
.section-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.linkbtn { background: none; border: 0; color: var(--muted); font-size: 14px; padding: 6px; cursor: pointer; }

/* картки */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.list { display: grid; gap: 10px; }
.cand {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 12px; align-items: center; padding: 10px; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
}
.cand img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: var(--sand); }
.cand b { display: block; font-size: 15px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cand .muted { font-size: 13px; }
.pct { font-size: 13px; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.pct.mid { color: var(--gold-ink); background: #fdf1d8; }
.pct.low { color: var(--muted); background: var(--sand); }

/* кадрування */
.crop-wrap { position: relative; margin: 0 -16px; background: #111; touch-action: none; user-select: none; -webkit-user-select: none; }
.crop-in { position: relative; margin: 0 auto; }
.crop-wrap canvas { display: block; width: 100%; height: 100%; }
.crop-wrap svg.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.handle {
  position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; touch-action: none; cursor: grab;
  background: rgba(255,255,255,.18); border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(13,107,94,.9), 0 2px 8px rgba(0,0,0,.5);
}
.handle::after { content: ''; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: var(--gold); }
.handle.active { cursor: grabbing; background: rgba(242,184,75,.35); }
.hint { font-size: 14px; color: var(--ink-2); margin: 14px 0; }

/* очікування */
.wait { text-align: center; padding: 40px 0; }
.wait img { width: 180px; height: 180px; object-fit: cover; margin: 0 auto 20px; border-radius: 14px; opacity: .9; }
.spinner { width: 36px; height: 36px; margin: 0 auto 14px; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { background: linear-gradient(90deg, var(--sand), #fbf9f5, var(--sand)); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: 10px; }
@keyframes sh { to { background-position: -200% 0; } }

/* результат */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 5px 11px; border-radius: 999px; margin-bottom: 12px; }
.badge.high { background: var(--accent-soft); color: var(--accent-ink); }
.badge.mid { background: #fdf1d8; color: var(--gold-ink); }
.work-img { margin: 0 -16px 16px; background: var(--sand); }
.work-img img { width: 100%; max-height: 60dvh; object-fit: contain; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; margin: 12px 0 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.stat { padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.stat b { display: block; font-size: 24px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.wide { grid-column: 1 / -1; }
.chart { padding: 14px 14px 10px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; margin-top: 8px; }
.bars div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.bars i { display: block; width: 100%; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--accent); }
.bars i.zero { background: var(--line); }
.bars small { font-size: 10px; color: var(--muted); margin-top: 4px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .t { font-weight: 600; font-size: 15px; }
.timeline .s { grid-column: 1; font-size: 13px; color: var(--muted); }
.timeline .p { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 22px 16px; }
.empty svg { width: 40px; height: 40px; color: var(--muted); margin-bottom: 8px; }
.notice { padding: 14px; border-radius: var(--r); background: var(--sand); font-size: 14px; color: var(--ink-2); }
.notice.err { background: #fbe9e7; color: var(--danger); }
.sticky-cta { position: sticky; bottom: 0; padding: 12px 0 calc(12px + var(--safe-b)); background: linear-gradient(transparent, var(--paper) 30%); margin-top: 16px; }
.foot { margin-top: 36px; font-size: 13px; color: var(--muted); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
