/* КинезАналитик — клиент v6. Цвета и шрифты как на прежней версии сайта. */
:root {
  --bg: #080c14;
  --surface: #0d1320;
  --card: rgba(255, 255, 255, 0.04);
  --card-2: rgba(255, 255, 255, 0.07);
  --accent: #00f5a0;
  --accent-2: #7c3aed;
  --text: #f0f4ff;
  --muted: #8b9bbf;
  --border: rgba(255, 255, 255, 0.09);
  --red: #ff4560;
  --amber: #ffb547;
  --radius: 14px;
  --font: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.45;
  background-image: radial-gradient(ellipse 80% 60% at 20% -10%, rgba(124, 58, 237, 0.12), transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 110%, rgba(0, 245, 160, 0.07), transparent 60%);
}
.hidden { display: none !important; }
a { color: var(--accent); }
h2 { font-size: 1.35rem; margin-bottom: 8px; }
h3 { font-size: 0.95rem; margin: 18px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.85rem; margin: -4px 0 10px; }
.error { color: var(--red); }

/* Верхняя панель */
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.brand span { color: var(--accent); }
.topbar nav { display: flex; gap: 6px; flex-wrap: wrap; }
.account { margin-left: auto; color: var(--muted); font-size: 0.9rem; display: flex; gap: 8px; align-items: center; }

