:root {
  --bg: #0c0c0f;
  --paper: #16161b;
  --line: #2a2a32;
  --text: #ecebe6;
  --muted: #9a998f;
  --accent: #ff5a36;
  --accent-deep: #c63d1f;
  --ok: #4ade80;
  --field: #101014;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --mx: 50vw;
  --my: 30vh;
  color-scheme: dark;
}

/* регистрируем координаты фонарика, чтобы их можно было плавно анимировать */
@property --mx { syntax: "<length>"; inherits: true; initial-value: 0px; }
@property --my { syntax: "<length>"; inherits: true; initial-value: 0px; }

@property --angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  padding: 32px 16px 48px;
  overflow-x: hidden;
}

/* ---------- фон: фонарик над засекреченным досье ---------- */
.bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.bg::before {
  /* сам луч фонарика */
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(420px circle at var(--mx) var(--my), #ff5a3614, transparent 70%);
}
.dossier {
  /* строки «текста», закрытые чёрными плашками; видны только в круге света */
  position: absolute;
  inset: -40px;
  background:
    repeating-linear-gradient(90deg, transparent 0 9%, var(--bg) 9% 10.5%, transparent 10.5% 23%, var(--bg) 23% 24%, transparent 24% 37%),
    repeating-linear-gradient(180deg, transparent 0 20px, #ffffff12 20px 30px);
  transform: rotate(-4deg);
  -webkit-mask-image: radial-gradient(300px circle at var(--mx) var(--my), #000 0%, transparent 75%);
  mask-image: radial-gradient(300px circle at var(--mx) var(--my), #000 0%, transparent 75%);
}
.grain {
  position: absolute;
  inset: -100%;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.8s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); }
  75% { transform: translate(-1%, -2%); }
}
/* на телефоне курсора нет — фонарик бродит сам */
@media (hover: none) {
  .bg::before, .dossier { animation: wander 14s ease-in-out infinite alternate; }
}
@keyframes wander {
  0% { --mx: 20vw; --my: 18vh; }
  50% { --mx: 80vw; --my: 45vh; }
  100% { --mx: 35vw; --my: 85vh; }
}

/* ---------- карточка ---------- */
.sheet {
  max-width: 560px;
  margin: 0 auto;
  background: linear-gradient(180deg, #1a1a20, var(--paper));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px 28px 28px;
  position: relative;
  box-shadow: 0 30px 80px -20px #000c, 0 0 0 1px #ffffff05 inset;
  animation: rise 0.7s var(--ease-out) both;
}
/* светящийся контур, который бежит по рамке */
.sheet::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(from var(--angle), transparent 0 62%, #ff5a3500 66%, var(--accent) 80%, #ffd0c4 84%, transparent 92%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: orbit 7s linear infinite;
  pointer-events: none;
}
@keyframes orbit { to { --angle: 360deg; } }
@keyframes rise {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.sheet.thud { animation: thud 0.35s ease-out; }
@keyframes thud {
  30% { transform: translateY(3px) rotate(-0.3deg); }
  60% { transform: translateY(-1px) rotate(0.15deg); }
}

/* ---------- переключатель языков ---------- */
.langs {
  position: relative;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: 22px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 999px;
  animation: fade 0.6s 0.15s both;
}
.langs button {
  position: relative;
  z-index: 1;
  border: 0;
  background: none;
  color: var(--muted);
  font: 700 12px/1 var(--mono);
  letter-spacing: 0.06em;
  padding: 7px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s;
}
.langs button:hover { color: var(--text); }
.langs button[aria-pressed="true"] { color: #140a07; }
.langs .pill {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 18px #ff5a3666;
  transition: transform 0.45s var(--ease-out), width 0.45s var(--ease-out);
}

/* ---------- шапка ---------- */
.head { position: relative; margin-bottom: 28px; }

h1, h2 {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
h1 {
  font-size: clamp(30px, 8vw, 42px);
  background: linear-gradient(90deg, var(--text) 0 40%, #fff 50%, var(--text) 60%) 0 0 / 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: sheen 6s 1.6s ease-in-out infinite;
}
@keyframes sheen {
  0% { background-position: 100% 0; }
  30%, 100% { background-position: 0 0; }
}
h1.scrambling { color: var(--accent); background: none; -webkit-background-clip: border-box; animation: none; }
h2 { font-size: 30px; }

.lead { margin: 0; color: var(--muted); max-width: 40ch; }

.stamp {
  position: absolute;
  top: -48px;
  right: -6px;
  font: 700 13px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  border: 2px solid currentColor;
  border-radius: 6px;
  padding: 6px 10px;
  transform: rotate(8deg);
  opacity: 0.9;
  mix-blend-mode: screen;
  animation: slam 0.55s 0.55s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
@keyframes slam {
  0% { opacity: 0; transform: rotate(-14deg) scale(2.8); filter: blur(4px); }
  60% { opacity: 1; transform: rotate(10deg) scale(0.9); filter: none; }
  100% { opacity: 0.9; transform: rotate(8deg) scale(1); }
}
.stamp--ok {
  color: var(--ok);
  position: static;
  display: inline-block;
  margin-bottom: 20px;
  font-size: 16px;
  padding: 8px 14px;
  transform: rotate(-4deg);
  animation: slam-ok 0.6s 0.1s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}
@keyframes slam-ok {
  0% { opacity: 0; transform: rotate(-20deg) scale(3); filter: blur(4px); }
  60% { opacity: 1; transform: rotate(-2deg) scale(0.9); filter: none; }
  100% { opacity: 0.95; transform: rotate(-4deg) scale(1); }
}

/* ---------- поля ---------- */
.field {
  display: block;
  margin-bottom: 20px;
  position: relative;
  animation: rise 0.6s calc(0.25s + var(--i, 0) * 0.08s) var(--ease-out) both;
}

.label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font: 600 13px/1.2 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  transition: color 0.2s;
}
.field:focus-within .label { color: var(--accent); }
.label i { color: var(--accent); font-style: normal; }
.label small { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; white-space: nowrap; }

input[type="text"], textarea {
  width: 100%;
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
textarea { resize: vertical; min-height: 120px; }
input::placeholder, textarea::placeholder { color: #66655e; }
input:focus, textarea:focus, .drop:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: #131217;
  box-shadow: 0 0 0 4px #ff5a3622, 0 0 24px -6px #ff5a3655;
}
.invalid { border-color: var(--accent) !important; animation: shake 0.4s; }
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ---------- фото ---------- */
.drop {
  display: grid;
  justify-items: center;
  gap: 4px;
  text-align: center;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 20px 16px;
  cursor: pointer;
  background: var(--field);
  transition: border-color 0.2s, background-color 0.2s, transform 0.2s var(--ease-out);
}
.drop:hover, .drop.over { border-color: var(--accent); background: #1a1214; }
.drop.over { transform: scale(1.015); }
.drop-icon {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linejoin: round;
  margin-bottom: 4px;
  transition: transform 0.3s var(--ease-out);
}
.drop:hover .drop-icon, .drop.over .drop-icon { transform: translateY(-3px) rotate(-6deg); }
.drop strong { font-weight: 600; }
.drop span { color: var(--muted); font-size: 13px; }
.drop .desk { color: inherit; font-size: inherit; font-weight: 400; }
@media (pointer: coarse) { .drop .desk { display: none; } }
.drop.full { opacity: 0.5; cursor: default; }
kbd {
  font: 12px var(--mono);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
}

.thumbs {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}
.thumbs:empty { display: none; }
.thumbs li {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--field);
  border: 1px solid var(--line);
  animation: pop 0.4s var(--ease-out) both;
}
.thumbs li.leaving { animation: unpop 0.25s ease-in both; }
@keyframes pop { from { opacity: 0; transform: scale(0.6) rotate(-6deg); } }
@keyframes unpop { to { opacity: 0; transform: scale(0.6) rotate(6deg); } }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* луч сканера, пока фото чистится от метаданных */
.thumbs li.busy::after, .thumbs li.cleaned::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(180deg, transparent, #ff5a3655 85%, var(--accent) 100%);
  animation: scan 0.9s ease-in-out infinite;
}
.thumbs li.cleaned::after { animation: scan 0.9s ease-in-out 1 forwards; }
@keyframes scan {
  from { top: -40%; }
  to { top: 100%; }
}
.badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  font: 700 9px/1 var(--mono);
  letter-spacing: 0.04em;
  background: #000000c0;
  color: var(--ok);
  padding: 3px 5px;
  border-radius: 4px;
  animation: badge 2.2s 0.5s both;
}
@keyframes badge {
  0% { opacity: 0; transform: translateY(4px); }
  15%, 75% { opacity: 1; transform: none; }
  100% { opacity: 0; }
}
.thumbs button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 0;
  background: #000000b3;
  color: #fff;
  font-size: 15px;
  line-height: 24px;
  padding: 0;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s;
}
.thumbs button:hover { background: var(--accent); transform: rotate(90deg); }

.trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

.error {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #ff5a361a;
  border: 1px solid #ff5a3633;
  color: #ffb4a3;
  font-size: 14px;
  animation: fade 0.3s both;
}
@keyframes fade { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- кнопки ---------- */
button[type="submit"], .ghost {
  position: relative;
  overflow: hidden;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 16px 18px;
  font: 700 16px/1 var(--mono);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.25s;
}
button[type="submit"] {
  --p: 0%;
  color: #140a07;
  background: linear-gradient(90deg, #ffa58c var(--p), var(--accent) var(--p));
  box-shadow: 0 10px 30px -10px #ff5a36aa;
}
button[type="submit"]:hover { box-shadow: 0 14px 38px -10px #ff5a36dd; transform: translateY(-1px); }
button[type="submit"]:active { transform: translateY(1px) scale(0.99); }
/* блик, пробегающий по кнопке */
button[type="submit"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, #ffffff66 50%, transparent 65%);
  transform: translateX(-100%);
  animation: shine 4s 2s ease-in-out infinite;
}
@keyframes shine {
  0% { transform: translateX(-100%); }
  25%, 100% { transform: translateX(100%); }
}
button[type="submit"] span { position: relative; z-index: 1; }
button:disabled { cursor: progress; }
button:disabled::after { animation: none; }
.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.ghost:hover { border-color: var(--accent); }

.fine { margin: 14px 0 0; color: var(--muted); font-size: 13px; text-align: center; animation: fade 0.6s 0.8s both; }

/* ---------- смена языка: текст мягко перетекает ---------- */
.swap [data-i18n], .swap [data-i18n-ph] { animation: swap 0.35s var(--ease-out); }
@keyframes swap { from { opacity: 0; filter: blur(3px); } }

/* ---------- отправлено: поля закрашиваются, как в рассекреченном деле ---------- */
.redacting .field::after, .redacting .lead::after {
  content: "";
  position: absolute;
  left: -4px;
  right: -4px;
  top: 22px;
  bottom: -4px;
  background: #050506;
  border-radius: 4px;
  transform-origin: left;
  animation: redact 0.35s calc(var(--i, 0) * 0.09s) cubic-bezier(0.7, 0, 0.3, 1) both;
  z-index: 2;
}
.redacting .lead { position: relative; }
.redacting .lead::after { top: 0; }
.redacting .field:has(button)::after { top: -4px; }
.redacting .fine { opacity: 0; transition: opacity 0.3s; }
@keyframes redact { from { transform: scaleX(0); } }

.done { text-align: center; padding: 8px 0 4px; }
.done h2, .done p, .done .ghost { animation: rise 0.6s var(--ease-out) both; }
.done p { color: var(--muted); margin: 0 0 24px; animation-delay: 0.45s; }
.done .ghost { animation-delay: 0.6s; }
.done b { color: var(--text); font-family: var(--mono); }

@media (max-width: 480px) {
  body { padding: 16px 12px 32px; }
  .sheet { padding: 18px 18px 20px; border-radius: 14px; }
  .stamp { font-size: 11px; padding: 5px 8px; top: -44px; right: -4px; }
  .langs button { padding: 7px 8px; }
}

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