/* Shelfmade: cozy indie bookstore meets sticker pack. */

:root {
  --cream: #FFF8EE;
  --cream-2: #FBEEDD;
  --pink: #F4A7B9;
  --pink-soft: #FBE1E8;
  --brown: #5B4636;
  --brown-soft: #8A7160;
  --sage: #A8C5A0;
  --sage-dark: #8DB185;
  --line: #EEDFCB;
  --white: #FFFFFF;
  --radius: 18px;
  --shadow: 0 2px 0 rgba(91, 70, 54, 0.06), 0 8px 24px rgba(91, 70, 54, 0.08);
  --display: 'Fraunces', Georgia, serif;
  --body: 'Nunito', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--brown);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
/* Pins the page in place while the book search is open (see lockScroll in app.js). */
body.sheet-open { position: fixed; left: 0; right: 0; overflow: hidden; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }

#app {
  max-width: 452px; /* 420px of content, same as the shelf preview */
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

.screen { animation: screen-in 0.35s ease both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- type ---------- */

.display {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(40px, 12vw, 56px);
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin: 4px 0 12px;
}
.kicker {
  display: inline-block;
  margin: 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--pink-soft);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.lede { margin: 0 0 20px; font-size: 17px; color: var(--brown-soft); max-width: 30ch; }
.title { font-family: var(--display); font-weight: 700; font-size: 30px; line-height: 1.1; margin: 8px 0 6px; }
.sub { margin: 0 0 18px; color: var(--brown-soft); }
.center { text-align: center; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 800;
  text-decoration: none; /* links styled as buttons */
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease, opacity 0.2s ease;
}
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn-big { width: 100%; min-height: 56px; font-size: 18px; }
.btn-primary {
  background: var(--sage);
  color: #2F4A2B;
  box-shadow: 0 4px 0 var(--sage-dark);
}
.btn-primary:active:not(:disabled) { box-shadow: 0 2px 0 var(--sage-dark); }
.btn-primary:disabled { background: #E3DDD3; color: #A99A8C; box-shadow: 0 4px 0 #D6CEC2; }
.btn-ghost {
  background: var(--white);
  color: var(--brown);
  box-shadow: inset 0 0 0 2px var(--line), 0 4px 0 var(--line);
}
.link {
  background: none;
  border: 0;
  padding: 10px;
  color: var(--brown-soft);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: var(--white);
  box-shadow: inset 0 0 0 2px var(--line);
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.input {
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--white);
  font-size: 16px; /* 16px stops iOS from zooming in */
  outline: none;
}
.input:focus { border-color: var(--pink); }

/* ---------- 1. home ---------- */

.home { display: flex; flex-direction: column; align-items: flex-start; padding-top: 12px; }
.sample-wrap {
  width: 100%;
  margin: 0 0 8px;
  transform: rotate(-1.5deg);
}
.sample-hint { align-self: center; margin: 0 0 18px; font-size: 14px; font-weight: 700; color: var(--brown-soft); }
/* Sample books are tappable: they lift a little on hover and show a focus ring. */
#sample-frame .cover { cursor: pointer; transition: translate 0.15s ease; }
#sample-frame .cover:hover { translate: 0 -3px; }
#sample-frame .cover:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }
.home .btn-big { margin-top: 4px; }
.home .link { align-self: center; margin-top: 6px; }

/* ---------- topbar ---------- */

.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.step { flex: 1; text-align: center; font-weight: 800; font-size: 13px; color: var(--brown-soft); letter-spacing: 0.03em; }
.topbar-spacer { width: 44px; }

/* ---------- 2. chapters ---------- */

.chapters { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.chapter {
  position: relative;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 10px 12px;
  transition: opacity 0.2s ease;
}
.chapter.dragging { opacity: 0.4; }
.chapter.drop-before::before, .chapter.drop-after::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px;
  height: 4px;
  border-radius: 4px;
  background: var(--pink);
}
.chapter.drop-before::before { top: -8px; }
.chapter.drop-after::after { bottom: -8px; }

.chapter-top { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.handle { width: 24px; height: 36px; display: grid; place-items: center; cursor: grab; color: #CDBBA7; touch-action: none; }
.handle svg { width: 20px; height: 20px; fill: currentColor; }
.chapter-num {
  width: 24px; height: 24px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--pink-soft);
  font-size: 12px; font-weight: 800;
}
.chapter-label {
  flex: 1;
  width: 0; /* inputs have a built-in width; let flex size it instead */
  min-width: 0;
  border: 0;
  border-radius: 10px;
  padding: 6px 8px;
  background: transparent;
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  outline: none;
  background-image: linear-gradient(var(--line), var(--line));
  background-size: calc(100% - 16px) 2px;
  background-position: 8px calc(100% - 3px);
  background-repeat: no-repeat;
}
.chapter-label:focus { background-color: var(--cream); background-image: linear-gradient(var(--pink), var(--pink)); }
.chapter-tools { display: flex; gap: 2px; }
.mini {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px;
  background: transparent;
  color: var(--brown-soft);
}
.mini:hover:not(:disabled) { background: var(--cream); }
.mini:disabled { opacity: 0.25; }
.mini svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.slot {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 14px;
  text-align: left;
}
.slot.empty {
  justify-content: center;
  min-height: 64px;
  border: 2px dashed #E4CFB7;
  background: var(--cream);
  color: var(--brown-soft);
  font-weight: 800;
}
.slot.empty:hover { border-color: var(--pink); color: var(--brown); }
.slot-plus { font-size: 22px; line-height: 1; }
.slot.filled { border: 0; padding: 6px; background: var(--cream); }
.slot.pop { animation: pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes pop { 0% { transform: scale(0.9); } 60% { transform: scale(1.03); } 100% { transform: scale(1); } }
.slot-cover {
  width: 40px; height: 60px; flex: none;
  object-fit: cover;
  border-radius: 4px 6px 6px 4px;
  box-shadow: 0 2px 6px rgba(91, 70, 54, 0.2);
  background: var(--line);
}
.slot-text { flex: 1; min-width: 0; display: grid; }
.slot-author { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-title { font-weight: 800; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.slot-author { font-size: 14px; color: var(--brown-soft); }
.slot-swap { font-size: 13px; font-weight: 800; color: var(--brown-soft); padding: 6px 10px; border-radius: 999px; background: var(--white); }

#btn-add-chapter { width: 100%; min-height: 50px; margin-bottom: 12px; }

.bottom-bar {
  position: sticky;
  bottom: 0;
  margin: 0 -16px;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(255, 248, 238, 0), var(--cream) 28%);
}
.hint { margin: 0 0 8px; text-align: center; font-weight: 700; font-size: 14px; color: var(--brown-soft); }

/* ---------- search sheet ---------- */

.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(58, 44, 34, 0.35);
  z-index: 20;
  animation: fade 0.2s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0; /* app.js sets top and height to fit above the keyboard */
  z-index: 21;
  max-width: 560px;
  margin: 0 auto;
  height: min(88dvh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--cream);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px rgba(58, 44, 34, 0.2);
  padding: 8px 16px 0;
  animation: sheet-up 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.05);
}
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet-grip { width: 44px; height: 5px; border-radius: 5px; background: #E4D3C0; margin: 0 auto 8px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h3 { margin: 0; font-family: var(--display); font-size: 20px; line-height: 1.2; }
.search { position: relative; margin: 12px 0 8px; }
.search svg { position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); fill: none; stroke: var(--brown-soft); stroke-width: 2.2; stroke-linecap: round; }
.search .input { padding-left: 44px; -webkit-appearance: none; appearance: none; }
.search .input::-webkit-search-cancel-button, .search .input::-webkit-search-decoration { -webkit-appearance: none; }
.results {
  list-style: none;
  margin: 0 -16px;
  padding: 0 16px calc(16px + env(safe-area-inset-bottom));
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.results-note { padding: 24px 8px; text-align: center; color: var(--brown-soft); }
.results-skel {
  height: 78px;
  margin: 6px 0;
  border-radius: 14px;
  background: linear-gradient(90deg, #F6EADB 0%, #FBF3E8 50%, #F6EADB 100%) 0 0 / 200% 100%;
  animation: shimmer 1.1s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.result {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px;
  margin: 4px 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  text-align: left;
}
.result:hover, .result:focus-visible { background: var(--white); }
.result:active { transform: scale(0.99); }
.result img, .result-nocover {
  width: 44px; height: 66px; flex: none;
  border-radius: 4px 6px 6px 4px;
  object-fit: cover;
  background: var(--line);
  box-shadow: 0 2px 6px rgba(91, 70, 54, 0.18);
}
.result-nocover { display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 22px; color: var(--brown-soft); }
.result-text { display: grid; min-width: 0; }
.result-title { font-weight: 800; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result-meta { font-size: 14px; color: var(--brown-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 3. reveal ---------- */

.reveal { display: flex; flex-direction: column; align-items: center; padding-top: 16px; }
.flip {
  position: relative;
  width: min(300px, 82vw);
  aspect-ratio: 3 / 4;
  margin: 8px 0 20px;
  padding: 0;
  border: 0;
  background: none;
  perspective: 1000px;
}
.flip-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 24px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 16px 40px rgba(91, 70, 54, 0.18);
  padding: 24px;
  text-align: center;
}
.flip-front {
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.5) 0 6px, transparent 7px) 0 0 / 38px 38px,
    var(--pink);
  color: var(--white);
}
.flip-q { font-family: var(--display); font-size: 96px; font-weight: 700; line-height: 1; }
.flip-tap { font-weight: 800; font-size: 14px; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.9; }
.flip-back {
  transform: rotateY(180deg);
  background: var(--badge, var(--sage));
  color: var(--badge-ink, var(--brown));
}
.reveal-icon {
  width: 84px; height: 84px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  margin-bottom: 8px;
}
.reveal-icon svg { width: 46px; height: 46px; }
.reveal-kicker { font-weight: 800; font-size: 14px; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.85; }
.reveal-type { font-family: var(--display); font-weight: 700; font-size: 34px; line-height: 1.05; }
.reveal-tagline { font-size: 17px; font-weight: 700; opacity: 0.9; }
.sparkles { position: absolute; left: 50%; top: 50%; pointer-events: none; }
.sparkles i {
  position: absolute;
  width: 12px; height: 12px;
  margin: -6px;
  background: #F6C85F;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: sparkle 0.9s ease-out forwards;
  opacity: 0;
}
.sparkles i:nth-child(3n) { background: var(--pink); }
.sparkles i:nth-child(3n + 1) { background: var(--sage); }
@keyframes sparkle {
  0% { opacity: 0; transform: translate(0, 0) scale(0.2); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--x), var(--y)) scale(1) rotate(90deg); }
}
.why, #btn-see-shelf { opacity: 0; transform: translateY(6px); transition: opacity 0.35s ease, transform 0.35s ease; }
.why.show, #btn-see-shelf.show { opacity: 1; transform: none; }
.why { margin: 0 0 20px; font-weight: 700; color: var(--brown-soft); text-align: center; min-height: 1.45em; }

/* ---------- 4. share ---------- */

.preview-wrap { display: flex; justify-content: center; margin: 8px 0 18px; }
.preview-frame {
  position: relative;
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  border-radius: 16px;
  box-shadow: 0 14px 36px rgba(91, 70, 54, 0.18);
}
.preview-frame[data-size='story'] { max-width: 280px; }
.preview-scale { width: 360px; transform-origin: 0 0; }

.controls { display: grid; gap: 16px; margin-bottom: 20px; }
.control { display: grid; gap: 8px; }
.control-label { font-weight: 800; font-size: 14px; }
.control-label em { font-style: normal; font-weight: 600; color: var(--brown-soft); }
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  border: 0;
  border-radius: 14px;
  background: var(--white);
  box-shadow: inset 0 0 0 2px var(--line);
  font-weight: 800;
  font-size: 13px;
}
.chip[aria-checked='true'] { box-shadow: inset 0 0 0 3px var(--pink); background: var(--pink-soft); }
.chip-swatch { width: 36px; height: 36px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 999px; background: var(--white); box-shadow: inset 0 0 0 2px var(--line); }
.seg button { border: 0; border-radius: 999px; background: transparent; padding: 10px; font-weight: 800; }
.seg button[aria-checked='true'] { background: var(--pink); color: var(--white); }

.share-actions { display: grid; gap: 12px; justify-items: center; }
.status { margin: 0; min-height: 0; font-weight: 700; color: var(--brown-soft); text-align: center; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.confetti i {
  position: absolute;
  top: -12px;
  width: 8px; height: 12px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to { transform: translate(var(--drift), 105vh) rotate(var(--spin)); }
}

/* ---------- shared links ---------- */

.link-box {
  margin: 12px 0 8px;
  padding: 18px 16px;
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
  text-align: center;
}
.link-title { margin: 0; font-family: var(--display); font-size: 20px; }
.link-note { margin: 0; color: var(--brown-soft); font-size: 15px; }
.link-row { display: flex; gap: 8px; }
.link-row .input { flex: 1; min-width: 0; width: 0; font-size: 15px; color: var(--brown-soft); }
.link-box .status { min-height: 0; }
.link-box .status:empty { display: none; }
.link-box .link { justify-self: center; }

.shared { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 12px; }
.shared .title { margin-top: 12px; }
.shared .preview-wrap { width: 100%; }
.shared .btn-big { margin-top: 4px; }
.shared-owner { margin: 14px 0 0; color: var(--brown-soft); }
.shared .link.small { margin-top: 10px; font-size: 13px; }
#shared-frame .cover { cursor: pointer; transition: translate 0.15s ease; }
#shared-frame .cover:hover { translate: 0 -3px; }
#shared-frame .cover:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }

/* ---------- book details modal ---------- */

.book-modal {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 21;
  max-width: 560px;
  max-height: 90dvh;
  margin: 0 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  background: var(--cream);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px rgba(58, 44, 34, 0.2);
  animation: sheet-up 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.05);
}
.book-close { position: absolute; top: 14px; right: 14px; }
.book-hero { display: flex; gap: 16px; align-items: flex-end; margin: 6px 0 16px; padding-right: 44px; }
.book-cover {
  position: relative;
  flex: none;
  width: 132px;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 3px 8px 8px 3px;
  background: var(--sage);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12), 4px 10px 22px rgba(58, 44, 34, 0.3);
}
.book-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.book-cover-drawn {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 18% 10% 12%;
  text-align: center;
  color: #2F4A2B;
}
.book-cover-drawn b { font-family: var(--display); font-size: 15px; line-height: 1.1; }
.book-cover-drawn i { font-style: normal; font-weight: 800; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; }
.book-head { min-width: 0; }
.book-chapter {
  display: inline-block;
  margin: 0 0 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--pink-soft);
  font-size: 12px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase;
}
.book-title { margin: 0; font-family: var(--display); font-size: 24px; line-height: 1.1; }
.book-author { margin: 4px 0 0; font-weight: 700; color: var(--brown-soft); }
.book-facts { margin: 8px 0 0; font-size: 14px; color: var(--brown-soft); }
.book-desc { margin: 0 0 12px; font-size: 16px; line-height: 1.55; }
.book-desc.loading {
  height: 4.6em;
  border-radius: 10px;
  background: linear-gradient(90deg, #F6EADB 0%, #FBF3E8 50%, #F6EADB 100%) 0 0 / 200% 100%;
  animation: shimmer 1.1s linear infinite;
}
.book-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.book-tags:empty { display: none; }
.book-tags span { padding: 4px 10px; border-radius: 999px; background: var(--white); box-shadow: inset 0 0 0 2px var(--line); font-size: 13px; font-weight: 700; }
.book-link { display: inline-block; padding: 6px 0; margin-bottom: 12px; }
@media (min-width: 640px) {
  .book-modal { top: 50%; bottom: auto; left: 50%; right: auto; width: 520px; margin: 0; border-radius: 24px; transform: translate(-50%, -50%); animation: fade 0.2s ease; }
}

/* ==========================================================
   The share image. Laid out at 360px wide; exported at 3x.
   Everything here must be self-contained so export = preview.
   ========================================================== */

.shelf-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 12px;
  background: linear-gradient(170deg, var(--bg) 40%, var(--bg2));
  color: var(--ink);
  font-family: var(--body);
  text-align: center;
  line-height: 1.2;
}
.sc-stars { position: absolute; inset: 0; pointer-events: none; }
.sc-stars i { position: absolute; border-radius: 50%; background: #FFF6DC; }
.sc-stars svg { position: absolute; }

.sc-head { position: relative; }
.sc-name {
  margin: 0 0 2px;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sub);
  white-space: nowrap;
}
.sc-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 25px;
  line-height: 1.05;
  letter-spacing: -0.01em;
  white-space: nowrap; /* line breaks are set by hand so preview and export always match */
}
.theme-starry .sc-title, .theme-library .sc-title { font-weight: 500; }

