/* Альбом коллекционера: нейтральный тёмный биндер, 9 кармашков на странице */
@property --p { syntax: '<number>'; inherits: true; initial-value: 0; }

.alb {
  --ink: #ececf0; --muted: #8e929c; --line: rgba(255, 255, 255, .1);
  --page: #1b1d22; --page2: #16181c;
  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .16 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; color: var(--ink);
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  background: radial-gradient(120% 70% at 50% -10%, #2a2d34 0%, #121317 55%, #08090b 100%);
  opacity: 0; transform: scale(1.02); transition: opacity .28s ease, transform .28s ease;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overflow: hidden; touch-action: none;
}
.alb.shown { opacity: 1; transform: none; }
.alb[hidden] { display: none !important; }
.alb button { font-family: inherit; color: inherit; cursor: pointer; }
.alb svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.alb-ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; padding: 0; flex: none;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--line); transition: transform .15s, opacity .2s; }
.alb-ico svg { width: 20px; height: 20px; }
.alb-ico:active { transform: scale(.9); }
.alb-ico:disabled { opacity: .28; pointer-events: none; }
.alb-ico.ghost { visibility: hidden; }
.alb.standalone .alb-close { visibility: hidden; }

.alb-top { display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top) + 12px) 16px 4px; }
.alb-title { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.alb-title b { font-size: 17px; letter-spacing: .2px; }
.alb-count { font-size: 12.5px; color: var(--muted); }

.alb-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 10px 16px; }

/* биндер */
.alb-binder { position: relative;
  width: calc(var(--spine) + 3 * var(--pw) + 2 * var(--g) + 2 * var(--pp));
  height: calc(3 * var(--ph) + 2 * var(--g) + 2 * var(--pp)); }
.alb-cover { position: absolute; inset: calc(-1 * var(--pad)); border-radius: 18px;
  background: var(--noise), linear-gradient(150deg, #2a2c31 0%, #151619 45%, #1d1e22 100%);
  box-shadow: 0 34px 70px rgba(0, 0, 0, .65), 0 6px 18px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .08); }
