/* まちの切手帳：机の上に開いた切手帳。紙は温かい白、インクは藍。切手の色がいちばん目立つように周りは静かにする */
:root {
  --desk: #ece7dc;
  --page: #faf8f3;
  --strip: rgba(255, 255, 255, .55);
  --ink: #1f2540;
  --ink-soft: rgba(31, 37, 64, .6);
  --ink-faint: rgba(31, 37, 64, .22);
  --indigo: #24345c;
  --vermilion: #c2492f;
  --serif: "Shippori Mincho B1", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --sans: "Zen Kaku Gothic New", "Hiragino Sans", system-ui, sans-serif;
  --sheet-ratio: 856 / 1218;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
p { margin: 0; }

.view {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- 切手帳 ---------- */

.album-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 22px 22px 14px;
}
.album-head h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 23px;
  letter-spacing: .14em;
}
.count { margin-top: 4px; font-size: 12.5px; color: var(--ink-soft); letter-spacing: .04em; }
.pageno { font-family: var(--serif); font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.head-right { display: flex; align-items: center; gap: 6px; }
/* 共有：箱から上へ出る矢印 */
.page-share {
  position: relative;
  width: 40px; height: 40px;
  margin: -8px -10px -8px 0;
  border: 0;
  background: linear-gradient(var(--ink), var(--ink)) 19.2px 10px / 1.6px 14px no-repeat;
}
.page-share::before {
  content: "";
  position: absolute;
  left: 13px; top: 17px;
  width: 14px; height: 12px;
  border: 1.6px solid var(--ink);
  border-top: 0;
  border-radius: 0 0 2px 2px;
}
.page-share::after {
  content: "";
  position: absolute;
  left: 15.5px; top: 9px;
  width: 9px; height: 9px;
  border-left: 1.6px solid var(--ink);
  border-top: 1.6px solid var(--ink);
  transform: rotate(45deg);
}

.pages {
  flex: 1;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.pages::-webkit-scrollbar { display: none; }

.page {
  flex: 0 0 100%;
  scroll-snap-align: center;
  padding: 0 14px;
}
.grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 22px;
  padding: 20px 28px 22px;
  width: min(100%, calc(0.4687 * (100dvh - 284px) + 78px));
  margin: 0 auto;
  background: var(--page);
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 10px 30px -12px rgba(60, 45, 25, .25), 0 1px 2px rgba(60, 45, 25, .12);
}
/* 切手帳のポケット：各段の下半分に、薄い帯を切手の後ろに敷く。隣の帯とつなげて1本に見せる */
.slot::before {
  content: "";
  position: absolute;
  top: 46%;
  bottom: -4px;
  z-index: -1;
  background: rgba(31, 37, 64, .045);
  border-top: 1px solid rgba(255, 255, 255, .9);
  box-shadow: 0 -1px 0 rgba(31, 37, 64, .06);
}
.slot:nth-child(odd)::before { left: -28px; right: -11px; }
.slot:nth-child(even)::before { left: -11px; right: -28px; }

.slot {
  position: relative;
  z-index: 1;
  aspect-ratio: var(--sheet-ratio);
  display: grid;
  place-items: center;
}
.slot.empty {
  outline: 1px dashed var(--ink-faint);
  outline-offset: -6px;
}
.slot.empty span {
  font-family: var(--serif);
  font-size: 18px;
  color: var(--ink-faint);
}
.slot.next { outline-color: rgba(36, 52, 92, .45); cursor: pointer; }
.slot.next span { color: var(--indigo); font-size: 20px; }
.slot.next::after {
  content: "";
  position: absolute;
  inset: auto 0 14% 0;
  margin: auto;
  width: 18px; height: 18px;
  background:
    linear-gradient(var(--indigo), var(--indigo)) center / 100% 1.5px no-repeat,
    linear-gradient(var(--indigo), var(--indigo)) center / 1.5px 100% no-repeat;
  opacity: .55;
}
.slot.invite { animation: invite 2.4s ease-in-out 2; }
@keyframes invite {
  0%, 100% { background: transparent; }
  50% { background: rgba(36, 52, 92, .06); }
}

.slot.sample { cursor: pointer; }
.slot.sample img { width: 100%; opacity: .5; filter: saturate(.8) drop-shadow(0 2px 3px rgba(40,30,20,.12)); }
.slot.sample span {
  position: absolute;
  top: 40%;
  padding: 3px 10px;
  border: 1px solid var(--vermilion);
  color: var(--vermilion);
  background: rgba(250, 248, 243, .85);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: .3em;
  transform: rotate(-8deg);
}

.stamp {
  position: relative;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  transform: rotate(var(--tilt, 0deg));
  transition: transform .2s;
}
.stamp img {
  display: block;
  width: 100%;
  filter: drop-shadow(0 1.5px 2px rgba(40, 30, 20, .2));
}
.stamp:active { transform: rotate(var(--tilt, 0deg)) scale(.96); }
.stamp.pressed { animation: pressed .45s ease-out; }
@keyframes pressed {
  0% { transform: rotate(var(--tilt)) scale(1.08); }
  45% { transform: rotate(var(--tilt)) scale(.97); }
  100% { transform: rotate(var(--tilt)) scale(1); }
}

.dots { display: flex; justify-content: center; gap: 7px; height: 22px; align-items: center; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-faint); }
.dots i.on { background: var(--indigo); }
.credit { font-size: 10px; color: var(--ink-soft); opacity: .7; }
.foot { text-align: center; font-size: 10.5px; color: var(--ink-soft); padding: 2px 16px 4px; letter-spacing: .02em; }
.foot a { color: inherit; text-decoration: none; padding: 4px; }

