:root {
  color-scheme: light;
  --ink: #3a2719;
  --ink-soft: #765b3f;
  --muted: #8a6f4d;
  --paper: #f8dfa4;
  --paper-light: #fff1c7;
  --paper-edge: #dbad67;
  --cover: #7d341f;
  --cover-dark: #4d1d13;
  --accent: #8d4a2b;
  --accent-dark: #61301e;
  --gold: #bd842f;
  --shadow: rgba(40, 21, 9, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  color: var(--ink);
  font-family: "Avenir Next", Avenir, Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(ellipse at 50% 44%, rgba(255, 231, 164, 0.22), transparent 42%),
    linear-gradient(90deg, rgba(74, 38, 15, 0.24) 0 2px, transparent 2px 100%),
    repeating-linear-gradient(0deg, #a56732 0 46px, #8f5428 47px 50px, #b4733a 51px 94px);
  background-size: auto, 180px 100%, auto;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 50%, transparent 42%, rgba(38, 18, 7, 0.46) 100%),
    repeating-linear-gradient(7deg, rgba(255, 228, 170, 0.08) 0 1px, transparent 1px 10px);
  mix-blend-mode: multiply;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.setup-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(48, 24, 8, 0.62);
  backdrop-filter: blur(4px);
}

.setup-card {
  position: relative;
  width: min(720px, 100%);
  border: 1px solid rgba(116, 62, 25, 0.36);
  border-radius: 8px;
  padding: 28px;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 20%, rgba(255, 248, 218, 0.92), transparent 62%),
    var(--paper-light);
  box-shadow: 0 26px 60px rgba(42, 19, 7, 0.42), inset 0 0 34px rgba(138, 79, 30, 0.12);
}

.setup-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  color: #7b6043;
  background: rgba(255, 241, 203, 0.72);
  box-shadow: inset 0 0 0 1px rgba(132, 78, 37, 0.2);
  font-size: 1.55rem;
  line-height: 1;
}

.setup-close:hover {
  transform: translateY(-1px);
}

.setup-card h2 {
  margin: 2px 0 22px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  line-height: 1.1;
}

.setup-field {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.setup-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  width: 100%;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  min-height: 92px;
  width: 100%;
  min-width: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(122, 76, 34, 0.28);
  border-radius: 20px;
  color: #7b6043;
  background:
    linear-gradient(180deg, rgba(255, 250, 230, 0.82), rgba(255, 236, 190, 0.54)),
    rgba(255, 246, 219, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48), 0 8px 18px rgba(97, 48, 30, 0.08);
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, color 160ms ease;
}

.segmented-control label {
  min-width: 0;
  display: block;
  width: 100%;
}

.segmented-control label:hover span {
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48), 0 12px 22px rgba(97, 48, 30, 0.12);
}

.segmented-control input:checked + span {
  color: #fff5d8;
  background: linear-gradient(180deg, #9f5632, var(--accent-dark));
  box-shadow: 0 12px 22px rgba(97, 48, 30, 0.22), inset 0 1px 0 rgba(255, 236, 187, 0.2);
}

.setup-age {
  max-width: 140px;
}

.setup-name {
  max-width: 320px;
}

.setup-copy {
  margin: -8px 0 16px;
  color: #60442d;
  line-height: 1.5;
}

.privacy-note {
  margin: -4px 0 16px;
  border: 1px solid rgba(132, 78, 37, 0.2);
  border-radius: 8px;
  padding: 12px 14px;
  color: #60442d;
  background: rgba(255, 246, 219, 0.6);
  font-size: 0.92rem;
  line-height: 1.45;
}

.access-gate {
  z-index: 35;
}

.account-gate {
  z-index: 34;
}

.access-card {
  width: min(560px, 100%);
}

.account-card {
  width: min(600px, 100%);
}

.access-code-input {
  text-transform: uppercase;
}

.setup-submit {
  width: 100%;
  margin-top: 22px;
}

.storybook-shell {
  position: relative;
  width: min(1240px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(14px, 2.4vw, 34px);
  padding-bottom: max(34px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.topbar {
  min-height: 56px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-width: 0;
  color: #ffe8af;
  text-shadow: 0 2px 10px rgba(55, 25, 8, 0.5);
}

.brand-block {
  display: grid;
  gap: 3px;
  flex: 1 1 300px;
  min-width: 0;
}

.brand-logo {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  width: max-content;
  max-width: 100%;
  color: #fff0bd;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.1rem, 5vw, 4.1rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: 0;
  text-shadow: 0 3px 0 rgba(79, 35, 14, 0.38), 0 12px 22px rgba(52, 24, 8, 0.32);
}

.brand-eleven {
  position: relative;
  z-index: 2;
  margin-left: 0.02em;
  color: #f7c85e;
  font-family: "Avenir Next", Avenir, Inter, system-ui, sans-serif;
  font-size: 0.86em;
  font-weight: 950;
  letter-spacing: -0.03em;
  text-shadow: 0 2px 0 rgba(101, 52, 14, 0.52), 0 0 16px rgba(247, 200, 94, 0.42);
}

.brand-plus {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 0.86em;
  height: 0.86em;
  margin: 0 -0.08em 0 0.02em;
  border: 2px solid rgba(255, 238, 183, 0.82);
  border-radius: 50%;
  color: #5a2c18;
  background: #f7c85e;
  box-shadow: 0 4px 12px rgba(64, 27, 9, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.32);
  color: transparent;
  font-family: "Avenir Next", Avenir, Inter, system-ui, sans-serif;
  font-size: 0.32em;
  font-weight: 950;
  line-height: 1;
  text-shadow: none;
  transform: translate(-0.08em, -0.48em) rotate(-8deg);
}

.brand-plus::before,
.brand-plus::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  border-radius: 999px;
  background: #5a2c18;
  color: #5a2c18;
  transform: translate(-50%, -50%);
}

.brand-plus::before {
  width: 58%;
  height: 18%;
}

.brand-plus::after {
  width: 18%;
  height: 58%;
}

.brand-mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 1.06em;
  margin: 0 0.02em;
}

.brand-mark .brand-eleven {
  grid-area: 1 / 1;
  margin-left: 0;
  letter-spacing: 0;
}

.brand-mark .brand-plus {
  grid-area: 1 / 1;
  z-index: 1;
  margin: 0;
  pointer-events: none;
}

.brand-logo-option .brand-mark .brand-plus {
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  color: #f7c85e;
  background: transparent;
  box-shadow: none;
  font-family: "Avenir Next", Avenir, Inter, system-ui, sans-serif;
  font-size: 1.12em;
  font-weight: 950;
  line-height: 0.78;
  opacity: 0.82;
  text-shadow: 0 2px 0 rgba(101, 52, 14, 0.52), 0 0 16px rgba(247, 200, 94, 0.42);
}

.brand-logo-option .brand-plus::before,
.brand-logo-option .brand-plus::after {
  content: none;
}

.brand-logo-option {
  font-size: clamp(2.2rem, 6vw, 4.8rem);
  white-space: nowrap;
}

.brand-logo-plus-seal .brand-plus {
  font-size: 1.2em;
  opacity: 0.78;
  transform: translate(0.04em, 0.12em) rotate(0deg);
}

.brand-logo-plus-watermark .brand-mark {
  min-width: 1.1em;
}

.brand-logo-plus-watermark .brand-plus {
  font-size: 1.36em;
  opacity: 0.68;
  transform: translate(0.08em, 0.14em) rotate(0deg);
}

.brand-logo-plus-badge .brand-plus {
  font-size: 1.28em;
  opacity: 0.8;
  transform: translate(0.16em, 0.16em) rotate(0deg);
}

.brand-logo-plus-shift .brand-mark {
  min-width: 1.08em;
}

.brand-logo-plus-shift .brand-plus {
  font-size: 1.42em;
  opacity: 0.78;
  transform: translate(0.2em, 0.18em) rotate(0deg);
}

.logo-options-body {
  min-height: 100vh;
  margin: 0;
  color: #fff0bd;
  background:
    linear-gradient(180deg, rgba(73, 39, 18, 0.16), rgba(47, 24, 10, 0.4)),
    radial-gradient(circle at 18% 0%, rgba(247, 200, 94, 0.18), transparent 28%),
    #8a5127;
}

.logo-options-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 0 54px;
}

.logo-options-header {
  margin-bottom: 22px;
}

.logo-options-header h1 {
  color: #fff3cb;
  text-shadow: 0 3px 0 rgba(79, 35, 14, 0.28), 0 12px 22px rgba(52, 24, 8, 0.22);
}

.logo-options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.logo-option {
  display: grid;
  gap: 18px;
  min-width: 0;
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid rgba(255, 238, 183, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 231, 181, 0.12), rgba(76, 38, 14, 0.1)),
    rgba(91, 48, 19, 0.48);
  box-shadow: 0 18px 42px rgba(43, 20, 6, 0.22);
  overflow: hidden;
}

