/* Signed-in app: library, wizard, book workspace, credits, account. */
body { min-height: 100vh; }
body:not(.ready) main { opacity: 0; }
body.ready main { opacity: 1; transition: opacity .2s; }
.page { padding-block: clamp(24px, 4vw, 48px) 80px; }
.page-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; justify-content: space-between; margin-bottom: 1.6rem; }
.page-head h1 { font-size: var(--t-2xl); margin: 0; }
.crumb { display: inline-flex; gap: .4rem; align-items: center; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: var(--t-sm); margin-bottom: .6rem; }
.banner { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: .8rem 1rem; border-radius: var(--r-md); background: var(--tint-yellow); margin-bottom: 1.4rem; font-size: var(--t-sm); }

/* ---------------------------------------------------------------- auth */
.auth { min-height: 100vh; display: grid; }
@media (min-width: 900px) { .auth { grid-template-columns: 1fr 1fr; } }
.auth-art { display: none; position: relative; overflow: hidden; background: var(--blue); }
@media (min-width: 900px) { .auth-art { display: block; } }
/* A slow slideshow of finished books, each drifting closer (Ken Burns). */
.ken { position: absolute; inset: 0; }
.ken img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; animation: ken 18s linear infinite; animation-delay: calc(var(--n) * 6s); }
.ken img:first-child { opacity: 1; }
@keyframes ken { 0% { opacity: 0; transform: scale(1.02); } 5% { opacity: 1; } 33% { opacity: 1; } 40% { opacity: 0; transform: scale(1.14) translate(-1.5%, -1%); } 100% { opacity: 0; } }
.auth-art::after { content: ""; position: absolute; inset: auto 0 0; height: 55%; background: linear-gradient(transparent, rgba(28, 36, 89, .82)); }
.art-star { position: absolute; z-index: 2; left: var(--x); top: var(--y); width: 18px; height: 18px; background: #fff7cf; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); animation: twinkle 2.8s ease-in-out infinite; animation-delay: var(--d); filter: drop-shadow(0 0 6px #fff); }
.auth-art p { position: absolute; z-index: 3; inset-inline: 40px; bottom: 40px; color: #fff; font: 700 var(--t-2xl)/1.15 var(--f-display); max-width: 18ch; margin: 0; animation: rise .9s var(--ease) .3s both; }
[dir="rtl"] .auth-art p { font-weight: 400; }
.auth-main { display: grid; align-content: center; padding: clamp(24px, 6vw, 72px); }
.auth-box { width: min(100%, 440px); margin-inline: auto; padding: clamp(22px, 4vw, 36px); border-radius: var(--r-lg); background: color-mix(in srgb, var(--sheet) 78%, transparent); backdrop-filter: blur(16px); border: 1.5px solid color-mix(in srgb, var(--line) 70%, transparent); box-shadow: 0 30px 70px -40px rgba(28, 36, 89, .6); animation: rise .7s var(--ease) both; }
.auth-box h1 { font-size: var(--t-2xl); }
.divider { display: flex; align-items: center; gap: .8rem; color: var(--ink-3); font-size: var(--t-sm); margin: 1.2rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.g-btn img { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- library */
.shelf-item a { text-decoration: none; color: inherit; }
.shelf-item .meta { display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.book-status { position: absolute; z-index: 3; inset-block-start: 8px; inset-inline-end: 8px; }
.book-fresh { display: grid; place-items: center; text-align: center; padding: 1rem; font: 400 var(--t-lg)/1.2 var(--f-display); color: var(--blue); background: var(--tint-blue); border: 2px dashed var(--blue); box-shadow: none; }
.tools { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 1rem; }
.tool { display: block; text-decoration: none; color: var(--ink); }
.tool:hover { color: var(--ink); border-color: var(--blue); }
.empty { text-align: center; padding: clamp(32px, 6vw, 64px) 16px; }
.empty .book { width: 160px; margin: 0 auto 1.5rem; }

/* ---------------------------------------------------------------- wizard */
.wizard { max-width: 760px; }
.wizard .panel { margin-bottom: 1rem; }
.wz-foot { position: sticky; bottom: 0; z-index: 5; display: flex; gap: .8rem; justify-content: space-between; align-items: center; padding: 14px 0; background: linear-gradient(transparent, var(--paper) 30%); }
.photo-pick { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.photo-thumb { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; border: 3px solid var(--sheet); box-shadow: 0 0 0 2px var(--line); }
.char-row { display: grid; gap: .6rem; grid-template-columns: 1fr 1fr auto; align-items: end; padding-block: .8rem; border-bottom: 1px dashed var(--line); }
.char-row .field + .field { margin: 0; }
.char-row .notes { grid-column: 1 / -1; }
@media (max-width: 560px) { .char-row { grid-template-columns: 1fr; } }
.mode-choices { --min: 240px; }
.mode-choices .choice > span { padding: 1.2rem; gap: .5rem; }
.mode-choices strong { font-family: var(--f-display); font-size: var(--t-lg); font-weight: 700; }
[dir="rtl"] .mode-choices strong { font-weight: 400; }
.manual-pages { display: grid; gap: 1rem; counter-reset: pg; }
.manual-pages .textarea { min-height: 96px; }
.styles { --min: 130px; }
.styles .choice > span { padding: .5rem; text-align: center; font-size: var(--t-sm); }
.pages-seg button { min-width: 3.2rem; }
.cost-line { font-size: var(--t-sm); color: var(--ink-2); }

/* ---------------------------------------------------------------- book workspace */
.ws-head { display: grid; gap: 1.5rem; align-items: center; margin-bottom: 2rem; }
@media (min-width: 760px) { .ws-head { grid-template-columns: 220px 1fr; } }
.ws-head h1 { font-size: var(--t-2xl); margin-bottom: .3rem; }
.ws-steps { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .6rem; }
.ws-steps .chip[aria-current="step"] { background: var(--blue); color: var(--on-blue); }
.stage { display: grid; gap: 1.2rem; }
.story-edit { display: grid; gap: 1rem; }
.story-edit .pg { display: grid; gap: .35rem; }
.story-edit .pg .textarea { min-height: 90px; }
.story-edit .sec { color: var(--ink-3); font-size: var(--t-sm); }
.cast { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.cast-card { display: grid; gap: .6rem; align-content: start; }
.cast-card h3 { margin: 0; display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.cast-card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .2rem .7rem; font-size: var(--t-sm); }
.cast-card dt { color: var(--ink-3); }
.cast-card dd { margin: 0; }
.sheet-img { aspect-ratio: 3 / 4; border-radius: var(--r-md); overflow: hidden; background: var(--paper-2); display: grid; place-items: center; }
.sheet-img img { width: 100%; height: 100%; object-fit: cover; }
.pages-grid { display: grid; gap: clamp(20px, 3vw, 32px); grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.pg-card { display: grid; gap: .7rem; align-content: start; }
.pg-card .book { --ox: 4px; --oy: 4px; }
.pg-card p { margin: 0; font-size: var(--t-sm); color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.pg-card .row { gap: .4rem; }
.pg-wait { display: grid; place-items: center; height: 100%; color: var(--ink-3); font-weight: 600; gap: .5rem; text-align: center; }
.side-tools { display: grid; gap: 1rem; }
@media (min-width: 1000px) { .ws-body { display: grid; grid-template-columns: 1fr 320px; gap: 2rem; align-items: start; } .side-tools { position: sticky; top: 84px; } }
.voices { display: grid; gap: .5rem; }
.voice-opt { display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border: 2px solid var(--line); border-radius: var(--r-md); cursor: pointer; }
.voice-opt:has(input:checked) { border-color: var(--blue); background: var(--tint-blue); }
.voice-opt input { accent-color: var(--blue); }
.voice-opt .grow { flex: 1; display: grid; }
.voice-opt small { color: var(--ink-2); }
.versions { display: flex; gap: .6rem; flex-wrap: wrap; }
.versions button { padding: 0; border: 3px solid transparent; border-radius: var(--r-sm); background: none; cursor: pointer; width: 84px; }
.versions button[aria-pressed="true"] { border-color: var(--blue); }
.versions img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 5px; }

/* reader overlay */
.reader-dlg { width: min(1000px, 100% - 24px); }
.reader-stage { display: grid; gap: 1.2rem; align-items: center; }
@media (min-width: 800px) { .reader-stage { grid-template-columns: 1.1fr .9fr; } }
.reader-stage .read-text { font-size: clamp(1.15rem, 1rem + .8vw, 1.55rem); line-height: 1.7; }
.reader-nav { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1rem; }

/* ---------------------------------------------------------------- credits */
.balance { display: flex; gap: 1rem; align-items: baseline; flex-wrap: wrap; }
.balance strong { font: 700 3.2rem/1 var(--f-display); color: var(--blue); }
.req-steps { display: grid; gap: .3rem; padding-inline-start: 1.2em; color: var(--ink-2); font-size: var(--t-sm); }
.hist { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.hist td, .hist th { text-align: start; padding: .55rem .4rem; border-bottom: 1px solid var(--line); }
.hist .num { text-align: end; white-space: nowrap; font-weight: 700; }

/* ---------------------------------------------------------------- account */
.danger-zone { border-color: color-mix(in srgb, var(--red) 35%, var(--line)); }

.btn-soft { --bg: color-mix(in srgb, var(--sheet) 70%, transparent); --bd: color-mix(in srgb, var(--line) 80%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.btn-soft:hover { --bd: var(--ink-3); }

/* ---------------------------------------------------------------- library (1.2.5)
   One shape for every book: a 3:4 cover. Finished books sit on a shelf grid;
   books still being made are a tidy list above it. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lb-head { align-items: center; margin-bottom: .6rem; }
.lb-count { margin: .25rem 0 0; font-size: var(--t-sm); }
.lb-section { margin-top: clamp(1.8rem, 4vw, 2.8rem); }
.lb-h2 { font-size: var(--t-lg); margin: 0 0 1rem; }

.lb-cover { position: relative; aspect-ratio: 3 / 4; border-radius: 4px 12px 12px 4px; overflow: hidden; background: var(--paper-2);
  box-shadow: 4px 4px 0 var(--pink), var(--shadow-lift); }
[dir="rtl"] .lb-cover { border-radius: 12px 4px 4px 12px; box-shadow: -4px 4px 0 var(--pink), var(--shadow-lift); }
.lb-cover::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 6%; z-index: 2; pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, .22), rgba(255, 255, 255, .2) 55%, rgba(0, 0, 0, .05)); }
[dir="rtl"] .lb-cover::before { background: linear-gradient(-90deg, rgba(0, 0, 0, .22), rgba(255, 255, 255, .2) 55%, rgba(0, 0, 0, .05)); }
.lb-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Printed cover for books without pictures */
.lb-print { --c: var(--blue); display: flex; flex-direction: column; justify-content: flex-end; gap: .35em; padding: 14% 12% 13% 16%; color: #fff;
  background: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .16) 1.2px, transparent 1.6px) 0 0 / 14px 14px,
              radial-gradient(120% 70% at 85% 0%, rgba(255, 255, 255, .22), transparent 60%), var(--c); }
[dir="rtl"] .lb-print { padding: 14% 16% 13% 12%; }
.lb-print::after { content: ""; position: absolute; inset-block-start: 11%; inset-inline-end: 12%; width: 26%; aspect-ratio: 1; border-radius: 50%;
  background: var(--yellow); box-shadow: inset -6px -4px 0 rgba(0, 0, 0, .12); }
.lb-print.has-bg { background: var(--bg) center / cover, var(--c); color: #1c2459; }
.lb-print.has-bg::after { display: none; }
.lb-print.has-bg .lb-print-title { background: rgba(255, 255, 255, .9); padding: .35em .5em; border-radius: 10px; }
.lb-print-title { position: relative; z-index: 1; font: 700 clamp(1.05rem, .8rem + .9vw, 1.4rem)/1.1 var(--f-display); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
[dir="rtl"] .lb-print-title { font-weight: 400; }
.lb-print-hero { position: relative; z-index: 1; font-size: var(--t-xs); font-weight: 700; opacity: .85; }
.ink-blue { --c: var(--blue); } .ink-pink { --c: var(--pink); } .ink-teal { --c: var(--teal); } .ink-plum { --c: var(--plum); } .ink-ink { --c: #1c2459; }

/* Ready to read: the shelf */
.lb-grid { display: grid; gap: clamp(20px, 2.6vw, 32px) clamp(16px, 2.2vw, 28px); grid-template-columns: repeat(auto-fill, minmax(min(calc(50% - 10px), 176px), 1fr)); }
.lb-book { display: flex; flex-direction: column; min-width: 0; animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms); }
.lb-open { position: relative; display: block; border-radius: 4px 12px 12px 4px; }
.lb-open .lb-cover { transition: transform .4s var(--spring), box-shadow .3s var(--ease); transform-origin: 0 50%; }
[dir="rtl"] .lb-open .lb-cover { transform-origin: 100% 50%; }
.lb-open:hover .lb-cover, .lb-open:focus-visible .lb-cover { transform: perspective(900px) rotateY(-10deg) translateY(-4px); }
[dir="rtl"] .lb-open:hover .lb-cover, [dir="rtl"] .lb-open:focus-visible .lb-cover { transform: perspective(900px) rotateY(10deg) translateY(-4px); }
.lb-title { font: 700 var(--t-md)/1.25 var(--f-body); color: var(--ink); margin: .9rem 0 0; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lb-book .lb-title { min-height: 2.5em; }
.lb-meta { display: flex; flex-wrap: wrap; gap: .3rem .7rem; align-items: center; margin: .2rem 0 0; font-size: var(--t-xs); color: var(--ink-3); }
.lb-shared { display: inline-flex; align-items: center; gap: .3em; color: var(--pink); font-weight: 700; }
.lb-actions { display: flex; gap: .45rem; margin-top: auto; padding-top: .7rem; }
.lb-actions .btn { min-height: 38px; gap: .4rem; }
.lb-actions .btn-primary { flex: 1; }
:root:not([data-theme="dark"]) .lb-actions .btn-primary { color: #fff; }
.lb-edit { width: 38px; padding: 0; justify-content: center; flex: none; }
.lb-skel-line { height: 1rem; width: 70%; margin-top: .9rem; }

.play-orb { position: absolute; inset: 0; margin: auto; z-index: 3; width: 60px; height: 60px; display: grid; place-items: center; border-radius: 50%;
  color: var(--blue); background: rgba(255, 255, 255, .86); border: 1.5px solid rgba(255, 255, 255, .95);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 14px 30px -12px rgba(20, 16, 60, .6);
  opacity: 0; transform: scale(.8); transition: opacity .25s var(--ease), transform .35s var(--spring), background .2s, color .2s; }
.play-orb svg { margin-inline-start: 4px; }
[dir="rtl"] .play-orb svg { margin-inline-start: 0; margin-inline-end: 4px; transform: scaleX(-1); }
.lb-open:hover .play-orb, .lb-open:focus-visible .play-orb { opacity: 1; transform: scale(1); color: #fff; background: var(--blue); border-color: transparent; }
@media (hover: none) { .play-orb { display: none; } }
:root[data-theme="dark"] .play-orb { color: #fff; background: color-mix(in srgb, #1c2459 55%, transparent); border-color: rgba(255, 255, 255, .35); }

/* Still in the works: one row per book */
.lb-rows { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); }
.lb-row { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 1rem; align-items: center; padding: .75rem 1rem .75rem .75rem;
  border: 1px solid var(--line); border-radius: var(--r-md); background: color-mix(in srgb, var(--sheet) 82%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); color: var(--ink); text-decoration: none;
  transition: border-color .2s, transform .3s var(--spring), box-shadow .2s; animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms); }
[dir="rtl"] .lb-row { padding: .75rem .75rem .75rem 1rem; }
.lb-row:hover, .lb-row:focus-visible { border-color: var(--blue); color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.lb-row.is-bad { border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.lb-thumb .lb-cover { box-shadow: 2px 2px 0 var(--pink); border-radius: 2px 6px 6px 2px; }
[dir="rtl"] .lb-thumb .lb-cover { box-shadow: -2px 2px 0 var(--pink); border-radius: 6px 2px 2px 6px; }
.lb-thumb .lb-print { padding: 0; }
.lb-thumb .lb-print-title, .lb-thumb .lb-print-hero { display: none; }
.lb-thumb .lb-print::after { inset-block-start: 14%; width: 34%; box-shadow: none; }
.lb-row-main { display: grid; gap: .35rem; min-width: 0; }
.lb-row .lb-title { margin: 0; -webkit-line-clamp: 1; }
.lb-row-status { display: flex; }
.lb-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; max-width: 180px; }
.lb-steps i { height: 4px; border-radius: 4px; background: var(--line); }
.lb-steps i.on { background: var(--teal); }
.lb-steps i.now { background: linear-gradient(90deg, var(--blue) 0 40%, var(--line) 40%); background-size: 250% 100%; animation: lb-fill 1.6s ease-in-out infinite; }
.is-bad .lb-steps i.on { background: var(--red); }
@keyframes lb-fill { from { background-position: 100% 0; } to { background-position: 0 0; } }
.lb-go { display: inline-flex; align-items: center; gap: .2rem; font-size: var(--t-sm); font-weight: 700; color: var(--blue-deep); white-space: nowrap; }
.flip { flex: none; }
[dir="rtl"] .flip { transform: scaleX(-1); }

/* More from Softbook */
.lb-tools { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.lb-tool { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 1rem; align-items: center; padding: 1rem 1.1rem;
  border: 1px solid var(--line); border-radius: var(--r-md); background: color-mix(in srgb, var(--sheet) 82%, transparent);
  color: var(--ink); text-decoration: none; transition: border-color .2s, transform .3s var(--spring); }
.lb-tool:hover, .lb-tool:focus-visible { border-color: var(--blue); color: var(--ink); transform: translateY(-2px); }
.lb-tool strong { display: block; font-size: var(--t-md); }
.lb-tool .flip { color: var(--ink-3); }
.lb-tool-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: var(--c); }

.lb-empty-cover { width: 150px; margin: 0 auto 1.6rem; }

@media (max-width: 560px) {
  .lb-head .btn { width: 100%; }
  .lb-row { grid-template-columns: 46px minmax(0, 1fr) auto; gap: .8rem; }
  .lb-go span, .lb-go { font-size: 0; } .lb-go svg { width: 22px; height: 22px; }
}
@media (prefers-reduced-motion: reduce) { .lb-book, .lb-row { animation: none; } .lb-steps i.now { animation: none; } }

/* Wizard bits (restored in 1.2.4: they were dropped by mistake in 1.2.3) */
.photo-fig { margin: 0; display: grid; gap: .3rem; justify-items: center; animation: pop-in .45s var(--spring); }
.photo-fig .photo-thumb { width: 96px; height: 96px; object-fit: cover; border-radius: 16px; }
label.btn.busy { opacity: .6; pointer-events: none; }
.bgs .choice img { aspect-ratio: 16 / 10; }

/* Failed book (1.3.0) */
.fail-panel { display: grid; grid-template-columns: auto 1fr; gap: 1.1rem; align-items: start; border-color: color-mix(in srgb, var(--red) 30%, var(--line)); }
.fail-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; color: var(--red); background: var(--tint-red); }
.fail-tech { margin-top: 1.1rem; font-size: var(--t-xs); color: var(--ink-3); }
.fail-tech summary { cursor: pointer; }
.fail-tech code { display: block; margin-top: .5rem; padding: .6rem .8rem; border-radius: 10px; background: var(--paper-2); white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 560px) { .fail-panel { grid-template-columns: 1fr; } }
.char-row .char-photo { grid-column: 1 / -1; }
.char-row .char-photo .photo-thumb { width: 72px; height: 72px; }
.check.photo-ai { margin-top: 1rem; padding: .8rem 1rem; border-radius: var(--r-md); background: color-mix(in srgb, var(--tint-blue) 55%, transparent); }

/* 1.3.1: the wizard's bottom bar is a full-width band that reaches the bottom
   of the screen, so the page never shows through below it at the end of the
   scroll. The shadow paints the band without widening the page. */
.wz-foot { --fb: color-mix(in srgb, var(--paper) 94%, transparent);
  background: var(--fb); box-shadow: 0 0 0 100vmax var(--fb), 0 -1px 0 100vmax var(--line);
  clip-path: inset(-1px -100vmax -100vmax -100vmax); padding: 12px 0; margin-top: 1.5rem; }

.bk-del-quiet { color: var(--red); }

/* ---------------------------------------------------------------- saved characters (1.4.0) */
.saved-row { margin: .2rem 0 1.2rem; }
.saved-list { display: flex; gap: .7rem; overflow-x: auto; padding: .2rem .1rem .6rem; scrollbar-width: thin; }
.saved-chip { flex: none; display: grid; justify-items: center; gap: .35rem; width: 92px; padding: .45rem .4rem .55rem; border-radius: var(--r-md);
  border: 1.5px solid var(--line); background: var(--sheet); color: var(--ink); font: 600 var(--t-xs)/1.2 var(--f-body); cursor: pointer;
  transition: border-color .2s, transform .3s var(--spring); }
.saved-chip img { width: 72px; height: 72px; object-fit: cover; object-position: 30% 30%; border-radius: 50%; background: var(--paper-2); }
.saved-chip span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-chip:hover { border-color: var(--blue); transform: translateY(-2px); }
.saved-chip.on { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 22%, transparent); }
.saved-new .saved-plus { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; font-size: 2rem; color: var(--blue); background: var(--tint-blue); }
.saved-list-dlg { flex-wrap: wrap; overflow: visible; }
.saved-using { display: grid; grid-template-columns: minmax(120px, 220px) 1fr; gap: 1.2rem; align-items: start; }
.saved-using img { width: 100%; border-radius: var(--r-md); background: var(--paper-2); }
.saved-tag { display: inline-flex; align-items: center; gap: .5rem; font-size: var(--t-xs); font-weight: 700; color: var(--teal); }
.saved-tag img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; object-position: 30% 30%; }
@media (max-width: 560px) { .saved-using { grid-template-columns: 1fr; } .saved-using img { max-width: 220px; } }

.ch-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); margin-top: 1rem; }
.ch-card { display: grid; grid-template-rows: auto 1fr; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--sheet);
  animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms); }
.ch-img { aspect-ratio: 4 / 3; background: var(--paper-2); }
.ch-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ch-body { padding: 1rem 1.1rem 1.1rem; display: grid; gap: .3rem; align-content: start; }
.ch-body h3 { margin: 0; font-size: var(--t-lg); }
.ch-body .row { margin-top: .5rem; gap: .4rem; }
.ch-del { color: var(--red); }

/* ---- Look-alike characters (1.4.1) */
.use-saved { display: flex; flex-wrap: wrap; gap: .8rem 1.2rem; align-items: center; justify-content: space-between;
  margin: .2rem 0 1.1rem; padding: .9rem 1rem; border-radius: var(--r-md); border: 1.5px dashed color-mix(in srgb, var(--blue) 45%, transparent);
  background: color-mix(in srgb, var(--tint-blue) 40%, transparent); }
.use-saved p { margin: .15rem 0 0; }
.likeness h3 { margin-top: 0; }
.like-choices { --min: 260px; }
.like-choice > span { padding: 1rem 1.1rem; gap: .35rem; }
.like-choice strong { font-size: var(--t-md); }
.saved-base-ok { color: var(--teal); font-weight: 600; }
.base-box { margin: 0; display: grid; grid-template-columns: 64px 1fr; gap: .7rem; align-items: center; }
.base-box img, .base-box .skeleton { width: 64px; aspect-ratio: 3 / 4; border-radius: var(--r-sm); object-fit: cover; background: #fff; border: 1px solid var(--line); display: block; }
.base-box figcaption { color: var(--teal); font-weight: 600; }
.sheet-img { position: relative; }
.base-mini { position: absolute; inset-inline-end: 8px; bottom: 8px; width: 22% !important; height: auto !important; aspect-ratio: 3 / 4; object-fit: cover;
  border-radius: var(--r-sm); border: 2px solid var(--sheet); box-shadow: 0 2px 6px rgb(0 0 0 / .18); background: #fff; }
.ch-img { position: relative; }
.ch-img.is-photo { background: #fff; }
.ch-img.is-photo img { object-fit: contain; }
.ch-wait, .ch-none { display: grid; place-items: center; align-content: center; gap: .6rem; padding: 1rem; text-align: center; }
.ch-wait .skeleton { width: 40%; aspect-ratio: 3 / 4; border-radius: var(--r-sm); }
.ch-flip { position: absolute; inset-inline-start: 8px; bottom: 8px; display: flex; border-radius: 999px; overflow: hidden; background: var(--sheet); box-shadow: 0 1px 4px rgb(0 0 0 / .15); }
.ch-flip button { border: 0; background: none; padding: .25rem .7rem; font: inherit; font-size: var(--t-xs); color: var(--ink-2); cursor: pointer; }
.ch-flip button[aria-pressed="true"] { background: var(--blue); color: #fff; }
.ch-badge { position: absolute; inset-inline-end: 8px; top: 8px; padding: .2rem .6rem; border-radius: 999px; background: var(--yellow); color: #1b1b1b; font-size: var(--t-xs); font-weight: 600; }
.ch-new { display: grid; grid-template-columns: 150px 1fr; gap: 1rem; margin: .4rem 0 1rem; }
.ch-new-photo { display: grid; gap: .5rem; align-content: start; justify-items: center; padding: .6rem; border-radius: var(--r-md); background: var(--paper-2); }
.ch-new-photo img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--r-sm); }
.ch-new-photo > span { min-height: 120px; display: grid; place-items: center; text-align: center; }
.ch-new-fields .field { margin-bottom: .7rem; }
@media (max-width: 520px) { .ch-new { grid-template-columns: 1fr; } }
.likeness-in { margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.saved-using .check { margin: .4rem 0 1rem; }
.ch-new-empty { width: 100%; aspect-ratio: 3 / 4; border-radius: var(--r-sm); border: 1.5px dashed var(--line); background: var(--sheet); }
.like-cost { color: var(--blue) !important; font-weight: 600 !important; margin-top: .2rem; }
.look-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem; margin: .4rem 0 1.2rem; padding: .6rem .8rem; border-radius: var(--r-md); background: var(--paper-2); }
.look-bar > span { display: flex; align-items: center; gap: .7rem; }
.look-bar > span > span { display: grid; }
.look-bar img { width: 44px; height: 44px; border-radius: var(--r-sm); object-fit: cover; }
.look-styles { --min: 110px; max-height: 46vh; overflow: auto; }
.xconsent { margin-top: 1rem; }

/* ---- PDF formats (1.4.4) */
.pdf-choices { --min: 100%; }
.pdf-choice > span { gap: .3rem; }
.pdf-price { font-style: normal; font-weight: 600; color: var(--blue); margin-inline-start: .4rem; font-size: var(--t-sm); }
.pdf-print-note { margin-top: 1rem; }
.pdf-list { list-style: none; padding: 0; margin: .8rem 0 0; display: grid; gap: .5rem; }
.pdf-list li { display: flex; flex-wrap: wrap; gap: .2rem .6rem; align-items: baseline; padding-top: .5rem; border-top: 1px solid var(--line); }
.pdf-kind { font-weight: 600; }

/* ---- 1.7 book categories in the wizard */
.cat-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); margin-top: .9rem; }
.cat-card { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start; text-align: start; padding: 10px 12px; cursor: pointer;
  border: 2px solid var(--line); border-radius: var(--r-md); background: var(--sheet); color: var(--ink); font: inherit; transition: border-color .15s, transform .2s var(--spring); }
.cat-card:hover { border-color: var(--blue); transform: translateY(-1px); }
.cat-card:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.cat-card[aria-pressed="true"] { border-color: var(--blue); background: var(--tint-blue); box-shadow: 4px 4px 0 var(--blue); }
.cat-card strong { display: block; font-size: var(--t-md); }
.cat-card small { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--ink-2); font-size: var(--t-xs); line-height: 1.4; margin-top: 2px; }
.cat-card strong { font-size: var(--t-sm); line-height: 1.3; }
.cat-icon { width: 34px; height: 34px; display: grid; place-items: center; font-size: 18px; border-radius: 10px; background: var(--paper-2); }
.seg-mini { display: inline-flex; }
.list-row { display: grid; grid-template-columns: minmax(80px, 1fr) 3fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.mem-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); margin: 1rem 0; }
.mem { margin: 0; display: grid; gap: 6px; padding: 8px; border: 1.5px solid var(--line); border-radius: var(--r-md); background: var(--paper); }
.mem img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.mem .input, .mem .select { min-height: 38px; font-size: var(--t-xs); }
.mem-logo { max-width: 180px; }
.mem-logo img { object-fit: contain; background: #fff; }
@media (max-width: 620px) { .list-row { grid-template-columns: 1fr auto; } .list-row [data-li="when"], .list-row [data-li="from"] { grid-column: 1 / -1; } }
.chip-sm { font-size: 11px; padding: .1rem .5rem; }
.lb-tabs { margin: -.4rem 0 1.2rem; gap: 6px; }
.media-part { margin-top: 1.4rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.media-part h4 { margin: 0 0 .25rem; }
.media-part > .small { margin: 0 0 .7rem; }

/* 1.7.1: how each page is made (story check and "Change this page") */
.pe { display: grid; gap: .6rem; margin-top: .7rem; padding: .75rem .85rem; border-radius: 14px; background: var(--paper-2, #f4f6ff); }
.pe-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin: 0; }
.pe-row .select { width: auto; min-width: 0; flex: 1 1 220px; max-width: 360px; }
.select-sm { padding-block: .35rem; font-size: var(--t-sm, 14px); min-height: 38px; }
.pe-photos { display: flex; flex-wrap: wrap; gap: 8px; }
.pe-ph { position: relative; width: 64px; height: 64px; padding: 0; border-radius: 12px; border: 2px solid var(--line, #dfe3f5); background: #fff; overflow: hidden; cursor: pointer; display: grid; place-items: center; }
.pe-ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pe-prod img { object-fit: contain; background: #fff; }
.pe-ph[aria-pressed="true"] { border-color: var(--blue, #2f55d4); box-shadow: 0 0 0 3px rgba(47, 85, 212, .18); }
.pe-ph:focus-visible { outline: 3px solid var(--yellow, #ffd23f); outline-offset: 2px; }
.pe-tick { position: absolute; top: 4px; inset-inline-end: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--blue, #2f55d4); color: #fff; font-size: 12px; display: grid; place-items: center; }
.pe-add { border-style: dashed; color: var(--muted, #667); font-size: 26px; }
.pe-lay { gap: 6px; flex-wrap: wrap; }
.pe-lay .chip { cursor: pointer; border: 1.5px solid var(--line, #dfe3f5); }
.pe-words { gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.pe-words .select { width: auto; }
.choice.is-off { opacity: .55; cursor: not-allowed; }
.look-modes .choice > span { align-content: start; gap: .45rem; }
/* 1.7.1: face photos for drawn pages (every kind but kids) */
.faces { display: grid; gap: .2rem; margin-top: .8rem; }
.face-row { display: grid; grid-template-columns: minmax(90px, 160px) auto 1fr; gap: .8rem; align-items: center; padding-block: .7rem; border-bottom: 1px dashed var(--line); }
.face-row .photo-pick { margin: 0; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.face-row .photo-thumb { width: 64px; height: 64px; }
@media (max-width: 640px) { .face-row { grid-template-columns: 1fr; } }
/* 1.7.2: one look grid (photos, art styles, words only) */
.look-grid .look-card > span { align-content: start; }
.look-glyph { display: grid; place-items: center; aspect-ratio: 4 / 3; width: 100%; border-radius: 10px; font-size: 34px; font-weight: 800; color: var(--blue, #2f55d4); background: linear-gradient(135deg, #eef1ff, #fdf0f6); margin-bottom: .45rem; }
.look-retouch img { filter: saturate(1.15) contrast(1.06) brightness(1.04); }
.look-card img { aspect-ratio: 4 / 3; object-fit: cover; width: 100%; border-radius: 10px; margin-bottom: .45rem; }
.look-card small { line-height: 1.35; }
/* 1.7.3: "make the pages?" pop-up */
.ask-cast { display: flex; gap: 10px; flex-wrap: wrap; margin: .6rem 0; }
.ask-cast figure { margin: 0; width: 84px; text-align: center; }
.ask-cast img { width: 84px; height: 84px; object-fit: cover; border-radius: 14px; background: var(--paper-2); }
.ask-cast figcaption { font-size: 12px; margin-top: 4px; }
.seg-wrap { flex-wrap: wrap; height: auto; }

/* 1.7.3: fun and trending kinds */
.cat-group { margin: 1.1rem 0 .6rem; font-size: 1rem; }
.cat-card-trend { border-color: color-mix(in srgb, #ff4d8d 40%, var(--line)); background: linear-gradient(135deg, color-mix(in srgb, #ff4d8d 8%, var(--sheet)), var(--sheet)); }
.trend-badge { display: inline-block; margin: 0 0 .15rem; padding: .1rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 700; line-height: 1.5;
  color: #fff; background: linear-gradient(90deg, #ff4d8d, #ff8a3d); }
.cat-card .trend-badge + strong { display: block; }
.trend-pick { margin: 1rem 0 .6rem; }
.trend-pick .mem { max-width: 260px; }
.trend-tips { margin: .4rem 0 0; padding-inline-start: 1.1rem; }
.input-num { max-width: 140px; }
.pstyles { display: grid; grid-template-columns: repeat(2, minmax(0, 230px)); gap: .8rem; }
.pstyles .choice > span { display: grid; gap: .25rem; }
.pstyles img { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 10px; margin-bottom: .35rem; }
/* 1.7.5: a note for each picture, under its words */
.pnote { margin-top: .45rem; font-size: var(--t-sm); }
.pg-busy::before { content: ""; width: 26px; height: 26px; border-radius: 50%; border: 3px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; animation: pg-spin .9s linear infinite; }
@keyframes pg-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pg-busy::before { animation: none; } }
/* 1.7.5: on phones the plan's action bar stacks: the main button full width
   on top, the smaller actions under it (no more squeezed buttons). */
@media (max-width: 640px) {
  .plan-foot { position: static; background: none; flex-direction: column-reverse; align-items: stretch; gap: .6rem; padding: 12px 0 18px; }
  .plan-foot > div[style*="text-align:end"] { text-align: center !important; }
  .plan-foot .btn-lg { width: 100%; white-space: normal; line-height: 1.25; padding-block: .8rem; }
  .plan-foot > .row { justify-content: center; flex-wrap: wrap; }
  .plan-foot > .row .btn { flex: 1 1 auto; }
}
@media (hover: none) {
  .lb-row:hover, .lb-tool:hover, .cat-card:hover, .saved-chip:hover { transform: none; box-shadow: none; }
  .lb-open:hover .lb-cover { transform: none; }
}
/* 1.7.6 */
.nowords-note { margin: .35rem 0 0; font-style: italic; }
.pe-words-hint { margin: .6rem 0 .25rem; }
.pe-words label { align-self: center; }