.dock {
  position: sticky;
  bottom: 0;
  padding: 10px 22px calc(16px + env(safe-area-inset-bottom, 0px));
  margin-bottom: calc(-1 * env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to bottom, rgba(236, 231, 220, 0), var(--desk) 30%);
}
.make, .primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 17px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--indigo);
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: .12em;
  box-shadow: 0 8px 20px -8px rgba(36, 52, 92, .6);
  transition: transform .15s;
}
.make:active, .primary:active { transform: scale(.98); }
.make-plus {
  width: 14px; height: 14px;
  background:
    linear-gradient(#fff, #fff) center / 100% 1.6px no-repeat,
    linear-gradient(#fff, #fff) center / 1.6px 100% no-repeat;
}
.ghost {
  width: 100%;
  padding: 14px;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 14.5px;
  letter-spacing: .08em;
}
.ghost.danger { color: var(--vermilion); }

/* 残りの枚数：つくるボタンの右に小さく */
.make-credits {
  margin-left: 2px;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, .3);
  font-size: 11.5px;
  font-weight: 400;
  letter-spacing: .06em;
  opacity: .78;
  white-space: nowrap;
}

/* ログインの入口とログイン中の表示：見出しの下に控えめに */
.account { margin-top: 6px; font-size: 11.5px; color: var(--ink-soft); letter-spacing: .04em; }
.account-login {
  padding: 3px 0;
  border: 0;
  border-bottom: 1px solid rgba(36, 52, 92, .35);
  background: none;
  color: var(--indigo);
  font-size: 11.5px;
  letter-spacing: .06em;
}
.account-on {
  display: inline-block;
  max-width: 62vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.account-on::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--indigo);
  opacity: .55;
  vertical-align: 1px;
}
.foot-logout { border: 0; background: none; padding: 4px; margin-left: 4px; font-size: inherit; color: inherit; }