.logo-option-label {
  width: max-content;
  color: #f7c85e;
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 760px) {
  .logo-options-shell {
    width: min(100% - 22px, 520px);
    padding-top: 24px;
  }

  .logo-options-grid {
    grid-template-columns: 1fr;
  }

  .brand-logo-option {
    font-size: clamp(2rem, 12vw, 3.6rem);
  }
}

.brand-tagline {
  margin: 0;
  color: #f4cc7a;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.brand-logo-setup {
  margin-bottom: 10px;
  color: #7a4e30;
  font-size: clamp(2.2rem, 7vw, 3.6rem);
  text-shadow: none;
}

.brand-logo-setup .brand-eleven {
  text-shadow: 0 0 14px rgba(201, 147, 54, 0.38);
}

.eyebrow {
  margin: 0 0 2px;
  color: #f4cc7a;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 2.8vw, 3rem);
  font-weight: 700;
  letter-spacing: 0;
}

.book-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1 1 520px;
  min-width: 0;
}

.account-badge {
  max-width: min(220px, 100%);
  min-width: 0;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 12px;
  color: #fff1c7;
  background: rgba(70, 31, 12, 0.24);
  box-shadow: inset 0 0 0 1px rgba(255, 225, 160, 0.14);
  font-size: 0.82rem;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button,
.primary-button,
.secondary-button,
.text-button {
  border: 0;
  min-height: 42px;
  border-radius: 8px;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.icon-button {
  width: 44px;
  color: #ffe8af;
  background: rgba(70, 31, 12, 0.38);
  box-shadow: inset 0 0 0 1px rgba(255, 225, 160, 0.22), 0 8px 18px rgba(39, 18, 7, 0.28);
  font-size: 2rem;
  line-height: 1;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  color: #fff5d8;
  background: linear-gradient(180deg, #9f5632, var(--accent-dark));
  box-shadow: 0 9px 16px rgba(97, 48, 30, 0.22), inset 0 1px 0 rgba(255, 236, 187, 0.24);
  font-weight: 850;
}

.primary-button:disabled {
  cursor: wait;
  background: #8b7b63;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  color: #684129;
  background: rgba(255, 241, 203, 0.72);
  box-shadow: inset 0 0 0 1px rgba(132, 78, 37, 0.22), 0 7px 14px rgba(97, 48, 30, 0.1);
  font-weight: 850;
}

.secondary-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 1 auto;
  min-width: 0;
  padding: 0 14px;
  color: #ffe8af;
  background: rgba(70, 31, 12, 0.3);
  box-shadow: inset 0 0 0 1px rgba(255, 225, 160, 0.16), 0 8px 18px rgba(39, 18, 7, 0.18);
  font-weight: 850;
  white-space: nowrap;
}

.guide-link {
  text-decoration: none;
}

.text-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.icon-button:not(:disabled):hover,
.primary-button:not(:disabled):hover,
.secondary-button:not(:disabled):hover,
.text-button:not(:disabled):hover {
  transform: translateY(-1px);
}

.page-counter {
  min-width: 84px;
  text-align: center;
  font-weight: 850;
  white-space: nowrap;
}

.book {
  position: relative;
  align-self: start;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: min(680px, calc(100vh - 122px));
  border-radius: 6px 6px 12px 12px;
  padding: clamp(18px, 2.2vw, 28px) clamp(18px, 2.4vw, 32px) clamp(22px, 2.6vw, 36px);
  background:
    linear-gradient(90deg, rgba(49, 18, 8, 0.72), transparent 3.2%, transparent 96.8%, rgba(49, 18, 8, 0.72)),
    linear-gradient(180deg, #9f4a27, var(--cover) 46%, var(--cover-dark));
  box-shadow:
    0 34px 70px rgba(42, 19, 7, 0.54),
    0 6px 0 #4d1d13,
    inset 0 0 0 2px rgba(80, 29, 13, 0.45);
}

.book::before,
.book::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.book::before {
  left: clamp(16px, 2.2vw, 28px);
  right: clamp(16px, 2.2vw, 28px);
  bottom: clamp(8px, 1.3vw, 16px);
  height: 42px;
  border-radius: 0 0 48% 48%;
  background:
    linear-gradient(180deg, rgba(148, 87, 33, 0), rgba(108, 54, 19, 0.24)),
    repeating-linear-gradient(0deg, rgba(255, 231, 181, 0.28) 0 2px, rgba(118, 67, 26, 0.2) 3px 5px);
  filter: blur(0.2px);
  z-index: 1;
}

.book::after {
  inset: auto 5% -26px;
  height: 38px;
  border-radius: 50%;
  background: rgba(34, 13, 4, 0.36);
  filter: blur(17px);
}

.page {
  position: relative;
  min-width: 0;
  min-height: 0;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 34%, rgba(255, 246, 207, 0.82), transparent 58%),
    radial-gradient(ellipse at 50% 100%, rgba(180, 112, 41, 0.16), transparent 42%),
    radial-gradient(circle at 22% 18%, rgba(148, 89, 34, 0.08) 0 1px, transparent 2px),
    radial-gradient(circle at 74% 70%, rgba(148, 89, 34, 0.06) 0 1px, transparent 2px),
    var(--paper);
  background-size: auto, auto, 42px 46px, 58px 52px, auto;
  z-index: 2;
}

.page::before,
.page::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.page::before {
  inset: 12px;
  border: 1px solid rgba(155, 100, 42, 0.12);
  box-shadow: inset 0 0 36px rgba(142, 82, 31, 0.16);
}

.page::after {
  top: 0;
  bottom: 0;
  width: 52px;
  z-index: 1;
}

.page-left {
  border-radius: 58px 16px 28px 8px / 32px 10px 34px 8px;
  box-shadow:
    inset -28px 0 42px rgba(112, 66, 27, 0.22),
    inset 0 -24px 26px rgba(133, 76, 29, 0.13),
    10px 6px 18px rgba(63, 27, 10, 0.16);
}

.page-left::after {
  right: -4px;
  background: linear-gradient(90deg, transparent, rgba(117, 70, 31, 0.18) 56%, rgba(82, 44, 20, 0.38));
}

.page-right {
  border-radius: 16px 58px 8px 28px / 10px 32px 8px 34px;
  box-shadow:
    inset 28px 0 42px rgba(112, 66, 27, 0.22),
    inset 0 -24px 26px rgba(133, 76, 29, 0.13),
    -10px 6px 18px rgba(63, 27, 10, 0.16);
}

.page-right::after {
  left: -4px;
  background: linear-gradient(90deg, rgba(82, 44, 20, 0.38), rgba(117, 70, 31, 0.18) 44%, transparent);
}

.page-inner {
  position: relative;
  z-index: 2;
  min-height: 0;
  height: 100%;
  padding: clamp(34px, 4.2vw, 62px) clamp(34px, 4.8vw, 72px) clamp(32px, 4vw, 54px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.book.painting-page .page-left .page-inner::before {
  content: "";
  position: absolute;
  left: clamp(18px, 2vw, 28px);
  right: clamp(18px, 2vw, 28px);
  top: clamp(62px, 5.8vw, 86px);
  height: min(56vh, 58%);
  z-index: 8;
  border-radius: 8px;
  background:
    linear-gradient(105deg, transparent 0 32%, rgba(255, 255, 255, 0.62) 46%, transparent 60%),
    radial-gradient(circle at 24% 30%, rgba(255, 247, 203, 0.94), transparent 34%),
    radial-gradient(circle at 74% 74%, rgba(219, 164, 77, 0.28), transparent 38%),
    repeating-linear-gradient(-12deg, rgba(178, 121, 50, 0.12) 0 9px, rgba(255, 239, 184, 0.2) 10px 22px),
    rgba(255, 238, 181, 0.9);
  background-size: 220% 100%, auto, auto, auto, auto;
  box-shadow: 0 12px 24px rgba(91, 53, 22, 0.16);
  animation: paintWash 1.55s ease-in-out infinite;
}

.book.painting-page .page-left .page-inner::after {
  content: "Unlocking your picture...";
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 9;
  transform: translate(-50%, -50%);
  width: min(78%, 420px);
  border-radius: 999px;
  padding: 14px 18px;
  color: #6d3b24;
  background: rgba(255, 244, 205, 0.9);
  box-shadow: 0 10px 24px rgba(91, 53, 22, 0.18), inset 0 0 0 1px rgba(150, 85, 36, 0.18);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.4vw, 1.3rem);
  font-style: italic;
  text-align: center;
  animation: paintMessagePulse 1.55s ease-in-out infinite;
}

.book.page-complete.painting-page .page-left .page-inner::before,
.book.page-complete.painting-page .page-left .page-inner::after {
  content: none;
}

.book.painting-page .page-left .word-panel,
.book.painting-page .page-left .progress-panel {
  visibility: hidden;
}

.page-heading {
  color: rgba(94, 61, 35, 0.6);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.3vw, 1.22rem);
  font-style: italic;
  text-align: center;
}

.word-panel,
.progress-panel,
.word-bank {
  border: 1px solid rgba(144, 89, 36, 0.18);
  border-radius: 8px;
  background: rgba(255, 239, 194, 0.38);
  box-shadow: inset 0 1px 0 rgba(255, 248, 221, 0.48);
}

.word-panel {
  margin-top: auto;
  padding: 18px;
}

label,
.section-title,
.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.word-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  margin-top: 10px;
}

input {
  min-width: 0;
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(122, 76, 34, 0.28);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255, 246, 219, 0.72);
  outline: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  box-shadow: inset 0 2px 7px rgba(96, 55, 21, 0.08);
}

