:root {
  --bg: #0d0e10;
  --panel: #16181b;
  --panel-2: #1e2125;
  --line: #26292e;
  --text: #f3f2ef;
  --muted: #9b9ea5;
  --accent: #e23a44;
  --accent-ink: #fff;
  --radius: 14px;
  --row: 240px;
  --gap: 6px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Шапка */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px max(18px, env(safe-area-inset-left));
  background: rgba(13, 14, 16, .82);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.site { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .04em; white-space: nowrap; }
.site img { height: 34px; width: auto; display: block; }
.cart-link {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); font-size: 14px; font-weight: 600;
  transition: border-color .2s, background .2s;
}
.cart-link:hover { border-color: #3a3e45; background: var(--panel); }
.cart-link b {
  min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--accent-ink);
  font-size: 12px; line-height: 20px; text-align: center;
}

main { width: 100%; max-width: 1560px; margin: 0 auto; padding: 22px 18px 90px; flex: 1; }

/* Главная */
.hero {
  text-align: center; padding: 34px 16px 40px; margin: -22px -18px 26px;
  background:
    radial-gradient(60% 90% at 50% 0%, rgba(226, 58, 68, .20), transparent 70%),
    linear-gradient(#131518, var(--bg));
  border-bottom: 1px solid var(--line);
}
.hero img { height: clamp(150px, 26vw, 230px); width: auto; filter: drop-shadow(0 12px 30px rgba(0, 0, 0, .5)); }
.hero p { margin: 18px auto 0; max-width: 520px; color: var(--muted); font-size: clamp(15px, 2.2vw, 18px); }

/* Поиск */
.search { margin: 0 0 22px; }
.search input {
  width: 100%; max-width: 560px; display: block; margin: 0 auto; padding: 14px 20px 14px 48px;
  border-radius: 999px; border: 1px solid #34383e; color: var(--text); font: inherit; font-size: 16px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%239b9ea5' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='9' cy='9' r='6'/%3E%3Cpath d='m14 14 4 4'/%3E%3C/svg%3E") no-repeat 18px center;
  transition: border-color .2s;
}
.search input:focus { outline: 0; border-color: var(--accent); }
.search input::-webkit-search-cancel-button { filter: invert(.7); }
.folder.no-cover { background: linear-gradient(160deg, #23262b, #15171a); }
.folder.no-cover::after { background: linear-gradient(to top, rgba(0, 0, 0, .55), transparent 60%); }
.folder.no-cover .cover {
  background: url("/static/mark.png") no-repeat center 38% / 38%; opacity: .5;
}

/* Альбом по коду */
.lock {
  max-width: 460px; margin: 30px auto; padding: 22px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.lock h2 { margin: 0 0 8px; }
.lock p { color: var(--muted); margin: 0 0 16px; }
.lock-row { display: flex; gap: 10px; }
.lock-row input {
  flex: 1; min-width: 0; padding: 12px 16px; border-radius: 999px; border: 1px solid #34383e;
  background: var(--bg); color: var(--text); font: inherit; font-size: 20px; letter-spacing: .2em; text-align: center;
}
.lock-row input:focus { outline: 0; border-color: var(--accent); }

/* Заголовок раздела */
.crumbs { display: flex; flex-wrap: wrap; gap: 4px 0; color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.crumbs:empty { display: none; }
.crumbs a { transition: color .15s; }
.crumbs a:hover { color: var(--text); }
.crumbs span { margin: 0 8px; opacity: .45; }
h1 { margin: 0; font-size: clamp(24px, 4.4vw, 38px); line-height: 1.15; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
h2 { font-size: 20px; margin: 30px 0 10px; }
.meta { margin: 8px 0 22px; color: var(--muted); font-size: 15px; }
.meta:empty { margin: 0 0 22px; }
.state { color: var(--muted); text-align: center; padding: 40px 0; }
.state:empty { display: none; }

/* Карточки разделов и альбомов */
.folders {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  margin-bottom: 28px;
}
.folders:empty { display: none; }
.folder {
  position: relative; display: block; aspect-ratio: 4 / 5; overflow: hidden;
  border-radius: var(--radius); background: var(--panel);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset;
  transition: transform .25s ease, box-shadow .25s ease;
}
.folder .cover { position: absolute; inset: 0; }
.folder img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s ease; }
.folder::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, .86) 0%, rgba(0, 0, 0, .35) 38%, transparent 62%);
}
.folder .info { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; padding: 16px; }
.folder .name { font-weight: 650; font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; text-shadow: 0 1px 8px rgba(0, 0, 0, .6); }
.folder .sub { color: rgba(255, 255, 255, .75); font-size: 13px; margin-top: 4px; }
@media (hover: hover) {
  .folder:hover { transform: translateY(-3px); box-shadow: 0 18px 40px rgba(0, 0, 0, .45); }
  .folder:hover img { transform: scale(1.05); }
}

/* Полоса покупки над сеткой */
.buybar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 16px; padding: 12px 14px 12px 18px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 15px;
}

/* Сетка фотографий: ряды одинаковой высоты, кадры не обрезаются */
.photos { display: flex; flex-wrap: wrap; gap: var(--gap); }
.photos::after { content: ""; flex: 100000 1 0; }
.photo {
  position: relative; overflow: hidden; border-radius: 4px; background: var(--panel-2); cursor: zoom-in;
  flex: calc(var(--r) * 100) 1 calc(var(--r) * var(--row));
  aspect-ratio: var(--r);
}
.photo img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity .35s ease, transform .5s ease;
}
.photo img.loaded { opacity: 1; }
.photo .add {
  position: absolute; right: 8px; bottom: 8px; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .25); background: rgba(13, 14, 16, .55); color: #fff;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font-size: 22px; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0;
  transition: background .2s, transform .2s, opacity .2s;
}
.photo .add.on { background: var(--accent); border-color: var(--accent); font-size: 17px; }
.photo.in-cart { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (hover: hover) {
  .photo:hover img { transform: scale(1.03); }
  .photo .add:not(.on) { opacity: 0; }
  .photo:hover .add, .photo .add:focus-visible { opacity: 1; }
  .photo .add:hover { transform: scale(1.08); }
}

/* Кнопки */
.btn {
  display: inline-block; border: 0; border-radius: 999px; padding: 12px 22px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-weight: 650; text-align: center;
  transition: filter .2s, transform .1s, background .2s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(.98); }
.btn.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px #3a3e45; }
.btn:disabled { opacity: .5; cursor: default; }

/* Плавающая панель корзины */
.cartbar {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 6; display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 20px;
  border-radius: 999px; background: rgba(30, 33, 37, .92); border: 1px solid #3a3e45;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .55); white-space: nowrap; font-size: 15px;
}
.cartbar .btn { padding: 10px 18px; }

/* Просмотр */
.lightbox {
  position: fixed; inset: 0; z-index: 20; background: rgba(5, 5, 6, .96);
  display: flex; align-items: center; justify-content: center;
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }
.lightbox img {
  max-width: 100vw; max-height: 100vh; max-height: 100dvh; object-fit: contain;
  -webkit-touch-callout: none;
}
.lb-btn {
  position: absolute; z-index: 2; border: 0; color: #fff; background: rgba(255, 255, 255, .1);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  width: 48px; height: 48px; border-radius: 50%; font-size: 28px; line-height: 1; cursor: pointer;
  display: grid; place-items: center; padding: 0; transition: background .2s;
}
.lb-btn:hover { background: rgba(255, 255, 255, .22); }
.lb-close { top: max(14px, env(safe-area-inset-top)); right: 14px; }
.lb-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 14px; top: 50%; transform: translateY(-50%); }
.lb-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 16px max(16px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, .7), transparent);
}
.lb-bottom .btn { pointer-events: auto; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }
.lb-caption { color: #d4d6da; font-size: 13px; letter-spacing: .02em; }

.foot { padding: 22px 18px 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; text-align: center; }
.foot:empty { display: none; }
.foot a { text-decoration: underline; }
.info h2 { margin-top: 28px; }
.info p, .info li { color: #d6d7da; }
.info ul { padding-left: 20px; }
.info .card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 20px 12px; margin-top: 14px; }

/* Корзина и заказ */
.narrow { max-width: 760px; }
.narrow h1 { margin-bottom: 18px; }
.items { list-style: none; padding: 0 16px; margin: 0 0 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.items:empty { display: none; }
.items li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.items li:last-child { border-bottom: 0; }
.items img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: var(--panel-2); flex: none; }
.items .t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.items .t small { display: block; color: var(--muted); }
.items .p { white-space: nowrap; font-weight: 650; }
.items .x { border: 0; background: none; color: var(--muted); font-size: 22px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.items .x:hover { color: var(--text); background: var(--panel-2); }
.total { display: flex; justify-content: space-between; font-size: 22px; font-weight: 700; margin: 0 4px 24px; }
.form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.form label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.form input[type=text], .form input[type=tel], .form input[type=email] {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid #34383e; background: var(--bg); color: var(--text); font: inherit; font-size: 16px;
  transition: border-color .2s;
}
.form input:focus { outline: 0; border-color: var(--accent); }
.form .check { display: flex; gap: 10px; align-items: flex-start; color: var(--text); }
.form .check input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.form a, .note a { text-decoration: underline; }
.form .btn { width: 100%; padding: 15px; font-size: 17px; }
.err { color: #ff8a80; min-height: 1.4em; margin: 10px 0; }
.err:empty { margin: 0; min-height: 0; }
.note { color: var(--muted); font-size: 14px; }
.downloads { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); margin: 18px 0 26px; }
.downloads:empty { display: none; }
.downloads a { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: block; transition: border-color .2s; }
.downloads a:hover { border-color: var(--accent); }
.downloads img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--panel-2); }
.downloads span { display: block; padding: 9px 10px; font-size: 13px; overflow-wrap: anywhere; }

