:root {
  --bg: #fff6f2;
  --bg-2: #ffe9e6;
  --paper: #fffdfb;
  --rose: #e05a7a;
  --rose-dark: #c03d5f;
  --rose-soft: #f9c9d4;
  --blush: #fde3e8;
  --ink: #5b2a3a;
  --ink-soft: #9a6b78;
  --gold: #e8b46a;
  --shadow: 0 10px 30px -12px rgba(160, 50, 80, .35);
  --shadow-lg: 0 24px 50px -18px rgba(160, 50, 80, .45);
  --radius: 18px;
  --script: "Caveat", "Segoe Script", cursive;
  --sans: "Nunito", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #ffd9e2 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #ffe7d6 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
}

/* плавающие сердечки на фоне */
.hearts-bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='%23f4a7b9' fill-opacity='.35'%3E%3Cpath d='M30 42c-4-8-16-6-16 3 0 7 9 12 16 18 7-6 16-11 16-18 0-9-12-11-16-3z'/%3E%3Cpath transform='translate(95 95) scale(.6)' d='M30 42c-4-8-16-6-16 3 0 7 9 12 16 18 7-6 16-11 16-18 0-9-12-11-16-3z'/%3E%3Cpath transform='translate(110 10) scale(.4)' d='M30 42c-4-8-16-6-16 3 0 7 9 12 16 18 7-6 16-11 16-18 0-9-12-11-16-3z'/%3E%3C/g%3E%3C/svg%3E");
  animation: drift 60s linear infinite;
}
@keyframes drift { to { background-position: 160px -320px; } }
@media (prefers-reduced-motion: reduce) { .hearts-bg { animation: none; } }

.container { max-width: 1180px; margin: 0 auto; padding: 0 16px 80px; }

/* ---------- шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px;
  background: rgba(255, 246, 242, .8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rose-soft);
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar form { margin: 0; }
.who { font-weight: 600; color: var(--ink-soft); }

.logo {
  font-family: var(--script); font-weight: 700; font-size: 2rem;
  color: var(--rose); text-decoration: none; line-height: 1;
}
.logo span { color: var(--gold); }
.logo-big { font-size: 4rem; margin: 0; }

/* ---------- заголовки ---------- */
.hero { text-align: center; padding: 40px 0 28px; }
.script-title {
  font-family: var(--script); font-weight: 700;
  font-size: clamp(2.6rem, 6vw, 4rem);
  color: var(--rose-dark); margin: 0; line-height: 1.05;
}
.script-title.sm { font-size: 2.4rem; margin-bottom: 8px; }
.hero-sub { color: var(--ink-soft); font-size: 1.1rem; margin: 8px auto 22px; max-width: 600px; }
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.back { display: inline-block; margin-top: 20px; color: var(--ink-soft); text-decoration: none; font-weight: 600; }
.back:hover { color: var(--rose); }

/* ---------- кнопки ---------- */
.btn {
  font: inherit; font-weight: 700; cursor: pointer;
  border: 0; border-radius: 999px;
  padding: 11px 22px;
  transition: transform .15s, box-shadow .15s, background .15s;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #f27a95, var(--rose-dark));
  box-shadow: 0 8px 20px -8px rgba(192, 61, 95, .7);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 12px 26px -8px rgba(192, 61, 95, .8); transform: translateY(-1px); }