select,
textarea {
  min-width: 0;
  width: 100%;
  border: 1px solid rgba(122, 76, 34, 0.28);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(255, 246, 219, 0.72);
  outline: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  box-shadow: inset 0 2px 7px rgba(96, 55, 21, 0.08);
}

select {
  min-height: 46px;
}

textarea {
  min-height: 132px;
  resize: vertical;
  line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(141, 74, 43, 0.13), inset 0 2px 7px rgba(96, 55, 21, 0.08);
}

.status-line {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.progress-panel {
  padding: 16px 18px;
}

.progress-track {
  height: 10px;
  margin-top: 12px;
  border-radius: 999px;
  background: rgba(121, 76, 36, 0.14);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(94, 55, 22, 0.13);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #96512f, #c99336);
  transition: width 280ms ease;
}

.word-bank {
  flex: 0 1 auto;
  min-height: 116px;
  padding: 16px 18px;
  overflow: hidden;
}

.word-chips {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  margin-top: 14px;
}

.word-chip {
  position: relative;
  max-width: 100%;
  min-height: 31px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(150, 85, 36, 0.22);
  border-radius: 999px;
  padding: 5px 10px;
  color: #56331f;
  background: rgba(241, 204, 126, 0.54);
  font-size: 0.88rem;
  font-weight: 850;
  overflow-wrap: anywhere;
  cursor: help;
  overflow: visible;
}

.illustration-wrap {
  position: relative;
  flex: 0 1 auto;
  min-height: 0;
  width: 100%;
  margin: 0 auto;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: transparent;
  box-shadow: 0 12px 24px rgba(91, 53, 22, 0.16);
  animation: pageReveal 900ms cubic-bezier(0.19, 1, 0.22, 1) both;
}

.illustration-wrap img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(62vh, 100%);
  object-fit: contain;
  background: transparent;
}