.sc-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px 5px;
  border-radius: 999px;
  background: var(--badge);
  color: var(--badge-ink);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.1);
  text-align: left;
}
.sc-badge-icon {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
}
.sc-badge-icon svg { width: 18px; height: 18px; }
.sc-badge-text { display: grid; white-space: nowrap; }
.sc-badge-text b { font-family: var(--display); font-weight: 700; font-size: 14px; line-height: 1.1; }
.sc-badge-text i { font-style: normal; font-weight: 700; font-size: 9.5px; opacity: 0.9; }

.sc-shelves { position: relative; width: 100%; display: flex; flex-direction: column; gap: 10px; }
.sc-shelf { position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; }
.sc-case {
  width: 100%;
  padding: 14px 0 0;
  border-radius: 14px 14px 0 0;
  background: var(--wall);
  display: flex;
  justify-content: center;
}
.sc-row { display: flex; align-items: flex-end; gap: 4px; }
.sc-plant, .sc-cat { display: block; flex: none; position: relative; z-index: 1; }
.sc-cat { width: 40px; height: 28px; }
.sc-books { display: flex; align-items: flex-end; }
.sc-plank {
  position: relative;
  z-index: 2;
  width: calc(100% + 12px);
  height: 12px;
  border-radius: 3px;
  background: var(--wood);
  box-shadow: inset 0 -4px 0 var(--wood-dark), 0 4px 8px rgba(0, 0, 0, 0.12);
}
.theme-pastel .sc-plank { box-shadow: inset 0 -4px 0 var(--wood-dark), 0 4px 10px rgba(110, 79, 124, 0.15); }

