:root{
  --ink: #1d1d1f;
  --ink-soft: #6e6e73;
  --hair: #e6e6e8;
  --pink: #ff6fa5;
  --pink-soft: #ffe0ec;

  /* wood */
  --wood-top: #c98f52;
  --wood-top-2: #bd8047;
  --wood-edge: #a86e39;
  --wood-edge-2: #8f5a2b;

  --book-w: 250px;   /* front cover width */

  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --serif: "New York", "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 16px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: var(--sans);
  background: #fff;
  color: var(--ink);
  overflow-x:hidden;
  min-height:100vh;
  position:relative;
  -webkit-font-smoothing: antialiased;
}

/* filter defs must not take part in layout (an inline <svg> defaults to
   300x150 and would push the whole page down) */
.svg-defs{ position:absolute; width:0; height:0; overflow:hidden; }

/* ---------- background decoration ---------- */
.side-character{
  position:fixed;
  bottom: 92px;
  z-index:1;
  height: 62vh;
  max-height: 560px;
  width:auto;
  pointer-events:none;
  filter: drop-shadow(0 20px 30px rgba(80,60,70,0.10));
  animation: bob 7s ease-in-out infinite;
}
.side-left{ left: 10px; }
.side-right{ right: 10px; animation-delay: -3.4s; }

/* Asanali is the settings menu, so he takes clicks */
#asanaliMenu{
  pointer-events:auto;
  cursor:pointer;
  z-index: 40;
}
.side-character-img{
  height: 62vh;
  max-height: 560px;
  width: auto;
  display:block;
  transition: transform .25s ease;
}
#asanaliMenu:hover .side-character-img,
#ayaulymMenu:hover .side-character-img{ transform: translateY(-6px); }

/* the tools fan out beside him */
.char-tools{
  position:absolute;
  left: calc(100% + 8px);
  top: 40%;
  display:flex;
  flex-direction:column;
  gap:10px;
  pointer-events:none;
}
.char-tool{
  width:42px; height:42px;
  border-radius:50%;
  border:none;
  background: var(--ink);
  color:#fff;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  padding:0;
  opacity:0;
  transform: translateX(-12px) scale(.86);
  pointer-events:none;
  transition: opacity .26s ease, transform .34s cubic-bezier(.2,1.3,.4,1), background .16s ease;
  box-shadow: 0 8px 18px -6px rgba(0,0,0,.4);
  position:relative;
}
.char-tool svg{ width:18px; height:18px; stroke:currentColor; fill:none; stroke-width:2.1; stroke-linecap:round; stroke-linejoin:round; }
/* applies to whichever character was tapped */
.side-character.open .char-tools{ pointer-events:auto; }
.side-character.open .char-tool{
  opacity:1;
  transform:none;
  pointer-events:auto;
}
/* stagger so they pop out one after another */
.side-character.open .char-tool:nth-child(1){ transition-delay: .02s; }
.side-character.open .char-tool:nth-child(2){ transition-delay: .07s; }
.side-character.open .char-tool:nth-child(3){ transition-delay: .12s; }
.side-character.open .char-tool:nth-child(4){ transition-delay: .17s; }
.char-tool:hover{ background:#000; transform: scale(1.07); }
.char-tool.active{ background: var(--pink); }
/* name appears on hover */
.char-tool::after{
  content: attr(data-label);
  position:absolute;
  left: calc(100% + 10px);
  top:50%;
  transform: translateY(-50%);
  background: var(--ink);
  color:#fff;
  font-size: 11px;
  font-weight:600;
  white-space:nowrap;
  padding: 5px 10px;
  border-radius: 8px;
  opacity:0;
  pointer-events:none;
  transition: opacity .16s ease;
}
.char-tool:hover::after{ opacity:1; }

/* ---------- the heart is the "new album" button ---------- */
.heart-add{
  border:none;
  background:none;      /* the drawing is the whole button — no disc behind it */
  padding:0;
  cursor:pointer;
  display:block;
  line-height:0;
  transition: transform .2s cubic-bezier(.2,1.4,.4,1);
}
.heart-add img{
  width: 42px;
  height: 42px;
  object-fit: contain;
  display:block;
}
.heart-add:hover{ transform: scale(1.16) rotate(-5deg); }
.heart-add:active{ transform: scale(1.02); }

/* Ayaulym's side fans out to her left */
#ayaulymMenu{
  pointer-events:auto;
  cursor:pointer;
  z-index:40;
}
.char-tools-right{
  left:auto;
  right: calc(100% + 8px);
  align-items:flex-end;
}
/* same size as Asanali's tools — only the colour sets it apart */
#ayaulymMenu .char-tool{
  transform: translateX(12px) scale(.86);
  background: var(--pink);
  box-shadow: 0 8px 18px -6px rgba(255,111,165,.6);
}
#ayaulymMenu .char-tool:hover{ background: #f2568f; transform: scale(1.07); }
#ayaulymMenu .char-tool::after{ background: var(--pink); }
.char-tools-right .char-tool::after{
  left:auto;
  right: calc(100% + 10px);
}
.game-glyph{ fill: currentColor; stroke:none; }
@keyframes bob{
  0%,100%{ transform: translateY(0); }
  50%{ transform: translateY(-12px); }
}
/* ---------- the heart's drop-down (phones) ---------- */
.mobile-menu{ display:none; }

/* Below this width the characters step aside entirely; every action lives
   under the heart instead, and the tool buttons are moved in here by script. */
