*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f4f6fb;
  --surface:  #ffffff;
  --surface2: #f0f2f8;
  --border:   #e2e6f0;
  --accent:   #5b5ef4;
  --accent-h: #4345d4;
  --text:     #1a1a2e;
  --muted:    #5c6280;   /* контраст с --surface ~6:1, соответствует WCAG AA */
  --ok:       #17a86a;
  --warn:     #e07b20;
  --err:      #d63a5a;
  --shadow:   0 2px 12px rgba(80,90,140,0.08);
  --shadow-lg:0 4px 24px rgba(80,90,140,0.13);
  --radius:   14px;
  --radius-sm:8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 14px 48px;
  gap: 16px;
}

/* ── Header ── */
header { text-align: center; }
header h1 {
  font-size: 1.5rem; font-weight: 800;
  letter-spacing: -0.03em; color: var(--text);
}
header p { color: var(--muted); font-size: 0.85rem; margin-top: 3px; }

/* Версия: раньше терялась из-за color+opacity вместе (контраст ~2.3:1).
   Теперь один источник затемнения — сама переменная --muted (контраст ~6:1). */
.version-tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  vertical-align: middle;
  margin-left: 6px;
}

/* ── Steps ── */
.steps {
  display: flex; gap: 6px; align-items: center;
  font-size: 0.8rem; color: var(--muted);
  flex-wrap: wrap; justify-content: center;
}
.step-dot {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--border); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700;
  transition: background 0.25s, color 0.25s;
}
.step-dot.active { background: var(--accent); color: #fff; }
.step-dot.done   { background: var(--ok); color: #fff; }
.step-sep { color: var(--border); }

/* ── Video ── */
.video-wrap {
  position: relative;
  width: 100%; max-width: 480px;
  aspect-ratio: 4/3;
  background: #1a1a2e;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
#video  {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; transform: scaleX(-1);
}
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.badge {
  position: absolute; top: 10px; left: 12px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.6);
  border-radius: 99px;
  padding: 6px 16px;
  font-size: 0.88rem; font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  transition: color 0.2s;
}

/* ── Confidence bars / список найденных предметов ── */
#conf-wrap {
  width: 100%; max-width: 480px;
  display: flex; flex-direction: column; gap: 7px;
  min-height: 16px;
}
.conf-row  { display: flex; align-items: center; gap: 10px; }
.conf-label {
  width: 110px; font-size: 0.85rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conf-bg {
  flex: 1; height: 7px;
  background: var(--border); border-radius: 99px; overflow: hidden;
}
.conf-bar  {
  height: 100%; border-radius: 99px;
  transition: width 0.15s ease; width: 0%;
  opacity: 0.85;
}
.conf-pct  {
  width: 40px; text-align: right;
  font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.sample-info { color: var(--muted); }
/* Раньше .muted добавлял ещё и opacity:0.5 поверх --muted — контраст падал
   вдвое. Разница "есть примеры / нет примеров" теперь только в тексте. */
.sample-info.muted { color: var(--muted); }

/* ── Layout ── */
.main { width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 12px; }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.card-title {
  display: block;
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin-bottom: 12px;
}

/* ── Ползунок порога уверенности ──
   Раньше был голым браузерным <input type=range> без стилей — на разных
   платформах выглядел по-разному, и ползунок мог быть мельче 24px
   (минимальный touch-таргет). Теперь стилизован явно, с общим для label
   и слайдера цветом дорожки/бегунка и размером бегунка 24px. */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 24px;
  background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 99px;
  background: var(--border);
}
input[type="range"]::-moz-range-track {
  height: 6px; border-radius: 99px;
  background: var(--border);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(80,90,140,0.35);
  margin-top: -9px;
  transition: box-shadow 0.15s;
}
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(80,90,140,0.35);
}
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(91,94,244,0.3); }
input[type="range"]:focus-visible::-moz-range-thumb     { box-shadow: 0 0 0 4px rgba(91,94,244,0.3); }

/* ── Log ── */
.log {
  font-size: 0.86rem; line-height: 1.7;
  min-height: 80px; color: var(--text);
}
.log span   { display: block; }
.log .ok    { color: var(--ok); }
.log .warn  { color: var(--warn); }
.log .err   { color: var(--err); }

/* ── Desktop 2-column ── */
@media (min-width: 900px) {
  body { padding: 28px 24px 48px; }

  .desktop-wrap {
    display: grid;
    grid-template-columns: 480px 1fr;
    gap: 24px;
    width: 100%;
    max-width: 980px;
    align-items: start;
  }

  .col-left  { display: flex; flex-direction: column; gap: 14px; }
  .col-right { display: flex; flex-direction: column; gap: 12px; }

  .video-wrap { max-width: 100%; }
  #conf-wrap  { max-width: 100%; }
  .main       { max-width: 100%; }
}

.save-note {
  font-size: 0.82rem; color: var(--muted); line-height: 1.55;
  padding: 6px 2px 2px;
}