/* 購入の小さな画面：下から出る1枚の紙 */
.shade {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(31, 37, 64, .28);
  animation: fade .2s ease-out both;
}
@keyframes fade { from { opacity: 0; } }
.buy {
  width: min(100%, 440px);
  padding: 26px 22px calc(12px + env(safe-area-inset-bottom, 0px));
  border-radius: 16px 16px 0 0;
  background: var(--page);
  box-shadow: 0 -10px 30px -12px rgba(60, 45, 25, .35);
  display: grid;
  gap: 12px;
  animation: rise .28s ease-out both;
}
.buy-title { font-family: var(--serif); font-weight: 700; font-size: 19px; letter-spacing: .1em; text-align: center; }
.buy-lead { font-size: 12.5px; line-height: 1.7; color: var(--ink-soft); text-align: center; }
.packs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.pack {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 16px 8px 13px;
  border: 1px solid rgba(36, 52, 92, .28);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
button.pack { box-shadow: 0 6px 16px -10px rgba(36, 52, 92, .55); transition: transform .15s; }
button.pack:active { transform: scale(.97); }
button.pack:disabled { opacity: .5; }
.pack-n { font-family: var(--serif); font-weight: 700; font-size: 30px; line-height: 1.1; color: var(--indigo); }
.pack-n small { font-size: 13px; margin-left: 2px; }
.pack-yen { font-size: 16px; font-weight: 500; letter-spacing: .04em; }
.pack-per { font-size: 11px; color: var(--ink-soft); }
.buy-note { font-size: 11.5px; color: var(--ink-soft); text-align: center; }
.buy .ghost { padding: 10px; }

/* ---------- 刷る ---------- */

.press-head {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: 10px 10px 0;
}
.press-title {
  text-align: center;
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: .14em;
  color: var(--ink-soft);
}
.back {
  width: 44px; height: 44px;
  border: 0;
  background: none;
  position: relative;
}
.back::before {
  content: "";
  position: absolute;
  left: 17px; top: 16px;
  width: 11px; height: 11px;
  border-left: 1.8px solid var(--ink);
  border-bottom: 1.8px solid var(--ink);
  transform: rotate(45deg);
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 0 12px;
}
.hint { font-size: 12px; color: var(--ink-soft); letter-spacing: .04em; }

.sheet {
  position: relative;
  width: min(68vw, 300px, calc((100dvh - 330px) * 856 / 1218));
  aspect-ratio: var(--sheet-ratio);
  background-size: 100% 100%;
  container-type: inline-size;
  filter: drop-shadow(0 14px 22px rgba(60, 45, 25, .22)) drop-shadow(0 1px 1px rgba(60, 45, 25, .15));
  transition: transform .5s cubic-bezier(.3, .7, .2, 1);
}
.sheet.printed { transform: rotate(-1.2deg); }
.window {
  position: absolute;
  left: calc(44 / 856 * 100%);
  top: calc(44 / 1218 * 100%);
  width: calc(768 / 856 * 100%);
  height: calc(1024 / 1218 * 100%);
  overflow: hidden;
  outline: 1px solid rgba(31, 37, 64, .5);
  touch-action: none;
  background: #e9e3d6;
}
#photo {
  position: absolute;
  left: 0; top: 0;
  max-width: none;
  user-select: none;
  -webkit-user-select: none;
  transition: filter .6s;
}
#photo.plate { filter: grayscale(1) contrast(.75) brightness(1.15) sepia(.25); }
#art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#art.reveal { animation: reveal 1.1s cubic-bezier(.45, 0, .25, 1) both; }
@keyframes reveal {
  from { clip-path: inset(0 0 100% 0); }
  to { clip-path: inset(0 0 0 0); }
}

/* 刷りのローラー：インクの帯が上から下へ通る */
.roller {
  position: absolute;
  left: -2%; right: -2%;
  height: 16%;
  top: -16%;
  background: linear-gradient(to bottom,
    rgba(36, 52, 92, 0) 0%, rgba(36, 52, 92, .18) 55%, rgba(36, 52, 92, .55) 92%, rgba(250, 248, 243, .9) 96%, rgba(36, 52, 92, 0) 100%);
  pointer-events: none;
}
.roller.loop { animation: roll 1.6s cubic-bezier(.45, 0, .25, 1) infinite; }
.roller.final { animation: roll 1.1s cubic-bezier(.45, 0, .25, 1) 1 both; }
@keyframes roll {
  from { top: -16%; }
  to { top: 100%; }
}

