:root {
  --ink: #342318;
  --muted: #725943;
  --paper: #ecd8aa;
  --paper-light: #f8eac2;
  --leather: #2b180f;
  --rose: #8f4338;
  --gold: #d8b577;
  font-family: Inter, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 10%, rgba(216, 181, 119, 0.18), transparent 28%),
    linear-gradient(135deg, #160b07 0%, #2a160f 52%, #0f0805 100%);
  overflow-x: hidden;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 238, 199, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 238, 199, 0.026) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at center, black 32%, transparent 86%);
}

.app-shell {
  width: min(1180px, calc(100vw - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 10px 0 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  height: 44px;
  color: #f0d9aa;
}

button {
  font: inherit;
}

.brand,
.view-button,
.open-book,
.icon-button,
.photo-arrow,
.letter-tab,
.memory-pill,
.photo-dot {
  border: 0;
  cursor: pointer;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  color: inherit;
  background: transparent;
  font-family: Playfair Display, Georgia, serif;
  font-size: 17px;
  font-weight: 700;
}

.brand-heart {
  position: relative;
  isolation: isolate;
  display: grid;
  width: 35px;
  height: 31px;
  place-items: center;
  transform: rotate(-45deg);
  background: linear-gradient(145deg, #ae5549, #733029);
  border-radius: 45% 45% 8px 45%;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.26);
}

.brand-heart::before,
.brand-heart::after {
  position: absolute;
  z-index: -1;
  width: 100%;
  height: 100%;
  content: "";
  background: inherit;
  border-radius: 50%;
}

.brand-heart::before {
  top: -50%;
  left: 0;
}

.brand-heart::after {
  top: 0;
  right: -50%;
}

.brand-heart span {
  color: #fff1cf;
  font-family: Caveat, cursive;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  transform: rotate(45deg);
}

.view-switch {
  display: flex;
  gap: 8px;
  padding: 4px;
  border: 1px solid rgba(234, 215, 173, 0.16);
  border-radius: 999px;
  background: rgba(22, 11, 7, 0.42);
}

.view-button {
  min-height: 32px;
  padding: 0 14px;
  color: #e8c996;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  background: transparent;
}

.view-button.active {
  color: #2d170f;
  background: #efd8a8;
}

.book-stage {
  display: grid;
  min-height: calc(100vh - 54px);
  place-items: center;
  perspective: 1800px;
}

.book {
  position: relative;
  width: min(1110px, 100%);
  aspect-ratio: 16 / 9;
  transform-style: preserve-3d;
  filter: drop-shadow(0 25px 42px rgba(0, 0, 0, 0.44));
}

.cover,
.spread {
  position: absolute;
  inset: 0;
  border-radius: 15px;
  transition: transform 900ms cubic-bezier(0.2, 0.74, 0.22, 1), opacity 450ms ease;
  backface-visibility: hidden;
}

.cover {
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 40px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent 10%, transparent 90%, rgba(0, 0, 0, 0.22)),
    linear-gradient(135deg, #4c2b1d, #25130d 58%, #170b07);
  border: 2px solid #8c6941;
  box-shadow: inset 0 0 0 10px rgba(18, 9, 6, 0.55), inset 0 0 0 12px rgba(207, 169, 99, 0.18);
  transform-origin: left center;
}

.cover-grain {
  position: absolute;
  inset: 0;
  opacity: 0.24;
  background:
    repeating-linear-gradient(82deg, transparent 0 7px, rgba(255,255,255,0.06) 8px 9px),
    repeating-linear-gradient(0deg, rgba(0,0,0,0.08) 0 1px, transparent 1px 5px);
}

.cover-frame {
  position: relative;
  display: grid;
  width: min(520px, 82%);
  min-height: 390px;
  place-items: center;
  padding: 40px;
  text-align: center;
  border: 1px solid rgba(234, 215, 173, 0.5);
  outline: 1px solid rgba(234, 215, 173, 0.18);
  outline-offset: 12px;
}

.cover-heart {
  position: relative;
  display: grid;
  width: 150px;
  height: 150px;
  place-items: center;
  transform: rotate(-45deg);
  background: linear-gradient(145deg, #b65b4c, #6f2f25);
  border-radius: 42% 42% 14px 42%;
  box-shadow: inset 12px 12px 28px rgba(255, 255, 255, 0.12), inset -12px -12px 26px rgba(0, 0, 0, 0.22), 0 18px 36px rgba(0, 0, 0, 0.32);
  animation: heartPulse 2.9s ease-in-out infinite;
}

.cover-heart::before,
.cover-heart::after {
  position: absolute;
  width: 150px;
  height: 150px;
  content: "";
  background: inherit;
  border-radius: 50%;
}

.cover-heart::before {
  top: -75px;
  left: 0;
}

.cover-heart::after {
  top: 0;
  left: 75px;
}

.cover-heart span {
  position: relative;
  z-index: 1;
  color: #fff0cf;
  font-family: Caveat, cursive;
  font-size: 46px;
  font-weight: 700;
  transform: rotate(45deg);
}

.cover h1 {
  margin: 30px 0 0;
  color: #f5dfad;
  font-family: Playfair Display, Georgia, serif;
  font-size: clamp(44px, 6vw, 72px);
  line-height: 1;
}

.cover p {
  margin: 6px 0 26px;
  color: #d6b887;
  font-family: Caveat, cursive;
  font-size: 30px;
}

.open-book {
  min-width: 132px;
  min-height: 44px;
  padding: 0;
  color: #2d170f;
  font-weight: 800;
  border-radius: 999px;
  background: linear-gradient(180deg, #f2dba9, #c99a5e);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
}

.spread {
  opacity: 0;
  overflow: visible;
  transform: rotateY(8deg) translateY(18px);
}

.book-base {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
  pointer-events: none;
  user-select: none;
}

.book.open .cover {
  opacity: 0;
  pointer-events: none;
  transform: rotateY(-104deg);
}

.book.open .spread {
  opacity: 1;
  transform: rotateY(0) translateY(0);
}

.page-overlay {
  position: absolute;
  color: #332218;
}

.left-overlay {
  top: 17.2%;
  left: 16.5%;
  width: 30.5%;
  height: 68%;
  text-align: center;
}

.right-overlay {
  top: 13%;
  left: 52.1%;
  width: 32.7%;
  height: 75%;
}

.letter-mark {
  margin-top: 3.5%;
  font-family: Playfair Display, Georgia, serif;
  font-size: clamp(78px, 10.4vw, 142px);
  font-weight: 700;
  line-height: 0.82;
  color: #4c3323;
}

.left-overlay h2 {
  margin: 5% 0 0;
  font-family: Caveat, cursive;
  font-size: clamp(30px, 4vw, 50px);
  font-weight: 600;
  line-height: 0.95;
}

.tiny-heart,
.divider-heart {
  position: relative;
  width: 16px;
  height: 16px;
  margin: 10px auto;
  transform: rotate(-45deg);
  border: 1.7px solid #6f392f;
  border-top-color: transparent;
  border-right-color: transparent;
}

.tiny-heart::before,
.tiny-heart::after,
.divider-heart::before,
.divider-heart::after {
  position: absolute;
  width: 13px;
  height: 13px;
  content: "";
  border: 1.7px solid #6f392f;
  border-radius: 50%;
}

.tiny-heart::before,
.divider-heart::before {
  top: -7px;
  left: -2px;
  border-right-color: transparent;
  border-bottom-color: transparent;
}

.tiny-heart::after,
.divider-heart::after {
  top: 1px;
  left: 6px;
  border-left-color: transparent;
  border-bottom-color: transparent;
}

.memory-list {
  display: grid;
  gap: 7px;
  width: min(260px, 88%);
  margin: 9% auto 0;
}

.memory-list.timeline-list {
  width: min(330px, 94%);
  max-height: 166px;
  margin-top: 6%;
  padding-right: 3px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}

.memory-list.timeline-list::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.memory-pill {
  min-height: 32px;
  padding: 4px 12px;
  color: #684b36;
  font-family: Caveat, cursive;
  font-size: 22px;
  line-height: 1;
  text-align: left;
  border-radius: 999px;
  background: rgba(255, 245, 219, 0.28);
  transition: color 180ms ease, background 180ms ease, transform 180ms ease;
}

.timeline-list .memory-pill {
  min-height: 29px;
  font-size: 18px;
  white-space: normal;
}

.memory-pill.active,
.memory-pill:hover {
  color: #321f14;
  background: rgba(239, 216, 168, 0.72);
  transform: translateX(5px);
}

.empty-letter {
  margin: 0;
  color: #745a43;
  font-family: Caveat, cursive;
  font-size: 24px;
  line-height: 1.1;
}

.memory-content {
  --photo-height: 45%;
  height: 100%;
  text-align: center;
}

.script-title {
  margin: 0;
  font-family: Caveat, cursive;
  font-size: clamp(33px, 4.6vw, 56px);
  font-weight: 600;
  line-height: 0.95;
  white-space: nowrap;
}

time {
  display: block;
  margin-top: 1px;
  color: #5c432f;
  font-family: Playfair Display, Georgia, serif;
  font-size: clamp(12px, 1.35vw, 16px);
  font-weight: 700;
}

.photo-frame {
  position: relative;
  display: inline-block;
  width: auto;
  max-width: 78%;
  height: var(--photo-height);
  margin: 4.5% auto 2.6%;
  padding: 9px;
  background: #fff8e8;
  box-shadow: 0 13px 22px rgba(77, 47, 27, 0.2);
  transform: rotate(-0.8deg);
}

.photo-frame img {
  display: block;
  width: auto;
  max-width: 100%;
  height: 100%;
  object-fit: contain;
  border: 1px solid rgba(69, 44, 27, 0.15);
}

.photo-arrow {
  position: absolute;
  top: 50%;
  z-index: 3;
  display: grid;
  width: 26px;
  height: 46px;
  padding: 0;
  place-items: center;
  color: #4e3323;
  background: rgba(255, 247, 225, 0.2);
  border-radius: 999px;
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity 160ms ease, background 160ms ease;
}

.photo-frame.has-multiple .photo-arrow {
  opacity: 0.5;
}

.photo-arrow:hover {
  opacity: 0.8;
  background: rgba(255, 247, 225, 0.42);
}

.photo-arrow svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.photo-arrow-prev {
  left: -34px;
}

.photo-arrow-next {
  right: -34px;
}

.photo-frame.is-hidden {
  display: none;
}

.tape {
  position: absolute;
  z-index: 2;
  width: 78px;
  height: 22px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.18), transparent),
    rgba(181, 135, 84, 0.54);
  box-shadow: 0 2px 6px rgba(88, 51, 20, 0.2);
}

.tape-one {
  top: -9px;
  left: -25px;
  transform: rotate(-26deg);
}

.tape-two {
  right: -24px;
  bottom: -6px;
  transform: rotate(-22deg);
}

.photo-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  min-height: 17px;
  padding-top: 10px;
}

.photo-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border-radius: 50%;
  background: rgba(96, 68, 47, 0.32);
}

