/* Тема по образцу roeid.ro: белый фон, светло-серые секции, синий #2e5ae6, шрифт Sora, пилюльные кнопки. */
:root {
  --bg: #ffffff;
  --bg-2: #f1f3f8;
  --surface: #ffffff;
  --surface-2: #e8ecf5;
  --border: #dfe3ee;
  --border-2: #cdced9;
  --text: #060e24;
  --text-2: #272833;
  --muted: #6b6c7e;
  --primary: #2e5ae6;
  --primary-dark: #0d3994;
  --primary-tint: #e4eafc;
  --primary-tint-2: #dfe6fb;
  --yellow: #ffce2d;
  --coral: #f47c7c;
  --ok: #287d3c;
  --ok-tint: #e3f3e7;
  --warn: #b7791f;
  --warn-tint: #fff3c9;
  --bad: #d93025;
  --bad-tint: #fde8e6;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(13, 57, 148, 0.10);
  --font: "Sora", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input { font: inherit; }
button, a, label, input, .doc-card { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
input, select, textarea { font-size: 16px; } /* iOS не зумит поля с шрифтом от 16px */
h1 { font-size: clamp(32px, 7vw, 48px); font-weight: 700; letter-spacing: -0.02em; margin: 18px 0 12px; line-height: 1.08; }
h2 { font-size: clamp(24px, 5vw, 30px); font-weight: 700; letter-spacing: -0.01em; margin: 14px 0 12px; line-height: 1.15; }
p { line-height: 1.55; }
.lead { color: var(--text-2); font-size: 17px; margin: 0 0 22px; }
.fineprint { color: var(--muted); font-size: 12.5px; margin-top: 18px; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--bg-2); padding: 2px 8px; border-radius: 8px; color: var(--primary-dark); }

/* Фон: чистый белый с мягкими декоративными формами в углах, как на roeid.ro */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--bg); }
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.35; animation: float 20s ease-in-out infinite; }
.b1 { width: 420px; height: 420px; background: var(--primary-tint-2); top: -200px; right: -160px; }
.b2 { width: 360px; height: 360px; background: #fff1bf; bottom: -200px; left: -160px; animation-delay: -8s; }
.b3 { display: none; }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-30px, 24px) scale(1.06); } }

