/* ================= Background page ================= */
.bg-page {
  max-width: 1000px;
  margin: 0 auto 60px;
}

/* ===== Preview (16:9 iframe) ===== */
.bg-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 24px 0 32px;
  border-radius: 14px;
  overflow: hidden;
  background: #ede9e0;
  border: 1px solid var(--border);
  box-shadow: 0 10px 40px rgba(168, 155, 200, 0.2);
}

.bg-preview iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.preview-fullscreen {
  position: absolute;
  bottom: 12px;
  right: 12px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted-strong);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.2s;
}

.preview-fullscreen:hover {
  background: rgba(255, 255, 255, 1);
  color: var(--accent);
  text-decoration: none;
}

/* ===== Header ===== */
.bg-header {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.bg-header-text {
  flex: 1;
  min-width: 240px;
}

.bg-header-text h1 {
  font-size: clamp(24px, 3vw, 34px);
  margin-bottom: 10px;
}

.bg-description {
  font-size: 15px;
  color: var(--muted-strong);
  line-height: 1.6;
}

.bg-header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-download {
  padding: 12px 28px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #b8a9d9, #8fc9b8);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 6px 24px rgba(168, 155, 200, 0.3);
}

.btn-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(168, 155, 200, 0.45);
}

.bg-size {
  font-size: 13px;
  color: var(--muted);
}

/* ===== Meta (dl) ===== */
.bg-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 24px 40px;
  padding: 18px 22px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 32px;
}

.bg-meta div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bg-meta dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 500;
}

.bg-meta dd {
  font-size: 14px;
  color: var(--fg);
  font-weight: 500;
}

.bg-meta code {
  background: #ede9e0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-family: monospace;
}

/* ===== Tags ===== */
.bg-tags {
  margin-bottom: 24px;
}

.tags-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 10px;
}

.tag-group {
  margin-bottom: 12px;
}

.tag-group-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-strong);
  margin-right: 8px;
}

.tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(168, 155, 200, 0.1);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-strong);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.tag:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  text-decoration: none;
}

/* ===== Related ===== */
.related {
  margin-top: 60px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

.related h2 {
  font-size: clamp(20px, 2.6vw, 26px);
  margin-bottom: 24px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(58, 53, 72, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 480px;
  padding: 40px 36px 36px;
  border-radius: 20px;
  background: rgba(250, 248, 243, 0.98);
  border: 1px solid var(--border);
  box-shadow:
    0 24px 80px rgba(58, 53, 72, 0.28),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.25s ease;
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin: 0 0 12px;
  text-align: center;
  color: var(--fg);
}

.modal p {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  margin: 0 0 28px;
  line-height: 1.6;
}

.modal p strong {
  color: var(--fg);
  font-weight: 600;
}

.modal form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal input[type="email"] {
  width: 100%;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--fg);
  font-family: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.modal input[type="email"]:focus {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(168, 155, 200, 0.15);
}

.modal input[type="email"]::placeholder {
  color: #b0aab8;
}

.modal button[type="submit"] {
  padding: 16px 24px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #b8a9d9, #8fc9b8);
  color: #ffffff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s, box-shadow 0.2s;
  box-shadow: 0 6px 24px rgba(168, 155, 200, 0.3);
  margin-top: 4px;
}

.modal button[type="submit"]:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 32px rgba(168, 155, 200, 0.4);
}

.modal button[type="submit"]:active:not(:disabled) {
  transform: translateY(0);
}

.modal button[type="submit"]:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.modal .btn {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 8px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(168, 155, 200, 0.12);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
  background: rgba(168, 155, 200, 0.25);
  color: var(--fg);
}

.modal .status {
  font-size: 13.5px;
  color: #6aab96;
  text-align: center;
  margin-top: 16px;
  min-height: 20px;
  line-height: 1.5;
  padding: 0 4px;
}

/* ===== Успешный экран (check email) ===== */
#download-step-success {
  text-align: center;
}

#download-step-success p {
  margin-bottom: 12px;
}

#download-step-success p:first-of-type {
  margin-bottom: 20px;
  font-size: 15px;
}

#download-step-success strong {
  color: var(--accent);
  font-weight: 600;
  word-break: break-all;
}

/* ===== Mobile ===== */
@media (max-width: 480px) {
  .modal {
    padding: 32px 24px 28px;
    border-radius: 16px;
  }
  .modal h2 { font-size: 19px; }
  .modal input[type="email"],
  .modal button[type="submit"] {
    padding: 14px 16px;
    font-size: 14px;
  }
  .modal-close {
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
  }
}

/* ===== Mobile ===== */
@media (max-width: 640px) {
  .bg-preview { aspect-ratio: 4 / 3; }
  .bg-header { flex-direction: column; }
  .bg-meta { gap: 16px 24px; padding: 14px 16px; }
}