:root {
  color-scheme: light;
  --navy: #070d59;
  --royal: #1f3c88;
  --light-blue: #5893d4;
  --gold: #f7b633;
  --sky-deep: var(--navy);
  --sky: var(--navy);
  --sky-mid: var(--royal);
  --sky-soft: var(--light-blue);
  --cream: #fff8e9;
  --paper: #fffdf7;
  --paper-warm: #fff7e7;
  --ink: var(--navy);
  --ink-soft: var(--royal);
  --muted: #4f5b83;
  --line: rgba(7, 13, 89, 0.14);
  --white: #ffffff;
  --danger: #a64040;
  --success: #3f846d;
  --shadow-soft: 0 22px 70px rgba(7, 13, 89, 0.2);
  --shadow-card: 0 22px 45px rgba(7, 13, 89, 0.14);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 15px;
  --reader-scale: 1;
  --safe-top: max(20px, env(safe-area-inset-top));
  --safe-bottom: max(22px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -15%, rgba(88, 147, 212, 0.34), transparent 40%),
    linear-gradient(180deg, var(--sky-deep) 0, var(--sky) 52%, var(--royal) 100%);
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  color: inherit;
}

button,
a,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent;
}

button:not(:disabled),
a,
select {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  padding: 10px 14px;
  color: var(--ink);
  background: var(--cream);
  border-radius: 10px;
  font-weight: 800;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.night-sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.night-sky::before,
.night-sky::after {
  position: absolute;
  border-radius: 50%;
  content: "";
  filter: blur(1px);
}

.night-sky::before {
  width: 620px;
  height: 620px;
  top: -410px;
  right: -170px;
  background: rgba(247, 182, 51, 0.1);
  box-shadow: 0 0 110px rgba(247, 182, 51, 0.1);
}

.night-sky::after {
  width: 520px;
  height: 520px;
  left: -360px;
  bottom: -260px;
  background: rgba(88, 147, 212, 0.12);
  box-shadow: 0 0 120px rgba(88, 147, 212, 0.12);
}

.star {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(247, 182, 51, 0.78);
  box-shadow: 0 0 10px rgba(247, 182, 51, 0.55);
  animation: twinkle 4.8s ease-in-out infinite;
}

.star::before,
.star::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1px;
  height: 11px;
  background: rgba(247, 182, 51, 0.5);
  content: "";
  transform: translate(-50%, -50%);
}

.star::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.star-one {
  top: 12%;
  left: 7%;
}

.star-two {
  top: 22%;
  right: 11%;
  animation-delay: -1.3s;
}

.star-three {
  top: 49%;
  left: 4%;
  animation-delay: -3.2s;
}

.star-four {
  top: 63%;
  right: 5%;
  animation-delay: -2.2s;
}

.star-five {
  top: 82%;
  left: 13%;
  animation-delay: -0.7s;
}

.star-six {
  top: 88%;
  right: 17%;
  animation-delay: -4.1s;
}

.site-header {
  position: relative;
  z-index: 20;
  display: flex;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: var(--safe-top) 0 18px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-block;
  flex: 0 0 auto;
  text-decoration: none;
}