.btn-ghost { background: var(--paper); color: var(--rose-dark); border: 1.5px solid var(--rose-soft); }
.btn-ghost:hover { background: var(--blush); }
.btn-danger { background: #fff; color: #b3261e; border: 1.5px solid #f2b8b5; }
.btn-danger:hover { background: #fdecea; }
.btn-sm { padding: 7px 14px; font-size: .9rem; }
.btn-block { width: 100%; }

/* ---------- формы ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .95rem; }
.form small { font-weight: 400; color: var(--ink-soft); }
input, textarea {
  font: inherit; color: var(--ink);
  border: 1.5px solid var(--rose-soft); border-radius: 12px;
  padding: 10px 14px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus { outline: none; border-color: var(--rose); box-shadow: 0 0 0 4px var(--blush); }
textarea { resize: vertical; }

/* ---------- вход ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--paper); border-radius: 28px; padding: 36px 28px;
  box-shadow: var(--shadow-lg); border: 1px solid #fde0e6;
}
.login-card .form { text-align: left; margin-top: 22px; }
.login-heart { font-size: 2.4rem; animation: beat 1.6s ease-in-out infinite; }
.login-sub { font-family: var(--script); font-size: 1.5rem; color: var(--ink-soft); margin: 4px 0 0; }
@keyframes beat { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.18); } 30% { transform: scale(1); } 45% { transform: scale(1.12); } }

/* ---------- сообщения ---------- */
.flashes { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 50; display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); }
.flash {
  background: var(--paper); border: 1px solid var(--rose-soft); border-left: 4px solid var(--rose);
  padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow);
  animation: fadeout 4.5s forwards;
}
@keyframes fadeout { 0%, 80% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

/* ---------- альбомы ---------- */
.album-grid {
  display: grid; gap: 34px 26px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  padding-top: 10px;
}
.album-tile {
  display: block; text-decoration: none; color: inherit;
  background: var(--paper); padding: 12px 12px 16px; border-radius: 6px;
  box-shadow: var(--shadow);
  transform: rotate(var(--tilt, 0deg));
  transition: transform .25s, box-shadow .25s;
  position: relative;
}
/* «скотч» сверху */
.album-tile::before {
  content: ""; position: absolute; top: -10px; left: 50%; width: 80px; height: 22px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(249, 201, 212, .75); border-radius: 2px;
}
.album-tile:hover { transform: rotate(0) translateY(-6px) scale(1.02); box-shadow: var(--shadow-lg); }
.album-cover { aspect-ratio: 1; overflow: hidden; border-radius: 3px; background: var(--blush); }
.album-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-empty { height: 100%; display: grid; place-items: center; font-size: 3.5rem; }
.album-meta { padding-top: 12px; text-align: center; }
.album-meta h2 { font-family: var(--script); font-size: 1.9rem; margin: 0; color: var(--rose-dark); line-height: 1.1; overflow-wrap: anywhere; }
.album-meta span { color: var(--ink-soft); font-size: .9rem; }

.empty-state { text-align: center; color: var(--ink-soft); padding: 40px 16px; max-width: 420px; margin: 0 auto; }
.empty-heart { font-size: 4rem; animation: beat 1.8s ease-in-out infinite; }

/* ---------- карточки ---------- */
/* карточки квадратные (1254×1254) — ровная сетка */
.card-grid {
  display: grid; gap: 28px 24px;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
}
.love-card {
  margin: 0; align-self: start;
  background: var(--paper); padding: 10px 10px 12px; border-radius: 8px;
  box-shadow: var(--shadow);
  transform: rotate(var(--tilt, 0deg));
  transition: transform .25s, box-shadow .25s;
}
.love-card:hover { transform: rotate(0) translateY(-4px); box-shadow: var(--shadow-lg); }
.love-card-img { all: unset; display: block; cursor: zoom-in; border-radius: 4px; overflow: hidden; }
.love-card-img:focus-visible { outline: 3px solid var(--rose); outline-offset: 2px; }
.love-card img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; display: block; background: var(--blush); }
.love-card figcaption { padding: 10px 4px 0; text-align: center; }
.love-card .cap { display: block; font-family: var(--script); font-size: 1.45rem; line-height: 1.15; overflow-wrap: anywhere; }
.love-card .cap b { color: var(--rose); }
.love-card time { display: block; font-size: .8rem; color: var(--ink-soft); margin-top: 4px; }

