* { box-sizing: border-box; }

/* Атрибут hidden должен побеждать: у .prompt-field, .video-downloads и .download
   задан свой display, который иначе перекрывает браузерное [hidden]{display:none}
   — и скрытые элементы продолжали показываться. */
[hidden] { display: none !important; }

:root {
  --bg-1: #eef2ff;
  --bg-2: #fdf4ff;
  --card: #ffffff;
  --text: #1c1c26;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #7c3aed;
  --accent-2: #4f46e5;
  --accent-soft: #ede9fe;
  --success: #16a34a;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --error-text: #b91c1c;
  --shadow: 0 10px 40px rgba(76, 29, 149, 0.10);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-1: #14101f;
    --bg-2: #1a1424;
    --card: #201a2e;
    --text: #ede9fe;
    --muted: #a5a3b8;
    --border: #362d49;
    --accent: #a78bfa;
    --accent-2: #818cf8;
    --accent-soft: #2e2545;
    --success: #4ade80;
    --error-bg: #2a1616;
    --error-border: #5c2323;
    --error-text: #fca5a5;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  }
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 15% -10%, var(--bg-2), transparent 55%),
              radial-gradient(circle at 85% 0%, var(--bg-1), transparent 45%),
              var(--bg-1);
  background-attachment: fixed;
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0 1.5rem;
}

.brand {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-mark { margin-right: 0.25rem; }

.logout, .nav-link {
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
}
.logout:hover, .nav-link:hover { color: var(--text); }

.hero {
  text-align: center;
  padding: 1.5rem 0 2rem;
}
.hero h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .hint {
  color: var(--muted);
  max-width: 34rem;
  margin: 0 auto;
  line-height: 1.5;
}

.error {
  color: var(--error-text);
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  font-size: 0.9rem;
  max-width: 40rem;
  margin: 0 auto 1rem;
}

.upload-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border: 1px solid var(--border);
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-align: center;
  padding: 2.5rem 1.5rem;
  border: 2px dashed var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }

.dropzone-icon { font-size: 2rem; }
.dropzone-text { color: var(--muted); font-size: 0.95rem; }
.dropzone-text strong { color: var(--text); }

.dropzone-files {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin-top: 0.25rem;
}

.file-chip {
  background: var(--accent-soft);
  color: var(--accent-2);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-chip-error { background: var(--error-bg); color: var(--error-text); }

.prompt-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.prompt-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.prompt-optional {
  font-weight: 400;
  color: var(--muted);
}
.prompt-field input[type="text"] {
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}
.prompt-field input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

/* История обработок: по одной секции на день. */
.photo-day { margin-bottom: 2rem; }
.day-label {
  font-size: 1rem;
  font-weight: 600;
  text-transform: capitalize;
}
/* Исходник мог быть удалён — тогда в плитке только результат. */
.compare-single { grid-template-columns: 1fr; }
.center { text-align: center; }

/* Выбор модели обработки: дороже — аккуратнее к лицам и деталям. */
.model-choice {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.model-option {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "radio name price" ". hint hint";
  align-items: center;
  gap: 0.15rem 0.6rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.model-option:hover { border-color: var(--accent); }
.model-option.is-active {
  border-color: var(--accent);
  background: rgba(124, 58, 237, 0.08);
}
.model-option input { grid-area: radio; accent-color: var(--accent); }
.model-name { grid-area: name; font-size: 0.92rem; font-weight: 600; }
.model-price { grid-area: price; font-size: 0.92rem; font-weight: 600; }
.model-hint { grid-area: hint; font-size: 0.78rem; color: var(--muted); }

/* Админка: карточка цены на каждую модель. */
.model-price-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}
.model-price-card {
  padding: 0.9rem 0;
  border-top: 1px solid var(--border);
}

button, .download, .new-photo {
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

#submit-btn {
  align-self: center;
  padding: 0.7rem 2rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.35);
  transition: transform 0.1s ease, opacity 0.15s ease;
}
#submit-btn:hover:not(:disabled) { transform: translateY(-1px); }
#submit-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.progress-hint {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.results { margin-top: 2.5rem; }

.results-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  padding: 0 0.25rem;
}
.total-cost { font-weight: 600; color: var(--text); margin-right: auto; }

.download-zip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: var(--accent-2);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}
.download-zip:hover { filter: brightness(1.08); }
.download-zip::before { content: "🗂"; }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.compare-pane {
  position: relative;
  display: block;
  cursor: zoom-in;
  color: inherit;
  text-decoration: none;
}
.compare-pane img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}
/* Значок «открыть целиком»: в плитке фото обрезано по квадрату. */
.zoom-hint {
  position: absolute;
  right: 0.4rem;
  bottom: 0.4rem;
  width: 1.7rem;
  height: 1.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 0.85rem;
  backdrop-filter: blur(2px);
  opacity: 0.85;
  transition: opacity 0.15s, transform 0.15s;
}
.compare-pane:hover .zoom-hint { opacity: 1; transform: scale(1.08); }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  background: rgba(8, 8, 14, 0.92);
  cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 100%;
  max-height: calc(100vh - 6rem);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}