.brand-logo {
  display: block;
  width: auto;
  height: 64px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.header-button {
  position: relative;
  display: inline-flex;
  min-height: 44px;
  padding: 0 14px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 14px;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 800;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.header-button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.header-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.shelf-count {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  color: var(--sky-deep);
  background: var(--gold);
  border-radius: 999px;
  font-size: 0.7rem;
  place-items: center;
}

main {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.maker-view {
  display: grid;
  min-height: calc(100vh - 152px);
  padding: 32px 0 66px;
  grid-template-columns: minmax(0, 0.92fr) minmax(460px, 0.82fr);
  align-items: center;
  gap: clamp(50px, 7vw, 100px);
}

.intro-column {
  position: relative;
  max-width: 570px;
  padding: 8px 0;
  color: var(--white);
}

.eyebrow {
  margin: 0 0 15px;
  color: var(--gold);
  font-size: 0.77rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.intro-column h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.45rem, 6vw, 5.75rem);
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 0.91;
}

.intro-column h1 em {
  color: var(--gold);
  font-weight: 400;
}

.intro-copy {
  max-width: 530px;
  margin: 28px 0 0;
  color: rgba(255, 255, 255, 0.73);
  font-size: clamp(1rem, 1.5vw, 1.13rem);
  line-height: 1.72;
}

.promise-card {
  display: inline-flex;
  margin-top: 28px;
  padding: 12px 17px 12px 12px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.075);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 17px;
  align-items: center;
  gap: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.promise-icon {
  display: grid;
  width: 39px;
  height: 39px;
  color: var(--sky-deep);
  background: var(--gold);
  border-radius: 12px;
  place-items: center;
  transform: rotate(-4deg);
}

.promise-icon svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.promise-card div:last-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.promise-card strong {
  font-size: 0.76rem;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.promise-card span {
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.98rem;
  font-style: italic;
}

.storybook-scene {
  position: relative;
  width: min(480px, 88%);
  height: 150px;
  margin-top: 32px;
  overflow: hidden;
  border-radius: 24px;
  opacity: 0.95;
}

.scene-moon {
  position: absolute;
  top: 13px;
  right: 60px;
  width: 42px;
  height: 42px;
  background: var(--cream);
  border-radius: 50%;
  box-shadow: 0 0 28px rgba(255, 248, 233, 0.22);
}

.scene-moon::after {
  position: absolute;
  top: -5px;
  left: -8px;
  width: 40px;
  height: 40px;
  background: var(--sky);
  border-radius: 50%;
  content: "";
}

.scene-cloud {
  position: absolute;
  height: 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}

.scene-cloud::before,
.scene-cloud::after {
  position: absolute;
  bottom: 0;
  background: inherit;
  border-radius: 50%;
  content: "";
}

.scene-cloud::before {
  width: 18px;
  height: 18px;
  left: 10px;
}

.scene-cloud::after {
  width: 24px;
  height: 24px;
  left: 25px;
}

.cloud-left {
  top: 46px;
  left: 18px;
  width: 65px;
}

.cloud-right {
  top: 68px;
  right: 105px;
  width: 72px;
  transform: scale(0.72);
}

.scene-hill {
  position: absolute;
  left: -9%;
  width: 120%;
  border-radius: 50% 50% 0 0;
}

.hill-back {
  bottom: -71px;
  height: 140px;
  background: #5893d4;
  transform: rotate(-2deg);
}

.hill-front {
  bottom: -96px;
  left: -2%;
  height: 154px;
  background: #1f3c88;
  transform: rotate(3deg);
}

.scene-book {
  position: absolute;
  bottom: 12px;
  left: 50%;
  width: 136px;
  height: 72px;
  transform: translateX(-50%) rotate(-1deg);
}

.book-page {
  position: absolute;
  bottom: 0;
  width: 70px;
  height: 59px;
  background: var(--cream);
  border: 3px solid #1f3c88;
  box-shadow: 0 9px 18px rgba(7, 13, 89, 0.3);
}

.page-left {
  left: 0;
  border-radius: 10px 2px 4px 13px;
  transform: skewY(5deg);
}

.page-right {
  right: 0;
  border-radius: 2px 10px 13px 4px;
  transform: skewY(-5deg);
}

.book-spine {
  position: absolute;
  bottom: 0;
  left: 50%;
  z-index: 3;
  width: 4px;
  height: 59px;
  background: #1f3c88;
  border-radius: 999px;
  transform: translateX(-50%);
}

.book-star {
  position: absolute;
  z-index: 4;
  color: var(--gold);
  text-shadow: 0 0 13px rgba(247, 182, 51, 0.6);
  animation: float-star 3s ease-in-out infinite;
}

.star-a {
  top: -17px;
  left: 34px;
  font-size: 1.3rem;
}

.star-b {
  top: -37px;
  left: 65px;
  font-size: 1.75rem;
  animation-delay: -0.8s;
}

.star-c {
  top: -14px;
  right: 25px;
  font-size: 1.1rem;
  animation-delay: -1.7s;
}

.story-form {
  position: relative;
  padding: clamp(24px, 3.7vw, 38px);
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.8), transparent 42%),
    var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
}

.story-form::before {
  position: absolute;
  width: 180px;
  height: 180px;
  top: -92px;
  right: -78px;
  background: rgba(247, 182, 51, 0.2);
  border-radius: 50%;
  content: "";
}

.form-heading-row {
  position: relative;
  display: flex;
  margin-bottom: 27px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.step-pill {
  display: inline-flex;
  min-height: 28px;
  padding: 0 11px;
  color: #070d59;
  background: rgba(247, 182, 51, 0.22);
  border: 1px solid rgba(247, 182, 51, 0.45);
  border-radius: 999px;
  align-items: center;
  font-size: 0.71rem;
  font-weight: 900;
  letter-spacing: 0.085em;
  text-transform: uppercase;
}

.api-status {
  display: inline-flex;
  color: var(--muted);
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  font-weight: 800;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #5893d4;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(88, 147, 212, 0.13);
}

.api-status.ready .status-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(63, 132, 109, 0.12);
}

.api-status.sample .status-dot {
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(247, 182, 51, 0.13);
}

.field-group {
  position: relative;
}

.field-group label {
  display: block;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.42rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.field-help {
  margin: 6px 0 13px;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.45;
}

.textarea-shell {
  position: relative;
}

textarea,
input[type="text"] {
  width: 100%;
  color: var(--ink);
  background: var(--white);
  border: 1.5px solid rgba(7, 13, 89, 0.17);
  border-radius: var(--radius-md);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(7, 13, 89, 0.025);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

textarea {
  min-height: 160px;
  padding: 18px 18px 38px;
  resize: vertical;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  line-height: 1.55;
}

input[type="text"] {
  height: 52px;
  padding: 0 15px;
  font-size: 0.92rem;
}

textarea::placeholder,
input[type="text"]::placeholder {
  color: #4f5b83;
}

textarea:focus,
input[type="text"]:focus {
  background: #fffdf7;
  border-color: var(--light-blue);
  box-shadow: 0 0 0 4px rgba(88, 147, 212, 0.22);
}

textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(166, 64, 64, 0.1);
}

.character-count {
  position: absolute;
  right: 13px;
  bottom: 11px;
  color: #4f5b83;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.idea-row {
  display: flex;
  margin: 12px 0 24px;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.idea-row > span {
  margin-right: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.idea-chip {
  min-height: 30px;
  padding: 0 10px;
  color: #1f3c88;
  background: rgba(88, 147, 212, 0.1);
  border: 1px solid rgba(7, 13, 89, 0.1);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  transition:
    background 150ms ease,
    color 150ms ease,
    transform 150ms ease;
}

.idea-chip:hover {
  color: var(--ink);
  background: rgba(88, 147, 212, 0.22);
  transform: translateY(-1px);
}

.compact-field label {
  display: flex;
  margin-bottom: 9px;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 900;
  letter-spacing: 0;
}

.compact-field label span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.form-error {
  margin: -4px 0 15px;
  padding: 11px 13px;
  color: var(--danger);
  background: rgba(166, 64, 64, 0.07);
  border: 1px solid rgba(166, 64, 64, 0.13);
  border-radius: 11px;
  font-size: 0.8rem;
  font-weight: 750;
  line-height: 1.4;
}

.create-button {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 58px;
  padding: 0 18px;
  overflow: hidden;
  color: var(--cream);
  background: var(--ink);
  border: 0;
  border-radius: 16px;
  align-items: center;
  justify-content: center;
  gap: 11px;
  box-shadow: 0 12px 26px rgba(7, 13, 89, 0.24);
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.005em;
  transition:
    background 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.create-button::before {
  position: absolute;
  top: -40%;
  left: -35%;
  width: 25%;
  height: 180%;
  background: rgba(255, 255, 255, 0.11);
  content: "";
  transform: skewX(-20deg);
  transition: left 420ms ease;
}

.create-button:hover:not(:disabled) {
  background: #1f3c88;
  box-shadow: 0 15px 30px rgba(7, 13, 89, 0.29);
  transform: translateY(-2px);
}

.create-button:hover:not(:disabled)::before {
  left: 112%;
}

.create-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.button-sparkle {
  color: var(--gold);
  font-size: 1.05rem;
}

.privacy-note {
  margin: 12px 0 0;
  color: #4f5b83;
  font-size: 0.68rem;
  line-height: 1.4;
  text-align: center;
}

.story-view {
  padding: 36px 0 80px;
}

.story-paper {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 26px clamp(24px, 6vw, 78px) clamp(44px, 6vw, 72px);
  background:
    linear-gradient(rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0.52)),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 31px,
      rgba(7, 13, 89, 0.021) 32px
    ),
    var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 34px;
  box-shadow: var(--shadow-soft);
}

.story-toolbar {
  display: flex;
  margin: 0 calc(clamp(24px, 6vw, 78px) * -1) 48px;
  padding: 0 24px 22px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.back-button,
.tool-button,
.font-controls button {
  display: inline-flex;
  min-height: 38px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-radius: 10px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 0.76rem;
  font-weight: 850;
  transition:
    color 150ms ease,
    background 150ms ease;
}

.back-button {
  padding: 0 9px 0 5px;
}

.back-button:hover,
.tool-button:hover,
.font-controls button:hover {
  color: var(--ink);
  background: rgba(7, 13, 89, 0.06);
}

.back-button svg,
.tool-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.reader-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.font-controls {
  display: flex;
  margin-right: 5px;
  padding-right: 7px;
  border-right: 1px solid var(--line);
  align-items: center;
}

.font-controls button {
  width: 34px;
  padding: 0;
}

.tool-button {
  padding: 0 9px;
}

.story-header {
  margin-bottom: 26px;
  text-align: center;
}

.story-header .eyebrow {
  margin-bottom: 12px;
  color: #1f3c88;
}

.story-header h2 {
  max-width: 720px;
  margin: 0 auto;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.3rem, 5.5vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.048em;
  line-height: 1.03;
  text-wrap: balance;
}

.story-meta {
  display: flex;
  margin-top: 17px;
  color: var(--muted);
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
  font-size: 0.73rem;
  font-weight: 750;
}

.story-meta i {
  width: 3px;
  height: 3px;
  background: #5893d4;
  border-radius: 50%;
}

.listen-card {
  display: flex;
  margin: 34px 0 18px;
  padding: 15px 17px;
  background: #f0ece1;
  border: 1px solid rgba(7, 13, 89, 0.08);
  border-radius: 17px;
  align-items: center;
  gap: 12px;
}

.listen-icon {
  display: grid;
  flex: 0 0 auto;
  width: 43px;
  height: 43px;
  color: var(--ink);
  background: var(--gold);
  border-radius: 13px;
  place-items: center;
}

.listen-icon svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.listen-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.listen-copy strong {
  color: var(--ink);
  font-size: 0.82rem;
}

.listen-copy > span {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.speech-progress {
  width: 100%;
  height: 3px;
  margin-top: 8px;
  overflow: hidden;
  background: rgba(7, 13, 89, 0.09);
  border-radius: 999px;
}

.speech-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--royal);
  border-radius: inherit;
  transition: width 220ms ease;
}

.listen-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
}

.rate-control {
  display: flex;
  color: var(--muted);
  align-items: center;
  gap: 6px;
  font-size: 0.65rem;
  font-weight: 800;
}

.rate-control select {
  height: 35px;
  padding: 0 25px 0 9px;
  color: var(--ink-soft);
  background: var(--white);
  border: 1px solid rgba(7, 13, 89, 0.13);
  border-radius: 10px;
  outline: none;
  font-size: 0.68rem;
  font-weight: 800;
}

.listen-button,
.stop-button {
  display: inline-flex;
  height: 39px;
  color: var(--cream);
  background: var(--ink);
  border: 0;
  border-radius: 11px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 0.73rem;
  font-weight: 900;
  transition:
    background 150ms ease,
    transform 150ms ease;
}

.listen-button {
  padding: 0 13px;
}

.stop-button {
  width: 39px;
  padding: 0;
  color: var(--ink);
  background: rgba(7, 13, 89, 0.1);
}

.listen-button:hover,
.stop-button:hover {
  transform: translateY(-1px);
}

.listen-button:hover {
  background: #1f3c88;
}

.listen-button svg,
.stop-button svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  stroke: currentColor;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.catchphrase-banner {
  display: flex;
  margin: 18px 0 37px;
  padding: 14px 16px;
  color: #070d59;
  background: rgba(247, 182, 51, 0.22);
  border: 1px solid rgba(247, 182, 51, 0.45);
  border-radius: 15px;
  align-items: center;
  gap: 13px;
}

.catchphrase-burst {
  display: grid;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  color: var(--white);
  background: var(--royal);
  clip-path: polygon(
    50% 0%,
    61% 20%,
    82% 9%,
    79% 32%,
    100% 42%,
    78% 53%,
    93% 74%,
    67% 72%,
    62% 100%,
    47% 78%,
    29% 97%,
    27% 72%,
    0% 74%,
    20% 54%,
    0% 39%,
    24% 32%,
    16% 9%,
    39% 20%
  );
  place-items: center;
  font-size: 0.63rem;
  font-weight: 1000;
  letter-spacing: 0.04em;
  transform: rotate(-8deg);
}

.catchphrase-banner div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.catchphrase-banner strong {
  font-size: 0.7rem;
  letter-spacing: 0.015em;
  text-transform: uppercase;
}

.catchphrase-banner div span {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.03rem;
  font-style: italic;
  font-weight: 700;
}

.story-text {
  color: #070d59;
  font-family: Georgia, "Times New Roman", serif;
  font-size: calc(1.16rem * var(--reader-scale));
  line-height: 1.84;
  transition: font-size 150ms ease;
}

.story-text p {
  position: relative;
  margin: 0 0 1.38em;
  padding: 3px 6px;
  border-radius: 9px;
  transition:
    background 180ms ease,
    box-shadow 180ms ease;
}

.story-text p:first-child::first-letter {
  float: left;
  margin: 0.04em 0.08em 0 0;
  color: var(--royal);
  font-size: 3.2em;
  font-weight: 700;
  line-height: 0.75;
}

.story-text p.speaking {
  background: rgba(247, 182, 51, 0.15);
  box-shadow: 0 0 0 5px rgba(247, 182, 51, 0.07);
}

.story-text .sound-effect {
  color: #1f3c88;
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.86em;
  font-weight: 950;
  letter-spacing: 0.035em;
}

.story-text .catchphrase {
  display: inline;
  color: #070d59;
  background: linear-gradient(transparent 56%, rgba(247, 182, 51, 0.42) 56%);
  font-weight: 700;
}

.story-text .final-line {
  margin-top: 2.5em;
  color: #1f3c88;
  font-style: italic;
  text-align: center;
}

.story-text .final-line::before {
  display: block;
  margin-bottom: 20px;
  color: var(--gold);
  content: "✦  ·  ✦  ·  ✦";
  font-family: inherit;
  font-size: 0.7rem;
  font-style: normal;
  letter-spacing: 0.25em;
}

.story-footer {
  margin-top: 50px;
  padding-top: 31px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.footer-stars {
  color: var(--gold);
  font-size: 1rem;
}

.story-footer p {
  margin: 10px 0 15px;
  color: var(--muted);
  font-size: 0.72rem;
}

.story-footer button {
  min-height: 42px;
  padding: 0 15px;
  color: var(--ink);
  background: #f1ece0;
  border: 1px solid rgba(7, 13, 89, 0.1);
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 900;
  transition:
    background 150ms ease,
    transform 150ms ease;
}

.story-footer button:hover {
  background: rgba(88, 147, 212, 0.22);
  transform: translateY(-1px);
}

.site-footer {
  display: flex;
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 17px 0 var(--safe-bottom);
  color: rgba(255, 255, 255, 0.47);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  align-items: center;
  justify-content: center;
  gap: 18px;
  font-size: 0.69rem;
  text-align: center;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  padding: 24px;
  background: rgba(7, 13, 89, 0.82);
  backdrop-filter: blur(13px);
  place-items: center;
}

.loading-card {
  width: min(390px, 100%);
  padding: 37px 32px 34px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 27px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.36);
  text-align: center;
}

.loading-book {
  position: relative;
  width: 112px;
  height: 76px;
  margin: 0 auto 22px;
  perspective: 400px;
}

.loading-book::before,
.loading-book::after {
  position: absolute;
  bottom: 0;
  width: 56px;
  height: 55px;
  background: #fff6dc;
  border: 3px solid var(--ink);
  content: "";
  box-shadow: 0 8px 13px rgba(7, 13, 89, 0.13);
}

.loading-book::before {
  left: 0;
  border-radius: 10px 2px 3px 12px;
  transform: skewY(5deg);
}

.loading-book::after {
  right: 0;
  border-radius: 2px 10px 12px 3px;
  transform: skewY(-5deg);
}

.loading-page {
  position: absolute;
  right: 5px;
  bottom: 5px;
  z-index: 3;
  width: 48px;
  height: 47px;
  background: #fffdf3;
  border-left: 2px solid rgba(7, 13, 89, 0.35);
  border-radius: 2px 8px 9px 2px;
  transform-origin: left center;
  animation: page-turn 1.85s ease-in-out infinite;
}

.page-two {
  animation-delay: -0.62s;
}

.page-three {
  animation-delay: -1.24s;
}

.loading-moon {
  position: absolute;
  top: -9px;
  left: 50%;
  z-index: 5;
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.1rem;
  transform: translateX(-50%);
  animation: float-moon 2.2s ease-in-out infinite;
}

.loading-kicker {
  margin: 0 0 7px;
  color: #1f3c88;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.loading-card strong {
  display: block;
  min-height: 54px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  line-height: 1.35;
}

.loading-dots {
  display: flex;
  margin-top: 18px;
  justify-content: center;
  gap: 5px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  background: var(--light-blue);
  border-radius: 50%;
  animation: dot-bounce 1s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 149;
  background: rgba(7, 13, 89, 0.55);
  backdrop-filter: blur(3px);
}

.story-shelf {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 150;
  display: flex;
  width: min(430px, 92vw);
  height: 100dvh;
  padding: var(--safe-top) 22px var(--safe-bottom);
  color: var(--ink);
  background: var(--paper);
  box-shadow: -24px 0 70px rgba(7, 13, 89, 0.28);
  flex-direction: column;
  transform: translateX(105%);
  transition: transform 250ms cubic-bezier(0.2, 0.75, 0.2, 1);
}

.story-shelf.open {
  transform: translateX(0);
}

.shelf-header {
  display: flex;
  padding: 8px 0 19px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.shelf-header .eyebrow {
  margin: 0 0 6px;
  color: #1f3c88;
  font-size: 0.65rem;
}

.shelf-header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.7rem;
  letter-spacing: -0.035em;
}

.close-shelf {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  color: var(--ink-soft);
  background: #f3efe6;
  border: 0;
  border-radius: 12px;
  place-items: center;
}

.close-shelf:hover {
  color: var(--ink);
  background: #ebe3d3;
}

.close-shelf svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.shelf-list {
  min-height: 0;
  padding: 15px 2px 24px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(7, 13, 89, 0.16) transparent;
  scrollbar-width: thin;
}

.shelf-item {
  position: relative;
  display: block;
  width: 100%;
  margin-bottom: 10px;
  overflow: hidden;
  color: var(--ink);
  background: #f7f3e9;
  border: 1px solid rgba(7, 13, 89, 0.08);
  border-radius: 15px;
  text-align: left;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.shelf-item-main {
  display: grid;
  width: 100%;
  padding: 15px 44px 15px 16px;
  color: inherit;
  background: transparent;
  border: 0;
  text-align: left;
}

.shelf-item-main:focus-visible {
  outline: 3px solid var(--light-blue);
  outline-offset: -3px;
}

.shelf-item:hover {
  background: rgba(88, 147, 212, 0.22);
  border-color: rgba(88, 147, 212, 0.55);
  transform: translateY(-1px);
}

.shelf-item-title {
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shelf-item-scenario {
  display: -webkit-box;
  margin-top: 5px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.shelf-item-meta {
  display: flex;
  margin-top: 10px;
  color: var(--muted);
  align-items: center;
  gap: 7px;
  font-size: 0.63rem;
  font-weight: 750;
}

.delete-story {
  position: absolute;
  top: 12px;
  right: 10px;
  display: grid;
  width: 30px;
  height: 30px;
  color: #4f5b83;
  background: transparent;
  border: 0;
  border-radius: 9px;
  place-items: center;
}

.delete-story:hover {
  color: var(--danger);
  background: rgba(166, 64, 64, 0.08);
}

.delete-story svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.shelf-empty {
  display: flex;
  margin: auto 0;
  padding: 36px 20px;
  color: var(--muted);
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.shelf-empty > span {
  display: grid;
  width: 64px;
  height: 64px;
  margin-bottom: 15px;
  color: #070d59;
  background: rgba(247, 182, 51, 0.22);
  border-radius: 21px;
  place-items: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
}

.shelf-empty strong {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
}

.shelf-empty p {
  margin: 6px 0 0;
  font-size: 0.75rem;
}

.shelf-footer {
  margin-top: auto;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.shelf-footer button {
  width: 100%;
  min-height: 40px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 10px;
  font-size: 0.71rem;
  font-weight: 850;
}

.shelf-footer button:hover:not(:disabled) {
  color: var(--danger);
  background: rgba(166, 64, 64, 0.06);
}

.shelf-footer button:disabled {
  cursor: default;
  opacity: 0.4;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: calc(var(--safe-bottom) + 8px);
  z-index: 300;
  max-width: min(390px, calc(100% - 44px));
  padding: 13px 16px;
  color: var(--cream);
  background: #1f3c88;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 13px;
  box-shadow: 0 16px 40px rgba(7, 13, 89, 0.32);
  font-size: 0.78rem;
  font-weight: 780;
  line-height: 1.45;
  animation: toast-in 220ms ease both;
}

:focus-visible {
  outline: 3px solid var(--light-blue);
  outline-offset: 3px;
}

button:active:not(:disabled),
.brand:active {
  filter: brightness(0.94);
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.7);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes float-star {
  0%,
  100% {
    transform: translateY(0) rotate(-4deg);
  }
  50% {
    transform: translateY(-7px) rotate(5deg);
  }
}

@keyframes page-turn {
  0%,
  25% {
    opacity: 0.15;
    transform: rotateY(0deg);
  }
  70%,
  100% {
    opacity: 0.9;
    transform: rotateY(-165deg);
  }
}

@keyframes float-moon {
  0%,
  100% {
    transform: translate(-50%, 0) rotate(-4deg);
  }
  50% {
    transform: translate(-50%, -7px) rotate(4deg);
  }
}

@keyframes dot-bounce {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .maker-view {
    min-height: auto;
    padding-top: 48px;
    grid-template-columns: 1fr;
    gap: 42px;
  }

  .intro-column {
    max-width: 720px;
    margin: 0 auto;
    text-align: center;
  }

  .intro-copy {
    margin-right: auto;
    margin-left: auto;
  }

  .storybook-scene {
    width: min(520px, 100%);
    margin-right: auto;
    margin-left: auto;
  }

  .story-form {
    width: min(620px, 100%);
    margin: 0 auto;
  }
}

@media (max-width: 680px) {
  :root {
    --radius-xl: 24px;
  }

  .site-header,
  main,
  .site-footer {
    width: min(100% - 28px, 1180px);
  }

  .site-header {
    gap: 12px;
  }

  .brand-logo {
    height: 50px;
  }

  .header-button {
    width: 42px;
    min-height: 42px;
    padding: 0;
    justify-content: center;
  }

  .header-button > span:not(.shelf-count) {
    display: none;
  }

  .shelf-count {
    position: absolute;
    top: -5px;
    right: -5px;
  }

  .maker-view {
    padding: 29px 0 54px;
    gap: 31px;
  }

  .intro-column h1 {
    font-size: clamp(3.1rem, 16vw, 4.25rem);
  }

  .intro-copy {
    margin-top: 20px;
    font-size: 0.95rem;
  }

  .promise-card {
    margin-top: 22px;
  }

  .storybook-scene {
    height: 116px;
    margin-top: 20px;
  }

  .scene-book {
    transform: translateX(-50%) scale(0.84);
    transform-origin: bottom center;
  }

  .story-form {
    padding: 24px 20px 22px;
  }

  .form-heading-row {
    margin-bottom: 22px;
  }

  .api-status {
    max-width: 150px;
    line-height: 1.2;
    text-align: right;
  }

  .field-group label {
    font-size: 1.27rem;
  }

  textarea {
    min-height: 148px;
    font-size: 1.04rem;
  }

  .compact-field label {
    font-size: 0.8rem;
  }

  .compact-field label span {
    max-width: 145px;
    text-align: right;
  }

  .story-view {
    padding: 18px 0 54px;
  }

  .story-paper {
    padding: 18px 20px 42px;
    border-radius: 25px;
  }

  .story-toolbar {
    margin: 0 -20px 38px;
    padding: 0 14px 16px;
  }

  .tool-button span {
    display: none;
  }

  .tool-button {
    width: 36px;
    padding: 0;
  }

  .back-button {
    font-size: 0.7rem;
  }

  .story-header h2 {
    font-size: clamp(2.15rem, 11vw, 3rem);
  }

  .listen-card {
    padding: 13px;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .listen-copy {
    padding-top: 4px;
  }

  .listen-actions {
    width: 100%;
    padding-left: 55px;
  }

  .rate-control {
    margin-right: auto;
  }

  .catchphrase-banner {
    align-items: flex-start;
  }

  .catchphrase-banner div span {
    font-size: 0.93rem;
  }

  .story-text {
    font-size: calc(1.08rem * var(--reader-scale));
    line-height: 1.78;
  }

  .story-text p {
    padding-right: 2px;
    padding-left: 2px;
  }

  .site-footer {
    justify-content: center;
    text-align: center;
  }

  .toast {
    right: 14px;
    bottom: calc(var(--safe-bottom) + 2px);
    max-width: calc(100% - 28px);
  }
}

@media (max-width: 420px) {
  .promise-card {
    width: 100%;
    justify-content: center;
  }

  .idea-row {
    margin-bottom: 21px;
  }

  .idea-chip:nth-of-type(3) {
    display: none;
  }

  .listen-actions {
    padding-left: 0;
  }

  .rate-control span {
    display: none;
  }

  .story-meta {
    gap: 7px;
  }
}

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

@media print {
  @page {
    margin: 0.65in;
  }

  body {
    color: #111;
    background: #fff;
  }

  .night-sky,
  .site-header,
  .site-footer,
  .story-toolbar,
  .listen-card,
  .catchphrase-banner,
  .story-footer,
  .drawer-overlay,
  .story-shelf,
  .toast,
  .loading-overlay {
    display: none !important;
  }

  main {
    width: auto;
  }

  .story-view {
    padding: 0;
  }

  .story-paper {
    width: auto;
    padding: 0;
    background: #fff;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .story-header {
    margin-bottom: 28px;
  }

  .story-header h2 {
    color: #111;
    font-size: 30pt;
  }

  .story-text {
    color: #222;
    font-size: 12.5pt;
    line-height: 1.65;
  }

  .story-text p {
    break-inside: avoid;
  }
}