/* ---------- модальные окна ---------- */
.modal {
  border: 0; border-radius: 24px; padding: 26px;
  width: min(440px, calc(100% - 32px));
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow-lg);
}
.modal-wide { width: min(720px, calc(100% - 32px)); }
.modal::backdrop, .lightbox::backdrop { background: rgba(91, 42, 58, .45); backdrop-filter: blur(4px); }
.modal[open] { animation: pop .22s ease-out; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.danger-zone { border-top: 1px dashed var(--rose-soft); margin-top: 18px; padding-top: 14px; text-align: right; }

/* загрузка */
.dropzone {
  border: 2px dashed var(--rose-soft); border-radius: 18px;
  padding: 28px 16px; text-align: center; cursor: pointer;
  display: flex !important; align-items: center; gap: 6px !important;
  background: #fffafa; transition: background .15s, border-color .15s;
}
.dropzone.drag, .dropzone:hover { background: var(--blush); border-color: var(--rose); }
.dz-heart { font-size: 2rem; }
.upload-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-height: 45vh; overflow-y: auto; }
.upload-item {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 12px; align-items: center;
  background: #fff; border: 1px solid var(--rose-soft); border-radius: 14px; padding: 8px;
}
.upload-item img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }
.upload-fields { display: grid; grid-template-columns: 1fr 150px; gap: 8px; min-width: 0; }
.upload-fields input { padding: 8px 10px; min-width: 0; }
.upload-remove { all: unset; cursor: pointer; font-size: 1.4rem; color: var(--ink-soft); padding: 4px 8px; }
.upload-remove:hover { color: var(--rose); }
.upload-status { margin: 0; color: var(--ink-soft); min-height: 1.2em; }
@media (max-width: 560px) {
  .upload-fields { grid-template-columns: 1fr; }
  .upload-item { grid-template-columns: 56px 1fr auto; }
  .upload-item img { width: 56px; height: 56px; }
}

/* ---------- лайтбокс ---------- */
.lightbox {
  border: 0; padding: 0; background: transparent;
  width: 100%; max-width: 100%; height: 100%; max-height: 100%;
  overflow: hidden;
}
.lightbox[open] { display: grid; place-items: center; }
.lb-body {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  max-width: min(900px, calc(100% - 32px)); max-height: calc(100% - 32px);
  background: var(--paper); border-radius: 14px; padding: 14px; box-shadow: var(--shadow-lg);
  animation: pop .2s ease-out;
}
.lb-img { width: min(760px, 100%, 68vh); aspect-ratio: 1; object-fit: contain; background: var(--blush); border-radius: 6px; display: block; }
.lb-info { width: 100%; padding: 12px 4px 2px; text-align: center; }
.lb-caption { font-family: var(--script); font-size: 1.9rem; margin: 0; line-height: 1.15; overflow-wrap: anywhere; }
.lb-caption b { color: var(--rose); }
.lb-meta { color: var(--ink-soft); font-size: .9rem; margin: 4px 0 10px; }
.lb-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.lb-actions form { margin: 0; }
.lb-edit-form { text-align: left; max-width: 460px; margin: 0 auto; }
.lb-close, .lb-nav {
  position: fixed; z-index: 2; border: 0; cursor: pointer;
  background: rgba(255, 253, 251, .9); color: var(--rose-dark);
  width: 46px; height: 46px; border-radius: 50%; font-size: 1.8rem; line-height: 1;
  box-shadow: var(--shadow); display: grid; place-items: center;
}
.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-close:hover, .lb-nav:hover { background: #fff; }
@media (max-width: 640px) {
  .lb-nav { top: auto; bottom: 16px; transform: none; }
  .lb-img { width: min(100%, 58vh); }
  .topbar { padding: 10px 16px; }
  .who { display: none; }
}

/* ---------- титульное изображение ---------- */
.album-title-img {
  width: 170px; margin: 0 auto 18px; padding: 8px 8px 22px;
  background: var(--paper); border-radius: 6px; box-shadow: var(--shadow);
  transform: rotate(-2deg);
}
.album-title-img img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; border-radius: 3px; }

.cover-picker { border: 1.5px solid var(--rose-soft); border-radius: 16px; padding: 12px 14px 14px; margin: 0; }
.cover-picker legend { font-weight: 600; padding: 0 6px; }
.cover-options {
  display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  max-height: 240px; overflow-y: auto; padding: 4px;
}
.form .cover-opt { position: relative; cursor: pointer; display: block; }
.cover-opt input { position: absolute; opacity: 0; pointer-events: none; }
.cover-opt img, .cover-opt-auto span {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: grid; place-items: center; text-align: center;
  border-radius: 10px; border: 3px solid transparent; background: var(--blush);
  transition: border-color .15s, transform .15s; font-size: .85rem; line-height: 1.2;
}
.cover-opt:hover img, .cover-opt:hover span { transform: scale(1.04); }
.cover-opt input:checked + img, .cover-opt input:checked + span { border-color: var(--rose); box-shadow: 0 0 0 3px var(--blush); }
.cover-opt input:focus-visible + img, .cover-opt input:focus-visible + span { outline: 2px solid var(--rose-dark); outline-offset: 2px; }
.form .cover-upload { margin-top: 12px; font-weight: 400; }
