@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;1,400&family=Noto+Serif+JP:wght@400;500&display=swap');
:root {
  --page-ratio: 0.73;
  --card-ratio: 0.78;
  --photo-share: 66.667%;
  --paper: #f8f5ec;
  --ink: #514c40;
  --olive: #747861;
  --page-w: 350px;
  --page-h: 480px;
  --spread: 1;
  --serif: 'Cormorant Garamond', 'Noto Serif JP', serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: #e8e5dc;
  color: var(--ink);
  font-family: 'Noto Serif JP', serif;
  background-image: radial-gradient(ellipse at 45% 30%, #f4f1e8 0, transparent 65%);
  min-height: 100dvh;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
  color: inherit;
}
button:disabled {
  cursor: default;
  opacity: 0.35;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #747861;
  outline-offset: 4px;
}
button {
  border: 0;
  background: transparent;
}
button[hidden],
[hidden] {
  display: none !important;
}
.topbar {
  height: 88px;
  margin: 0 5%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #cac5b85e;
}
.brand {
  font-family: var(--serif);
  font-size: 25px;
  letter-spacing: 4px;
  text-decoration: none;
  color: inherit;
}
.brand span {
  display: block;
  font:
    8px Arial,
    sans-serif;
  letter-spacing: 2.4px;
  margin-top: 4px;
}
.outline {
  border: 1px solid #a6a594;
  border-radius: 2px;
  padding: 11px 18px;
  font-size: 11px;
  letter-spacing: 1px;
}
.chapter {
  display: flex;
  gap: 17px;
  align-items: center;
  justify-content: center;
  height: 62px;
  font-size: 10px;
  letter-spacing: 1px;
}
.chapter > span:first-child {
  font:
    10px Arial,
    sans-serif;
  letter-spacing: 2px;
}
.fine-rule {
  height: 1px;
  width: 30px;
  background: #b9b6a7;
}
#stage {
  height: calc(100dvh - 270px);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 25px;
  perspective: 1800px;
}
#book {
  position: relative;
  width: calc(var(--page-w) * var(--spread));
  height: var(--page-h);
  display: flex;
  touch-action: pan-y;
  perspective: 1600px;
}
.page {
  width: var(--page-w);
  height: var(--page-h);
  position: relative;
  flex: none;
  background: var(--paper);
  box-shadow:
    8px 12px 24px #544a3827,
    2px 2px 0 #d6d0c1,
    4px 4px 0 #f6f2e9;
  overflow: hidden;
  padding: calc(var(--page-w) * 0.07);
  background-image: linear-gradient(90deg, #9f958415, transparent 6%, transparent 97%, #9f958419);
  container-type: inline-size;
}
.page.left {
  background-image: linear-gradient(270deg, #a99e8f27, transparent 10%);
}
.page.right:not(.cover) {
  box-shadow:
    inset 10px 0 15px -13px #544a3899,
    8px 12px 24px #544a3827,
    2px 2px 0 #d6d0c1;
}
.cover {
  padding: 0;
  background: #eeeadf;
  box-shadow:
    inset 8px 0 9px -8px #5c514d,
    10px 18px 34px #544a3833,
    3px 3px 0 #bdb5a6,
    5px 5px 0 #e6dfd1;
  border-radius: 2px 5px 5px 2px;
}
.cover:before {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid #a89a7250;
  pointer-events: none;
  z-index: 2;
}
.cover-top {
  height: 34%;
  text-align: center;
  padding: 10% 5% 0;
}
.eyebrow {
  font:
    9px Arial,
    sans-serif;
  letter-spacing: 2.6px;
  color: #8f8b75;
}
.cover h1 {
  font: italic 12cqw/0.85 var(--serif);
  font-weight: 400;
  margin: 6% 0 4%;
}
.cover .cover-sub {
  font:
    8px Arial,
    sans-serif;
  letter-spacing: 3px;
  color: #89816f;
}
.cover-photo {
  height: 45%;
  width: 76%;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 48% 48% 0 0;
}
.cover-photo img {
  height: 100%;
  width: 100%;
  object-fit: cover;
  filter: saturate(0.65);
}
.cover-bottom {
  text-align: center;
  padding: 5% 0;
}
.couple {
  font: italic 7cqw var(--serif);
  margin: 0 0 5%;
}
.date {
  font:
    8px Arial,
    sans-serif;
  letter-spacing: 2px;
}
.cover-flower {
  position: absolute;
  right: 3%;
  bottom: 13%;
  font-size: 13cqw;
  color: #8d9279;
  transform: rotate(-20deg);
  opacity: 0.8;
}
.page-heading {
  text-align: center;
  margin: 0 0 5%;
  font: italic 8cqw var(--serif);
}
.page-kicker {
  text-align: center;
  font-size: 2.5cqw;
  letter-spacing: 1px;
  margin: 0 0 7%;
  color: #928874;
}
.page-number {
  position: absolute;
  bottom: 2.8%;
  left: 0;
  width: 100%;
  text-align: center;
  font: 10px var(--serif);
  letter-spacing: 2px;
  color: #a09987;
}
.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7% 7%;
  align-content: center;
  height: 78%;
}
.polaroid {
  display: block;
  text-align: left;
  align-self: center;
  position: relative;
  aspect-ratio: var(--card-ratio);
  background: #fffefa;
  padding: 5.3%;
  box-shadow: 1px 4px 9px #554a351c;
  width: 100%;
  container-type: inline-size;
  overflow: hidden;
}
.photo-grid > .polaroid:nth-child(odd) {
  transform: rotate(-3deg);
}
.photo-grid > .polaroid:nth-child(even) {
  transform: rotate(3deg);
}
.photo-grid > .polaroid:nth-child(3) {
  transform: rotate(2deg);
}
.photo-area {
  height: var(--photo-share);
  background: #eeeae1;
  position: relative;
  overflow: hidden;
}
.photo-area img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.8);
}
.empty-art {
  height: 100%;
  display: grid;
  place-content: center;
  color: #b4b1a2;
  font: italic 12cqw var(--serif);
  text-align: center;
}
.empty-art small {
  font-size: 4cqw;
  margin-top: 8px;
  letter-spacing: 1px;
}
.card-name {
  position: absolute;
  right: 7%;
  bottom: 4%;
  font-size: 4cqw;
  color: #aaa18e;
  letter-spacing: 0.5px;
}
.message {
  position: absolute;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  width: 84%;
  text-align: center;
  line-height: 1.7;
  transform: translate(-50%, -50%) rotate(var(--rotation, 0deg));
  font-size: 5.5cqw;
  pointer-events: none;
}
.play-badge {
  position: absolute;
  right: 9%;
  top: 48%;
  border: 1px solid #ffffffa0;
  background: #ffffffd9;
  border-radius: 50%;
  width: 19%;
  aspect-ratio: 1;
  display: grid;
  place-content: center;
  font: 7cqw Arial;
  color: #77775e;
}
.movie-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.movie-page video {
  width: 100%;
  max-height: 64%;
  object-fit: contain;
  background: #dad4c5;
}
.movie-caption {
  font-size: 2.6cqw;
  text-align: center;
  margin-top: 8%;
  color: #8c846f;
  line-height: 2;
}
.movie-num {
  font: 9px Arial;
  letter-spacing: 3px;
  text-align: center;
  color: #a59a85;
  margin-bottom: 8%;
}
.book-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  margin-top: 22px;
}
.book-nav > button {
  border: 1px solid #bbb7a8;
  border-radius: 50%;
  height: 36px;
  width: 36px;
  font-size: 17px;
}
.book-nav > div {
  text-align: center;
  min-width: 92px;
}
#page-count {
  font: 11px Arial;
  letter-spacing: 2px;
}
#dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
}
#dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #c5c0b1;
}
#dots i.active {
  background: #72765d;
}
.hint {
  text-align: center;
  color: #96917f;
  font-size: 9px;
  letter-spacing: 1px;
  margin: 15px 0;
}
footer {
  display: flex;
  justify-content: space-between;
  margin: 0 5%;
  padding: 14px 0;
  font: 8px Arial;
  letter-spacing: 1.7px;
  color: #aaa291;
}
footer button {
  font-size: 9px;
  letter-spacing: 1px;
}
.turn-leaf {
  position: absolute;
  top: 0;
  z-index: 5;
  transform-origin: left center;
  backface-visibility: hidden;
  pointer-events: none;
  animation: turn 0.65s ease-in-out both;
}
.turn-leaf.backward {
  transform-origin: right center;
  animation-name: turnback;
}
@keyframes turn {
  to {
    transform: rotateY(-105deg);
    filter: brightness(0.82);
    opacity: 0.15;
  }
}
@keyframes turnback {
  to {
    transform: rotateY(105deg);
    filter: brightness(0.82);
    opacity: 0.15;
  }
}
dialog {
  border: 1px solid #e1dbce;
  background: #faf8f1;
  color: var(--ink);
  border-radius: 4px;
  padding: 34px;
  width: min(92vw, 450px);
  max-height: 91dvh;
  box-shadow: 0 25px 80px #29251930;
}
dialog::backdrop {
  background: #39392d66;
  backdrop-filter: blur(6px);
}
.close {
  position: absolute;
  right: 13px;
  top: 10px;
  font: 26px Arial;
  color: #7b7769;
  width: 32px;
  height: 32px;
}
h2 {
  font-size: 23px;
  font-weight: 400;
  line-height: 1.8;
  margin: 16px 0;
}
.muted {
  font-size: 11px;
  color: #9a9383;
  line-height: 1.9;
}
.demo-note {
  font-size: 10px;
  line-height: 1.8;
  color: #948a77;
  background: #f0ede3;
  padding: 10px;
}
label {
  display: block;
  font-size: 11px;
  margin: 17px 0;
  line-height: 1.8;
}
input:not([type='range'], [type='file']),
select,
textarea {
  display: block;
  width: 100%;
  padding: 11px;
  border: 1px solid #d6d0c1;
  background: #fffef9;
  border-radius: 2px;
  margin-top: 7px;
  color: var(--ink);
  font-size: 13px;
}
input[type='range'] {
  display: block;
  width: 100%;
  accent-color: #777d60;
  margin-top: 10px;
}
.primary {
  background: #777d60;
  color: #fffef6;
  width: 100%;
  padding: 14px;
  font-size: 12px;
  letter-spacing: 1px;
  margin-top: 14px;
}
.text-button {
  font-size: 11px;
  text-decoration: underline;
  margin-top: 10px;
}
.danger {
  color: #9f6556;
  border: 1px solid #bfa697;
  padding: 12px;
  width: 100%;
  margin-top: 15px;
  font-size: 12px;
}
#editor {
  width: min(92vw, 850px);
}
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 35px;
  align-items: start;
}
.preview-column {
  padding: 18px 16px;
  background: #eae6dc;
  text-align: center;
}
.preview-column .polaroid {
  max-width: 285px;
  margin: auto;
  text-align: left;
}
.preview-column .photo-area {
  touch-action: none;
  cursor: move;
}
.preview-column .photo-area img {
  position: absolute;
  max-width: none;
  width: auto;
  height: auto;
  filter: none;
  transform-origin: 0 0;
}
.preview-column .message {
  pointer-events: auto;
  cursor: move;
  touch-action: none;
}
.preview-column .message.selected {
  outline: 1px dashed #908f70;
  outline-offset: 3px;
}
.preview-column.crop-mode .photo-area:after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid #fff9;
  background:
    linear-gradient(
      90deg,
      transparent 33%,
      #ffffff66 33.3%,
      transparent 33.6%,
      transparent 66%,
      #ffffff66 66.3%,
      transparent 66.6%
    ),
    linear-gradient(
      transparent 33%,
      #ffffff66 33.3%,
      transparent 33.6%,
      transparent 66%,
      #ffffff66 66.3%,
      transparent 66.6%
    );
  pointer-events: none;
}
.tabs {
  display: flex;
  border-bottom: 1px solid #dbd4c5;
  gap: 8px;
}
.tabs button {
  font-size: 11px;
  padding: 10px 3px;
  color: #aaa28c;
  flex: 1;
}
.tabs button.active {
  color: #5b6249;
  border-bottom: 2px solid #777d60;
}
.upload {
  display: block;
  border: 1px dashed #b8b49e;
  text-align: center;
  padding: 23px 10px;
  cursor: pointer;
  background: #f2f0e7;
}
.upload input {
  display: block;
  width: 100%;
  font-size: 10px;
  margin-top: 10px;
}
#colors {
  display: flex;
  gap: 12px;
  margin: 18px 0;
}
#colors button {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  border: 3px solid #faf8f1;
  outline: 1px solid transparent;
}
#colors button.active {
  outline-color: #817963;
}
#char-count {
  float: right;
  color: #aaa18e;
}
#edit-error,
#auth-error,
#movie-error {
  color: #a65b49;
  font-size: 11px;
  line-height: 1.8;
}
#movie {
  width: min(94vw, 950px);
  background: #22231f;
  color: #faf8ee;
  text-align: center;
}
#movie .close {
  color: white;
}
#movie video {
  max-height: 72dvh;
  width: 100%;
  object-fit: contain;
}
#movie-title {
  font-size: 13px;
}
#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: #626850;
  color: white;
  padding: 13px 23px;
  font-size: 12px;
  transition: 0.3s;
  z-index: 20;
  white-space: nowrap;
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
@media (max-width: 600px) {
  .topbar {
    height: 72px;
  }
  .brand {
    font-size: 20px;
  }
  .brand span {
    font-size: 6px;
  }
  .outline {
    padding: 9px 12px;
    font-size: 10px;
  }
  .chapter {
    height: 54px;
    font-size: 8px;
    gap: 10px;
  }
  .chapter > span:first-child {
    font-size: 8px;
  }
  #stage {
    height: calc(100dvh - 254px);
    padding: 10px 20px;
  }
  .book-nav {
    margin-top: 18px;
  }
  footer {
    font-size: 6px;
  }
  .editor-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  #editor {
    padding: 25px 20px;
  }
  #editor h2 {
    font-size: 18px;
    margin: 10px 0;
  }
  .preview-column {
    padding: 12px;
  }
  .preview-column .polaroid {
    max-width: 200px;
  }
  .preview-column .muted {
    margin: 8px 0 0;
    font-size: 9px;
  }
  .controls label {
    margin: 12px 0;
  }
  dialog {
    padding: 28px;
  }
}
@media (orientation: landscape) and (max-height: 600px) {
  .topbar {
    height: 45px;
  }
  .brand {
    font-size: 17px;
  }
  .brand span {
    display: none;
  }
  .chapter {
    height: 29px;
  }
  #stage {
    height: calc(100dvh - 145px);
    min-height: 140px;
    padding: 5px 25px;
  }
  .book-nav {
    margin-top: 10px;
  }
  .book-nav > button {
    width: 28px;
    height: 28px;
  }
  .hint {
    display: none;
  }
  footer {
    padding: 8px 0;
  }
  .editor-grid {
    grid-template-columns: 1fr 1fr;
  }
  .preview-column .polaroid {
    max-width: 210px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .turn-leaf {
    animation-duration: 0.01s;
  }
  * {
    scroll-behavior: auto !important;
  }
}