/* Кнопки */
button { font: inherit; cursor: pointer; }
.primary, .secondary, .ghost {
  border-radius: 10px; padding: 11px 18px; font-weight: 600; border: 1px solid transparent; transition: 0.15s;
}
.primary { background: var(--accent); color: #04130c; width: 100%; margin-top: 12px; }
.primary:disabled { background: #2a3448; color: #6b7894; cursor: not-allowed; }
.secondary { background: var(--card-2); color: var(--text); border-color: var(--border); }
.ghost { background: transparent; color: var(--muted); border-color: var(--border); padding: 6px 12px; font-size: 0.9rem; }
.ghost.off { opacity: 0.5; }
.link { background: none; border: none; color: var(--accent); padding: 6px 8px; text-decoration: none; font-size: 0.95rem; }
.link.back { padding-left: 0; margin-bottom: 6px; }

/* Раскладка */
.layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(340px, 1fr); gap: 20px; padding: 20px; max-width: 1600px; margin: 0 auto; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; align-self: start; max-height: calc(100vh - 110px); overflow-y: auto; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .panel { max-height: none; }
}

/* Камера */
.stage { position: sticky; top: 12px; align-self: start; }
@media (max-width: 900px) { .stage { position: static; } }
.viewport { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; border: 1px solid var(--border); }
.viewport video, .viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.viewport.mirror video, .viewport.mirror canvas { transform: scaleX(-1); }
.viewport.demo video { display: none; }
.hud { position: absolute; bottom: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; pointer-events: none; }
.status { background: rgba(8, 12, 20, 0.75); border: 1px solid var(--border); padding: 5px 10px; border-radius: 999px; font-size: 0.8rem; color: var(--muted); }
.status.ok { color: var(--accent); }
.status.error { color: var(--red); }
.hud-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
/* Счёт и подсказки должны читаться с 3 м: крупно, в долях меньшей стороны экрана */
.hud-main { font-size: clamp(4rem, 24vmin, 14rem); line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; text-shadow: 0 4px 24px rgba(0, 0, 0, 0.8); }
.hud-sub { font-size: clamp(1.1rem, 5vmin, 2.4rem); font-weight: 600; margin-top: 0.4em; background: rgba(8, 12, 20, 0.65); padding: 0.2em 0.7em; border-radius: 0.4em; text-align: center; }
/* Во время записи камера занимает весь экран */
body[data-screen="record"] .viewport { position: fixed; inset: 0; z-index: 40; aspect-ratio: auto; border-radius: 0; border: 0; }
.stop-overlay { display: none; position: absolute; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2;
  background: rgba(8, 12, 20, 0.72); color: #fff; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 999px; padding: 12px 30px; font-weight: 700; font-size: 1rem; }
body[data-screen="record"] .stop-overlay:not(.hidden) { display: block; }
.level-enable { width: 100%; margin: 4px 0 10px; }
/* Подсказка установки поверх камеры — видна издалека, когда телефон уже на штативе */
.hud-hint { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); text-align: center; pointer-events: none;
  font-size: clamp(0.95rem, 3.6vmin, 1.8rem); line-height: 1.25; font-weight: 700; padding: 0.3em 0.8em; border-radius: 0.5em; background: rgba(8, 12, 20, 0.72); color: var(--amber); }
.hud-hint.ok { color: var(--accent); }
.hud-hint:empty, body:not([data-screen="setup"]) .hud-hint { display: none; }
.hud-sub:empty { display: none; }
/* на узком экране во время записи статус не должен наезжать на кнопку «Остановить» */
@media (max-width: 600px) { body[data-screen="record"] .hud { display: none; } }
body:not([data-screen="record"]) .hud-center { display: none; }
.stage-bar { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.demo-badge { display: none; margin-left: auto; color: var(--amber); font-size: 0.85rem; }
.is-demo .demo-badge { display: inline; }

/* Формы */
form label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 10px; }
input, select { display: block; width: 100%; margin-top: 4px; background: var(--card-2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 10px; font: inherit; }
.row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 480px) { .row { grid-template-columns: 1fr 1fr; } }
label.check { display: flex; gap: 10px; align-items: flex-start; color: var(--text); font-size: 0.88rem; }
label.check input { width: auto; margin-top: 3px; }

/* Выбор теста */
.group { margin-bottom: 14px; }
.cards { display: grid; gap: 8px; }
.card { text-align: left; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; color: var(--text); display: grid; gap: 3px; }
.card:hover { border-color: rgba(0, 245, 160, 0.4); background: var(--card-2); }
.card span { color: var(--muted); font-size: 0.9rem; }
.card small { color: var(--muted); font-size: 0.78rem; }

/* Установка */
ol, ul { padding-left: 20px; }
li { margin-bottom: 4px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin: 6px 0; }
.segmented button { background: none; border: none; color: var(--muted); padding: 8px 18px; }
.segmented button.active { background: var(--accent); color: #04130c; font-weight: 600; }
.segmented button:disabled { opacity: 0.4; }
.checklist { list-style: none; padding: 0; }
.checklist li { padding: 7px 10px 7px 34px; border-radius: 8px; position: relative; margin-bottom: 4px; background: var(--card); font-size: 0.92rem; }
.checklist li::before { position: absolute; left: 11px; top: 7px; font-weight: 700; }
.checklist li.ok::before { content: '✓'; color: var(--accent); }
.checklist li.bad::before { content: '•'; color: var(--red); }
.checklist li.soft::before { content: '!'; color: var(--amber); }
.checklist li.pending { color: var(--muted); }
.checklist li.pending::before { content: '…'; color: var(--muted); }
.checklist label { display: flex; gap: 8px; align-items: center; margin: 0; color: var(--text); }
.checklist input { width: auto; margin: 0; }
.sources { margin-top: 16px; font-size: 0.85rem; color: var(--muted); }

/* Результаты */
.quality { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--card); margin-bottom: 10px; font-size: 0.9rem; }
.quality.poor { border: 1px solid var(--red); }
.quality.fair { border: 1px solid var(--amber); }
.quality span { color: var(--muted); }
.warnings { background: rgba(255, 181, 71, 0.08); border: 1px solid rgba(255, 181, 71, 0.3); border-radius: 10px; padding: 10px 12px 10px 28px; margin-bottom: 10px; font-size: 0.88rem; }
.metrics { display: grid; gap: 10px; }
.metric { background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--muted); border-radius: 12px; padding: 12px 14px; }
.metric.ok { border-left-color: var(--accent); }
.metric.attention { border-left-color: var(--amber); }
.metric header { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.metric h4 { font-size: 0.95rem; font-weight: 600; }
.metric .side { color: var(--muted); font-weight: 400; }
.m-value { font-size: 1.8rem; font-weight: 800; margin: 4px 0; }
.m-spread, .m-note { color: var(--muted); font-size: 0.85rem; }
.m-spread span { font-size: 0.8rem; }
.m-ref { font-size: 0.88rem; margin-top: 6px; }
.status.provisional, .m-ref .status { color: var(--muted); font-size: 0.8rem; border: none; background: none; padding: 0; }
.metric details { margin-top: 6px; font-size: 0.85rem; color: var(--muted); }
.metric details p { margin-top: 6px; }
.metric .src { font-size: 0.8rem; }
.chip { font-size: 0.75rem; padding: 3px 8px; border-radius: 999px; white-space: nowrap; background: var(--card-2); color: var(--muted); }
.chip.ok { background: rgba(0, 245, 160, 0.12); color: var(--accent); }
.chip.attention { background: rgba(255, 181, 71, 0.14); color: var(--amber); }
.sub { margin-top: 16px; }
.asym { padding: 10px 12px; border-radius: 10px; background: var(--card); margin-bottom: 8px; font-size: 0.9rem; display: grid; gap: 2px; }
.asym.attention { border: 1px solid rgba(255, 181, 71, 0.5); }
.asym span { color: var(--muted); font-size: 0.85rem; }
.disclaimer { color: var(--muted); font-size: 0.8rem; margin-top: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.actions .primary { width: auto; margin-top: 0; }

/* История */
.hist { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.hist header { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.hist time { color: var(--muted); font-size: 0.85rem; }
.hist ul { list-style: none; padding: 0; font-size: 0.9rem; }
.hist li { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--border); padding: 4px 0; }
.hist b.attention { color: var(--amber); }
.hist b.ok { color: var(--accent); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--border); padding: 12px 18px; border-radius: 10px; z-index: 10; max-width: 90vw; }
.toast.error { border-color: var(--red); }
.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 16px 20px 24px; }

.file-box { margin-top: 16px; padding: 12px; border: 1px dashed var(--border); border-radius: 12px; }
.file-box .hint { margin: 4px 0 10px; }
.file-btn { display: inline-block; cursor: pointer; }
.level { margin-top: 8px; }
.experimental { margin-top: 12px; color: var(--muted); }
.experimental summary { cursor: pointer; padding: 6px 0; }
.experimental .metrics { margin-top: 8px; }