.label {
  position: absolute;
  left: calc(44 / 856 * 100%);
  right: calc(44 / 856 * 100%);
  top: calc(1068 / 1218 * 100%);
  bottom: 0;
  display: flex;
  justify-content: space-between;
  gap: 3cqw;
}
.label-main { min-width: 0; padding-top: 2.4cqw; }
.label-place {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 5.84cqw;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.label-date {
  margin-top: 1.6cqw;
  font-size: 2.8cqw;
  letter-spacing: .35cqw;
  color: var(--ink-soft);
  font-weight: 500;
}
.label-no {
  flex: none;
  padding-top: 1.2cqw;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 8.9cqw;
  line-height: 1;
}
.label-no small {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 2.6cqw;
  color: var(--ink-soft);
  margin-right: 1cqw;
}

.press-form, .press-done, .detail-actions, .press-status {
  padding: 0 22px calc(18px + env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 10px;
  min-height: 150px;
  align-content: end;
}
.press-form { grid-template-columns: 1fr auto; }
.press-form .primary { grid-column: 1 / -1; margin-top: 4px; }
.field {
  display: grid;
  gap: 4px;
  padding: 9px 14px 10px;
  border-radius: 12px;
  background: var(--page);
  box-shadow: 0 0 0 1px rgba(31, 37, 64, .08);
}
.field span { font-size: 11px; color: var(--ink-soft); letter-spacing: .06em; }
.field em { font-style: normal; margin-left: 8px; color: var(--indigo); opacity: .75; }
.field input {
  width: 100%;
  border: 0;
  padding: 0;
  background: none;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  outline: none;
}
.field input::placeholder { color: rgba(31, 37, 64, .3); font-weight: 500; }
.field-date input { font-family: var(--sans); font-size: 15px; font-weight: 500; min-height: 23px; }
.field:focus-within { box-shadow: 0 0 0 1.5px var(--indigo); }

.press-status { align-content: center; justify-items: center; }
.press-status p {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: .2em;
  color: var(--ink-soft);
  animation: breathe 2.2s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: .45; } }

.press-done { animation: rise .4s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- 1枚を見る ---------- */

.flip {
  width: min(78vw, 340px, calc((100dvh - 280px) * 856 / 1218));
  aspect-ratio: var(--sheet-ratio);
  perspective: 1400px;
  cursor: pointer;
}
.flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.3, .7, .2, 1);
}
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip-front, .flip-back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.flip-front { filter: drop-shadow(0 14px 22px rgba(60, 45, 25, .22)); }
.flip-back {
  transform: rotateY(180deg);
  background: var(--page);
  padding: 6%;
  display: flex;
  flex-direction: column;
  gap: 5%;
  box-shadow: 0 14px 30px -10px rgba(60, 45, 25, .3);
}
.flip-back img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.flip-back p { font-family: var(--serif); font-size: 14px; color: var(--ink-soft); letter-spacing: .06em; }

/* ---------- 共通 ---------- */

.flyer {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  transform-origin: 0 0;
}
.flyer img { width: 100%; height: 100%; display: block; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 40px);
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(31, 37, 64, .92);
  color: #fff;
  font-size: 13px;
  z-index: 30;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------- 文書のページ（ご利用について、共通部品が作るプライバシーポリシーなど） ---------- */
body.doc, body:has(> main > h1) { background: var(--page); }
main:has(> h1) { max-width: 40rem; margin: 0 auto; padding: 32px 20px 56px; line-height: 1.85; font-size: 15px; }
main:has(> h1) h1 { font-family: var(--serif); font-size: 24px; letter-spacing: .08em; margin: 0 0 6px; }
main:has(> h1) h2 { font-family: var(--serif); font-size: 17px; margin: 30px 0 8px; }
main:has(> h1) p, main:has(> h1) li { margin: 0 0 10px; }
main:has(> h1) a { color: var(--indigo); }