@media (max-width: 1280px){
  .side-character{ display:none; }
  #asanaliMenu, #ayaulymMenu{ display:none; }

  .heart-add img{ width: 40px; height: 40px; }
  .heart-add:hover{ transform: scale(1.1); }
  .topbar.open .heart-add{ transform: scale(1.12) rotate(-8deg); }

  .mobile-menu{
    display:flex;
    flex-direction:column;
    gap:10px;
    position:absolute;
    top: calc(100% + 12px);
    left: 0;
    opacity:0;
    transform: translateY(-10px) scale(.9);
    transform-origin: top left;
    pointer-events:none;
    transition: opacity .2s ease, transform .26s cubic-bezier(.2,1.2,.4,1);
  }
  .topbar.open .mobile-menu{
    opacity:1;
    transform:none;
    pointer-events:auto;
  }

  .mobile-menu .char-tool{
    opacity:1;
    transform:none;
    pointer-events:auto;
    transition: background .16s ease, transform .16s ease;
  }
  .mobile-menu .char-tool svg{ width:19px; height:19px; }
  /* labels sit to the right of each button, always readable on touch */
  .mobile-menu .char-tool::after{
    opacity:1;
    left: calc(100% + 9px);
    right:auto;
    font-size:11.5px;
  }
  .mobile-menu #gameBtn{
    background: var(--pink);
    box-shadow: 0 8px 18px -6px rgba(255,111,165,.6);
  }
  .mobile-menu #gameBtn::after{ background: var(--pink); }
}

/* the pair, standing side by side at the end of the page (phones only) */
.couple-footer{ display:none; }
@media (max-width: 1280px){
  .couple-footer{
    display:flex;
    align-items:flex-end;
    justify-content:center;
    gap: 4vw;
    padding: 30px 20px 130px;
    position:relative;
    z-index:5;
  }
  .couple-footer img{
    width: 34vw;
    max-width: 190px;
    height: auto;
    filter: drop-shadow(0 14px 22px rgba(80,60,70,.12));
  }
  .couple-footer img:first-child{ animation: bob 7s ease-in-out infinite; }
  .couple-footer img:last-child{ animation: bob 7s ease-in-out infinite -3.4s; }
}


/* ---------- control cluster ---------- */
.topbar{
  position:fixed;
  top: 22px;
  left: 24px;
  z-index:60;
}
/* the drop-down hangs off the header, so it needs a positioning context */
.topbar{ isolation: isolate; }
.controls{
  display:flex;
  align-items:center;
  gap:8px;
}
.ctl{
  width:32px; height:32px;
  border-radius:50%;
  border:none;
  background: var(--ink);
  color:#fff;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  padding:0;
  transition: transform .16s ease, background .16s ease, opacity .16s ease;
  opacity:.88;
}
.ctl svg{ width:15px; height:15px; stroke:currentColor; fill:none; stroke-width:2.2; stroke-linecap:round; stroke-linejoin:round; }
.ctl:hover{ transform: translateY(-1px) scale(1.07); opacity:1; }
.ctl.active{ background: var(--pink); }
.char-tool.active{ background: var(--pink); }
.ctl-sep{ width:1px; height:18px; background: var(--hair); margin:0 3px; }