.book.painting-page .illustration-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  background:
    linear-gradient(105deg, transparent 0 32%, rgba(255, 255, 255, 0.62) 46%, transparent 60%),
    radial-gradient(circle at 24% 30%, rgba(255, 247, 203, 0.94), transparent 34%),
    radial-gradient(circle at 74% 74%, rgba(219, 164, 77, 0.28), transparent 38%),
    repeating-linear-gradient(-12deg, rgba(178, 121, 50, 0.12) 0 9px, rgba(255, 239, 184, 0.2) 10px 22px),
    rgba(255, 238, 181, 0.9);
  background-size: 220% 100%, auto, auto, auto, auto;
  animation: paintWash 1.55s ease-in-out infinite;
}

.book.painting-page .illustration-wrap::after {
  content: "Unlocking your picture...";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  transform: translate(-50%, -50%);
  width: min(82%, 520px);
  border-radius: 999px;
  padding: 14px 18px;
  color: #6d3b24;
  background: rgba(255, 244, 205, 0.9);
  box-shadow: 0 10px 24px rgba(91, 53, 22, 0.18), inset 0 0 0 1px rgba(150, 85, 36, 0.18);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.4vw, 1.3rem);
  font-style: italic;
  text-align: center;
  animation: paintMessagePulse 1.55s ease-in-out infinite;
}

.book.painting-page .illustration-wrap img {
  filter: saturate(0.72) opacity(0.42);
}

.book.page-complete .page-left .page-inner {
  gap: 14px;
}

.book.page-complete .page-left .page-heading {
  color: #8c442d;
  margin-bottom: -2px;
}

.book.page-complete .word-panel,
.book.page-complete .progress-panel {
  display: none;
}

.book.page-complete .illustration-wrap {
  flex: 0 1 auto;
  display: block;
  min-height: 0;
  width: calc(100% + clamp(18px, 2.5vw, 42px));
  max-width: none;
  margin-left: calc(clamp(9px, 1.25vw, 21px) * -1);
}

.book.page-complete .word-bank {
  flex: 1 1 auto;
  min-height: 98px;
  overflow: auto;
}

.hidden {
  display: none;
}

.library-overlay {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(48, 24, 8, 0.66);
  backdrop-filter: blur(4px);
}

.library-overlay.hidden {
  display: none;
}

.library-panel {
  position: relative;
  width: min(920px, 100%);
  max-height: min(760px, 88vh);
  overflow: auto;
  border: 1px solid rgba(116, 62, 25, 0.36);
  border-radius: 8px;
  padding: 28px;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(255, 248, 218, 0.92), transparent 62%),
    var(--paper-light);
  box-shadow: 0 26px 60px rgba(42, 19, 7, 0.42), inset 0 0 34px rgba(138, 79, 30, 0.12);
}

.library-panel h2 {
  margin: 0 0 20px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
}

.library-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 18px;
  align-items: end;
  padding: 18px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(119, 68, 31, 0.14), rgba(119, 68, 31, 0.28));
}

.library-shelf.hidden,
.library-preview.hidden {
  display: none;
}

.library-empty {
  margin: 0;
  color: var(--muted);
}