.photo-dot.active {
  background: #7d3f35;
}

.memory-text {
  max-width: 320px;
  max-height: 19%;
  margin: 2.2% auto 36px;
  padding-right: 6px;
  overflow-y: auto;
  font-family: Playfair Display, Georgia, serif;
  font-size: clamp(11px, 1.2vw, 14px);
  line-height: 1.62;
  text-align: left;
  scrollbar-width: thin;
  scrollbar-color: rgba(111, 57, 47, 0.45) transparent;
}

.page-controls {
  position: absolute;
  right: 0;
  bottom: -10px;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #5f422c;
  font-size: 12px;
  font-weight: 800;
}

.right-overlay.compact-memory .memory-content {
  --photo-height: 34%;
}

.right-overlay.dense-memory .memory-content {
  --photo-height: 29%;
}

.right-overlay.compact-memory .photo-frame {
  margin-top: 3.6%;
  margin-bottom: 2%;
}

.right-overlay.dense-memory .photo-frame {
  margin-top: 2.8%;
  margin-bottom: 1.8%;
}

.right-overlay.dense-memory .memory-text {
  max-height: 21%;
  font-size: clamp(10px, 1.05vw, 13px);
}

.icon-button {
  display: grid;
  width: 21px;
  height: 21px;
  padding: 0 !important;
  place-items: center;
  color: #4e3323;
  border-radius: 50%;
  background: rgba(255, 247, 225, 0.56);
  transition: transform 180ms ease, background 180ms ease;
}