.lightbox-caption {
  margin: 0;
  color: #d7d7e2;
  font-size: 0.85rem;
}
.lightbox-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.22); }
body.no-scroll { overflow: hidden; }
.tag {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  backdrop-filter: blur(2px);
}
.tag-after { background: var(--accent); }

.result-footer {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0.9rem;
}
.filename {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cost { font-size: 0.8rem; font-weight: 600; color: var(--text); }

.download {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: var(--success);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.8rem;
  white-space: nowrap;
}
.download:hover { filter: brightness(1.08); }

.result-error { padding: 1rem; }
.error-body .filename { display: block; margin-bottom: 0.4rem; }
.error-body .error { margin: 0; max-width: none; }

.new-photo {
  display: inline-block;
  margin-top: 1.5rem;
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}
.new-photo:hover { filter: brightness(0.97); }

@media (max-width: 480px) {
  .compare-pane img { aspect-ratio: 4 / 5; }
}

/* --- Баланс / цена в шапке --- */
.top-right { display: flex; align-items: center; gap: 0.9rem; }
.balance {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  background: var(--accent-soft);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
}
.top-right { gap: 0.6rem; }
.topup-btn {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 0.32rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
}
.topup-btn:hover { filter: brightness(1.05); }
.price-hint { color: var(--muted); font-size: 0.9rem; margin: 0.5rem 0 0; }
.price-hint strong { color: var(--text); }

/* --- Переключатель режима: реставрация / сразу в видео --- */
.mode-switch {
  display: flex;
  gap: 0.3rem;
  padding: 0.25rem;
  background: var(--accent-soft);
  border-radius: 999px;
  align-self: stretch;
}
.mode-btn {
  flex: 1;
  padding: 0.5rem 0.8rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.is-active {
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
}
.mode-note {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0;
}

/* --- Блок оживления фото (image-to-video) --- */
.animate-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.1rem 1.3rem;
  margin: 1.2rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.animate-head { display: flex; gap: 0.9rem; align-items: flex-start; }
.animate-icon { font-size: 1.6rem; line-height: 1; }
.animate-hint { color: var(--muted); font-size: 0.87rem; line-height: 1.5; margin: 0.25rem 0 0; }
.animate-card button {
  align-self: flex-start;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
}
.animate-card button:disabled { opacity: 0.55; cursor: not-allowed; }
.animate-status { color: var(--muted); font-size: 0.88rem; margin: 0; min-height: 1.2em; }
.animate-status.animate-error { color: var(--error-text); }
.animate-video {
  width: 100%;
  border-radius: 12px;
  background: #000;
  display: block;
}
.sound-select {
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  width: 100%;
  cursor: pointer;
}
.sound-select:focus { outline: none; border-color: var(--accent); }
.video-downloads { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.download-slow { opacity: 0.85; }

/* --- Экраны входа (login / verify / admin login) --- */
.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  min-height: 100vh;
  padding-top: 0;
}
.auth-card { width: 100%; max-width: 340px; text-align: center; }
.auth-brand { justify-content: center; display: flex; }
.auth-hint { color: var(--muted); font-size: 0.9rem; margin: 0; line-height: 1.4; }
.auth-hint strong { color: var(--text); }
.auth-input {
  padding: 0.7rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
}
.auth-input:focus { outline: none; border-color: var(--accent); }
.auth-code {
  text-align: center;
  letter-spacing: 0.5em;
  font-size: 1.3rem;
  font-weight: 600;
}
.auth-submit { display: block; width: 100%; align-self: stretch; }
.auth-resend { margin: 0; }
.notice {
  color: var(--success);
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  font-size: 0.88rem;
  margin: 0 auto;
  max-width: 40rem;
}
.linklike {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
  padding: 0;
}
.linklike:hover { color: var(--text); }

/* --- Админ-панель --- */
.admin-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
}
.admin-card h2 { margin: 0 0 0.9rem; font-size: 1.05rem; }
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
}
.stat-label { font-size: 0.78rem; color: var(--muted); }
.stat-value { font-size: 1rem; font-weight: 700; color: var(--text); }
.admin-hint { color: var(--muted); font-size: 0.88rem; line-height: 1.5; margin: 0.4rem 0 0.8rem; }
.admin-hint strong { color: var(--text); }
.admin-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}
.admin-form input[type="text"],
.admin-form input[type="email"] {
  flex: 1;
  min-width: 8rem;
  padding: 0.6rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}
.admin-form input:focus { outline: none; border-color: var(--accent); }
.admin-form input[type="file"] { flex: 1; min-width: 12rem; font-size: 0.85rem; color: var(--muted); }
.admin-unit { color: var(--muted); font-size: 0.85rem; }
.admin-form button {
  padding: 0.55rem 1.2rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
}
.admin-form button:disabled { opacity: 0.5; cursor: not-allowed; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.admin-table th, .admin-table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.admin-table th { color: var(--muted); font-weight: 600; }
.muted-cell { color: var(--muted); font-size: 0.8rem; }
.calib-result { margin-top: 1rem; }
.calib-list { list-style: none; padding: 0; margin: 0 0 0.5rem; }
.calib-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.error-text { color: var(--error-text); font-size: 0.85rem; }