/* Шапка бренда: логотип ROeID слева, переключатель языка справа (как на roeid.ro) */
.brandbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; min-height: 40px; }
.logo { display: inline-flex; align-items: center; }
.logo img { height: 30px; width: auto; display: block; }
.lang-switch { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; }
.lang-switch button { border: 0; background: transparent; color: var(--primary-dark); font-weight: 700; font-size: 12.5px; letter-spacing: 0.04em; padding: 6px 12px; border-radius: 999px; cursor: pointer; transition: background 0.2s, color 0.2s; }
.lang-switch button.active { background: var(--primary); color: #fff; }
.sitefoot { display: flex; align-items: center; gap: 12px; margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.gov-logo { height: 34px; width: auto; flex: none; }
.screen.camera ~ .sitefoot { display: none; }

/* Экраны */
#app { max-width: 560px; margin: 0 auto; padding: 20px 20px 40px; min-height: 100dvh; position: relative; }
.screen { display: none; animation: enter 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.screen.active { display: block; }
.screen.leaving { animation: leave 0.25s ease-in both; }
@keyframes enter { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes leave { to { opacity: 0; transform: translateY(-8px); } }

.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; min-height: 32px; }
.link { background: none; border: 0; color: var(--primary); cursor: pointer; padding: 6px 0; font-weight: 600; }
.link:hover { color: var(--primary-dark); }
.progress-label { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }

/* Кнопки: пилюли, как на roeid.ro */
.btn { border: 0; border-radius: 999px; padding: 14px 24px; font-weight: 600; cursor: pointer; transition: transform 0.15s, box-shadow 0.2s, background 0.2s, opacity 0.2s; color: var(--primary-dark); background: var(--surface-2); }
.btn:hover { background: #dde3f0; }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 8px 22px rgba(46, 90, 230, 0.28); }
.btn.primary:hover { background: var(--primary-dark); box-shadow: 0 10px 26px rgba(13, 57, 148, 0.32); }
.btn.big { width: 100%; padding: 17px 24px; font-size: 17px; }
.btn.ghost { background: var(--surface-2); color: var(--primary-dark); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }
.row { display: flex; gap: 12px; margin-top: 18px; }
.row .btn { flex: 1; }

/* Приветствие */
.hero { text-align: center; padding-top: 8px; }
.hero h1 { text-align: left; }
.hero .lead { text-align: left; }
.hero-art { width: min(340px, 84vw); margin: 0 auto; }
.hero-art svg { width: 100%; height: auto; }
.steps-overview { list-style: none; padding: 0; margin: 0 0 26px; text-align: left; display: grid; gap: 10px; }
.steps-overview li { display: flex; align-items: center; gap: 14px; background: var(--bg-2); border-radius: 14px; padding: 13px 14px; animation: enter 0.5s both; font-weight: 500; }
.steps-overview li:nth-child(2) { animation-delay: 0.08s; } .steps-overview li:nth-child(3) { animation-delay: 0.16s; }
.num { width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; font-size: 14px; }

/* Выбор документа */
.doc-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0 22px; }
.doc-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 10px 14px; border-radius: 18px; background: var(--surface); border: 1.5px solid var(--border); cursor: pointer; transition: transform 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s; text-align: center; }
.doc-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.doc-card input { position: absolute; opacity: 0; pointer-events: none; }
.doc-card:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); box-shadow: 0 0 0 4px rgba(46, 90, 230, 0.14); }
.doc-card:has(input:checked) .doc-art svg { transform: rotate(-4deg) scale(1.06); }
.doc-art { width: 84px; height: 64px; display: grid; place-items: center; }
.doc-art svg { width: 100%; height: auto; transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
.doc-title { font-weight: 700; font-size: 14px; }
.doc-sub { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
@media (max-width: 480px) {
  .doc-types { grid-template-columns: 1fr; gap: 10px; }
  .doc-card { display: grid; grid-template-columns: 72px 1fr; grid-template-areas: "art title" "art sub"; column-gap: 12px; row-gap: 2px; text-align: left; padding: 12px 14px; align-items: center; }
  .doc-art { grid-area: art; width: 72px; height: 54px; }
  .doc-title { grid-area: title; font-size: 15px; }
  .doc-sub { grid-area: sub; }
}

/* Форма */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.field input { background: var(--surface); border: 1.5px solid var(--border-2); color: var(--text); border-radius: 14px; padding: 14px 16px; font-size: 16px; outline: none; transition: border-color 0.2s, box-shadow 0.2s; }
.field input::placeholder { color: #a7a9bc; }
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(46, 90, 230, 0.14); }
.error { color: var(--bad); font-size: 14px; margin: 0; }

/* Инструкция */
.guide-art { width: min(360px, 88vw); margin: 6px auto 4px; }
.guide-art svg { width: 100%; height: auto; }
.tips { list-style: none; padding: 0; margin: 0 0 22px; display: grid; gap: 10px; }
.tips li { display: flex; gap: 12px; align-items: flex-start; background: var(--bg-2); border-radius: 14px; padding: 12px 14px; font-size: 15px; line-height: 1.45; animation: enter 0.5s both; color: var(--text-2); }
.tips li:nth-child(2) { animation-delay: 0.07s; } .tips li:nth-child(3) { animation-delay: 0.14s; } .tips li:nth-child(4) { animation-delay: 0.21s; }
.tips .ico { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--primary-tint); color: var(--primary); font-size: 14px; }

/* Выбор источника */
.choice { display: grid; gap: 10px; }
.btn-ico { margin-right: 8px; }
.upload-status { display: flex; align-items: center; gap: 10px; justify-content: center; color: var(--muted); margin-top: 14px; font-weight: 600; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }
.upload-hints { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.upload-hints li { display: flex; gap: 10px; align-items: flex-start; background: var(--bad-tint); border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.4; animation: enter 0.35s both; color: var(--text-2); }
.upload-hints li::before { content: "!"; flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 12px; background: var(--bad); color: #fff; }

/* Камера (видео — тёмная среда, поверх неё светлые элементы бренда) */
.screen.camera { position: fixed; inset: 0; z-index: 10; background: #060e24; }
.viewport { position: absolute; inset: 0; overflow: hidden; }
#video, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.viewport.mirror #video, .viewport.mirror #overlay { transform: scaleX(-1); }
#overlay { pointer-events: none; }
.frame-guide { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 92%; max-width: 720px; aspect-ratio: 1.586; pointer-events: none; transition: aspect-ratio 0.3s; box-shadow: 0 0 0 200vmax rgba(6, 14, 36, 0.45); border-radius: 14px; }
.frame-guide.passport { aspect-ratio: 1.41; }
.frame-guide .corner { position: absolute; width: 34px; height: 34px; border: 4px solid rgba(255, 255, 255, 0.95); border-radius: 6px; transition: border-color 0.25s, transform 0.25s; }
.corner.tl { left: -3px; top: -3px; border-right: 0; border-bottom: 0; }
.corner.tr { right: -3px; top: -3px; border-left: 0; border-bottom: 0; }
.corner.br { right: -3px; bottom: -3px; border-left: 0; border-top: 0; }
.corner.bl { left: -3px; bottom: -3px; border-right: 0; border-top: 0; }
.frame-guide.good .corner { border-color: #4ade80; transform: scale(1.1); }
.frame-guide.found .corner { border-color: var(--yellow); }
.oval-guide { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); width: min(66vw, 340px); aspect-ratio: 0.78; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 200vmax rgba(6, 14, 36, 0.55); pointer-events: none; transition: border-color 0.25s; animation: breathe 2.4s ease-in-out infinite; }
.oval-guide.good { border-color: #4ade80; animation: none; }
.oval-guide.found { border-color: var(--yellow); }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 200vmax rgba(6, 14, 36, 0.55), 0 0 0 0 rgba(255, 255, 255, 0.35); } 50% { box-shadow: 0 0 0 200vmax rgba(6, 14, 36, 0.55), 0 0 0 14px rgba(255, 255, 255, 0); } }
.cam-top { position: absolute; top: 0; left: 0; right: 0; padding: max(14px, env(safe-area-inset-top)) 16px 14px; display: flex; align-items: center; gap: 12px; background: linear-gradient(180deg, rgba(6, 14, 36, 0.6), transparent); color: #fff; }
.cam-title { font-weight: 700; flex: 1; }
.cam-step { color: rgba(255, 255, 255, 0.75); font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.18); color: #fff; font-size: 16px; cursor: pointer; backdrop-filter: blur(10px); }
.cam-bottom { position: absolute; bottom: 0; left: 0; right: 0; padding: 16px 16px max(18px, env(safe-area-inset-bottom)); display: grid; gap: 12px; justify-items: center; background: linear-gradient(0deg, rgba(6, 14, 36, 0.7), transparent); color: #fff; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 6px 11px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); backdrop-filter: blur(10px); color: rgba(255, 255, 255, 0.85); transition: background 0.25s, color 0.25s; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, 0.45); transition: background 0.25s; }
.chip.ok { background: rgba(74, 222, 128, 0.25); color: #eafff1; }
.chip.ok::before { background: #4ade80; box-shadow: 0 0 10px #4ade80; }
.chip.bad { background: rgba(244, 124, 124, 0.3); color: #ffe9e9; }
.chip.bad::before { background: var(--coral); }
.hint { margin: 0; text-align: center; font-weight: 600; font-size: 15px; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6); min-height: 22px; }
.shutter-row { display: flex; align-items: center; justify-content: center; }
.ring { position: relative; width: 84px; height: 84px; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { fill: none; stroke: rgba(255, 255, 255, 0.3); stroke-width: 5; }
.ring .bar { fill: none; stroke: var(--yellow); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 289; stroke-dashoffset: 289; transition: stroke-dashoffset 0.25s; }
.shutter { position: absolute; inset: 11px; border-radius: 50%; border: 0; background: #fff; cursor: pointer; box-shadow: inset 0 0 0 3px var(--primary), inset 0 0 0 5px #fff; transition: transform 0.1s; }
.shutter:active { transform: scale(0.92); }
.shutter[disabled] { opacity: 0.6; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash 0.45s ease-out; }
@keyframes flash { 0% { opacity: 0.9; } 100% { opacity: 0; } }

/* Просмотр */
.preview-wrap { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--bg-2); box-shadow: var(--shadow); animation: pop 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); border: 1px solid var(--border); }
.preview-wrap img { display: block; width: 100%; max-height: 62vh; object-fit: contain; }
.badge-ok { position: absolute; right: 14px; top: 14px; width: 42px; height: 42px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 20px; box-shadow: 0 6px 20px rgba(40, 125, 60, 0.4); animation: pop 0.6s 0.2s both; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.checklist { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.checklist li { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); background: var(--bg-2); border-radius: 12px; padding: 10px 12px; animation: enter 0.4s both; }
.checklist li::before { content: "✓"; color: var(--ok); font-weight: 900; }

/* Обработка */
.processing { text-align: center; padding-top: 30px; }
.scanner { width: min(260px, 70vw); margin: 0 auto 10px; }
.scanner svg { width: 100%; height: auto; }
.proc-steps { list-style: none; padding: 0; margin: 20px auto 0; max-width: 380px; text-align: left; display: grid; gap: 10px; }
.proc-steps li { display: flex; align-items: center; gap: 12px; color: var(--muted); background: var(--bg-2); border-radius: 14px; padding: 12px 14px; transition: color 0.3s; }
.proc-steps .dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-2); flex: none; display: grid; place-items: center; font-size: 11px; transition: all 0.3s; }
.proc-steps li.active { color: var(--text); }
.proc-steps li.active .dot { border-color: var(--primary); border-top-color: transparent; animation: spin 0.8s linear infinite; }
.proc-steps li.done { color: var(--text); }
.proc-steps li.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.proc-steps li.done .dot::after { content: "✓"; font-weight: 900; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Результат */
.result { text-align: center; padding-top: 24px; }
.result-icon { width: 120px; height: 120px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center; font-size: 56px; font-weight: 900; animation: pop 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); }
.result-icon.approved { background: var(--ok-tint); color: var(--ok); box-shadow: 0 0 0 12px rgba(40, 125, 60, 0.08); }
.result-icon.manual_review { background: var(--warn-tint); color: var(--warn); box-shadow: 0 0 0 12px rgba(255, 206, 45, 0.15); }
.result-icon.rejected { background: var(--bad-tint); color: var(--bad); box-shadow: 0 0 0 12px rgba(217, 48, 37, 0.08); }
.result .lead { text-align: center; }
.errors { list-style: none; padding: 0; margin: 0 0 22px; display: grid; gap: 8px; text-align: left; }
.errors li { display: flex; gap: 10px; align-items: flex-start; background: var(--bg-2); border-radius: 12px; padding: 12px 14px; font-size: 14.5px; line-height: 1.4; animation: enter 0.4s both; color: var(--text-2); }
.errors li::before { content: "!"; flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--yellow); color: var(--text); }
.errors li.reject::before { background: var(--bad); color: #fff; }
.app-id { color: var(--muted); font-size: 13px; margin: 0 0 18px; }

/* Тост */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--text); color: #fff; padding: 12px 18px; border-radius: 999px; font-size: 14px; z-index: 50; max-width: 90vw; box-shadow: 0 12px 30px rgba(6, 14, 36, 0.3); animation: enter 0.3s; }

/* SVG анимации */
.scan-line { animation: scan 2.4s ease-in-out infinite; }
@keyframes scan { 0%, 100% { transform: translateY(0); opacity: 0.2; } 50% { transform: translateY(var(--scan, 120px)); opacity: 1; } }
.hover { animation: hover 4s ease-in-out infinite; transform-origin: center; }
@keyframes hover { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-10px) rotate(1deg); } }
.pulse { animation: pulse 1.8s ease-in-out infinite; transform-origin: center; }
@keyframes pulse { 0%, 100% { opacity: 0.6; transform: scale(1); } 50% { opacity: 1; transform: scale(1.03); } }
.slide-in { animation: slideIn 3.2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite; }
@keyframes slideIn { 0% { transform: translate(-60px, 30px) rotate(-8deg); opacity: 0; } 30%, 80% { transform: none; opacity: 1; } 100% { transform: none; opacity: 0; } }
.brackets { animation: brackets 3.2s ease-in-out infinite; }
@keyframes brackets { 0%, 25% { stroke: #a9b8e8; opacity: 0.8; } 45%, 80% { stroke: #2e5ae6; opacity: 1; } 100% { opacity: 0; } }
.book-open { animation: bookOpen 3s ease-in-out infinite; transform-origin: 160px 0; }
@keyframes bookOpen { 0%, 15% { transform: rotateY(60deg); } 45%, 100% { transform: rotateY(0deg); } }
.tick-draw { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw 0.8s 1.2s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.dash-move { stroke-dasharray: 8 6; animation: dash 1.2s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -14; } }
.arrows { animation: arrows 1.6s ease-in-out infinite; }
@keyframes arrows { 0%, 100% { transform: scale(1); opacity: 0.6; } 50% { transform: scale(0.94); opacity: 1; } }
.flip { animation: flip 3.4s ease-in-out infinite; transform-origin: center; }
@keyframes flip { 0%, 20% { transform: rotateY(0); } 50%, 70% { transform: rotateY(180deg); } 100% { transform: rotateY(360deg); } }
.spin-slow { animation: spin 14s linear infinite; transform-origin: center; }

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