.library-recovery {
  margin-top: 18px;
}

.library-recovery:empty {
  display: none;
}

.library-recovery h3 {
  margin: 0 0 6px;
  color: #4c2d1b;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
}

.library-recovery p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.45;
}

.library-recovery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 18px;
  padding: 18px;
  border-radius: 8px;
  background: rgba(255, 246, 219, 0.5);
  box-shadow: inset 0 0 0 1px rgba(132, 78, 37, 0.16);
}

.library-book {
  display: grid;
  gap: 9px;
  border: 0;
  padding: 0;
  color: #4c2d1b;
  background: transparent;
  text-align: left;
}

.library-cover {
  aspect-ratio: 2 / 3;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 239, 184, 0.28), rgba(62, 27, 13, 0.2)),
    linear-gradient(135deg, #35556d, #7a4c63 58%, #c48a40);
  background-position: center;
  background-size: cover;
  box-shadow: 0 12px 20px rgba(62, 27, 13, 0.28), inset 0 0 0 2px rgba(255, 232, 175, 0.28);
}

.library-book strong {
  font-size: 0.95rem;
  line-height: 1.15;
}

.library-book span:last-child {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.library-preview {
  display: grid;
  grid-template-columns: minmax(190px, 270px) minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  padding: 18px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(119, 68, 31, 0.12), rgba(119, 68, 31, 0.24));
}

.library-preview .text-button {
  grid-column: 1 / -1;
  justify-self: start;
  color: #6d3b24;
  background: rgba(255, 241, 203, 0.72);
  box-shadow: inset 0 0 0 1px rgba(132, 78, 37, 0.2);
}

.library-preview-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  border: 8px solid rgba(178, 121, 50, 0.62);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 239, 184, 0.28), rgba(62, 27, 13, 0.2)),
    linear-gradient(135deg, #35556d, #7a4c63 58%, #c48a40);
  background-position: center;
  background-size: cover;
  box-shadow: 0 18px 32px rgba(62, 27, 13, 0.28), inset 0 0 0 2px rgba(255, 232, 175, 0.28);
}

.library-preview-copy {
  display: grid;
  gap: 14px;
}

.library-preview-copy h3 {
  margin: 0;
  color: #63361f;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.05;
}

.library-preview-copy p {
  margin: 0;
  color: var(--muted);
  font-weight: 850;
}

.print-area {
  display: none;
}

.guide-body {
  min-height: 100vh;
}

.guide-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  width: min(1060px, calc(100% - 28px));
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 14px auto 0;
  padding: 10px 14px;
  border: 1px solid rgba(255, 225, 160, 0.16);
  border-radius: 8px;
  background: rgba(70, 31, 12, 0.58);
  box-shadow: 0 14px 30px rgba(39, 18, 7, 0.24), inset 0 1px 0 rgba(255, 238, 183, 0.1);
  backdrop-filter: blur(8px);
}

.guide-nav-logo {
  display: inline-flex;
  align-items: baseline;
  color: #fff0bd;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: 0;
  text-decoration: none;
  text-shadow: 0 2px 0 rgba(79, 35, 14, 0.38), 0 8px 18px rgba(52, 24, 8, 0.3);
}

.guide-nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.guide-nav-links a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 12px;
  color: #ffe8af;
  background: rgba(70, 31, 12, 0.3);
  box-shadow: inset 0 0 0 1px rgba(255, 225, 160, 0.16);
  font-size: 0.92rem;
  font-weight: 850;
  text-decoration: none;
}

.guide-nav-links a:hover {
  transform: translateY(-1px);
}

.guide-shell {
  width: min(1060px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 42px);
}

.guide-hero {
  padding: clamp(24px, 4vw, 46px);
  border: 1px solid rgba(116, 62, 25, 0.34);
  border-radius: 8px;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 18%, rgba(255, 248, 218, 0.92), transparent 66%),
    var(--paper-light);
  box-shadow: 0 24px 56px rgba(42, 19, 7, 0.34), inset 0 0 34px rgba(138, 79, 30, 0.12);
}

.guide-hero .brand-logo {
  color: #7a4e30;
  font-size: clamp(2.5rem, 7vw, 4.8rem);
  text-shadow: none;
}

.guide-hero h1 {
  margin-top: 24px;
  color: #63361f;
  font-size: clamp(2rem, 4vw, 3.5rem);
}

.guide-hero p:last-child {
  max-width: 760px;
  margin: 14px 0 0;
  color: #60442d;
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  line-height: 1.55;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.guide-card,
.guide-routine {
  border: 1px solid rgba(150, 85, 36, 0.24);
  border-radius: 8px;
  padding: 22px;
  background: rgba(255, 241, 203, 0.82);
  box-shadow: 0 12px 26px rgba(55, 25, 8, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.46);
}

.guide-card h2,
.guide-routine h2 {
  margin: 0 0 12px;
  color: #7a3f2d;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.28rem;
}

.guide-card p {
  margin: 0;
  color: #4d3624;
  line-height: 1.5;
}

.guide-card p + p {
  margin-top: 10px;
}

.guide-routine {
  margin-top: 22px;
}

.guide-routine ol {
  margin: 0;
  padding-left: 1.5rem;
  color: #4d3624;
  line-height: 1.7;
}

.story-text {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: var(--story-gap, 0.62em);
  padding-top: clamp(4px, 1.3vh, 18px);
  padding-right: 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--story-font-size, clamp(1rem, 1.28vw, 1.28rem));
  line-height: var(--story-line-height, 1.42);
  color: #3a2719;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(140, 68, 45, 0.34) transparent;
}

.story-text::-webkit-scrollbar {
  width: 8px;
}

.story-text::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(140, 68, 45, 0.28);
}

.story-text-dense {
  --story-gap: 0.48em;
  --story-font-size: clamp(1rem, 1.18vw, 1.18rem);
  --story-line-height: 1.34;
}