.icon-button:hover {
  transform: translateY(-2px);
  background: rgba(255, 247, 225, 0.86);
}

.icon-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.35;
}

.alphabet-rail {
  position: absolute;
  top: 15.4%;
  right: 5.5%;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 54px;
  height: 70.5%;
  padding: 2px 0;
}

.letter-tab {
  width: 30px;
  height: calc(100% / 26);
  min-height: 14px;
  color: #4e3322;
  font-family: Playfair Display, Georgia, serif;
  font-size: 10px;
  line-height: 1;
  border: 1px solid rgba(86, 57, 34, 0.24);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  background: linear-gradient(90deg, #f0dfb8, #d6be8e);
  box-shadow: 3px 2px 5px rgba(67, 40, 18, 0.14);
  transform-origin: left center;
  transition: width 150ms ease, min-height 150ms ease, font-size 150ms ease, transform 150ms ease, background 150ms ease, color 150ms ease;
}

.letter-tab.has-items {
  font-weight: 700;
}

.letter-tab.active {
  color: #f7e8c8;
  background: linear-gradient(90deg, #6f392f, #9f5a46);
}

.letter-tab.near-1 {
  z-index: 5;
  width: 50px;
  min-height: 40px;
  font-size: 20px;
}

.letter-tab.near-2 {
  z-index: 4;
  width: 44px;
  min-height: 34px;
  font-size: 17px;
}

.letter-tab.near-3 {
  z-index: 3;
  width: 39px;
  min-height: 29px;
  font-size: 14px;
}

.letter-tab.near-4 {
  z-index: 2;
  width: 35px;
  min-height: 24px;
  font-size: 12px;
}

.right-overlay.turning {
  animation: pageTurn 520ms cubic-bezier(0.2, 0.72, 0.24, 1);
}

@keyframes heartPulse {
  0%, 100% { transform: rotate(-45deg) scale(1); }
  50% { transform: rotate(-45deg) scale(1.045); }
}

@keyframes pageTurn {
  0% { transform: rotateY(0deg); filter: brightness(1); }
  45% { transform: rotateY(-10deg); filter: brightness(0.92); }
  100% { transform: rotateY(0deg); filter: brightness(1); }
}

@media (max-width: 760px) {
  body {
    display: grid;
    place-items: center;
    min-height: 100vh;
  }

  body::before {
    content: "Hahah povedal som že na počítači lasik 😘";
    width: min(320px, calc(100vw - 44px));
    color: #f6dfb3;
    font-family: Caveat, cursive;
    font-size: 34px;
    font-weight: 700;
    line-height: 1.08;
    text-align: center;
    text-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
  }

  .app-shell {
    display: none;
  }

  .app-shell {
    width: min(100vw - 12px, 560px);
    padding-top: 14px;
  }

  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
  }

  .brand {
    margin-left: 14px;
  }

  .view-switch {
    width: 100%;
    gap: 4px;
    overflow: hidden;
  }

  .view-button {
    flex: 1;
    min-width: 0;
    padding: 0 4px;
    font-size: 11px;
    white-space: nowrap;
  }

  .book-stage {
    min-height: calc(100vh - 108px);
    align-items: start;
    justify-content: start;
    padding-top: 14px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .book {
    width: 920px;
    max-width: none;
    margin-left: 0;
  }

  .cover {
    transform: none;
  }

  .book.open .cover {
    transform: rotateY(-104deg);
  }

  .cover-frame {
    width: 68%;
    min-height: 360px;
  }

  .letter-mark {
    font-size: 76px;
  }

  .left-overlay h2 {
    font-size: 29px;
  }

  .memory-list {
    width: 80%;
    gap: 5px;
    margin-top: 7%;
  }

  .memory-pill {
    min-height: 27px;
    font-size: 17px;
  }

  .script-title {
    font-size: 34px;
  }

  .photo-frame {
    max-width: 76%;
    padding: 7px;
  }

  .memory-text {
    max-width: 260px;
    font-size: 11px;
    line-height: 1.45;
  }

  .alphabet-rail {
    right: 5.5%;
    width: 49px;
  }

  .letter-tab.near-1 {
    width: 46px;
    min-height: 34px;
    font-size: 18px;
  }

  .letter-tab.near-2 {
    width: 40px;
    min-height: 29px;
    font-size: 15px;
  }

  .letter-tab.near-3 {
    width: 36px;
    min-height: 25px;
    font-size: 13px;
  }

  .letter-tab.near-4 {
    width: 32px;
    min-height: 21px;
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