.alb-cover::after { content: ""; position: absolute; inset: 5px; border-radius: 14px; border: 1px dashed rgba(255, 255, 255, .09); }
.alb-spine { position: absolute; left: 0; top: 0; bottom: 0; width: var(--spine); z-index: 30; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-around; align-items: flex-start; padding: 16% 0;
  background: linear-gradient(90deg, #0c0d0f, #222429 65%, #141518); border-radius: 10px 0 0 10px;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .05); }
.alb-spine i { display: block; width: calc(var(--spine) + 9px); height: 9px; margin-left: 3px; border-radius: 5px;
  background: linear-gradient(180deg, #fafbfc 0%, #a3a8b1 45%, #e9ebee 62%, #7b808a 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .55); }
.alb-book { position: absolute; left: var(--spine); top: 0; right: 0; bottom: 0; perspective: 1900px; touch-action: none; }

/* страница */
.leaf { position: absolute; inset: 0; transform-origin: left center; transform-style: preserve-3d;
  transition: transform .62s cubic-bezier(.3, .7, .2, 1), --p .62s cubic-bezier(.3, .7, .2, 1); will-change: transform; }
.leaf.gone { visibility: hidden; }
.face { position: absolute; inset: 0; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.face.front { border-radius: 2px 10px 10px 2px;
  background: var(--noise), linear-gradient(180deg, #1c1e23, #131418);
  box-shadow: inset 14px 0 18px -12px rgba(0, 0, 0, .85), inset 0 0 0 1px rgba(255, 255, 255, .045); }
.face.front { opacity: clamp(0, (0.5 - var(--p)) * 1000, 1); }
.face.back { opacity: clamp(0, (var(--p) - 0.5) * 1000, 1); }
.face.back { transform: rotateY(180deg); border-radius: 10px 2px 2px 10px;
  background: var(--noise), linear-gradient(180deg, #18191d, #101114);
  box-shadow: inset -14px 0 18px -12px rgba(0, 0, 0, .85); }
.face .shade { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.face.front .shade { background: linear-gradient(90deg, rgba(0, 0, 0, .65), rgba(0, 0, 0, .15) 70%, rgba(255, 255, 255, .05)); opacity: calc(var(--p) * 1.3); }
.face.back .shade { background: linear-gradient(270deg, rgba(0, 0, 0, .6), rgba(0, 0, 0, 0) 70%); opacity: calc((1 - var(--p)) * 1.2); }
.holes { position: absolute; left: 4px; top: 0; bottom: 0; display: flex; flex-direction: column; justify-content: space-around; padding: 16% 0; }
.holes i { width: 7px; height: 7px; border-radius: 50%; background: #08090a; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .9), 0 1px 0 rgba(255, 255, 255, .06); }
.pnum { position: absolute; right: 10px; bottom: 5px; font-size: 10.5px; color: rgba(255, 255, 255, .22); letter-spacing: .08em; }

.grid { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, var(--pw)); grid-auto-rows: var(--ph);
  gap: var(--g); padding: var(--pp); justify-content: center; align-content: center; }

/* кармашек с прозрачным файлом */
.pocket { position: relative; border-radius: 7px; background: linear-gradient(180deg, rgba(0, 0, 0, .38), rgba(0, 0, 0, .24));
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .65), 0 1px 0 rgba(255, 255, 255, .045); transition: box-shadow .2s, background .2s; }
.pocket::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 3;
  border: 1px solid rgba(255, 255, 255, .075);
  background: linear-gradient(118deg, rgba(255, 255, 255, 0) 28%, rgba(255, 255, 255, .11) 40%, rgba(255, 255, 255, 0) 50%),
              linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, 0) 26%); }
.pocket::before { content: ""; position: absolute; left: 7%; right: 7%; top: 8%; height: 1px; z-index: 4; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .14), transparent); }
.pocket.empty { outline: 1px dashed rgba(255, 255, 255, .07); outline-offset: -6px; }
.pocket .num { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 600; letter-spacing: .14em; color: rgba(255, 255, 255, .15); }
.pocket.over { background: rgba(255, 255, 255, .07); box-shadow: 0 0 0 2px rgba(255, 255, 255, .6), 0 0 22px rgba(255, 255, 255, .22); }
.pocket.lifted .acard { opacity: .18; }

.acard { position: absolute; inset: 3px; display: grid; place-items: center; z-index: 2; transition: opacity .2s; }
.acard img { width: 100%; height: 100%; object-fit: contain; border-radius: 5px; pointer-events: none; display: block;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, .55)); }
.acard.current::before { content: ""; position: absolute; inset: -3px; border-radius: 8px; z-index: 5; pointer-events: none;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .75), 0 0 16px rgba(255, 255, 255, .25); }
.acard.fresh { animation: slotIn 1.1s cubic-bezier(.2, .8, .2, 1) .35s both; }
.acard.fresh::after { content: ""; position: absolute; inset: -3px; border-radius: 8px; z-index: 6; pointer-events: none;
  box-shadow: 0 0 0 2px #fff, 0 0 26px rgba(255, 255, 255, .55); animation: glowOut 2.4s ease 1.2s both; }
.acard.landed { animation: land .38s cubic-bezier(.2, .9, .3, 1.3); }
.alb.dragging .alb-book { cursor: grabbing; }

.alb-ghost { position: fixed !important; left: 0; top: 0; inset: auto; z-index: 90; pointer-events: none;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .7)); }
.alb-ghost img { width: 100%; height: 100%; object-fit: contain; border-radius: 5px; display: block; }

.alb-empty { position: absolute; left: 10%; right: 10%; top: 50%; transform: translateY(-50%); z-index: 6; text-align: center;
  display: flex; flex-direction: column; gap: 6px; padding: 16px 16px; border-radius: 16px;
  background: rgba(12, 13, 16, .86); border: 1px solid var(--line); }
.alb-empty b { font-size: 15px; }
.alb-empty span { font-size: 13px; color: var(--muted); line-height: 1.4; }

.alb-nav { display: flex; align-items: center; justify-content: center; gap: 22px; padding: 6px 0 calc(env(safe-area-inset-bottom) + 18px); }
.alb-dots { display: flex; gap: 6px; align-items: center; min-width: 60px; justify-content: center; font-size: 13px; color: var(--muted); }
.alb-dots i { width: 6px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .25); transition: width .3s, background .3s; }
.alb-dots i.on { width: 20px; background: #fff; }

.alb-tip { position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 76px); transform: translate(-50%, 10px);
  padding: 9px 15px; border-radius: 999px; font-size: 12.5px; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis;
  background: rgba(255, 255, 255, .1); border: 1px solid var(--line); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  opacity: 0; transition: .4s; pointer-events: none; }
