:root {
  --ink: #241e18;
  --muted: #6e6458;
  --ivory: #f6f0e4;
  --paper: #f7f3ea;
  --line: rgba(48, 36, 22, .14);
  --gold: #b08948;
  --cloth: #24362c;
  --cloth-deep: #1a2920;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background-color: #6e5038;
  background-image:
    radial-gradient(ellipse at 50% 18%, rgba(255, 232, 204, .28), transparent 42%),
    radial-gradient(ellipse at 50% 120%, rgba(20, 10, 4, .45), transparent 46%),
    repeating-linear-gradient(90deg, rgba(40, 22, 8, .045) 0 1px, transparent 1px 7px),
    linear-gradient(180deg, #d7b894, #8d684c 46%, #4e3426);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.svg-defs { position: absolute; }

/* ── studio ── */
#studio {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(380px, 560px) minmax(260px, 1fr);
  gap: 16px;
  padding: 12px 16px;
  align-items: stretch;
}
.panel {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: rgba(247, 241, 230, .96);
  border-radius: 16px;
  padding: 12px 14px 8px;
  box-shadow: 0 18px 50px rgba(40, 22, 8, .22);
}
.eyebrow {
  margin: 0 0 6px;
  letter-spacing: .22em;
  text-transform: uppercase;
  font-family: Outfit, sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: var(--gold);
}
h1 {
  margin: 0 0 4px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 500;
  font-size: 32px;
  letter-spacing: -.02em;
}
.lead, .fine, .preview-cap { color: var(--muted); }
.lead { margin: 0 0 10px; line-height: 1.4; font-size: 13px; }
.fine { margin: 4px 0 0; font-size: 12px; line-height: 1.4; }
.names, .model-row { display: flex; gap: 10px; }
.names label, .model-row label, .block { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: #4e463c; }
.names { margin-bottom: 8px; }
.names label { flex: 1; }
.block { margin-top: 8px; }
input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  border: 1px solid rgba(48, 36, 22, .16);
  background: #fffdf9;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 400;
  color: var(--ink);
}
textarea { resize: none; line-height: 1.45; font-size: 13.5px; }
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(176, 137, 72, .45); border-color: transparent; }
.slot-head, .cloth-row, .slot-actions, .actions, .model-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.slot-head { margin: 4px 0 8px; font-size: 12.5px; font-weight: 600; color: #4e463c; }
.slots {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.slot {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px dashed rgba(48, 36, 22, .28);
  background: rgba(255, 255, 255, .45);
  overflow: hidden;
  padding: 0;
}
.slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slot .n {
  position: absolute; left: 5px; top: 4px;
  font-family: Outfit, sans-serif; font-size: 10px; letter-spacing: .08em;
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.slot .pen {
  position: absolute; right: 4px; top: 4px;
  border: 0; border-radius: 999px;
  background: rgba(255,255,255,.86);
  font-size: 10px; padding: 2px 5px;
  color: #6a5a3a;
}
.slot .pen.on { background: #241e18; color: #f3e6c4; }
.slot .x {
  position: absolute; right: 4px; bottom: 4px;
  width: 18px; height: 18px; border: 0; border-radius: 50%;
  background: rgba(0,0,0,.45); color: #fff; line-height: 18px; padding: 0;
}
.slot-actions { justify-content: flex-start; margin-top: 8px; }
.text-btn {
  border: 0; background: transparent; padding: 0;
  color: #6d5430; font-weight: 600; font-size: 13px;
  text-decoration: underline; text-underline-offset: 3px;
}
.swatches { display: flex; gap: 8px; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2);
  padding: 0;
}
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.cloth-row { justify-content: flex-start; margin-top: 8px; font-size: 12.5px; font-weight: 600; color: #4e463c; }
.key-row { display: flex; align-items: flex-end; gap: 8px; }
.key-row .block { flex: 1; margin-top: 8px; }
.key-row .btn { flex: 0 0 auto; margin-bottom: 1px; padding: 10px 14px; }
.model-row { margin-top: 10px; align-items: end; }
.model-row label { font-weight: 600; }
.model-row .grow { flex: 1; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; color: #4e463c; font-weight: 500; }
.check input { accent-color: #24362c; }
.actions { margin-top: 10px; justify-content: flex-start; }
.btn {
  border: 0; border-radius: 999px; padding: 12px 18px; font-weight: 600;
}
.btn.primary { background: #24362c; color: #f6f0e4; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px rgba(36,30,24,.3); }
.btn:disabled { opacity: .45; cursor: default; }
.status { min-height: 0; margin: 4px 0 0; font-size: 13px; }
.preview-col {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  perspective: 1600px;
}
.preview {
  width: auto;
  height: min(74vh, 620px);
  aspect-ratio: 4 / 5.2;
  filter: none;
}
.case {
  position: relative;
  width: 100%;
  height: 100%;
  transform: rotateX(7deg) rotateY(-18deg);
  transform-style: preserve-3d;
}
.case-pages {
  position: absolute;
  z-index: 0;
  left: 8%;
  right: 0;
  top: 2.4%;
  bottom: 2.4%;
  border-radius: 0 3px 3px 0;
  background:
    linear-gradient(90deg, rgba(20, 12, 6, .22), transparent 14px),
    repeating-linear-gradient(#f8f3e8 0 1px, #e5d9c2 1px 2px);
  box-shadow: 2px 0 0 #c6a96a, 14px 22px 26px rgba(24, 12, 6, .34);
}
.case-pages::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0; height: 6px;
  background: repeating-linear-gradient(90deg, #7d3140 0 7px, #c6a15b 7px 10px, #f6f1e6 10px 13px);
}
.case .cover-face {
  position: absolute;
  z-index: 1;
  left: 0; top: 0; bottom: 0;
  width: calc(100% - 16px);
  border-radius: 2px 4px 4px 2px;
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,.32),
    inset -12px 0 18px rgba(0,0,0,.18),
    inset 0 -10px 14px rgba(0,0,0,.14);
}
.case-ribbon {
  position: absolute;
  z-index: 2;
  top: 16%;
  right: 22px;
  width: 10px;
  height: 42%;
  background: linear-gradient(90deg, #6a2c36, #b25a66 42%, #5a2430);
  border-radius: 0 0 2px 2px;
  box-shadow: 1px 3px 3px rgba(0,0,0,.28);
  pointer-events: none;
}
.preview-cap { margin: 0; font-size: 13px; color: #f6efe6; text-shadow: 0 1px 2px rgba(0,0,0,.25); text-align: center; }
.preview:has(.case-open) {
  height: min(52vh, 420px);
  aspect-ratio: 8 / 5;
  width: min(100%, 680px);
}
.case-open { transform: rotateX(5deg) rotateY(-10deg); }
.sample-book {
  position: absolute; inset: 0;
  display: flex;
  background: #f4efe6;
  box-shadow:
    0 0 0 8px var(--cloth),
    0 0 0 9px rgba(0,0,0,.28),
    0 18px 28px rgba(24, 12, 6, .34);
}
.sample-book > .page { position: relative; width: 50%; height: 100%; flex: none; }

/* ── cover ── */
.cover-face {
  position: relative;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 28% 0%, rgba(255,255,255,.2), transparent 36%),
    linear-gradient(180deg, rgba(255,255,255,.08), transparent 28%),
    var(--cf, var(--cloth));
  color: var(--cg, #e6d3a1);
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,.22),
    inset -2px -2px 4px rgba(0,0,0,.22);
}
.cover-face .linen {
  position: absolute; inset: 0;
  filter: url(#linen);
  opacity: .55;
  mix-blend-mode: overlay;
  pointer-events: none;
}
.cover-face::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 22px;
  background: linear-gradient(90deg, rgba(0,0,0,.5), rgba(255,255,255,.08) 18%, rgba(0,0,0,.16) 46%, transparent 100%);
}
.cover-face::after {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(118deg, transparent 30%, rgba(255,255,255,.16) 46%, transparent 54%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.04) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(0deg, rgba(0,0,0,.05) 0 1px, transparent 1px 4px);
}
.cover-inner {
  position: relative; z-index: 1;
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 14% 12% 18%;
}
.cov-kicker {
  font-family: Outfit, sans-serif;
  font-weight: 500;
  letter-spacing: .34em;
  font-size: 11px;
  text-indent: .34em;
}
.cov-icon { width: 34px; height: 34px; margin: 16px 0 10px; }
.cov-icon svg { width: 100%; height: 100%; display: block; }
.cov-rule { width: 42px; height: 1px; margin: 8px auto 10px; background: currentColor; opacity: .7; }
.foil {
  background: linear-gradient(100deg, #8a642e 0%, #f8f1d4 18%, #c4964a 34%, #fff8df 46%, #a67c38 58%, #f3e4b4 74%, #7a5a28 100%);
  background-size: 180% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.cov-name {
  font-family: "Great Vibes", cursive;
  font-size: clamp(42px, 6vw, 64px);
  line-height: .95;
  margin-top: 4px;
  filter: drop-shadow(0 1px 0 rgba(80, 50, 10, .25));
}
.cov-kr {
  margin-top: 6px;
  font-size: 14px;
  letter-spacing: .18em;
  opacity: .9;
}
.cov-line {
  margin-top: 16px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 16px;
  letter-spacing: .04em;
  opacity: .92;
}
.cov-foot {
  position: absolute; bottom: 8%;
  font-family: Outfit, sans-serif;
  letter-spacing: .28em;
  font-size: 11px;
  text-indent: .28em;
}

/* ── reader ── */
#reader { height: 100vh; display: flex; flex-direction: column; }
#reader[hidden], #studio[hidden], #busy[hidden], #toast[hidden] { display: none !important; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 16px;
  background: rgba(247, 241, 230, .94);
}
.top-actions { display: flex; align-items: center; gap: 14px; }
.dl-pop { position: relative; }
.dl-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  width: 220px; max-height: min(46vh, 320px); overflow: auto;
  overscroll-behavior: contain;
  background: #f7f1e6; border-radius: 12px;
  box-shadow: 0 12px 32px rgba(24, 12, 6, .28);
  padding: 8px;
}
.dl-menu button {
  display: block; width: 100%; text-align: left;
  border: 0; background: transparent; border-radius: 8px;
  padding: 7px 8px; font-size: 13px;
}
.dl-menu button:hover { background: rgba(36, 54, 44, .08); }
.who { font-family: "Cormorant Garamond", Georgia, serif; font-size: 22px; }
.flash-check { margin: 0; }
.reader-body {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 1fr 332px;
}
.stage {
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 236, 210, .16), transparent 48%),
    radial-gradient(ellipse at 50% 108%, rgba(0,0,0,.32), transparent 42%);
}
.book-slot {
  position: relative;
  flex: 1; min-height: 0;
  display: grid; place-items: center;
  padding: 10px 28px 6px;
}
.book-slot::after {
  content: "";
  position: absolute;
  left: 22%; right: 22%; bottom: 4%;
  height: 22px;
  background: radial-gradient(ellipse, rgba(16, 8, 2, .42), transparent 72%);
  filter: blur(5px);
  pointer-events: none;
  z-index: 0;
}
.persp { position: relative; z-index: 1; perspective: 2400px; width: 100%; height: 100%; display: grid; place-items: center; }
.open-book { transform-style: preserve-3d; user-select: none; }
.book-slot.is-closed .open-book { pointer-events: none; }
.book-slot.is-closed .leaf { pointer-events: auto; }
.board { width: 100%; }
.board { height: 100%; transform-style: preserve-3d; }
.sheets {
  position: relative;
  height: 100%;
  display: flex;
  transform-style: preserve-3d;
  background: transparent;
  border-radius: 2px;
}
.book-slot.is-open .sheets {
  background: #f3eee4;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.35),
    0 0 0 11px var(--cloth),
    0 0 0 12px rgba(0,0,0,.35),
    15px 0 0 #f4efe2,
    17px 0 0 #c6a96a,
    -15px 0 0 #f4efe2,
    -17px 0 0 #c6a96a,
    0 16px 0 #eadfcb,
    0 18px 0 #c6a96a,
    0 26px 36px rgba(28, 14, 6, .36);
}
.sheet { width: 50%; height: 100%; position: relative; }
.page {
  position: absolute; inset: 0; overflow: hidden;
  background: var(--paper);
}
.page::before {
  content: "";
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  opacity: .12;
  filter: url(#paperfiber);
  mix-blend-mode: multiply;
}
.page.paper-cream { background: #f7f1e6; }
.page.paper-warm { background: #f3e6d4; }
.page.paper-blush { background: #f6ebe6; }
.page.paper-sage { background: #e7eee6; }
.page.paper-mist { background: #eef1f4; }
.page.paper-ivory { background: #fbf8f2; }
.sheets::after {
  content: "";
  position: absolute; top: 0; bottom: 0; left: 50%; width: 22px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(60,40,20,.05) 30%, rgba(40,24,10,.16), rgba(60,40,20,.05) 70%, transparent);
  pointer-events: none; z-index: 5;
}
.book-slot.is-closed .sheets::after,
.book-slot.is-closed .nav,
.book-slot.is-closed .curl { visibility: hidden; }

.leaf {
  display: none;
  position: absolute; top: 0; bottom: 0; width: 50%;
  z-index: 4;
  transform-style: preserve-3d;
  --sh: 0;
  --hi: 0;
}
.leaf.show { display: block; }
.leaf.fwd { left: 50%; transform-origin: left center; }
.leaf.rev { left: 0; transform-origin: right center; }
.face {
  position: absolute; inset: 0;
  z-index: 1;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: visible;
}
.face.back { transform: rotateY(180deg); }
.face-clip { position: absolute; inset: 0; overflow: hidden; background: #f7f1e6; }
.leaf .edge {
  position: absolute; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(#fffaf3, #e7d7b0 42%, #cbb98a);
  pointer-events: none;
}
.leaf.fwd .edge { right: 0; transform-origin: right center; transform: rotateY(90deg); }
.leaf.rev .edge { left: 0; transform-origin: left center; transform: rotateY(-90deg); }
.leaf.fwd .face.front::after,
.leaf.rev .face.back::after {
  content: "";
  position: absolute; inset: 0; z-index: 6; pointer-events: none;
  background: linear-gradient(90deg, rgba(30,18,8,var(--sh)), rgba(255,248,230,var(--hi)) 7%, transparent 34%);
}
.leaf.rev .face.front::after,
.leaf.fwd .face.back::after {
  content: "";
  position: absolute; inset: 0; z-index: 6; pointer-events: none;
  background: linear-gradient(270deg, rgba(30,18,8,var(--sh)), rgba(255,248,230,var(--hi)) 7%, transparent 34%);
}
.book-slot.is-closed .leaf { cursor: pointer; }
.book-slot.is-closed .leaf::after {
  content: "";
  position: absolute;
  z-index: 0;
  left: calc(100% - 4px);
  width: 18px;
  top: 2.4%;
  bottom: 2.4%;
  border-radius: 0 2px 2px 0;
  background:
    linear-gradient(90deg, rgba(20, 12, 6, .2), transparent 7px),
    repeating-linear-gradient(#f8f3e8 0 1px, #e4d7bf 1px 2px);
  box-shadow: 2px 0 0 #c6a96a, 10px 16px 18px rgba(20, 10, 4, .22);
  pointer-events: none;
}
.book-slot.is-closed .leaf::before {
  content: "";
  position: absolute;
  z-index: 3;
  left: calc(100% - 4px);
  width: 18px;
  top: 2.4%;
  height: 7px;
  background: repeating-linear-gradient(90deg, #7d3140 0 6px, #c6a15b 6px 9px, #f7f2e6 9px 12px);
  pointer-events: none;
}
.book-slot.is-closed .cover-face {
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,.28),
    inset -2px 0 4px rgba(0,0,0,.2),
    1px 0 0 #f7f2e6, 2px 0 0 #e6dcc6, 3px 0 0 #f4efe2,
    4px 0 0 #dccdb0, 5px 0 0 #f3ead8, 6px 0 0 #cbb892,
    7px 0 0 #efe4cc, 8px 0 0 #c6a96a, 10px 0 0 #efe6d2,
    12px 0 0 #b89a58, 16px 20px 32px rgba(24, 12, 6, .4);
}

.nav {
  position: absolute; top: 50%; width: 42px; height: 42px;
  margin-top: -21px; z-index: 7;
  border: 0; border-radius: 50%;
  background: rgba(255,255,255,.55);
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  color: rgba(36, 30, 24, .55);
  font-family: Georgia, serif; font-size: 28px; line-height: 1;
}
.nav.prev { left: 8px; }
.nav.next { right: 8px; }
.nav.prev::before { content: "‹"; display: block; margin-top: -2px; }
.nav.next::before { content: "›"; display: block; margin-top: -2px; }
.nav:disabled { opacity: 0; pointer-events: none; }
.curl {
  position: absolute; right: 0; bottom: 0; width: 72px; height: 72px; z-index: 8;
  border: 0; padding: 0; background:
    linear-gradient(135deg, transparent 48%, rgba(255,255,255,.65) 54%, rgba(90,60,30,.16) 100%);
  cursor: grab;
}
.open-hint {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  margin: 0; padding: 7px 14px; border-radius: 999px;
  background: rgba(28, 20, 12, .45); color: #f6efe6;
  font-size: 13px; backdrop-filter: blur(6px);
}

/* pages */
.dedi, .index-page, .letter, .quiet {
  position: absolute; inset: 0;
}
.dedi {
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 10% 9% 12%;
}
.dedi .year {
  font-family: "Cormorant Garamond", Georgia, serif;
  letter-spacing: .16em; font-size: clamp(16px, 2.4vh, 26px);
}
.dedi .brand {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(26px, 3.4vh, 40px); margin-top: 2px;
}
.dedi .from {
  margin-top: 18px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(16px, 2.2vh, 24px); color: #4a453e;
}
.dedi .to-name {
  font-family: "Great Vibes", cursive;
  font-size: clamp(40px, 5.4vh, 62px);
  line-height: .9; margin-top: 4px;
}
.dedi .kr {
  margin-top: 6px; letter-spacing: .14em; color: #6e6458; font-size: 13px;
}
.index-page { display: flex; flex-direction: column; padding: 6.5% 6% 5%; }
.index-page h2 {
  margin: 0; font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 500; font-size: clamp(22px, 3vh, 34px);
}
.index-page .sub { margin: 2px 0 8px; color: #8a8175; font-size: 12px; letter-spacing: .08em; }
.thumbs {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(4, 1fr);
  gap: 7px;
}
.thumb {
  min-height: 0; display: flex; flex-direction: column;
  border: 0; background: #fff; padding: 4px 4px 0;
  box-shadow: 0 5px 14px rgba(60,40,20,.1);
  position: relative;
}
.thumb .ph { flex: 1; min-height: 0; overflow: hidden; background: #ece4d6; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb b {
  font-weight: 500; font-family: Outfit, sans-serif;
  font-size: 10px; letter-spacing: .14em; color: #8a8175;
  line-height: 16px;
}
.thumb .dot {
  position: absolute; right: 6px; top: 6px;
  width: 8px; height: 8px; border-radius: 50%; background: #241e18;
}
.frame { position: absolute; z-index: 1; }
.frame .clip { position: absolute; overflow: hidden; background: #ddd4c6; }
.clip.empty-face, .thumb .ph:empty {
  background:
    linear-gradient(180deg, rgba(255,255,255,.55), transparent 42%),
    repeating-linear-gradient(90deg, rgba(80, 60, 30, .05) 0 1px, transparent 1px 8px),
    #efe4d0;
}
.frame.is-empty { box-shadow: 0 8px 18px rgba(60, 40, 20, .08); }
.frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame.bleed .clip { inset: 0; }
.frame.mat .clip { inset: 8px; background: #fff; }
.frame.mat { background: #fff; box-shadow: 0 10px 24px rgba(60,40,20,.12); }
.frame.polaroid { background: #fff; box-shadow: 0 12px 26px rgba(60,40,20,.16); }
.frame.polaroid .clip { inset: 8px 8px 26px; }
.frame.circle .clip { inset: 0; border-radius: 50%; }
.frame.arch .clip { inset: 0; border-radius: 50% 50% 6px 6px; }
.frame.gold { background: #fff; box-shadow: 0 0 0 1px #c6a15b, 0 0 0 7px #fff, 0 0 0 8px #c6a15b, 0 10px 24px rgba(60,40,20,.1); }
.frame.gold .clip { inset: 11px; }
.frame.film { background: #1c1a17; box-shadow: 0 10px 22px rgba(0,0,0,.18); }
.frame.film .clip { inset: 12px 8px; }
.frame.sketch .clip {
  inset: 0;
  background: #f3ecdf;
  box-shadow: 0 10px 22px rgba(40,30,10,.12);
  outline: 1px solid rgba(40,30,10,.2);
}
.frame .tag {
  position: absolute; left: 8px; bottom: 6px; z-index: 2;
  font-family: "ColinHand", cursive; font-size: 15px; color: #1a1a1a;
}
.cap {
  position: absolute; z-index: 4; margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic; font-size: clamp(14px, 1.8vh, 22px);
  color: #3a342c; line-height: 1.25;
}
.cap.overlay { color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,.45); }
.folio {
  position: absolute; bottom: 8px; z-index: 4;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 12px; letter-spacing: .16em; color: #b3a894;
}
.folio.L { left: 12px; }
.folio.R { right: 12px; }
.fx { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.fx.vignette { background: radial-gradient(ellipse at center, transparent 48%, rgba(30,20,10,.3) 100%); }
.fx.grain {
  background-image: radial-gradient(rgba(70,50,20,.35) .6px, transparent .7px);
  background-size: 3px 3px; opacity: .28; mix-blend-mode: multiply;
}
.fx.leak { background: linear-gradient(115deg, rgba(255, 206, 130, .42), transparent 40%); }
.sticker {
  position: absolute; z-index: 6;
  width: 72px; height: 72px;
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  cursor: grab; filter: drop-shadow(0 2px 2px rgba(0,0,0,.12));
}
.sticker svg { width: 100%; height: 100%; display: block; }
.sticker.tape { width: 116px; height: 34px; }
.sticker.ribbon { width: 96px; height: 42px; }
.sticker.corner { width: 86px; height: 86px; }
.sticker.stamp { width: 64px; height: 76px; }

.letter { display: flex; align-items: center; justify-content: center; }
.letter.left { flex-direction: column; text-align: center; gap: 8px; }
.letter .for {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 500; font-size: clamp(18px, 2vh, 24px); letter-spacing: .2em;
  text-transform: uppercase; color: #8a8175;
}
.letter .nm {
  font-family: "Great Vibes", cursive;
  font-size: clamp(46px, 6vh, 72px); line-height: .9;
}
.letter .round {
  width: min(42%, 220px); aspect-ratio: 1; border-radius: 50%; overflow: hidden;
  box-shadow: 0 0 0 6px #f7f1e6, 0 0 0 7px rgba(176, 137, 72, .7);
  margin: 8px 0;
}
.letter .round img { width: 100%; height: 100%; object-fit: cover; }
.letter .meta { letter-spacing: .16em; font-size: 12px; color: #8a8175; }
.letter.right { align-items: stretch; }
.letter-sheet {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; justify-content: center;
  padding: 9% 10% 8%;
}
.letter-kicker {
  font-family: "Cormorant Garamond", Georgia, serif;
  letter-spacing: .22em; text-transform: uppercase;
  font-size: 12px; color: #111; margin-bottom: 6%;
}
.letter-lines { display: flex; flex-direction: column; gap: .42em; }
.letter-line {
  min-height: 1.2em;
  font-family: "ColinHand", "Segoe Script", cursive;
  color: #111;
  font-size: clamp(16px, 2.15vh, 27px);
  line-height: 1.15;
  white-space: nowrap;
}

/* film + drawer */
.film {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 8px 14px 12px;
}
.cell {
  flex: 0 0 auto; width: 58px;
  border: 0; background: transparent; padding: 0; opacity: .7;
}
.cell.on { opacity: 1; }
.cell .mini {
  height: 74px; border-radius: 2px; overflow: hidden;
  background: #f4efe4; box-shadow: 0 4px 12px rgba(0,0,0,.22);
  outline: 2px solid transparent;
}
.cell.on .mini { outline-color: #f0d48a; }
.cell small { display: block; text-align: center; color: #f6efe4; font-size: 10px; margin-top: 3px; }
.cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.drawer {
  background: rgba(247, 241, 230, .96);
  overflow: auto;
  padding: 16px 16px 28px;
  border-left: 1px solid rgba(255,255,255,.3);
}
.drawer h3 {
  margin: 16px 0 8px;
  font-size: 13px; letter-spacing: .08em;
  font-weight: 600; color: #4e463c;
}
.drawer h3:first-child { margin-top: 0; }
.groups { display: flex; flex-wrap: wrap; gap: 6px; }
.groups button, .mini-layout {
  border: 1px solid transparent; background: #fff; border-radius: 8px;
}
.groups button { padding: 5px 8px; font-size: 12px; }
.groups button.on, .mini-layout.on { border-color: #24362c; }
.layout-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.mini-layout { padding: 4px; aspect-ratio: 8/5; display: flex; gap: 2px; }
.mini-layout span { position: relative; flex: 1; background: #f3ecdf; overflow: hidden; }
.mini-layout i {
  position: absolute; background: #c4b39a; display: block;
}
.mini-layout.on i { background: #24362c; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; }
.palette button {
  width: 44px; height: 44px; border: 1px solid var(--line);
  background: #fff; border-radius: 8px; padding: 4px;
}
.side-pick { display: flex; gap: 6px; }
.side-pick button { flex: 1; border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: 6px; }
.side-pick button.on { background: #24362c; color: #f6f0e4; border-color: #24362c; }
.line-edit {
  width: 100%;
  font-family: "ColinHand", cursive;
  font-size: 20px; color: #111;
  border: 0; border-bottom: 1px solid rgba(0,0,0,.12);
  background: transparent; border-radius: 0;
  padding: 3px 2px 1px; margin-bottom: 4px;
}
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.45; margin: 0 0 8px; }
.fx-row { display: flex; flex-wrap: wrap; gap: 8px 12px; font-size: 13px; }
.drawer .btn { width: 100%; margin-top: 8px; }

#flash {
  position: fixed; inset: 0; background: #fff; opacity: 0;
  pointer-events: none; z-index: 40;
}
#flash.go { animation: camflash .55s ease-out; }
@keyframes camflash {
  0% { opacity: 0; }
  12% { opacity: .88; }
  100% { opacity: 0; }
}
#busy {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(40, 26, 16, .4);
}
.busy-card {
  width: min(420px, calc(100% - 32px));
  background: var(--ivory); border-radius: 16px; padding: 22px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.busy-kicker { margin: 0; letter-spacing: .2em; font-size: 11px; color: var(--gold); font-family: Outfit, sans-serif; }
.busy-card h2 { margin: 6px 0 12px; font-family: "Cormorant Garamond", Georgia, serif; font-weight: 500; font-size: 30px; }
.busy-bar { height: 4px; background: rgba(36,30,24,.1); border-radius: 99px; overflow: hidden; }
.busy-bar span { display: block; height: 100%; width: 10%; background: #24362c; border-radius: inherit; }
#busyText { margin: 10px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
#toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 60; max-width: min(560px, calc(100% - 24px));
  background: #241e18; color: #f6f0e4;
  padding: 10px 14px; border-radius: 10px; font-size: 13.5px;
}

@font-face {
  font-family: "ColinHand";
  src: url("assets/ColinHand.ttf") format("truetype");
  font-display: swap;
}

@media (max-width: 1100px) {
  #studio { grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); }
  .preview { height: min(68vh, 460px); }
  .reader-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 34vh); }
  .drawer { max-height: 34vh; border-left: 0; border-top: 1px solid var(--line); }
  .slots { grid-template-columns: repeat(6, 1fr); }
}
@media (max-height: 820px) {
  h1 { font-size: 26px; margin-bottom: 2px; }
  .lead { margin-bottom: 4px; font-size: 12.5px; }
  .slot { aspect-ratio: auto; height: 40px; }
  .names { margin-bottom: 4px; }
  .block { margin-top: 4px; }
  .cloth-row, .actions, .model-row { margin-top: 6px; }
  .check { margin-top: 4px; }
  .preview { height: min(86vh, 520px); }
}
@media (max-height: 820px) {
  .preview:has(.case-open) { height: min(46vh, 300px); }
}
@media (prefers-reduced-motion: reduce) {
  #flash.go { animation: none; }
  .case { transform: none; }
}
body.export-page {
  height: 100vh; overflow: hidden;
  display: grid; place-items: center;
}
.export-stage { width: min(96vw, 1200px); height: min(84vh, 760px); }
.export-stage .sheets { height: 100%; }
.export-cover { width: min(40vw, 440px); aspect-ratio: 4 / 5.2; filter: drop-shadow(12px 22px 24px rgba(24, 12, 6, .35)); }
.export-cover .cover-face { border-radius: 2px 6px 6px 2px; }