.paint-prompt {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(150, 85, 36, 0.24);
  border-radius: 8px;
  background: rgba(255, 238, 181, 0.58);
  box-shadow: inset 0 1px 0 rgba(255, 250, 224, 0.8);
}

.paint-prompt.hidden {
  display: none;
}

.paint-prompt p {
  margin: 0;
  color: #7a5d3f;
  font-size: 0.9rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.paint-prompt .primary-button {
  min-height: 44px;
  padding-inline: 18px;
  white-space: nowrap;
}

.finish-prompt {
  flex: 0 0 auto;
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid rgba(150, 85, 36, 0.28);
  border-radius: 8px;
  background: rgba(255, 238, 181, 0.66);
}

.finish-prompt.hidden {
  display: none;
}

.finish-prompt p {
  margin: 0;
  color: #7a3f2d;
  font-size: 0.95rem;
  font-weight: 850;
  text-align: center;
}

.feedback-reminder {
  color: #684129;
  font-size: 0.86rem;
}

.feedback-reminder.hidden {
  display: none;
}

.feedback-overlay {
  z-index: 32;
}

.feedback-card {
  width: min(680px, 100%);
  max-height: min(860px, calc(100vh - 40px));
  overflow: auto;
}

.feedback-card textarea {
  min-height: 86px;
  resize: vertical;
}

.feedback-file-input {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  font: inherit;
}

.feedback-file-status {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.feedback-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.feedback-preview-body {
  min-height: 100vh;
}

.feedback-preview-shell {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.feedback-preview-card h1 {
  margin: 10px 0 0;
  letter-spacing: 0;
}

.feedback-preview-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.admin-body {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 241, 203, 0.94), rgba(248, 223, 164, 0.9)),
    repeating-linear-gradient(0deg, #a56732 0 46px, #8f5428 47px 50px, #b4733a 51px 94px);
}

.admin-body::before {
  opacity: 0.22;
}

.admin-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.admin-header {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
  padding: 22px 0;
}

.admin-header h1,
.admin-panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.admin-header h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
}

.admin-header p,
.admin-status,
.admin-empty {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-weight: 750;
}

.admin-panel {
  border: 1px solid rgba(116, 62, 25, 0.28);
  border-radius: 8px;
  padding: 20px;
  background: rgba(255, 241, 203, 0.78);
  box-shadow: 0 14px 34px rgba(42, 19, 7, 0.16);
}

.admin-token-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
  margin-top: 14px;
}

.admin-dashboard.hidden,
#adminLogin.hidden {
  display: none;
}

.admin-dashboard {
  display: grid;
  gap: 18px;
}

.admin-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.admin-stat {
  min-height: 96px;
  border: 1px solid rgba(116, 62, 25, 0.22);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 250, 235, 0.84);
}

.admin-stat strong {
  display: block;
  color: var(--accent-dark);
  font-size: 1.9rem;
  line-height: 1;
}

.admin-stat span {
  display: block;
  margin-top: 8px;
  color: var(--ink-soft);
  font-weight: 850;
}

.admin-list,
.admin-response-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.admin-account,
.admin-response {
  border: 1px solid rgba(116, 62, 25, 0.18);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 250, 235, 0.82);
}

.admin-account h3 {
  margin: 0;
  color: var(--accent-dark);
  font-size: 1rem;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.admin-account p,
.admin-response-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.admin-question-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.admin-question {
  align-self: start;
}

.admin-choice-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.admin-choice-summary span {
  border: 1px solid rgba(141, 74, 43, 0.24);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--accent-dark);
  background: rgba(255, 250, 235, 0.86);
  font-size: 0.86rem;
  font-weight: 850;
}