/* A book standing face-out, like a bookstore display. */
.cover {
  position: relative;
  flex: none;
  overflow: hidden;
  border-radius: 2px 5px 5px 2px;
  transform-origin: 50% 100%;
  background: #E8D9C4;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15), 3px 6px 10px rgba(58, 44, 34, 0.28);
}
.cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-img:not([src]) { display: none; }
.cover-drawn {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16% 10% 10%;
  text-align: center;
  background:
    radial-gradient(circle at 50% 118%, rgba(255, 255, 255, 0.22) 0 34%, transparent 35%),
    var(--c);
  color: var(--ink);
}
.cover-title {
  width: 100%;
  font-family: var(--display);
  font-weight: 700;
  line-height: 1.05;
  overflow-wrap: normal; /* never split a word; fitCovers() shrinks the text instead */
}
.cover-author { margin-top: auto; font-weight: 800; letter-spacing: 0.08em; line-height: 1.15; opacity: 0.85; }
.cover-spine { position: absolute; left: 0; top: 0; bottom: 0; width: 6%; background: linear-gradient(90deg, rgba(0, 0, 0, 0.3), rgba(255, 255, 255, 0.16)); }
.cover-gloss { position: absolute; inset: 0; background: linear-gradient(115deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 40%); }

.sc-timeline { display: flex; gap: 4px; margin-top: 6px; }
.sc-pad { flex: none; }
.sc-time { display: flex; flex-direction: column; gap: 3px; color: var(--sub); }
.sc-arrow { display: block; opacity: 0.8; }
.sc-labels { display: flex; gap: 3px; }
.sc-labels span {
  flex: none;
  font-weight: 800;
  font-size: 10.5px;
  line-height: 1.15;
  color: var(--ink);
  overflow-wrap: break-word;
  hyphens: auto;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sc-foot {
  position: relative;
  margin: 0;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em; /* lowercase, so it reads as a web address */
  color: var(--sub);
  opacity: 0.85;
}

/* Story: same layout, taller shelf, more breathing room. */
.shelf-card.size-story { padding: 64px 16px 34px; justify-content: center; gap: 30px; }
.size-story .sc-name { font-size: 13px; margin-bottom: 6px; }
.size-story .sc-title { font-size: 34px; }
.size-story .sc-badge { padding: 7px 18px 7px 7px; }
.size-story .sc-badge-icon { width: 38px; height: 38px; }
.size-story .sc-badge-icon svg { width: 22px; height: 22px; }
.size-story .sc-badge-text b { font-size: 17px; }
.size-story .sc-badge-text i { font-size: 11px; }
.size-story .sc-case { padding-top: 40px; }
.size-story .sc-labels span { font-size: 11.5px; }
/* Two shelves: trim every bit of spare height so the covers can be bigger. */
.two-shelves .sc-case { padding-top: 6px; }
.two-shelves .sc-shelves { gap: 8px; }
.two-shelves .sc-timeline { margin-top: 5px; }
.shelf-card.size-portrait.two-shelves { padding: 14px 16px 10px; }
.size-portrait.two-shelves .sc-title { font-size: 23px; }
.shelf-card.size-story.two-shelves { gap: 22px; padding-top: 44px; }
.size-story .sc-foot { position: absolute; bottom: 26px; left: 0; right: 0; }

/* ?debug panel */
.debug {
  position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: 50;
  max-height: 45dvh; overflow: auto;
  padding: 8px; border-radius: 12px;
  background: rgba(20, 20, 20, 0.88); color: #E8FFE0;
  font: 11px/1.4 ui-monospace, Menlo, monospace;
}
.debug button { float: right; border: 0; border-radius: 6px; padding: 2px 8px; font: inherit; }
.debug pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
.debug.min { max-height: 28px; overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media (min-width: 700px) {
  #app { padding-top: 40px; }
  .home .display { font-size: 64px; }
}