@media (max-width: 640px) {
  :root { --row: 150px; --gap: 4px; }
  main { padding: 16px 10px 90px; }
  .hero { margin: -16px -10px 20px; padding: 26px 16px 30px; }
  .folders { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .folder .info { padding: 12px; }
  .folder .name { font-size: 15px; }
  .buybar { padding: 12px; }
  .buybar .btn { width: 100%; }
  .lb-prev, .lb-next { display: none; }
  .downloads { grid-template-columns: repeat(2, 1fr); }
  .cartbar { left: 10px; right: 10px; transform: none; justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* Админка */
.admin { max-width: 1320px; }
.admin h1 { font-size: 28px; }
.admin .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 16px 0; }
.admin .card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.admin .card b { display: block; font-size: 26px; }
.admin .card span { color: var(--muted); font-size: 13px; }
.admin .link { text-decoration: underline; }
.admin button {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 10px 16px;
  font-weight: 600; cursor: pointer; margin: 0 8px 8px 0;
}
.admin button.secondary { background: var(--panel-2); color: var(--text); }
.admin button:disabled { opacity: .5; cursor: default; }
.admin table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0 24px; }
.admin th, .admin td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: break-word; }
.admin th, .admin td button, .admin .abtn { white-space: nowrap; }
.admin #tree td { vertical-align: middle; }
.admin th { color: var(--muted); font-weight: 500; }
.admin .warn { background: #4a3413; border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.admin .scroll { overflow-x: auto; }
.admin .src-form { display: flex; flex-wrap: wrap; gap: 8px; }
.admin .src-form input {
  flex: 1 1 240px; padding: 10px 12px; border-radius: 8px; border: 1px solid #34383e;
  background: var(--panel); color: var(--text); font: inherit;
}
.admin .src-form button { margin: 0; }
.admin input.price {
  width: 92px; padding: 8px 10px; border-radius: 8px; border: 1px solid #34383e;
  background: var(--panel); color: var(--text); font: inherit;
}
.admin td button { margin: 0; }
.admin h3 { font-size: 16px; color: var(--muted); margin: 18px 0 6px; }
.admin .abtn {
  display: inline-block; border-radius: 8px; padding: 10px 16px; font-weight: 600; margin: 0 8px 8px 0;
  background: var(--panel-2); color: var(--text);
}
.admin .warn b { display: block; margin-bottom: 4px; }
.admin .warn p { margin: 4px 0; }
.admin tr.dim td { opacity: .55; }
.admin .small { font-size: 12px; color: var(--muted); white-space: nowrap; }
.admin td small { color: #ffb4a8; }
.admin input.date { width: 150px; color-scheme: dark; }
.admin input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.admin .cover-btn {
  width: 46px; height: 46px; border-radius: 8px; padding: 0; margin: 0; cursor: pointer;
  background: var(--panel-2) center / cover no-repeat; border: 1px solid var(--line);
}
.admin .crumbs { margin: 4px 0 8px; }
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .8); display: grid; place-items: center; padding: 16px; }
.modal-box {
  width: min(880px, 100%); max-height: 90vh; overflow: auto; padding: 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.modal-box h2 { margin-top: 0; }
.modal-box button { background: var(--panel-2); color: var(--text); border: 0; border-radius: 8px; padding: 10px 16px; font-weight: 600; cursor: pointer; margin: 0 8px 0 0; }
.cover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin: 12px 0 16px; }
.cover-grid button { aspect-ratio: 1; border-radius: 6px; padding: 0; margin: 0; background: var(--panel-2) center / cover no-repeat; border: 2px solid transparent; }
.cover-grid button.on { border-color: var(--accent); }
