:root {
  --night: #120a18;
  --ink: #24182c;
  --violet: #6e46b0;
  --violet-deep: #54348f;
  --lilac: #d9c8f5;
  --paper: #fbf8f4;
  --muted: #8d7aa3;
  --gold: #c6a37a;
  --rose: #e7b7c8;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: Manrope, "Segoe UI", sans-serif;
  --script: Caveat, cursive;
  --shadow: 0 30px 70px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: #f4effa;
  background:
    radial-gradient(1100px 640px at 88% -10%, rgba(142, 92, 214, 0.34), transparent 55%),
    radial-gradient(800px 520px at -10% 16%, rgba(92, 42, 140, 0.32), transparent 50%),
    var(--night);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
::selection { background: #d4c2f7; color: #1b1024; }
:focus-visible { outline: 2px solid #cbb6ef; outline-offset: 3px; }

#sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#boot {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: var(--night);
  font-family: var(--serif);
  font-size: clamp(40px, 6vw, 68px);
  letter-spacing: 0.01em;
}
body.ready #boot { display: none; }
body.lock { overflow: hidden; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.login, #app { position: relative; z-index: 1; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}
.login-card {
  width: min(440px, 100%);
  padding: 42px 36px 32px;
  border-radius: 28px;
  background: rgba(28, 16, 42, 0.72);
  border: 1px solid rgba(236, 224, 255, 0.16);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.login-card h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 68px;
  font-weight: 500;
  line-height: 0.9;
}
.script {
  margin: 0 0 6px;
  font-family: var(--script);
  font-size: 36px;
  color: #f0e6ff;
}
.login-lead {
  margin: 14px 0 26px;
  color: #ddd0ee;
  line-height: 1.55;
}
.login-card label, .composer-card label, .letter label {
  display: block;
  margin: 14px 0 6px;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}
.login-card label { color: #efe7f8; }
.login-card input {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  color: white;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
}
.pass-row { position: relative; }
.pass-row input { padding-right: 108px; }
.text-btn {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  border: 0;
  background: none;
  color: var(--lilac);
  font-size: 13px;
}
.form-error {
  min-height: 1.3em;
  margin: 10px 0 0;
  color: #ffc4d6;
  font-size: 14px;
}
.login-card.shake { animation: shake 0.42s ease; }

@keyframes shake {
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  letter-spacing: 0.02em;
}
.btn.primary {
  color: white;
  background: linear-gradient(180deg, #8d68d6, #5c3b9e);
  box-shadow: 0 10px 24px rgba(80, 40, 140, 0.28);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:disabled { opacity: 0.7; cursor: wait; }
.btn.ghost, .btn.ghost-dark {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #f4effa;
}
.btn.ghost-dark {
  border-color: rgba(36, 24, 44, 0.18);
  color: var(--ink);
}
.login-card .btn.primary { width: 100%; margin-top: 8px; }

.nav {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(18, 10, 24, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(16px);
}
.brand, .nav-links button, .quiet, .quiet-light, .tool-btn, .file-btn {
  border: 0;
  background: none;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-family: var(--serif);
  font-size: 28px;
}
.star { width: 18px; height: 18px; fill: #f0e4ff; }
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-links button, .quiet-light {
  color: #efe7f8;
  padding: 8px 12px;
  border-radius: 999px;
}
.nav-links button[aria-current="page"] { background: rgba(255, 255, 255, 0.08); }
.pill {
  color: white !important;
  background: linear-gradient(180deg, #8d68d6, #5c3b9e);
  padding: 10px 16px !important;
}
.who {
  margin-right: 8px;
  color: #d9c8f5;
  font-family: var(--script);
  font-size: 24px;
}
.view { padding: 112px 20px 80px; }

.letter, .sheet, .composer-card, .modal-card {
  background-color: var(--paper);
  background-image: radial-gradient(rgba(90, 60, 130, 0.045) 0.7px, transparent 0.7px);
  background-size: 4px 4px;
  color: var(--ink);
}
.letter {
  width: min(640px, 100%);
  margin: 0 auto;
  padding: 54px 52px 42px;
  border-radius: 32px;
  background-color: #fbf7f2;
  background-image: none;
  box-shadow: var(--shadow);
  animation: rise 0.9s cubic-bezier(.16, 1, .3, 1) both;
}
.kicker {
  margin: 0 0 8px;
  color: var(--violet);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.kicker.light { color: var(--lilac); }
.letter h1, .album-head h1, .composer-card h2, .empty h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  line-height: 0.95;
}
.letter h1 { font-size: clamp(52px, 7vw, 78px); }
.gold-rule {
  width: 72px;
  height: 1px;
  margin: 22px 0 8px;
  background: var(--gold);
}
.empty p {
  font-family: var(--serif);
  font-size: 23px;
  line-height: 1.45;
}
#letter-paragraphs p { margin: 0; }
.letter-lead {
  margin-top: 28px !important;
  font-family: var(--serif);
  font-size: 27px;
  line-height: 1.4;
  text-wrap: pretty;
}
.letter-lead em {
  font-style: italic;
  font-weight: 600;
  color: var(--violet);
}
.letter-note {
  margin-top: 22px !important;
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.55;
  color: #4a3b58;
}
.letter-close {
  margin-top: 26px !important;
  font-family: var(--script);
  font-size: 34px;
  line-height: 1.15;
  color: var(--violet);
  text-wrap: balance;
}
.empty .script {
  font-family: var(--script);
  font-size: 40px;
  color: #f0e6ff;
}
.signature {
  margin: 18px 0 0;
  font-family: var(--script);
  font-size: 40px;
  text-align: right;
  color: var(--violet);
}
.quiet {
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
}
.quiet:hover, .quiet-light:hover { color: var(--violet); }
.letter input, .letter textarea, .composer-card input, .composer-card textarea, .edit-box input, .edit-box textarea, .wish-card input, .scrap-form textarea {
  width: 100%;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(80, 50, 120, 0.16);
  border-radius: 14px;
}
.letter textarea, .composer-card textarea, .edit-box textarea, .scrap-form textarea { resize: vertical; line-height: 1.5; }
.hint, .date-preview, .count, .lede {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.letter .hint, .date-preview { color: #8a749f; }
.row-actions, .home-actions, .tool-row, .composer-top, .card-foot {
  display: flex;
  align-items: center;
  gap: 10px;
}
.row-actions { margin-top: 16px; justify-content: flex-end; flex-wrap: wrap; }

.about { width: min(980px, 100%); margin: 54px auto 0; }
.about h2, .album-head h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(40px, 5vw, 64px); }
.features {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.features article {
  padding: 22px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.features h3 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
}
.features p { margin: 0; color: #ddd0ee; line-height: 1.5; }
.home-actions { margin-top: 22px; flex-wrap: wrap; }

.album-head { width: min(860px, 100%); margin: 0 auto 10px; }
.album-head h1 { margin-top: 6px; }
.lede { max-width: 520px; color: #ddd0ee; }
.count { color: #cbb6ef; }
.date-search-wrap {
  width: min(860px, 100%);
  margin: 18px auto 0;
  padding: 0;
}
.date-search-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.date-search label {
  display: block;
  margin: 0 0 8px;
  color: #efe7f8;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: lowercase;
}
.date-search input[type="date"] {
  height: 46px;
  padding: 0 12px;
  color: white;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  color-scheme: dark;
}
.search-note {
  margin: 10px 0 0;
  color: #f4effa;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.35;
}
.search-note button {
  padding: 0;
  border: 0;
  background: none;
  color: #e4d4ff;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.empty {
  width: min(640px, 100%);
  margin: 28px auto;
  text-align: center;
}
.empty .script { color: #f0e6ff; }
.empty h2 { font-size: clamp(36px, 5vw, 56px); margin-bottom: 8px; }

.feed { width: min(860px, 100%); margin: 0 auto; }
.sheet {
  position: relative;
  scroll-margin-top: 96px;
  margin: 7vh auto;
  padding: 32px 32px 22px 42px;
  border-radius: 26px;
  box-shadow: var(--shadow);
  overflow: hidden;
  opacity: 0;
  transform: translateY(72px) scale(0.975);
  filter: blur(8px);
  transition: opacity 0.9s ease, transform 1s cubic-bezier(.16, 1, .3, 1), filter 0.9s ease;
}
.sheet::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 16px;
  background: linear-gradient(90deg, rgba(90, 50, 140, 0.16), transparent);
}
.sheet::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  border-style: solid;
  border-width: 0 0 54px 54px;
  border-color: transparent transparent rgba(186, 160, 224, 0.28) transparent;
}
.sheet.is-visible { opacity: 1; transform: none; filter: none; }
.sheet.is-found { outline: 2px solid rgba(212, 180, 130, 0.95); outline-offset: 6px; }
.sheet::before, .sheet::after { z-index: 2; pointer-events: none; }
.sheet.has-doodle {
  background-color: #fff;
  background-image: none;
}
.has-doodle .sheet-meta,
.has-doodle .moment-text {
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
}
.has-doodle .sheet-meta { padding: 8px 10px; }
.has-doodle .moment-text { padding: 8px 12px; }
.has-doodle {
  --tile-w: 240px;
  --tile-h: 71px;
}
.doodle-wash {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: var(--doodle);
  background-repeat: repeat;
  background-position: 0 0;
  background-size: var(--tile-w) auto;
  mix-blend-mode: multiply;
  pointer-events: none;
}
.pattern-rows .doodle-wash,
.pattern-columns .doodle-wash,
.pattern-chess .doodle-wash,
.pattern-steps .doodle-wash::before,
.pattern-steps .doodle-wash::after {
  -webkit-mask-mode: alpha;
  mask-mode: alpha;
}
.pattern-rows .doodle-wash {
  --row-mask: repeating-linear-gradient(
    to bottom,
    #000 0 var(--tile-h),
    transparent var(--tile-h) calc(var(--tile-h) * 2)
  );
  -webkit-mask-image: var(--row-mask);
  mask-image: var(--row-mask);
}
.pattern-columns .doodle-wash {
  --col-mask: repeating-linear-gradient(
    to right,
    #000 0 var(--tile-w),
    transparent var(--tile-w) calc(var(--tile-w) * 2)
  );
  -webkit-mask-image: var(--col-mask);
  mask-image: var(--col-mask);
}
.pattern-chess .doodle-wash {
  --chess-x: repeating-linear-gradient(
    to right,
    #000 0 var(--tile-w),
    transparent var(--tile-w) calc(var(--tile-w) * 2)
  );
  --chess-y: repeating-linear-gradient(
    to bottom,
    #000 0 var(--tile-h),
    transparent var(--tile-h) calc(var(--tile-h) * 2)
  );
  -webkit-mask-image: var(--chess-x), var(--chess-y);
  mask-image: var(--chess-x), var(--chess-y);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
}
.pattern-steps .doodle-wash { background-image: none; }
.pattern-steps .doodle-wash::before,
.pattern-steps .doodle-wash::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--doodle);
  background-repeat: repeat;
  background-size: var(--tile-w) auto;
  pointer-events: none;
}
.pattern-steps .doodle-wash::before {
  --step-a: repeating-linear-gradient(
    to bottom,
    #000 0 var(--tile-h),
    transparent var(--tile-h) calc(var(--tile-h) * 2)
  );
  -webkit-mask-image: var(--step-a);
  mask-image: var(--step-a);
}
.pattern-steps .doodle-wash::after {
  background-position: calc(var(--tile-w) / 2) 0;
  --step-b: repeating-linear-gradient(
    to bottom,
    transparent 0 var(--tile-h),
    #000 var(--tile-h) calc(var(--tile-h) * 2)
  );
  -webkit-mask-image: var(--step-b);
  mask-image: var(--step-b);
}
.pattern-preview {
  position: relative;
  height: 240px;
  margin-top: 8px;
  overflow: hidden;
  border: 1px solid rgba(110, 70, 176, 0.16);
  border-radius: 16px;
  background: #fff;
}
.sheet-meta, .collage, .card-foot { position: relative; z-index: 1; }
.sheet-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  margin-bottom: 16px;
}
.layout-story .sheet-body {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 8px 22px;
  align-items: start;
}
.layout-story .sheet-meta { display: block; margin: 0; }
.collage, .collage-media, .gallery { min-width: 0; }
.collage { display: flex; flex-direction: column; gap: 16px; }
.layout-media .collage { flex-direction: column-reverse; }
.layout-columns .collage,
.layout-flip .collage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 18px;
  align-items: start;
}
.layout-flip .collage-text { order: 2; }
.layout-note .collage { position: relative; }
.layout-note .collage-text {
  position: absolute;
  z-index: 2;
  left: 16px;
  bottom: 16px;
  max-width: min(420px, 72%);
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 30px rgba(40, 20, 70, 0.12);
  transform: rotate(-1.5deg);
}
.layout-note .collage:not(:has(.gallery)):not(:has(.moment-video)) .collage-text,
.layout-note.is-editing .collage-text {
  position: static;
  max-width: none;
  padding: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
}
.page-no {
  margin: 0 0 10px;
  color: #a08cb8;
  font-size: 12px;
  letter-spacing: 0.14em;
}
.weekday, .year { margin: 0; color: #8d73b8; font-family: var(--serif); font-style: italic; }
.weekday { font-size: 18px; }
.year { font-size: 18px; }
.dayline {
  margin: 2px 0;
  color: #4c2f86;
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 600;
  line-height: 0.95;
}
.place-line {
  margin: 8px 0 0;
  padding: 0;
  border: 0;
  background: none;
  color: #6e46b0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  cursor: pointer;
}
.love-map, .place-map {
  width: min(980px, 100%);
  height: min(70vh, 640px);
  margin: 8px auto 0;
  overflow: hidden;
  border-radius: 24px;
  background: #24182f;
}
.place-map {
  width: 100%;
  height: 240px;
  margin-top: 10px;
  border: 1px solid rgba(110, 70, 176, 0.22);
  border-radius: 16px;
}
.place-results { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.place-results button {
  padding: 10px 12px;
  border: 1px solid rgba(110, 70, 176, 0.22);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  text-align: left;
}
.place-results small { display: block; color: #8d73b8; }
.map-pin {
  position: absolute;
  z-index: 2;
  display: block;
  box-sizing: border-box;
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  border: 2px solid white;
  border-radius: 50%;
  background: #6e46b0;
  box-shadow: 0 0 0 6px rgba(110, 70, 176, 0.22);
  transform: translate(-50%, -50%);
}
.wish-pin {
  z-index: 1;
  width: 18px;
  height: 18px;
  background: transparent;
  border: 2px dashed #f7f1ff;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.45);
}
.plain-map { position: relative; }
.plain-map-view { position: absolute; inset: 0; overflow: hidden; cursor: grab; touch-action: none; }
.plain-map-tiles, .plain-map-markers { position: absolute; inset: 0; }
.plain-map-tiles img { position: absolute; width: 256px; height: 256px; max-width: none; }
.plain-popup {
  position: absolute;
  z-index: 3;
  min-width: 180px;
  max-width: 280px;
  padding: 14px 28px 12px 14px;
  border-radius: 16px;
  background: #fbf8f4;
  color: #24182c;
  box-shadow: 0 12px 30px rgba(36, 24, 44, 0.18);
  transform: translate(-50%, -100%);
}
.plain-popup-close {
  position: absolute;
  top: 4px;
  right: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: #8d73b8;
  font-size: 18px;
  line-height: 1;
}
.plain-zoom {
  position: absolute;
  left: 10px;
  z-index: 4;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(36, 24, 47, 0.16);
  background: white;
  color: #24182f;
  font-size: 20px;
  line-height: 1;
}
.plain-zoom-in { top: 10px; border-radius: 8px 8px 0 0; }
.plain-zoom-out { top: 41px; border-radius: 0 0 8px 8px; border-top: 0; }
.plain-credit {
  position: absolute;
  right: 8px;
  bottom: 4px;
  z-index: 4;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.82);
  color: #5c4d6e;
  font-size: 11px;
  line-height: 1.3;
}
.map-popup { display: flex; flex-direction: column; gap: 6px; min-width: 180px; }
.map-place {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 22px;
  font-weight: 600;
}
.map-jump {
  padding: 0;
  border: 0;
  background: none;
  color: #4c2f86;
  text-align: left;
  font-size: 14px;
  line-height: 1.35;
}
.map-jump:hover { color: #6e46b0; }
.map-dream {
  margin: 0;
  color: #8d73b8;
  font-family: var(--script);
  font-size: 22px;
}
.wish-card, .scrap-form {
  width: min(720px, 100%);
  margin: 22px auto 0;
  padding: 22px 22px 18px;
  border-radius: 24px;
  background: var(--paper);
  color: var(--ink);
  color-scheme: light;
  box-shadow: var(--shadow);
}
.wish-card h2 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 36px;
  font-weight: 500;
}
.wish-card label, .scrap-form label { display: block; margin: 14px 0 8px; }
.wish-card .hint { color: #8a749f; }
.wish-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.wish-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wish-jump {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 22px;
  text-align: left;
}
.scrap-form { display: flex; flex-direction: column; align-items: flex-start; }
.scrap-form .btn { margin-top: 14px; }
.scrap-preview {
  display: block;
  width: min(220px, 100%);
  margin-top: 12px;
  border-radius: 16px;
}
.scrap-grid {
  width: min(980px, 100%);
  margin: 22px auto 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}
.scrap-card {
  overflow: hidden;
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}
.scrap-card img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
  cursor: zoom-in;
  background: #f3eef8;
}
.scrap-card p {
  margin: 0;
  padding: 12px 14px 0;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.3;
}
.scrap-card .card-foot { padding: 8px 14px 12px; }
.moment-text {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.layout-mosaic .gallery {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 128px;
  gap: 8px;
}
.layout-mosaic .gallery img { height: 100%; }
.layout-mosaic .gallery img:nth-child(3n + 1) {
  grid-column: span 2;
  grid-row: span 2;
}
.gallery img {
  width: 100%;
  height: 210px;
  object-fit: cover;
  border-radius: 16px;
  cursor: zoom-in;
  background: #f3eef8;
}
.gallery.count-1 { grid-template-columns: 1fr; }
.gallery.count-1 > img { height: auto; max-height: 70vh; object-fit: contain; }
.crop-top .gallery > img { object-position: center top; }
.crop-bottom .gallery > img { object-position: center bottom; }
.crop-whole .gallery > img {
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  object-position: center;
  background: #f3eef8;
}
.shot {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  border: 0;
  border-radius: 16px;
  padding: 0;
  background: #f3eef8;
  aspect-ratio: var(--ratio, 1);
  cursor: zoom-in;
}
.gallery .shot img {
  position: absolute;
  left: calc(var(--x) / var(--w) * -100%);
  top: calc(var(--y) / var(--h) * -100%);
  width: calc(100% / var(--w));
  height: calc(100% / var(--h));
  max-width: none;
  max-height: none;
  object-fit: fill;
  border-radius: 0;
}
.layout-mosaic .gallery .shot {
  height: auto;
  grid-column: span 1;
  grid-row: span 1;
}
.layout-mosaic .gallery:has(.shot) { grid-auto-rows: minmax(110px, auto); }
.layout-mosaic.crop-whole .gallery {
  display: block;
  column-count: 2;
  column-gap: 8px;
}
.layout-mosaic.crop-whole .gallery > img {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  margin: 0 0 8px;
  break-inside: avoid;
}
.moment-video {
  display: block;
  width: 100%;
  max-height: 70vh;
  margin-top: 16px;
  border-radius: 16px;
  background: #1b1224;
}
.layouts { display: flex; flex-wrap: wrap; gap: 8px; }
.layouts button {
  border: 1px solid rgba(110, 70, 176, 0.28);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  font-size: 14px;
}
.layouts button[aria-pressed="true"] {
  color: white;
  background: var(--violet);
  border-color: transparent;
}
.card-foot { justify-content: space-between; margin-top: 18px; }
.byline { color: #8d73b8; font-size: 14px; }
.card-actions { display: flex; gap: 4px; }
.edit-box { margin-top: 8px; }
.sheet:not(.is-editing) .edit-box { display: none; }
.sheet.is-editing .moment-text { display: none; }

.composer {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow: auto;
  padding: 28px 16px 40px;
  background: rgba(12, 7, 18, 0.72);
  backdrop-filter: blur(8px);
}
.composer-card {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 28px 28px 22px;
  border-radius: 28px;
  box-shadow: var(--shadow);
  color-scheme: light;
}
.composer-top { justify-content: space-between; align-items: flex-start; }
.composer-card h2 { font-size: 48px; }
.field-label { margin: 18px 0 8px; font-size: 13px; letter-spacing: 0.04em; text-transform: lowercase; }
.attach { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.file-btn, .tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 14px;
  color: var(--violet-deep);
  border: 1px solid rgba(110, 70, 176, 0.25);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
}
.file-btn { cursor: pointer; }
.previews { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.preview {
  position: relative;
  width: 112px;
  height: auto;
  min-height: 72px;
}
.preview img, .preview video { width: 100%; height: 100%; object-fit: cover; object-position: center; border-radius: 12px; }
.preview .shot { height: auto; border-radius: 12px; cursor: default; }
.preview .frame-btn {
  top: auto;
  right: auto;
  bottom: 4px;
  left: 4px;
  width: auto;
  height: auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}
.preview button, #video-preview button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  color: white;
  background: rgba(20, 10, 28, 0.72);
}
#video-preview { position: relative; margin-top: 12px; }
#video-preview video { width: min(100%, 360px); border-radius: 16px; }
.tools, .tool-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tools { margin: 10px 0; }
.swatch {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.16);
}
.swatch[aria-pressed="true"], .tool-btn[aria-pressed="true"] {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
.custom-color input {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  overflow: hidden;
}
.size-label { display: flex; align-items: center; gap: 8px; color: #6d5a82; font-size: 14px; }
.pad {
  width: 100%;
  height: 190px;
  margin-top: 12px;
  border-radius: 16px;
  border: 1px dashed rgba(110, 70, 176, 0.38);
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}
.pad.erasing { cursor: cell; }
.composer-actions {
  position: sticky;
  bottom: 0;
  margin-top: 18px;
  padding-top: 16px;
  background: linear-gradient(transparent, var(--paper) 28%);
}
.date-preview { min-height: 1.2em; margin: 8px 0 0; font-family: var(--serif); font-size: 22px; color: var(--violet); }

.lightbox, .modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 6, 16, 0.88);
}
.lightbox img {
  max-width: min(1100px, 92vw);
  max-height: calc(100vh - 90px);
  object-fit: contain;
  border-radius: 12px;
}
.lightbox-close, .lightbox-arrow {
  position: absolute;
  border: 0;
  color: white;
  background: rgba(255, 255, 255, 0.08);
}
.lightbox-close { top: 18px; right: 18px; border-radius: 999px; padding: 8px 14px; }
.lightbox-arrow {
  top: 50%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 30px;
}
.lightbox-arrow.left { left: 16px; }
.lightbox-arrow.right { right: 16px; }
.modal-card { width: min(440px, 100%); padding: 28px; border-radius: 24px; }
.modal-card p { margin: 0; font-family: var(--serif); font-size: 28px; line-height: 1.25; }

.toast {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: 24px;
  max-width: min(440px, calc(100% - 32px));
  padding: 12px 16px;
  border-radius: 999px;
  color: white;
  background: rgba(36, 24, 50, 0.92);
  box-shadow: var(--shadow);
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: 0.3s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

.cropper {
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow: auto;
  padding: 24px 16px 32px;
  background: rgba(12, 7, 18, 0.82);
  backdrop-filter: blur(8px);
}
.cropper-card {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 22px 18px 18px;
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
  color-scheme: light;
}
.cropper-card h2 { margin: 0; font-size: 42px; }
.crop-stage {
  position: relative;
  margin: 14px auto 0;
  touch-action: none;
  user-select: none;
  background: #1b1224;
}
.crop-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}
.crop-box {
  position: absolute;
  border: 2px solid white;
  box-shadow: 0 0 0 9999px rgba(18, 10, 24, 0.62);
  cursor: move;
  touch-action: none;
}
.crop-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to right, transparent 33.2%, rgba(255, 255, 255, 0.9) 33.2% calc(33.2% + 1px), transparent calc(33.2% + 1px) 66.5%, rgba(255, 255, 255, 0.9) 66.5% calc(66.5% + 1px), transparent calc(66.5% + 1px)),
    linear-gradient(to bottom, transparent 33.2%, rgba(255, 255, 255, 0.9) 33.2% calc(33.2% + 1px), transparent calc(33.2% + 1px) 66.5%, rgba(255, 255, 255, 0.9) 66.5% calc(66.5% + 1px), transparent calc(66.5% + 1px));
}
.crop-box span {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid white;
  background: rgba(110, 70, 176, 0.35);
}
.crop-box span[data-handle="nw"] { top: -8px; left: -8px; cursor: nwse-resize; }
.crop-box span[data-handle="ne"] { top: -8px; right: -8px; cursor: nesw-resize; }
.crop-box span[data-handle="sw"] { bottom: -8px; left: -8px; cursor: nesw-resize; }
.crop-box span[data-handle="se"] { bottom: -8px; right: -8px; cursor: nwse-resize; }
.crop-box span[data-handle="n"],
.crop-box span[data-handle="s"] { left: 50%; width: 42px; height: 12px; margin-left: -21px; cursor: ns-resize; }
.crop-box span[data-handle="n"] { top: -7px; }
.crop-box span[data-handle="s"] { bottom: -7px; }
.crop-box span[data-handle="e"],
.crop-box span[data-handle="w"] { top: 50%; width: 12px; height: 42px; margin-top: -21px; cursor: ew-resize; }
.crop-box span[data-handle="e"] { right: -7px; }
.crop-box span[data-handle="w"] { left: -7px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 760px) {
  .nav {
    top: auto;
    bottom: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    border-bottom: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }
  .brand span, .who { display: none; }
  .nav-links { width: 100%; flex-wrap: wrap; justify-content: center; row-gap: 0; }
  .nav-links button { padding: 6px 8px; font-size: 13px; }
  .view { padding: 28px 14px 132px; }
  .sheet { scroll-margin-top: 20px; scroll-margin-bottom: 96px; }
  .letter { padding: 34px 22px 28px; }
  .letter-lead { font-size: 22px; }
  .letter-note { font-size: 18px; }
  .letter-close { font-size: 30px; }
  .features, .attach, .layout-story .sheet-body,
  .layout-columns .collage, .layout-flip .collage { grid-template-columns: 1fr; }
  .layout-note .collage-text {
    position: static;
    max-width: none;
    padding: 0;
    background: transparent;
    box-shadow: none;
    transform: none;
  }
  .layout-mosaic .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 110px; }
  .layout-mosaic.crop-whole .gallery { column-count: 1; }
  .letter h1 { font-size: 44px; }
  .dayline { font-size: 32px; }
  .love-map { height: calc(100vh - 220px); }
  .login-card { padding: 32px 20px 24px; }
  .login-card h1 { font-size: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .sheet { opacity: 1; transform: none; filter: none; }
}