.alb-tip.show { opacity: 1; transform: translate(-50%, 0); }

/* карточка крупно */
.alb-detail { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: calc(env(safe-area-inset-top) + 56px) 20px calc(env(safe-area-inset-bottom) + 20px);
  background: rgba(6, 7, 9, .84); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); opacity: 0; transition: opacity .25s; }
.alb-detail.shown { opacity: 1; }
.alb-detail[hidden] { display: none; }
.dv-close { position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: 16px; }
.dv-stage { perspective: 1300px; width: min(76vw, calc(58vh * .77), 420px); cursor: pointer; }
.dv-card { position: relative; width: 100%; transform-style: preserve-3d;
  transform: rotateX(var(--rx, 0deg)) rotateY(calc(var(--ry, 0deg) + var(--flip, 0deg)));
  transition: transform .5s cubic-bezier(.2, .8, .2, 1); animation: dvIn .45s cubic-bezier(.2, .9, .3, 1.15); }
.dv-card.flipped { --flip: 180deg; }
.dv-face { position: absolute; inset: 0; border-radius: 4.5% / 3.5%; overflow: hidden;
  box-shadow: 0 30px 60px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 255, 255, .06); background: #111; }
/* какая сторона видна, решает скрипт по реальному углу поворота: так задник
   показывается и в браузерах, которые «сплющивают» 3D (часть Android/Chromium) */
.dv-card .dv-back, .dv-card.show-back .dv-front { visibility: hidden; }
.dv-card.show-back .dv-back { visibility: visible; }
.dv-face img, .dv-face canvas { width: 100%; height: 100%; display: block; object-fit: cover; }
.dv-back { transform: rotateY(180deg); }
.dv-glare { position: absolute; inset: 0; border-radius: 4.5% / 3.5%; pointer-events: none; transform: translateZ(1px);
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 25%), rgba(255, 255, 255, .2), rgba(255, 255, 255, 0) 45%); }
.dv-info { display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center; }
.dv-name { font-size: 19px; }
.dv-sub { font-size: 13px; color: var(--muted); }
.dv-serial { margin-top: 2px; padding: 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; letter-spacing: .06em;
  border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .05); }
.dv-serial[hidden] { display: none; }
.dv-acts { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.dv-btn { height: 46px; padding: 0 18px 0 15px; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  font-size: 14.5px; font-weight: 600; color: #fff; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); cursor: pointer; }
.dv-btn svg { width: 20px; height: 20px; }
.dv-btn.primary { background: #f3f3f5; color: #0b0c0f; border-color: transparent; }
.dv-btn:active { transform: scale(.96); }

/* уведомление «добавлено в альбом» */
.alb-toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 68px); z-index: 60; transform: translate(-50%, -14px); opacity: 0;
  display: flex; align-items: center; gap: 12px; padding: 8px; width: max-content; max-width: calc(100vw - 32px);
  border-radius: 18px; background: rgba(10, 11, 14, .94); border: 1px solid rgba(255, 255, 255, .1); color: #f2f2f5;
  box-shadow: 0 16px 36px rgba(0, 0, 0, .55); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif; transition: opacity .35s, transform .35s; }
.alb-toast.show { opacity: 1; transform: translate(-50%, 0); }
.alb-toast img { width: 38px; border-radius: 5px; display: block; }
.alb-toast .tx { display: flex; flex-direction: column; gap: 2px; padding-right: 4px; }
.alb-toast .tx b { font-size: 14px; }
.alb-toast .tx span { font-size: 12px; color: #9a9ea8; }
.alb-toast button { height: 34px; padding: 0 14px; border-radius: 999px; border: 0; background: #f3f3f5; color: #0b0c0f; font: 600 13px inherit; font-family: inherit; cursor: pointer; }
.alb-toast.small { padding: 10px 16px; font-size: 13px; }

body.alb-page { margin: 0; background: #08090b; }

@keyframes slotIn { from { opacity: 0; transform: translateY(-55%) scale(1.25) rotate(-6deg); } 60% { opacity: 1; } to { opacity: 1; transform: none; } }
@keyframes glowOut { 0%, 40% { opacity: 1; } 100% { opacity: 0; } }
@keyframes land { 0% { transform: scale(.92); } 60% { transform: scale(1.05); } 100% { transform: none; } }
@keyframes dvIn { from { opacity: 0; transform: translateY(24px) scale(.94); } to { opacity: 1; } }
