:root {
  --ink: #17233a;
  --muted: #5a6577;
  --line: #d9dee6;
  --paper: #f4f5f7;
  --card: #ffffff;
  --accent: #0f5c4d;
  --accent-dark: #0a4539;
  --warn: #9a4d00;
  --warn-bg: #fff4e5;
  --ok-bg: #e7f3ef;
  --bad: #a4262c;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  max-width: 1040px; margin: 0 auto; padding: 16px 20px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; padding: 0; border: 0; background: none;
  color: var(--ink); font: inherit; font-weight: 700; cursor: pointer;
}
.mark { width: 16px; height: 24px; border: 2px solid var(--accent); border-radius: 2px; background: #fff; }
.privacy { color: var(--muted); font-size: 14px; text-align: right; }
main { max-width: 1040px; margin: 0 auto; padding: 12px 20px 48px; }
h1 { font-size: clamp(28px, 5vw, 42px); line-height: 1.15; margin: 0 0 14px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 8px; }
.lead { font-size: 18px; color: var(--muted); margin: 0 0 24px; max-width: 34em; }

.start { display: grid; grid-template-columns: 1.5fr 1fr; gap: 48px; align-items: start; padding-top: 36px; }
.rules { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; }
.rules ul, .self-check ul { margin: 0; padding-left: 20px; }
.rules li { margin: 6px 0; }
.drop-hint { color: var(--muted); font-size: 14px; margin: 12px 0 0; }
.error { color: var(--bad); background: #fdecec; border-radius: 8px; padding: 10px 14px; margin: 16px 0 0; }
body.dragging main { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: 10px; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.actions.center { justify-content: center; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 10px 22px;
  border: 1px solid var(--ink); border-radius: 8px; background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: #eceef2; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
:is(.btn, .link, .brand, summary, input):focus-visible { outline: 3px solid #7fb8aa; outline-offset: 2px; }

.camera { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.viewfinder {
  position: relative; width: min(100%, 400px); aspect-ratio: 2 / 3; max-height: 68vh;
  overflow: hidden; border-radius: 10px; background: #10151f;
}
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewfinder video.mirror { transform: scaleX(-1); }
.oval {
  position: absolute; left: 50%; top: 42%; width: 52%; height: 50%; transform: translate(-50%, -50%);
  border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 999px rgba(16, 21, 31, .38);
}
.oval.good { border-color: #58d6a9; }
.countdown {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; font-size: 96px; font-weight: 700; text-shadow: 0 2px 12px rgba(0,0,0,.6);
}
.hint { min-height: 1.6em; margin: 0; font-weight: 600; text-align: center; }

.busy { display: flex; flex-direction: column; align-items: center; padding: 96px 0; text-align: center; }
.busy p { margin: 16px 0 0; font-weight: 600; }
.busy .sub { margin-top: 4px; color: var(--muted); font-weight: 400; font-size: 14px; }
.spinner {
  width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.result { display: grid; grid-template-columns: minmax(240px, 360px) 1fr; gap: 40px; align-items: start; padding-top: 12px; }
.photo-frame { background: #cfd5de; padding: 14px; border-radius: 10px; }
.photo-frame canvas { display: block; width: 100%; height: auto; background: #fff; }
.meta { color: var(--muted); font-size: 14px; margin: 10px 0 0; text-align: center; }
.panel h1 { font-size: 26px; }
.checks { list-style: none; margin: 0 0 18px; padding: 0; }
.checks li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.checks li:last-child { border-bottom: 0; }
.checks .icon { width: 20px; height: 20px; margin-top: 2px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--ok-bg); color: var(--accent); }
.checks li.warn .icon { background: var(--warn-bg); color: var(--warn); }
.checks li.warn { color: var(--warn); font-weight: 600; }
.adjust { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; }
.adjust summary { cursor: pointer; font-weight: 600; }
.adjust label { display: block; margin-top: 12px; font-size: 14px; }
.adjust output { float: right; color: var(--muted); }
.adjust input[type=range] { width: 100%; accent-color: var(--accent); min-height: 28px; }
.link { margin-top: 8px; padding: 6px 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: 14px; text-decoration: underline; cursor: pointer; }
.self-check { margin-bottom: 20px; font-size: 15px; }

@media (max-width: 760px) {
  .top { padding: 12px 16px; }
  .privacy { font-size: 13px; }
  main { padding: 8px 16px 36px; }
  .start, .result { grid-template-columns: 1fr; gap: 24px; padding-top: 12px; }
  .photo-col { max-width: 300px; width: 100%; margin: 0 auto; }
  .actions .btn { flex: 1 1 140px; }
}