.admin-response-text {
  margin: 8px 0 0;
  color: var(--ink);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.admin-screenshots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.admin-screenshots a {
  color: var(--accent-dark);
  font-size: 0.86rem;
  font-weight: 850;
}

@media (max-width: 820px) {
  .admin-header,
  .admin-token-form,
  .admin-stats,
  .admin-question-grid {
    grid-template-columns: 1fr;
  }

  .admin-toolbar {
    justify-content: stretch;
  }

  .admin-toolbar button {
    flex: 1;
  }
}

.cover-preview {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.cover-preview.hidden,
.cover-loading.hidden,
.cover-preview img.hidden,
.finish-actions .hidden {
  display: none;
}

.cover-preview-frame {
  position: relative;
  width: min(168px, 52vw);
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border: 7px solid rgba(178, 121, 50, 0.58);
  border-radius: 6px;
  background:
    linear-gradient(105deg, transparent 0 32%, rgba(255, 255, 255, 0.62) 46%, transparent 60%),
    radial-gradient(circle at 30% 24%, rgba(255, 247, 203, 0.94), transparent 34%),
    linear-gradient(135deg, #35556d, #7a4c63 58%, #c48a40);
  background-size: 220% 100%, auto, auto;
  box-shadow: 0 14px 24px rgba(91, 53, 22, 0.22), inset 0 0 0 2px rgba(89, 51, 18, 0.18);
}

.cover-preview.cover-preview-loading .cover-preview-frame {
  animation: paintWash 1.55s ease-in-out infinite;
}

.cover-preview-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-loading {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(100% - 22px);
  border-radius: 12px;
  padding: 12px 10px;
  color: #6d3b24;
  background: rgba(255, 244, 205, 0.92);
  box-shadow: 0 8px 18px rgba(91, 53, 22, 0.18);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.86rem;
  font-style: italic;
  text-align: center;
  animation: paintMessagePulse 1.55s ease-in-out infinite;
}

.cover-preview h3 {
  max-width: 36ch;
  margin: 0;
  color: #6d3b24;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  line-height: 1.15;
  text-align: center;
}

.finish-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.finish-prompt.cover-is-ready .finish-actions {
  grid-template-columns: 1fr 1fr;
}

.the-end {
  margin-top: 0.55em;
  color: #8c442d;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.1em;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: center;
}

.story-text p {
  margin: 0;
}

.story-writing {
  color: #765b3f;
  font-style: italic;
}

.story-text p:first-child::first-letter {
  float: left;
  padding: 0.03em 0.12em 0 0;
  color: #8c442d;
  font-size: 2.75em;
  line-height: 0.82;
  font-weight: 700;
}

.book.page-complete .page-right .page-heading {
  color: #8c442d;
  font-size: clamp(0.9rem, 1vw, 1rem);
}

.book.page-complete .page-right .page-inner {
  gap: 14px;
}

.book.page-complete .story-text {
  font-size: clamp(1rem, 1.18vw, 1.18rem);
  line-height: 1.34;
  padding-bottom: 46px;
}

.page-curl-next {
  position: absolute;
  right: clamp(18px, 2.4vw, 34px);
  bottom: clamp(16px, 2.1vw, 30px);
  z-index: 5;
  min-width: 124px;
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  color: #704026;
  background: rgba(255, 246, 219, 0.9);
  box-shadow:
    0 8px 16px rgba(91, 53, 22, 0.14),
    inset 0 0 0 1px rgba(132, 78, 37, 0.22);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.page-curl-next::after {
  content: "\203A";
  margin-left: 8px;
  color: #7b3f26;
  font-size: 1.2rem;
  line-height: 1;
}

.page-curl-next span {
  position: relative;
  z-index: 1;
}

.page-curl-next:not(:disabled):hover {
  transform: translateY(-1px);
  background: rgba(255, 250, 230, 0.96);
  box-shadow:
    0 11px 20px rgba(91, 53, 22, 0.18),
    inset 0 0 0 1px rgba(132, 78, 37, 0.26);
}

.page-curl-next.hidden {
  display: none;
}

.story-sentence {
  position: relative;
}

.story-vocab-word {
  position: relative;
  display: inline;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  outline: 0;
  padding: 0;
  color: #63361f;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  font-weight: 800;
  line-height: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(150, 85, 36, 0.28);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.12em;
  cursor: help;
  overflow: visible;
  vertical-align: baseline;
}

.vocab-popover {
  position: relative;
}

.vocab-popover::selection {
  background: rgba(213, 154, 61, 0.28);
}

.word-chip::before {
  content: "";
  position: absolute;
  inset: -16% -10%;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(105deg, transparent 0 40%, rgba(255, 248, 199, 0.46) 50%, rgba(236, 174, 71, 0.22) 56%, transparent 68% 100%);
  opacity: 0;
  transform: translateX(-60%) skewX(-12deg);
  pointer-events: none;
}

.word-chip:hover::before,
.word-chip:focus-visible::before,
.word-chip.definition-visible::before {
  opacity: 0.8;
  animation: vocabShimmer 1250ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.story-vocab-word,
.word-chip {
  isolation: isolate;
}

.story-vocab-word:hover,
.story-vocab-word:focus-visible,
.story-vocab-word.definition-visible {
  color: #7d3d22;
  animation: vocabTextGleam 950ms ease-out both;
}

.definition-tooltip {
  position: fixed;
  z-index: 100;
  width: max-content;
  max-width: min(280px, calc(100vw - 24px));
  border: 1px solid rgba(122, 76, 34, 0.24);
  border-radius: 8px;
  padding: 9px 12px;
  color: #4e321f;
  background: #fff3cc;
  box-shadow: 0 12px 26px rgba(80, 42, 16, 0.2);
  font-family: "Avenir Next", Avenir, Inter, system-ui, sans-serif;
  font-size: 0.8rem;
  font-style: normal;
  font-weight: 400;
  line-height: 1.35;
  text-align: center;
  white-space: pre-line;
  pointer-events: none;
  animation: definitionFloatIn 170ms ease-out both;
}

.story-sentence-magical {
  filter: drop-shadow(0 0 10px rgba(190, 128, 44, 0.16));
}

.story-sentence-magical::after {
  content: "";
  position: absolute;
  left: -0.18em;
  right: -0.18em;
  bottom: -0.12em;
  height: 0.18em;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(211, 154, 61, 0.42), transparent);
  opacity: 0;
  animation: inkGlimmer 1400ms ease-out both;
}

.magic-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.22em) scale(0.985);
  color: rgba(58, 39, 25, 0);
  text-shadow: 0 0 12px rgba(136, 74, 39, 0.56);
  animation: wordInkIn 680ms cubic-bezier(0.19, 1, 0.22, 1) both;
  animation-delay: calc(var(--word-index) * 82ms);
}

.story-vocab-word.magic-word {
  display: inline-block;
  color: rgba(99, 54, 31, 0);
}

.empty-story {
  max-width: 28ch;
  margin: auto;
  color: rgba(82, 55, 33, 0.62);
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  text-align: center;
}

.folio-mark {
  margin: auto 0 0;
  color: rgba(99, 75, 52, 0.55);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.84rem;
  font-style: italic;
  text-align: center;
}

@keyframes sentenceIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes wordInkIn {
  0% {
    opacity: 0;
    color: rgba(58, 39, 25, 0);
    transform: translateY(0.22em) scale(0.985);
    filter: blur(5px);
    text-shadow: 0 0 16px rgba(191, 132, 47, 0.72);
  }
  62% {
    opacity: 1;
    color: rgba(117, 68, 37, 0.78);
    filter: blur(0.8px);
    text-shadow: 0 0 10px rgba(191, 132, 47, 0.38);
  }
  100% {
    opacity: 1;
    color: #3a2719;
    transform: translateY(0) scale(1);
    filter: blur(0);
    text-shadow: none;
  }
}

@keyframes pageReveal {
  0% {
    opacity: 0;
    transform: scale(0.96);
    filter: sepia(0.6) saturate(0.7) blur(8px);
  }
  45% {
    opacity: 1;
    filter: sepia(0.25) saturate(1.1) blur(1px);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter: none;
  }
}

@keyframes paintWash {
  0% {
    background-position: -120% 0, center, center, center, center;
    filter: saturate(0.92);
  }
  50% {
    background-position: 40% 0, center, center, center, center;
    filter: saturate(1.1);
  }
  100% {
    background-position: 160% 0, center, center, center, center;
    filter: saturate(0.92);
  }
}

@keyframes paintMessagePulse {
  0%,
  100% {
    opacity: 0.86;
    transform: translate(-50%, -50%) scale(0.99);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes vocabShimmer {
  0% {
    transform: translateX(-60%) skewX(-12deg);
  }
  100% {
    transform: translateX(60%) skewX(-12deg);
  }
}

@keyframes vocabTextGleam {
  0% {
    text-shadow: none;
  }
  45% {
    text-shadow: 0 0 10px rgba(218, 161, 59, 0.34);
  }
  100% {
    text-shadow: none;
  }
}

@keyframes definitionFloatIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes inkGlimmer {
  0% {
    opacity: 0;
    transform: scaleX(0);
  }
  28% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    transform: scaleX(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .magic-word,
  .story-sentence-magical::after,
  .book.painting-page .page-left .page-inner::before,
  .book.painting-page .page-left .page-inner::after {
    animation: none;
  }

  .magic-word {
    opacity: 1;
    transform: none;
    color: #3a2719;
    filter: none;
    text-shadow: none;
  }
}

@media (min-width: 861px) and (max-height: 760px) {
  .storybook-shell {
    min-height: auto;
    padding: 10px 26px 34px;
    gap: 10px;
  }

  .topbar {
    min-height: 46px;
  }

  .eyebrow {
    margin-bottom: 0;
    font-size: 0.68rem;
  }

  h1 {
    font-size: 2rem;
  }

  .book {
    min-height: 0;
    height: auto;
    padding: 16px 24px 24px;
  }

  .page-inner {
    padding: 30px 48px 28px;
    gap: 12px;
  }

  .page-heading {
    font-size: 1rem;
  }

  .word-panel {
    padding: 14px;
  }

  input,
  .primary-button {
    min-height: 40px;
  }

  .status-line {
    margin-top: 8px;
  }

  .progress-panel,
  .word-bank {
    padding: 13px 16px;
  }

  .word-bank {
    min-height: 80px;
  }

  .folio-mark {
    display: none;
  }
}

@media (max-width: 860px) {
  .storybook-shell {
    height: auto;
    min-height: 100vh;
    padding: 14px;
    overflow: visible;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .book {
    grid-template-columns: 1fr;
    gap: 0;
    min-height: auto;
    padding: 16px;
  }

  .book::before {
    display: none;
  }

  .page-left,
  .page-right {
    border-radius: 28px 28px 10px 10px;
    min-height: auto;
  }

  .page-inner {
    padding: 30px 24px;
  }

  .word-row {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .guide-grid {
    grid-template-columns: 1fr;
  }

  .library-preview {
    grid-template-columns: 1fr;
  }

  .library-preview-cover {
    width: min(260px, 100%);
    justify-self: center;
  }

  .guide-nav {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .guide-nav-links {
    justify-content: flex-start;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 12mm;
  }

  body {
    background: #fff;
    color: #2b2118;
  }

  body::before,
  .setup-overlay,
  .storybook-shell,
  .library-overlay,
  .definition-tooltip {
    display: none !important;
  }

  .guide-body .setup-overlay,
  .guide-body .storybook-shell,
  .guide-body .library-overlay,
  .guide-body .definition-tooltip,
  .guide-body .guide-nav {
    display: none !important;
  }

  .guide-body .guide-shell {
    display: block;
    padding: 0;
  }

  .guide-body .guide-grid {
    grid-template-columns: 1fr;
  }

  .guide-body .guide-card,
  .guide-body .guide-routine,
  .guide-body .guide-hero {
    break-inside: avoid;
    box-shadow: none;
  }

  .print-area {
    display: block;
  }

  .print-cover,
  .print-page {
    break-after: page;
    break-inside: avoid;
    height: 273mm;
    max-height: 273mm;
    display: flex;
    flex-direction: column;
    gap: 4mm;
    overflow: hidden;
    color: #2b2118;
    font-family: Georgia, "Times New Roman", serif;
  }

  .print-cover:last-child,
  .print-page:last-child {
    break-after: auto;
  }

  .print-cover {
    justify-content: center;
    text-align: center;
  }

  .print-cover img {
    width: 100%;
    max-height: 216mm;
    object-fit: cover;
    border-radius: 4mm;
  }

  .print-cover h1 {
    margin: 0;
    color: #7a3f2d;
    font-size: 24pt;
    line-height: 1.05;
  }

  .print-page h2 {
    margin: 0;
    color: #7a3f2d;
    font-size: 14pt;
    text-align: center;
  }

  .print-illustration {
    width: 100%;
    height: 105mm;
    max-height: 105mm;
    object-fit: cover;
    border: 2mm solid #bd842f;
  }

  .print-story {
    flex: 0 1 auto;
    font-size: 10.5pt;
    line-height: 1.18;
    overflow: hidden;
  }

  .print-story p {
    margin: 0 0 2mm;
  }

  .print-story button {
    border: 0;
    padding: 0;
    color: inherit;
    background: transparent;
    font-family: inherit;
    font-size: inherit;
    font-weight: 700;
    text-decoration: underline;
  }

  .print-vocabulary {
    margin-top: auto;
    max-height: 48mm;
    overflow: hidden;
    padding-top: 3mm;
    border-top: 0.4mm solid #d4aa65;
    columns: 2;
    font-family: "Avenir Next", Avenir, Arial, sans-serif;
    font-size: 7.8pt;
    line-height: 1.15;
  }

  .print-vocabulary p {
    break-inside: avoid;
    margin: 0 0 1.2mm;
  }

  .the-end {
    font-size: 13pt;
  }
}