/* ---------- title ---------- */
.site-title{
  position:relative;
  z-index:20;          /* stays above the shelf/stack */
  margin: 44px 0 0;
  text-align:center;
  line-height: 0;
}
.site-title-img{
  width: min(560px, 64vw);
  height: auto;
  display: inline-block;
}
/* days-together counter, sitting quietly under the masthead */
.together{
  position:relative;
  z-index:20;
  margin: 10px 0 0;
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- 3D scene ---------- */
.stage{
  position:relative;
  z-index:5;
  display:flex;
  flex-direction:column;
  justify-content:center;
  padding: 8px 0 150px;
}
.shelf{ position:relative; width:100%; padding: 0 20px; }

.scene{
  perspective: 2000px;
  perspective-origin: 50% 38%;
  padding-top: 26px;
}

.shelf-row{
  position:relative;
  z-index:2;                       /* books stand in front of the board */
  display:flex;
  align-items:flex-end;
  justify-content:center;
  gap: 6px;
  height: 380px;
  margin-bottom: 0;
  transform-style: preserve-3d;
  transform: translateZ(-125px);   /* put the spines at the focal plane */
}

/* ---------- a book ---------- */
.book{
  position:relative;
  width: var(--bt, 40px);
  height: var(--bh, 330px);
  flex:none;
  cursor:pointer;
  transform-style: preserve-3d;
  transition: width .66s cubic-bezier(.25,.85,.3,1);
}
/* inside a preserve-3d row the paint order comes from geometry, not z-index,
   so the slot must be wide enough that neighbours cannot overlap the cover */
.book.open{
  width: calc(var(--book-w) * 1.08);
  z-index: 30;
}

.book-3d{
  position:absolute;
  left:0; bottom:0;
  width: var(--bt, 40px);
  height: 100%;
  transform-style: preserve-3d;
  transform-origin: left center;
  transition: transform .66s cubic-bezier(.25,.85,.3,1);
}
/* the cover swings around the book's left edge, so shift right by half a cover
   width to land it inside the slot the book just widened into */
.book.open .book-3d{
  transform: translateX(calc(var(--book-w) * 0.54)) translateZ(18px) rotateY(-84deg);
}
.book:not(.open):hover .book-3d{ transform: translateY(-14px); }

/* --- faces --- */
.book-3d > *{
  position:absolute;
  top:0; left:0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}
/* the cover is the only face that spans the full book width */
.book-cover{
  width: var(--book-w);
  left: calc((var(--bt, 40px) - var(--book-w)) / 2);
}

/* spine — a flat painted strip with hand-drawn edges */
.book-spine{
  transform: translateZ(calc(var(--book-w) / 2));
  background: var(--c1);
  color: var(--fg, #fff);
  border-radius: 2px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:space-between;
  padding: 11px 0 10px;
  overflow:hidden;
  filter: url(#rough1);
}
.book:nth-child(3n+2) .book-spine{ filter: url(#rough2); }
.book:nth-child(3n+3) .book-spine{ filter: url(#rough3); }
.spine-title{
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .13em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 72%;
  margin-top: auto;
}
.spine-year{
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 7px;
  font-weight: 700;
  letter-spacing: .12em;
  opacity: .6;
  margin-top: 9px;
}
/* a few little stamped dashes near the head of the spine */
.spine-band{
  width: 44%;
  height: 9px;
  flex:none;
  background: repeating-linear-gradient(
    180deg,
    currentColor 0 1.5px,
    transparent 1.5px 4px);
  opacity: .5;
}

/* flat drawing, so the solid faces of a 3D book are not used */
.book-back, .book-top{ display:none; }

/* front cover — the album photo. deliberately unfiltered: a displacement
   filter here would warp the photo and bend the caption text */
.book-cover{
  transform: rotateY(90deg) translateZ(calc(var(--bt, 40px) / 2));
  background:#fff;
  border-radius: 4px;
  overflow:hidden;
  box-shadow: 0 10px 26px -12px rgba(70,50,35,.45);
}
.cover-img{
  position:absolute; inset:0;
  width:100%; height:100%;
  object-fit:cover;
  object-position: center 22%;
}
.cover-count{
  position:absolute; top:12px; right:12px;
  background: rgba(255,255,255,0.94);
  color:var(--ink);
  font-size:10.5px;
  font-weight:600;
  padding: 5px 10px;
  border-radius:999px;
  z-index:5;
}
.cover-info{
  position:absolute;
  left:0; right:0; bottom:0;
  padding: 14px 16px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.9) 26%, #fff 100%);
  z-index: 4;
}
.cover-date{
  font-size: 9.5px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
  margin-bottom: 3px;
}
.cover-title{
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.12;
  margin: 0 0 4px;
  color: var(--ink);
}
.cover-desc{
  font-size: 11.5px;
  line-height: 1.42;
  color: var(--ink-soft);
  margin: 0;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}


/* editing icons on the open cover */
.cover-edit-actions{
  position:absolute; top:12px; left:12px;
  display:flex; gap:6px;
  z-index:6;
}
.mini-icon-btn{
  width:28px;height:28px;border-radius:50%;
  border:none;
  background: rgba(255,255,255,0.95);
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.mini-icon-btn svg{ width:13px;height:13px; stroke:currentColor; fill:none; stroke-width:2.2; }
.mini-icon-btn.danger{ color:#e5484d; }
.mini-icon-btn:hover{ transform: scale(1.1); }

/* --- "new album" book --- */
.book.add-book .book-spine{
  background: #fafafa;
  border: 1.5px dashed #c9c9cd;
  color: var(--ink-soft);
}
.add-spine-plus{ font-size:16px; font-weight:600; line-height:1; }
.book.add-book .spine-title{ font-size:13px; color: var(--ink-soft); font-family: var(--sans); }
.book.add-book .book-cover,
.book.add-book .book-top,
.book.add-book .book-back{ display:none; }

/* ---------- the shelf board ---------- */
/* The shelf is a photograph carrying its own shadow (2962x332, so 0.11209 as
   tall as it is wide, with the plank's top edge at 15.36% of that height).
   --board-squash flattens it vertically without touching the width, and the
   pull-up that lands the plank under the books is derived from the same
   numbers so the books stay seated at any window size. */
.board-wrap{
  --board-w: min(1340px, 74vw);
  --board-squash: 0.7;                       /* 30% shorter than the artwork */
  --board-h: calc(var(--board-w) * 0.11209 * var(--board-squash));
  position:relative;
  z-index:1;
  width: var(--board-w);
  margin: calc(var(--board-h) * -0.1536) auto 0;
  pointer-events:none;
}
.board{
  display:block;
  width: 100%;
  height: var(--board-h);
}

/* ---------- modals ---------- */
.modal-overlay{
  position:fixed; inset:0;
  background: rgba(20,20,22,0.34);
  backdrop-filter: blur(8px);
  display:flex; align-items:center; justify-content:center;
  z-index:100;
  opacity:0; pointer-events:none;
  transition: opacity .28s ease;
  padding: 20px;
}
.modal-overlay.open{ opacity:1; pointer-events:auto; }
.modal{
  background: #fff;
  border-radius: 22px;
  max-width: 880px;
  width:100%;
  max-height: 88vh;
  overflow-y:auto;
  padding: 30px 34px 34px;
  position:relative;
  box-shadow: 0 40px 90px -24px rgba(0,0,0,.35), 0 2px 8px rgba(0,0,0,.06);
  transform: translateY(20px) scale(.98);
  transition: transform .32s cubic-bezier(.22,.9,.3,1);
}
.modal-overlay.open .modal{ transform: none; }
.modal-close{
  position:absolute; top:18px; right:18px;
  width:30px;height:30px;border-radius:50%;
  border:none; background:#f1f1f3;
  font-size:17px; line-height:1; color: var(--ink-soft);
  cursor:pointer;
  z-index:5;
}
.modal-close:hover{ background: var(--ink); color:#fff; }
/* the book has no chrome of its own, so its close button sits just above it */
.book-open > .modal-close{
  top: -46px;
  right: 0;
  background: rgba(255,255,255,.92);
  color: var(--ink);
  z-index: 10;
}

/* ---------- album opened as a book spread ---------- */
.book-open{
  position:relative;
  width: min(1080px, 94vw);
  height: min(660px, 82vh);
  perspective: 2600px;
  /* the shadow lives here, not on .spread — a filter on the preserve-3d
     element would flatten the whole 3D context and kill the page turn */
  filter: drop-shadow(0 34px 60px rgba(40,25,15,.42));
  transform: scale(.86) translateY(26px);
  opacity: 0;
  transition: transform .5s cubic-bezier(.22,.9,.3,1), opacity .35s ease;
}
.modal-overlay.open .book-open{ transform: none; opacity: 1; }

/* closed, the spread is shifted so the cover alone sits centred on screen */
.spread{
  position:relative;
  width:100%;
  height:100%;
  display:flex;
  transform-style: preserve-3d;
  transform: translateX(-25%);   /* brings the closed cover to screen centre */
  transition: transform 1.05s cubic-bezier(.55,.06,.24,1);
}
.book-open.opened .spread{ transform: none; }
.page{
  position:relative;
  width:50%;
  height:100%;
  background: #fbf7ef;
  overflow:hidden;
}
.page-left{
  border-radius: 8px 2px 2px 8px;
  opacity: 0;                       /* revealed as the cover swings clear */
  transition: opacity .4s ease;
}
.book-open.opened .page-left{ opacity: 1; transition-delay: .34s; }
.page-right{ border-radius: 2px 8px 8px 2px; }
/* paper shading: darker into the gutter, plus a hint of page edges outside */
.page-left::after, .page-right::after{
  content:"";
  position:absolute; top:0; bottom:0;
  width: 46px;
  pointer-events:none;
}
.page-left::after{
  right:0;
  background: linear-gradient(90deg, rgba(120,95,60,0) 0%, rgba(120,95,60,.20) 78%, rgba(90,68,40,.34) 100%);
}
.page-right::after{
  left:0;
  background: linear-gradient(270deg, rgba(120,95,60,0) 0%, rgba(120,95,60,.20) 78%, rgba(90,68,40,.34) 100%);
}
.page-inner{
  position:relative;
  z-index:2;
  height:100%;
  overflow-y:auto;
  padding: 42px 40px 44px;
  display:flex;
  flex-direction:column;
}
.page-right .page-inner{ padding: 34px 34px 40px; }
.page-folio{
  position:absolute;
  bottom: 14px;
  font-size: 10.5px;
  letter-spacing: .1em;
  color: #b3a68f;
  pointer-events:none;
}
.page-left .page-folio{ left: 40px; }
.page-right .page-folio{ right: 40px; }
.page-rule{
  display:block;
  width: 54px;
  height: 2px;
  background: var(--pink);
  margin: 14px 0 16px;
  flex:none;
}
.page-count{
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #a1957f;
  font-weight: 600;
  margin-top: auto;
  padding-top: 18px;
}

/* the front cover, hinged on the spine */
.flap{
  position:absolute;
  top:0; right:0;
  width:50%;
  height:100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  /* the trailing translateZ rides along with the rotation: it lifts the cover
     in front of the pages while closed, and drops it behind them once the
     cover has swung over to the left — exactly where a real cover ends up */
  transform: rotateY(0deg) translateZ(7px);
  transition: transform 1.05s cubic-bezier(.55,.06,.24,1);
}
.book-open.opened .flap{ transform: rotateY(-179.6deg) translateZ(7px); }
.flap-face{
  position:absolute;
  inset:0;
  backface-visibility: hidden;
  overflow:hidden;
  border-radius: 2px 8px 8px 2px;
}
.flap-front{ background:#e8e2d6; }
.flap-front img{
  position:absolute; inset:0;
  width:100%; height:100%;
  object-fit:cover;
  object-position: center 22%;
}
.flap-plate{
  position:absolute;
  left:0; right:0; bottom:0;
  padding: 26px 30px 30px;
  background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.92) 32%, #fff 100%);
}
.flap-date{
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
  margin-bottom: 4px;
}
.flap-title{
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--ink);
}
/* the inside of the cover, seen once it has swung across */
.flap-back{
  transform: rotateY(180deg);
  background:
    radial-gradient(ellipse at 88% 50%, rgba(120,95,60,.16), rgba(120,95,60,0) 62%),
    #f4eee2;
  border-radius: 8px 2px 2px 8px;
}

.am-header-actions{ display:flex; gap:8px; flex:none; margin-top: 14px; }
.am-title-input{
  font-family: var(--serif);
  font-size: clamp(26px,3.4vw,34px);
  font-weight:600;
  border:none; background:transparent; color:var(--ink);
  width:100%;
  padding: 2px 4px;
  border-radius: 8px;
  letter-spacing: -0.01em;
}
.am-date-input{
  border:none; background:transparent;
  font-size:11px; letter-spacing:1.8px; text-transform:uppercase;
  color: var(--ink-soft); font-weight:600;
  padding: 2px 4px;
  width: 100%;
  font-family: var(--sans);
}
.am-title-input:disabled, .am-date-input:disabled, .am-desc-input:disabled{
  opacity:1; -webkit-text-fill-color: currentColor; color: inherit;
}
.am-title-input:not(:disabled), .am-date-input:not(:disabled){
  background: #f7f7f8;
  outline: 1.5px solid var(--pink);
}
.ghost-btn{
  display:flex; align-items:center; gap:6px;
  background: #f5f5f7;
  border: none;
  padding: 9px 15px;
  border-radius: 999px;
  font-size:12.5px;
  font-weight:600;
  cursor:pointer;
  color: var(--ink);
}
.ghost-btn svg{ width:14px;height:14px; stroke:currentColor; fill:none; stroke-width:2; }
.ghost-btn:hover{ background: var(--ink); color:#fff; }
.ghost-btn.danger:hover{ background:#e5484d; color:#fff; }
.ghost-btn.active{ background: var(--pink); color:#fff; }

.am-desc-input{
  width:100%;
  border:none; background:transparent;
  resize:none;
  font-size:14.5px;
  line-height:1.68;
  color: #5f5748;
  font-family:inherit;
  min-height: 110px;
  padding: 6px 4px;
  flex: none;
}
.am-desc-input:not(:disabled){
  background: #f7f7f8;
  outline: 1.5px solid var(--pink);
  border-radius:10px;
  color: var(--ink);
}

.am-photos-grid{
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap:14px;
}
.am-photo{
  position:relative;
  border-radius: 14px;
  aspect-ratio: 4/5;
  background:#f2f2f4;
  cursor:pointer;
  overflow:hidden;
  box-shadow: 0 6px 18px -8px rgba(0,0,0,.3);
}
.am-photo img{ width:100%;height:100%; object-fit:cover; display:block; transition: transform .4s ease; }
.am-photo:hover img{ transform: scale(1.04); }
.am-photo-caption{
  position:absolute; left:0; right:0; bottom:0;
  padding: 14px 11px 9px;
  font-size:11.5px;
  color:#fff;
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.72));
  z-index:2;
}
.am-photo-cover-badge{
  position:absolute; top:8px; left:8px;
  background: var(--pink);
  color: #fff;
  font-size:8.5px; font-weight:700; letter-spacing:.8px; text-transform:uppercase;
  padding:4px 8px; border-radius:999px;
  z-index:4;
}
/* drag-to-reorder feedback */
.am-photo[draggable="true"], .book[draggable="true"]{ cursor: grab; }
.am-photo.dragging, .book.dragging{ opacity: .4; }
.am-photo.drop-target{ outline: 3px solid var(--pink); outline-offset: 2px; }
.book.drop-target .book-spine{ box-shadow: 0 0 0 3px var(--pink); }

/* heart that pulls a photo into the favourites volume */
.am-fav-btn{
  position:absolute;
  right: 8px;
  top: 8px;
  width: 30px; height: 30px;
  border:none;
  border-radius:50%;
  background: rgba(255,255,255,.9);
  color: #c9c4bb;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  z-index: 5;
  display:flex; align-items:center; justify-content:center;
  transition: transform .16s ease, color .16s ease, background .16s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.am-fav-btn:hover{ transform: scale(1.14); color: var(--pink); }
.am-fav-btn.on{ background: var(--pink); color:#fff; }

/* the favourites book on the shelf */
.book.fav-book .spine-heart{
  font-size: 12px;
  color: var(--pink-deep, #e8447e);
  flex:none;
}
.book.fav-book .spine-title{ font-weight: 700; }

.am-photo-actions{
  /* shifted left so the favourite heart keeps the corner to itself */
  position:absolute; top:8px; right:46px;
  display:flex; gap:5px;
  z-index:4;
}
.am-caption-input{
  position:absolute; left:6px; right:6px; bottom:6px;
  font-size:11px;
  border:none; border-radius:8px;
  padding:7px 9px;
  background: rgba(255,255,255,.96);
  color: var(--ink);
  z-index:4;
}

.am-add-photos{ margin-top:18px; }
.upload-drop{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:8px;
  border: 1.5px dashed #d2d2d7;
  border-radius: 16px;
  padding: 26px;
  cursor:pointer;
  color: var(--ink-soft);
  background: #fafafa;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
  text-align:center;
  font-size:13px;
  font-weight:600;
}
.upload-drop:hover, .upload-drop.dragover{ background: var(--pink-soft); border-color: var(--pink); color: var(--ink); }
.upload-drop svg{ width:24px;height:24px; stroke:currentColor; fill:none; stroke-width:1.8; }

/* ---------- lightbox ---------- */
.lightbox-inner{
  position:relative;
  max-width: 92vw; max-height: 90vh;
  display:flex; align-items:center; justify-content:center;
}
.lightbox-inner img{
  max-width: 88vw; max-height: 80vh;
  border-radius: 12px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
  transform: scale(.97);
  transition: transform .3s ease;
}
.modal-overlay.open .lightbox-inner img{ transform: none; }
.lb-caption{
  position:absolute; bottom:-36px; left:0; right:0;
  text-align:center; color:#fff; font-size:13.5px; opacity:.92;
}
.lb-nav{
  position:absolute; top:50%; transform:translateY(-50%);
  width:42px;height:42px;border-radius:50%;
  background: rgba(255,255,255,0.92);
  border:none; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
}
.lb-nav svg{ width:19px;height:19px; stroke: var(--ink); fill:none; stroke-width:2.2; }
.lb-prev{ left:-58px; }
.lb-next{ right:-58px; }
#lightbox .modal-close{ top:-44px; right:-44px; background: rgba(255,255,255,0.92); }
@media (max-width: 720px){
  .lb-prev{ left:6px; }
  .lb-next{ right:6px; }
  #lightbox .modal-close{ top:6px; right:6px; }
}

/* ---------- new album modal ---------- */
.new-album-modal{ max-width: 500px; }
.new-album-modal h2{
  font-family: var(--serif);
  margin: 2px 0 18px;
  font-size:26px;
  font-weight:600;
}
.cover-drop{ aspect-ratio: 16/9; position:relative; margin-bottom:14px; }
.cover-drop img{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; border-radius:16px; }
.field-input, .field-textarea{
  width:100%;
  border: 1px solid var(--hair);
  background: #fff;
  border-radius: 11px;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  margin-bottom: 11px;
}
.field-textarea{ min-height: 88px; resize: vertical; }
.field-input:focus, .field-textarea:focus,
.am-title-input:focus, .am-date-input:focus, .am-desc-input:focus{
  outline: 2px solid var(--pink); outline-offset: -1px;
}
.primary-btn{
  width:100%;
  background: var(--ink);
  color:#fff;
  border: none;
  border-radius: 999px;
  padding: 14px;
  font-size:14.5px;
  font-weight:600;
  cursor:pointer;
  transition: transform .15s ease, background .15s ease;
}
.primary-btn:hover{ transform: translateY(-1px); background:#000; }
.primary-btn:disabled{ opacity:.4; cursor:not-allowed; transform:none; }

/* ---------- album song picker + slideshow launcher ---------- */
.am-song{
  display:flex;
  flex-direction:column;
  gap:5px;
  margin-top: 14px;
  flex:none;
}
/* display:flex above would otherwise defeat the hidden attribute */
.am-song[hidden]{ display:none; }
.am-song-label{
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #a1957f;
  font-weight: 700;
}
.am-song-select{
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  padding: 9px 11px;
  border: 1.5px solid var(--pink);
  border-radius: 10px;
  background: #fff;
}
.play-album-btn{
  display:flex;
  align-items:center;
  gap: 12px;
  width:100%;
  margin-top: 16px;
  padding: 11px 14px;
  border: none;
  border-radius: 14px;
  background: #f3ede1;
  cursor: pointer;
  text-align: left;
  flex:none;
  transition: background .18s ease, transform .18s ease;
}
.play-album-btn:hover{ background: var(--pink-soft); transform: translateY(-1px); }
.play-album-btn:disabled{ opacity:.45; cursor:not-allowed; transform:none; }
.pab-icon{
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--ink);
  color:#fff;
  display:flex; align-items:center; justify-content:center;
  flex:none;
}
.pab-icon svg{ width:14px; height:14px; fill: currentColor; margin-left:2px; }
.pab-text{ display:flex; flex-direction:column; min-width:0; }
.pab-text strong{ font-size: 13px; font-weight: 700; color: var(--ink); }
.pab-text em{
  font-style: normal;
  font-size: 11.5px;
  color: var(--ink-soft);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}

/* ---------- slideshow ---------- */
.slideshow-overlay{ background: #0d0b0c; backdrop-filter:none; padding:0; }
.slide-stage{
  position:relative;
  width:100%;
  height:100%;
  overflow:hidden;
}
.slide-img{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 1.1s ease;
}
.slide-img.on{
  opacity: 1;
  animation: kenburns 9s ease-out forwards;   /* a slow drift keeps it alive */
}
@keyframes kenburns{
  from{ transform: scale(1.02); }
  to{ transform: scale(1.09); }
}
.slide-vignette{
  position:absolute; inset:0;
  pointer-events:none;
  background:
    linear-gradient(180deg, rgba(0,0,0,.42) 0%, rgba(0,0,0,0) 22%),
    linear-gradient(0deg, rgba(0,0,0,.72) 0%, rgba(0,0,0,0) 34%);
}
.slide-caption{
  position:absolute;
  left:0; right:0;
  bottom: 108px;
  text-align:center;
  color:#fff;
  font-size: 16px;
  letter-spacing: .01em;
  padding: 0 40px;
  text-shadow: 0 2px 14px rgba(0,0,0,.6);
  opacity:0;
  transition: opacity .6s ease .25s;
}
.slide-caption.on{ opacity:.96; }
.slide-progress{
  position:absolute;
  left:0; right:0; bottom: 86px;
  height:2px;
  background: rgba(255,255,255,.16);
}
.slide-progress span{
  display:block;
  height:100%;
  width:0;
  background: var(--pink);
}
.slide-bar{
  position:absolute;
  left:0; right:0; bottom:0;
  height: 86px;
  display:flex;
  align-items:center;
  gap: 18px;
  padding: 0 26px;
  color:#fff;
}
.slide-meta{ min-width:0; width: 210px; }
.slide-album{
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.slide-song{
  font-size: 11.5px;
  color: rgba(255,255,255,.6);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.slide-controls{
  display:flex;
  align-items:center;
  gap: 8px;
  margin: 0 auto;
}
.slide-btn{
  width: 40px; height: 40px;
  border:none;
  border-radius:50%;
  background: rgba(255,255,255,.12);
  color:#fff;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  transition: background .16s ease, transform .16s ease;
}
.slide-btn svg{ width:16px; height:16px; fill: currentColor; }
.slide-btn:hover{ background: rgba(255,255,255,.24); transform: scale(1.06); }
.slide-play{ width:52px; height:52px; background:#fff; color:#111; }
.slide-play:hover{ background:#fff; }
.slide-play svg{ width:19px; height:19px; }
.slide-count{
  font-size: 12px;
  color: rgba(255,255,255,.6);
  font-variant-numeric: tabular-nums;
  width: 60px;
  text-align:right;
}
.slide-close{ flex:none; }
@media (max-width: 760px){
  .slide-meta, .slide-count{ display:none; }
  .slide-bar{ justify-content:space-between; padding: 0 14px; height:78px; }
  .slide-caption{ bottom: 100px; font-size: 14px; padding: 0 20px; }
  .slide-progress{ bottom: 78px; }
}

/* ---------- PaoPao game window ---------- */
.ctl-game svg{ fill: currentColor; stroke: none; }
.ctl-game{ background: var(--pink); }
.ctl-game:hover{ background: var(--pink); }

.game-window{
  width: min(1120px, 94vw);
  height: min(820px, 90vh);
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 40px 90px -24px rgba(0,0,0,.42), 0 2px 8px rgba(0,0,0,.06);
  transform: translateY(20px) scale(.98);
  transition: transform .32s cubic-bezier(.22,.9,.3,1);
}
.modal-overlay.open .game-window{ transform: none; }
.game-bar{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 12px 14px 12px 18px;
  border-bottom: 1px solid var(--hair);
  background: #fff;
  flex: none;
}
.game-dot{
  width:10px; height:10px; border-radius:50%;
  background: var(--pink);
  flex:none;
}
.game-name{
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.game-name em{ font-style: normal; font-weight: 500; color: var(--ink-soft); }
.game-close{
  margin-left:auto;
  width:30px; height:30px;
  border:none; border-radius:50%;
  background:#f1f1f3;
  color: var(--ink-soft);
  font-size:18px; line-height:1;
  cursor:pointer;
  flex:none;
}
.game-close:hover{ background: var(--ink); color:#fff; }
.game-frame-wrap{ flex:1; min-height:0; }
#gameFrame{
  display:block;
  width:100%;
  height:100%;
  border:0;
}
@media (max-width: 760px){
  .game-window{ width: 96vw; height: 88vh; border-radius: 16px; }
}

/* ---------- toast ---------- */
.toast{
  position:fixed; bottom:112px; left:50%; transform:translateX(-50%) translateY(16px);
  background: rgba(29,29,31,.95);
  color:#fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size:13px;
  font-weight:500;
  z-index:200;
  opacity:0;
  transition: all .28s ease;
  pointer-events:none;
  box-shadow: 0 16px 34px rgba(0,0,0,0.24);
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }

::-webkit-scrollbar{ width:8px; }
::-webkit-scrollbar-thumb{ background: #d2d2d7; border-radius:8px; }

/* ---------- music player ---------- */
.player-bar{
  position:fixed;
  left:50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 50;
  display:flex;
  align-items:center;
  gap:16px;
  background: #fff;
  border-radius: 18px;
  padding: 9px 18px 9px 9px;
  max-width: 94vw;
  box-shadow:
    0 1px 2px rgba(0,0,0,.05),
    0 8px 18px -6px rgba(0,0,0,.10),
    0 26px 50px -14px rgba(0,0,0,.18);
}
.player-art{
  width:44px; height:44px;
  border-radius:10px;
  background: var(--pink-soft);
  display:flex; align-items:center; justify-content:center;
  flex:none;
  overflow:hidden;
}
.player-art img{ width:20px; height:20px; object-fit:contain; }
.player-bar.playing .player-art{ animation: artPulse 1.8s ease-in-out infinite; }
@keyframes artPulse{
  0%,100%{ transform: scale(1); }
  50%{ transform: scale(1.06); }
}
.player-info{ min-width: 110px; max-width: 168px; flex:none; }
.player-title{
  font-size:13px;
  font-weight:600;
  color: var(--ink);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  letter-spacing: -0.01em;
}
.player-artist{
  font-size:11.5px;
  color: var(--ink-soft);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.player-controls{ display:flex; align-items:center; gap:4px; flex:none; }
.player-btn{
  width:32px; height:32px;
  border-radius:50%;
  border:none;
  background: transparent;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  color: var(--ink);
  transition: background .15s ease, transform .15s ease;
}
.player-btn svg{ width:15px; height:15px; stroke:none; fill:currentColor; }
.player-btn:hover{ background:#f2f2f4; }
.player-btn.play-btn{
  width:40px; height:40px;
  background: var(--ink);
  color:#fff;
}
.player-btn.play-btn:hover{ background:#000; transform: scale(1.05); }
.player-btn.play-btn svg{ width:16px; height:16px; }

.player-progress{ display:flex; align-items:center; gap:10px; min-width: 210px; }
.player-time{ font-size:10.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; flex:none; }
.player-seek, .player-vol-range{
  -webkit-appearance:none; appearance:none;
  width:100%;
  height:4px;
  border-radius:999px;
  background: #e6e6e8;
  cursor:pointer;
  outline:none;
}
.player-seek::-webkit-slider-thumb, .player-vol-range::-webkit-slider-thumb{
  -webkit-appearance:none;
  width:11px; height:11px; border-radius:50%;
  background: var(--ink);
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.player-seek::-moz-range-thumb, .player-vol-range::-moz-range-thumb{
  width:11px; height:11px; border-radius:50%; border:none;
  background: var(--ink);
}
.player-volume{ display:flex; align-items:center; gap:7px; width:86px; flex:none; }
.player-volume svg{ width:15px; height:15px; stroke: var(--ink-soft); fill:none; stroke-width:1.8; flex:none; }

/* the playlist glyph is drawn with strokes, not fills — without this the
   player's blanket `fill: currentColor; stroke: none` collapsed it to a dot */
.playlist-btn{ flex:none; }
.playlist-btn svg{
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.playlist-btn svg circle{ fill: currentColor; stroke: none; }
.playlist-btn.open-state{ background: var(--pink-soft); }
.playlist-popover{
  position:absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: 288px;
  max-height: 264px;
  overflow-y:auto;
  background: #fff;
  border-radius: 16px;
  padding: 7px;
  display:none;
  flex-direction:column;
  gap:1px;
  box-shadow: 0 2px 6px rgba(0,0,0,.06), 0 20px 44px -12px rgba(0,0,0,.24);
}
.playlist-popover.open{ display:flex; }
.playlist-row{
  display:flex; align-items:center; gap:10px;
  padding: 9px 11px;
  border-radius: 10px;
  cursor:pointer;
}
.playlist-row:hover{ background:#f5f5f7; }
.playlist-row.active{ background: var(--pink-soft); }
.pl-index{ font-size:11px; color: var(--ink-soft); width:14px; flex:none; }
.pl-title{ font-size:12.5px; font-weight:600; color:var(--ink); flex:1; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.pl-artist{ font-size:11px; color: var(--ink-soft); flex:none; max-width:88px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

@media (max-width: 900px){
  .player-progress, .player-volume{ display:none; }
  .player-bar{ padding: 8px 14px 8px 8px; gap:12px; }
  .player-info{ max-width: 120px; }
  .playlist-popover{ right:-6px; width: 240px; }
}

/* ---------- phone: the spread folds into one scrolling column ---------- */
@media (max-width: 760px){
  .modal{ padding: 22px 18px 26px; border-radius:18px; }
  .am-header-actions{ align-self:flex-start; }

  .book-open{
    width: 94vw;
    height: 82vh;
    perspective: none;
    filter: drop-shadow(0 18px 40px rgba(40,25,15,.32));
  }
  .spread{
    flex-direction: column;
    transform: none;
    overflow-y: auto;
    border-radius: 14px;
    background: #fbf7ef;
  }
  /* no room for a two-page metaphor on a phone */
  .flap{ display:none; }
  .page{ width:100%; height:auto; flex:none; border-radius:0; }
  .page-left{ opacity:1; }
  .page-left::after, .page-right::after{ display:none; }
  .page-inner{ overflow: visible; padding: 26px 20px 20px; }
  .page-right .page-inner{ padding: 4px 20px 26px; }
  .page-folio{ display:none; }
  .am-desc-input{ min-height: 84px; }
  .book-open > .modal-close{ top: -42px; right: 2px; }
}

/* ---------- phone: vertical 3D album stack ---------- */
@media (max-width: 760px){
  .site-title{ margin-top: 60px; }
  .site-title-img{ width: 68vw; }
  .stage{ padding: 0 0 120px; }
  /* slabs stacked above the focused one fade out under the masthead
     instead of colliding with the title and controls */
  .stage::before{
    content:"";
    position:fixed;
    top:0; left:0; right:0;
    height: 178px;
    background: linear-gradient(180deg, #fff 0 62%, rgba(255,255,255,0) 100%);
    z-index: 110;
    pointer-events:none;
  }
  .shelf{ padding: 0 12px; }
  .scene{ perspective: 1000px; perspective-origin: 50% 50%; padding-top:0; }
  .board-wrap{ display:none; }

  .shelf-row.stack-mode{
    display:block;
    position:relative;
    height: 60vh;
    min-height: 360px;
    transform: rotateX(7deg);
    transform-style: preserve-3d;
    touch-action: none;
  }

  .shelf-row.stack-mode .book,
  .shelf-row.stack-mode .book.open{
    position:absolute;
    top: 47%;
    left: 50%;
    width: min(330px, 86vw);
    height: 176px;
    transform-style: preserve-3d;
    transition: transform .5s cubic-bezier(.25,.85,.3,1), opacity .4s ease;
  }
  /* flatten the 3D book down to a single slab */
  .shelf-row.stack-mode .book-3d,
  .shelf-row.stack-mode .book.open .book-3d{
    position:absolute;
    inset:0;
    width:100%;
    height:100%;
    transform:none;
    transition:none;
    transform-style: flat;
  }
  .shelf-row.stack-mode .book-spine,
  .shelf-row.stack-mode .book-top,
  .shelf-row.stack-mode .book-back{ display:none; }

  /* slabs are flat, so the hinge groove and cover sheen do not apply */
  .shelf-row.stack-mode .book-cover::after{ display:none; }

  .shelf-row.stack-mode .book-cover,
  .shelf-row.stack-mode .book.open .book-cover{
    position:absolute;
    inset:0;
    width:100%;
    height:100%;
    left:0;
    border-radius: 14px;
    transform:none;
    opacity:1;
    pointer-events:auto;
    transition:none;
    box-shadow: 0 16px 28px -14px rgba(0,0,0,.45);
  }

  /* photo starts below the caption strip and is anchored to its own top,
     so faces never hide behind the text */
  .shelf-row.stack-mode .cover-img{
    top: 46px;
    bottom: auto;
    height: calc(100% - 46px);
    object-position: center top;
  }
  .shelf-row.stack-mode .cover-info{
    top:0; bottom:auto; left:0; right:0;
    height: 46px;
    padding: 6px 12px;
    border-radius: 14px 14px 0 0;
    background: #fff;
    overflow:hidden;
  }
  .shelf-row.stack-mode .cover-date{ font-size:8.5px; letter-spacing:1.5px; margin-bottom:1px; }
  .shelf-row.stack-mode .cover-title{ font-size:18px; line-height:1.05; }
  .shelf-row.stack-mode .cover-desc{ display:none; }
  .shelf-row.stack-mode .cover-count{ top:auto; bottom:10px; right:10px; font-size:10px; padding:4px 9px; }
  .shelf-row.stack-mode .cover-edit-actions{ top:auto; bottom:8px; left:10px; }

  .shelf-row.stack-mode .add-book{
    background:#fff;
    border: 1.5px dashed #c9c9cd;
    border-radius: 14px;
    display:flex; align-items:center; justify-content:center;
    color: var(--ink-soft);
    font-size: 15px;
    font-weight: 600;
  }
  .shelf-row.stack-mode .add-book::after{ content:"+  Новый альбом"; }
  .shelf-row.stack-mode .add-book .book-3d{ display:none; }
}
