/* Full-bleed story builder and its optional, grouped questionnaire. */
.container.builder-container {
  width: 100%;
  max-width: none;
  margin-inline: 0;
  padding: clamp(30px, 3.6vw, 56px) clamp(18px, 4.5vw, 76px) clamp(38px, 4vw, 64px);
  border-right: 0;
  border-left: 0;
  border-radius: 0;
}

.builder-heading,
.builder-layout,
.builder-progress-wrap,
#storyForm,
.story-result {
  width: 100%;
  max-width: 1720px;
  margin-inline: auto;
}

.builder-layout {
  grid-template-columns: minmax(280px, .58fr) minmax(0, 1.42fr);
  align-items: start;
  gap: clamp(18px, 2.5vw, 38px);
}

.builder-showcase {
  position: sticky;
  top: 96px;
  align-self: start;
}

.showcase-guidance {
  position: relative;
  z-index: 2;
  margin: clamp(10px, 1.2vw, 14px) 5px 14px;
  padding: clamp(12px, 1.2vw, 15px) 16px;
  border-left: 3px solid #ffe45c;
  border-radius: 0 14px 14px 0;
  color: #f7f4ff;
  background: rgba(13, 19, 56, .82);
  box-shadow: 0 9px 18px rgba(0, 0, 0, .18);
}

.showcase-guidance-label {
  display: block;
  color: #ffe45c;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .1em;
  line-height: 1.4;
}

.showcase-guidance p {
  margin: 7px 0 0;
  color: #f4f1ff;
  font-size: clamp(14px, 1.15vw, 16px);
  line-height: 1.55;
}

.builder-form-panel,
.survey-step,
.survey-grid,
.question-group,
.field-group { min-width: 0; }

.survey-step > .step-intro { max-width: 900px; }

.survey-optional-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 18px;
  padding: 14px 17px;
  border: 1px solid #dfdaf4;
  border-left: 4px solid #7357cf;
  border-radius: 14px;
  color: #34304b;
  background: #f1effb;
  font-size: 15px;
  line-height: 1.55;
}

.survey-optional-note strong { color: #312653; }
.survey-optional-note span { color: #4d5369; }

.survey-required-question {
  margin: 0 0 18px;
  padding: 16px 17px;
  border: 1px solid #d9e3f2;
  border-radius: 15px;
  background: #f4f8ff;
}

.question-group {
  margin: 18px 0 0;
  padding: 19px 20px 20px;
  border: 1px solid #e4e5ef;
  border-radius: 18px;
  background: rgba(255, 255, 255, .78);
}

.question-group-quiet {
  border-color: #e9dfd7;
  background: #fcf8f5;
}

.question-group-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 15px;
}

.question-group-heading h3 {
  margin: 0 0 4px;
  color: #202a49;
  font: 800 19px/1.25 var(--display, inherit);
}

.question-group-heading p {
  margin: 0;
  color: #536079;
  font-size: 15px;
  line-height: 1.5;
}

.question-group-heading > span {
  flex: 0 0 auto;
  padding: 5px 10px;
  border-radius: 99px;
  color: #4b3b87;
  background: #eee9fb;
  font-size: 13px;
  font-weight: 700;
}

.survey-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 14px 16px;
}

.survey-grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.survey-grid .field-group { width: 100%; }
.survey-step .field-group input,
.survey-step .field-group select,
.survey-step .field-group textarea {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  box-sizing: border-box;
  font-size: 16px;
}

.survey-step .field-group textarea {
  min-height: 86px;
  line-height: 1.5;
}

.survey-step .field-group small {
  display: block;
  line-height: 1.45;
}

.survey-step .step-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 24px;
}

.survey-step .step-actions .button { min-height: 48px; }

.story-boundaries {
  margin: 14px 0 0;
  padding: 12px 15px;
  border-left: 3px solid #8d79cc;
  border-radius: 8px;
  color: #46536b;
  background: #f2effb;
  font-size: 15px;
  line-height: 1.6;
}

.story-excerpt ul { margin: 12px 0 0; padding-left: 22px; }
.story-excerpt li { margin: 5px 0; }

@media (max-width: 1100px) {
  .builder-layout { grid-template-columns: minmax(220px, .46fr) minmax(0, 1.54fr); }
  .survey-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 850px) {
  .builder-layout { grid-template-columns: 1fr; gap: 18px; }
  .builder-form-panel { order: 1; }
  .builder-showcase { position: relative; top: auto; order: 2; }
  .survey-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .container.builder-container {
    width: 100%;
    padding: 26px 16px 36px;
    border-radius: 0;
  }
  .builder-heading,
  .builder-layout,
  .builder-progress-wrap,
  #storyForm,
  .story-result { max-width: none; }
  .builder-layout { grid-template-columns: minmax(0, 1fr); }
  .builder-form-panel { order: 1; padding: 19px 16px; }
  .builder-showcase { order: 2; }
  .question-group { padding: 16px 14px; }
  .question-group-heading { gap: 9px; }
  .question-group-heading h3 { font-size: 18px; }
  .question-group-heading > span { white-space: normal; text-align: center; }
  .survey-optional-note { align-items: flex-start; flex-direction: column; gap: 3px; padding: 12px 13px; }
  .survey-required-question { padding: 13px; }
  .survey-grid,
  .survey-grid-two { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .survey-step .field-group input,
  .survey-step .field-group select,
  .survey-step .field-group textarea { font-size: 16px; }
  .survey-step .step-actions { align-items: stretch; }
  .survey-step .step-actions .button { flex: 1 1 0; justify-content: center; }
}

@media (max-width: 420px) {
  .container.builder-container { padding-inline: 12px; }
  .builder-form-panel { padding-inline: 12px; }
  .question-group { padding-inline: 12px; }
  .question-group-heading { flex-direction: column; }
  .question-group-heading > span { align-self: flex-start; }
  .survey-step .step-actions { flex-direction: column; }
  .survey-step .step-actions .button { width: 100%; }
}


/* Main free-form story prompt and optional details disclosure. */
.prompt-composer {
  margin: 0 0 18px;
  padding: clamp(18px, 2.3vw, 28px);
  border: 1px solid #ddd8f2;
  border-left: 5px solid #7154d2;
  border-radius: 22px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 14px 36px rgba(48, 44, 92, .08);
}

.prompt-label {
  display: block;
  margin: 0 0 12px;
  color: #242d4a;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.4;
}

.prompt-label i { color: #bd3e63; font-style: normal; }

.prompt-composer textarea#storyPrompt {
  display: block;
  width: 100%;
  min-height: 185px;
  padding: 17px 18px;
  border: 1px solid #c9c5da;
  border-radius: 15px;
  box-sizing: border-box;
  color: #28324e;
  background: #fff;
  font: 500 18px/1.6 var(--body, inherit);
  resize: vertical;
}

.prompt-composer textarea#storyPrompt::placeholder { color: #727b8e; opacity: 1; }
.prompt-composer textarea#storyPrompt:focus-visible { outline: 3px solid rgba(113, 84, 210, .32); outline-offset: 2px; }
.prompt-composer textarea#storyPrompt[aria-invalid="true"] { border-color: #b93c58; box-shadow: 0 0 0 3px rgba(185, 60, 88, .12); }

.prompt-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-top: 13px;
}

.dictation-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding: 10px 18px;
  border: 1px solid #c7bdf0;
  border-radius: 999px;
  color: #45328f;
  background: #f1edff;
  font: 800 16px/1.2 var(--body, inherit);
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.dictation-button svg { width: 20px; height: 20px; flex: 0 0 20px; }
.dictation-button:hover:not(:disabled) { background: #e7e0ff; border-color: #8c78dc; transform: translateY(-1px); }
.dictation-button:focus-visible { outline: 3px solid rgba(113, 84, 210, .35); outline-offset: 3px; }
.dictation-button:disabled { color: #515a6c; background: #f0f1f4; border-color: #d5d8df; cursor: not-allowed; }
.dictation-button[aria-pressed="true"] { color: #fff; background: #6848c5; border-color: #6848c5; }
.dictation-status { flex: 1 1 260px; min-width: 0; color: #46536b; font-size: 15px; line-height: 1.45; }
.prompt-counter { margin-left: auto; color: #4e5870; font-size: 14px; font-variant-numeric: tabular-nums; }
.prompt-help { margin: 12px 0 0; color: #46536b; font-size: 15px; line-height: 1.55; }

.story-duration-picker {
  margin: 18px 0 22px;
  padding: 17px 18px;
  border: 1px solid #d9d2ec;
  border-radius: 17px;
  background: linear-gradient(125deg, rgba(246, 243, 255, .9), rgba(255, 249, 239, .9));
}

.story-duration-picker .field-group { display: grid; gap: 8px; color: #29324d; font-size: 16px; font-weight: 800; }
.story-duration-picker select { width: 100%; min-height: 50px; padding: 10px 13px; border: 1px solid #c9c5da; border-radius: 12px; color: #28324e; background: #fff; font: 600 16px/1.35 var(--body, inherit); }
.story-duration-picker select:focus-visible { outline: 3px solid rgba(113, 84, 210, .32); outline-offset: 2px; }
.story-duration-picker small { color: #4e5870; font-size: 14px; font-weight: 500; line-height: 1.5; }
.story-result .story-excerpt { max-width: 100%; overflow-wrap: anywhere; }
.story-result .story-excerpt p { white-space: pre-wrap; }

.survey-details {
  margin: 18px 0 22px;
  border: 1px solid #d9d6e6;
  border-radius: 18px;
  background: rgba(255, 255, 255, .72);
  overflow: clip;
}

.survey-details-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 66px;
  padding: 12px 20px;
  list-style: none;
  cursor: pointer;
  color: #27314d;
  background: rgba(245, 242, 255, .78);
}

.survey-details-summary::-webkit-details-marker { display: none; }
.survey-details-summary:focus-visible { outline: 3px solid rgba(113, 84, 210, .4); outline-offset: -4px; }
.survey-details-title { font-size: 18px; font-weight: 850; }
.survey-details-hint { flex: 1 1 auto; color: #4e5970; font-size: 15px; line-height: 1.4; }
.survey-details-icon { display: grid; width: 32px; height: 32px; flex: 0 0 32px; place-items: center; border-radius: 50%; color: #4d3b99; background: #e7e0fb; }
.survey-details-icon::before { content: "+"; font-size: 22px; line-height: 1; }
.survey-details[open] .survey-details-icon::before { content: "−"; }
.survey-details-intro { margin: 0; padding: 0 20px 6px; color: #4e5970; font-size: 15px; line-height: 1.55; }
.survey-details .question-group { margin-inline: 16px; }
.survey-details .question-group:last-of-type { margin-bottom: 17px; }

@media (max-width: 760px) {
  .prompt-composer { padding: 17px 14px; border-radius: 18px; }
  .prompt-label { font-size: 18px; }
  .prompt-composer textarea#storyPrompt { min-height: 165px; padding: 14px; font-size: 17px; }
  .prompt-toolbar { gap: 10px; }
  .dictation-status { flex-basis: calc(100% - 8px); order: 2; }
  .prompt-counter { margin-left: auto; }
  .survey-details-summary { flex-wrap: wrap; gap: 8px 12px; padding: 13px 14px; }
  .survey-details-title { font-size: 17px; }
  .survey-details-hint { flex-basis: calc(100% - 48px); order: 2; }
  .survey-details-icon { margin-left: auto; }
  .survey-details-intro { padding: 0 14px 6px; }
  .survey-details .question-group { margin-inline: 9px; }
}

@media (max-width: 420px) {
  .prompt-toolbar { align-items: stretch; }
  .dictation-button { width: 100%; }
  .prompt-counter { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .dictation-button { transition: none; }
}


/* Explicit opt-in for provider processing; local demo stays available without sending data. */
.api-consent {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: start;
  gap: 13px;
  margin: 18px 0 10px;
  padding: 16px 18px;
  border: 1px solid #d7d0ef;
  border-radius: 16px;
  color: #29324d;
  background: #f7f4ff;
}

.api-consent input {
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
  accent-color: #6848c5;
  cursor: pointer;
}

.api-consent-copy { display: block; min-width: 0; font-size: 15px; line-height: 1.5; }
.api-consent-copy strong { display: block; color: #30264f; font-weight: 800; }
.api-consent-copy small { display: block; margin-top: 6px; color: #4e5870; font-size: 14px; line-height: 1.5; }
.api-consent:focus-within { outline: 3px solid rgba(113, 84, 210, .28); outline-offset: 2px; }

.story-api-status {
  min-height: 0;
  margin: 0;
  color: #3f4260;
  font-size: 15px;
  line-height: 1.5;
}

.story-api-status:not(:empty) {
  margin: 10px 0 0;
  padding: 11px 14px;
  border: 1px solid #e2d9c5;
  border-radius: 12px;
  color: #4b3b24;
  background: #fff8e9;
}

.story-generation-progress {
  display: grid;
  gap: 9px;
  margin: 11px 0 0;
  padding: 13px 15px;
  border: 1px solid #8f7cce;
  border-radius: 15px;
  color: #292347;
  background: linear-gradient(125deg, #f4efff, #fff8e8);
  box-shadow: 0 7px 18px rgba(68, 48, 115, .09);
}
.story-generation-progress[hidden] { display: none; }
.story-generation-progress-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.story-generation-progress-phase { color: #312653; font-size: 14px; font-weight: 800; line-height: 1.45; }
.story-generation-progress-percent { flex: 0 0 auto; color: #4b348f; font-size: 16px; font-weight: 900; font-variant-numeric: tabular-nums; }
.story-generation-progress progress {
  display: block;
  width: 100%;
  height: 13px;
  overflow: hidden;
  border: 0;
  border-radius: 99px;
  background: #e0d8f2;
  accent-color: #6549b4;
}
.story-generation-progress progress::-webkit-progress-bar { border-radius: 99px; background: #e0d8f2; }
.story-generation-progress progress::-webkit-progress-value { border-radius: 99px; background: linear-gradient(90deg, #6248b8, #a54589, #d29c3e); transition: width 220ms ease-out; }
.story-generation-progress progress::-moz-progress-bar { border-radius: 99px; background: linear-gradient(90deg, #6248b8, #a54589, #d29c3e); }
.story-generation-progress-words { margin: 0; color: #4f4a66; font-size: 12px; font-weight: 650; line-height: 1.4; }
@media (prefers-reduced-motion: reduce) {
  .story-generation-progress progress::-webkit-progress-value { transition: none; }
}

.local-preview-row { margin: 12px 0 0; text-align: center; }
.local-preview-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid rgba(113, 84, 210, .28);
  border-radius: 999px;
  color: #443386;
  background: #f5f1ff;
  font-size: 15px;
  font-weight: 750;
  text-decoration: none;
  transition: transform 160ms ease, color 160ms ease, background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.local-preview-button:hover { color: #2d205f; border-color: rgba(113, 84, 210, .5); background: #ebe4ff; text-decoration: none; transform: translateY(-1px); }
.local-preview-button:focus-visible { outline: 3px solid rgba(113, 84, 210, .4); outline-offset: 3px; border-radius: 999px; }

@media (max-width: 760px) {
  .story-duration-picker { margin-block: 14px 18px; padding: 14px 13px; }
  .story-duration-picker select { font-size: 15px; }
  .story-duration-picker small { font-size: 13px; }
  .api-consent { grid-template-columns: 22px minmax(0, 1fr); gap: 11px; padding: 14px 13px; }
  .api-consent-copy { font-size: 14px; }
  .api-consent-copy small { font-size: 13px; }
  .local-preview-row { margin-top: 9px; }
}


/* Optional Yandex SpeechKit narration for the selected full story format. */
.tts-controls {
  display: grid;
  gap: 14px;
  margin: 24px 0 20px;
  padding: clamp(16px, 2.2vw, 24px);
  border: 1px solid rgba(232, 218, 162, .78);
  border-radius: 20px;
  color: #f9f6ed;
  background: linear-gradient(135deg, rgba(20, 35, 76, .97), rgba(46, 43, 92, .96));
  box-shadow: 0 14px 34px rgba(13, 20, 52, .14);
}

.tts-heading .eyebrow { color: #ffe45c; }
.tts-heading h4 { margin: 7px 0 5px; color: #fffaf0; font: 800 22px/1.25 var(--display, inherit); }
.tts-heading p { margin: 0; color: #e3e5f2; font-size: 15px; line-height: 1.55; }
.tts-voice { display: grid; gap: 7px; max-width: 420px; color: #fffaf0; font-size: 15px; font-weight: 800; }
.tts-voice select { width: 100%; min-height: 48px; padding: 10px 13px; border: 1px solid #cfc8e8; border-radius: 12px; color: #28324e; background: #fff; font: 600 16px/1.3 var(--body, inherit); }
.tts-voice select:focus-visible { outline: 3px solid rgba(255, 228, 92, .55); outline-offset: 2px; }
.tts-consent { display: grid; grid-template-columns: 22px minmax(0, 1fr); align-items: start; gap: 12px; padding: 14px; border: 1px solid rgba(241, 236, 255, .36); border-radius: 14px; color: #fff; background: rgba(255, 255, 255, .08); cursor: pointer; }
.tts-consent input { width: 21px; height: 21px; margin: 2px 0 0; accent-color: #ffe45c; cursor: pointer; }
.tts-consent:focus-within { outline: 3px solid rgba(255, 228, 92, .4); outline-offset: 2px; }
.tts-consent-copy { display: block; font-size: 15px; line-height: 1.5; }
.tts-consent-copy strong { display: block; color: #fffdf6; font-weight: 800; }
.tts-consent-copy small { display: block; margin-top: 6px; color: #e2e4f1; font-size: 14px; line-height: 1.5; }
.tts-button { justify-self: start; min-height: 48px; }
.tts-button:disabled { color: #d3d1dc; background: #65647a; border-color: #65647a; cursor: not-allowed; box-shadow: none; }
.tts-status { min-height: 0; margin: 0; color: #fff4c0; font-size: 15px; line-height: 1.5; }
.tts-status:not(:empty) { padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, .09); }
.tts-status.is-warning { color: #ffe2b4; background: rgba(120, 48, 29, .3); outline: 1px solid rgba(255, 210, 156, .46); }
.tts-progress { display: grid; gap: 9px; padding: 13px 14px; border: 1px solid rgba(255, 228, 92, .28); border-radius: 13px; background: rgba(255, 255, 255, .08); }
.tts-progress[hidden],
.tts-play-button[hidden] { display: none !important; }
.tts-progress-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #fffaf0; font-size: 14px; font-weight: 750; }
.tts-progress-heading span:last-child { color: #ffe45c; font-variant-numeric: tabular-nums; }
.tts-progress progress { display: block; width: 100%; height: 12px; overflow: hidden; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .18); accent-color: #ffe45c; }
.tts-progress progress::-webkit-progress-bar { border-radius: 999px; background: rgba(255, 255, 255, .18); }
.tts-progress progress::-webkit-progress-value { border-radius: 999px; background: linear-gradient(90deg, #f3c95a, #fff2a8); transition: width .2s ease; }
.tts-progress progress::-moz-progress-bar { border-radius: 999px; background: linear-gradient(90deg, #f3c95a, #fff2a8); }
.tts-progress.is-error { border-color: rgba(255, 160, 160, .56); background: rgba(110, 36, 48, .3); }
.tts-progress.is-error .tts-progress-heading,
.tts-progress.is-error .tts-progress-heading span:last-child { color: #ffe0e0; }
.tts-progress.is-error progress { accent-color: #ffaaaa; }
.tts-play-button { justify-self: start; min-height: 48px; }
.tts-audio { display: block; width: 100%; min-height: 48px; border-radius: 14px; }

.tts-music-choice {
  margin: 0;
  padding: 12px 14px 13px;
  border: 1px solid rgba(241, 236, 255, .28);
  border-radius: 14px;
  background: rgba(255, 255, 255, .06);
}

.tts-music-choice legend { padding: 0 7px; color: #fffaf0; font-size: 16px; font-weight: 800; }
.tts-music-options { display: flex; flex-wrap: wrap; gap: 9px 12px; }
.tts-music-option { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 7px 11px; border: 1px solid rgba(255, 255, 255, .2); border-radius: 999px; color: #fff; background: rgba(255, 255, 255, .07); font-size: 15px; font-weight: 700; cursor: pointer; }
.tts-music-option input { width: 18px; height: 18px; margin: 0; accent-color: #ffe45c; cursor: pointer; }
.tts-music-option:focus-within { outline: 3px solid rgba(255, 228, 92, .42); outline-offset: 2px; }
.tts-music-help { margin: 8px 0 0; color: #e2e4f1; font-size: 14px; line-height: 1.5; }
.tts-music-status { min-height: 0; margin: 4px 0 0; color: #fff4c0; font-size: 14px; line-height: 1.45; }

@media (max-width: 760px) {
  .tts-controls { gap: 12px; margin-top: 19px; padding: 15px 13px; border-radius: 16px; }
  .tts-heading h4 { font-size: 20px; }
  .tts-consent { gap: 10px; padding: 12px; }
  .tts-consent-copy { font-size: 14px; }
  .tts-consent-copy small { font-size: 13px; }
  .tts-button { width: 100%; justify-content: center; }
  .tts-play-button { width: 100%; justify-content: center; }
  .tts-music-choice { padding: 11px; }
  .tts-music-option { flex: 1 1 170px; }
}

@media (prefers-reduced-motion: reduce) {
  .tts-button { transition: none; }
}

.tts-controls[hidden],
.tts-audio[hidden] { display: none !important; }


/* Voice and music preferences are visible before story generation. */
.audio-preferences {
  margin: 18px 0 22px;
  padding: clamp(18px, 3vw, 26px);
  border: 1px solid rgba(177, 147, 89, .34);
  border-radius: 22px;
  color: #293354;
  background: linear-gradient(145deg, #fffaf1 0%, #f7f2ff 100%);
  box-shadow: 0 12px 30px rgba(53, 52, 95, .07);
}
.audio-preferences-heading .eyebrow { color: #8e6c35; }
.audio-preferences-heading h3 {
  margin: 6px 0 5px;
  color: #25315b;
  font-family: var(--display, Georgia, serif);
  font-size: clamp(22px, 2.5vw, 29px);
  line-height: 1.2;
}
.audio-preferences-heading > p { margin: 0; color: #555c75; font-size: 15px; line-height: 1.55; }
.audio-preferences-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(240px, 1fr);
  gap: 16px;
  align-items: start;
  margin-top: 17px;
}
.voice-selection-group { display: grid; min-width: 0; gap: 9px; }
.audio-preferences .audio-preference-voice { margin: 0; }
.audio-preferences .audio-preference-voice > span,
.builder-music-choice legend { color: #303957; font-size: 16px; font-weight: 800; }
.audio-preferences .audio-preference-voice select {
  width: 100%;
  min-height: 50px;
  margin-top: 7px;
  padding: 10px 14px;
  border: 1px solid rgba(76, 83, 123, .26);
  border-radius: 14px;
  color: #273052;
  background: #fff;
  font: inherit;
}
.audio-preferences .audio-preference-voice select:focus-visible {
  outline: 3px solid rgba(169, 131, 69, .32);
  outline-offset: 2px;
  border-color: #98733f;
}
.voice-sample-preview { display: grid; min-width: 0; gap: 7px; }
.voice-sample-button {
  display: inline-flex;
  min-height: 42px;
  justify-self: start;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid rgba(150, 116, 57, .48);
  border-radius: 999px;
  color: #403656;
  background: rgba(255, 255, 255, .86);
  font: 750 14px/1.25 var(--body, inherit);
  cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, transform .18s ease;
}
.voice-sample-button:hover { border-color: #98733f; background: #fff; transform: translateY(-1px); }
.voice-sample-button:focus-visible { outline: 3px solid rgba(169, 131, 69, .34); outline-offset: 2px; }
.voice-sample-status { margin: 0; color: #5d6378; font-size: 13px; line-height: 1.45; }
.voice-sample-audio { display: block; width: 100%; max-width: 420px; min-height: 40px; }
.voice-sample-audio[hidden] { display: none !important; }
.tts-controls .voice-sample-preview { margin: 8px 0 14px; }
.tts-controls .voice-sample-button { border-color: rgba(255, 228, 92, .55); color: #fffaf0; background: rgba(255, 255, 255, .1); }
.tts-controls .voice-sample-button:hover { background: rgba(255, 255, 255, .18); }
.tts-controls .voice-sample-status { color: #e3e5f2; }
.builder-music-choice {
  min-width: 0;
  margin: 0;
  padding: 12px 14px 13px;
  border: 1px solid rgba(76, 83, 123, .2);
  border-radius: 16px;
  background: rgba(255, 255, 255, .72);
}
.builder-music-choice legend { padding: 0 7px; }
.builder-music-options { display: flex; flex-wrap: wrap; gap: 9px 10px; }
.builder-music-option {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(76, 83, 123, .19);
  border-radius: 999px;
  color: #313957;
  background: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.builder-music-option input { width: 18px; height: 18px; margin: 0; accent-color: #92703d; }
.builder-music-option:focus-within { outline: 3px solid rgba(169, 131, 69, .28); outline-offset: 2px; }
.builder-music-help { margin: 8px 0 0; color: #5d6378; font-size: 13px; line-height: 1.5; }
.audio-preference-note {
  grid-column: 1 / -1;
  margin: -3px 0 0;
  padding: 10px 13px;
  border-left: 3px solid #b8985b;
  border-radius: 0 10px 10px 0;
  color: #575d74;
  background: rgba(255, 255, 255, .58);
  font-size: 13px;
  line-height: 1.55;
}
@media (max-width: 680px) {
  .audio-preferences { margin: 14px 0 18px; padding: 17px 14px; border-radius: 18px; }
  .audio-preferences-grid { grid-template-columns: 1fr; gap: 13px; }
  .builder-music-options { display: grid; grid-template-columns: 1fr; }
  .builder-music-option { width: 100%; }
  .audio-preference-note { grid-column: auto; }
}

/* Card-based TTS voice picker and compact privacy disclosures */
.consent-control { display: grid; gap: 7px; min-width: 0; }
.consent-details { margin: 0 4px 4px 40px; color: #514768; font-size: 13px; line-height: 1.5; }
.consent-details summary { width: fit-content; color: #6a4aa0; font-weight: 750; cursor: pointer; text-underline-offset: 3px; }
.consent-details summary:focus-visible { outline: 3px solid rgba(113, 84, 210, .28); outline-offset: 3px; border-radius: 4px; }
.consent-details-copy { margin-top: 8px; padding: 11px 14px; border-left: 2px solid rgba(134, 105, 191, .5); border-radius: 0 10px 10px 0; background: rgba(255, 255, 255, .68); }
.consent-details-copy p { margin: 0 0 8px; }
.consent-details-copy p:last-child { margin-bottom: 0; }
.consent-details-heading { font-weight: 750; }
.consent-control--tts .consent-details,
.consent-control--audio .consent-details { color: #e2e4f1; }
.consent-control--tts .consent-details summary,
.consent-control--audio .consent-details summary { color: #ffe89a; }
.consent-control--tts .consent-details-copy,
.consent-control--audio .consent-details-copy { border-left-color: rgba(255, 228, 92, .55); background: rgba(255, 255, 255, .08); }

.voice-picker-disclosure {
  margin: 10px 0 14px;
  overflow: clip;
  border: 1px solid rgba(241, 236, 255, .28);
  border-radius: 17px;
  background: rgba(255, 255, 255, .045);
}
.voice-picker-disclosure > summary {
  display: flex;
  min-height: 50px;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  list-style: none;
  color: #fffaf0;
  cursor: pointer;
}
.voice-picker-disclosure > summary::-webkit-details-marker { display: none; }
.voice-picker-disclosure > summary:focus-visible { outline: 3px solid rgba(255, 228, 92, .48); outline-offset: -3px; border-radius: 15px; }
.voice-picker-disclosure-title { flex: 0 0 auto; font-size: 15px; font-weight: 800; }
.voice-picker-disclosure-current { flex: 1 1 auto; min-width: 0; overflow: hidden; color: #ffe89a; font-size: 13px; font-weight: 700; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.voice-picker-disclosure-icon { display: grid; width: 28px; height: 28px; flex: 0 0 28px; place-items: center; border-radius: 50%; color: #fff0bc; background: rgba(255, 232, 154, .12); font-size: 19px; line-height: 1; }
.voice-picker-disclosure-icon::before { content: "+"; }
.voice-picker-disclosure[open] .voice-picker-disclosure-icon::before { content: "−"; }
.voice-picker-disclosure[open] > summary { border-bottom: 1px solid rgba(241, 236, 255, .15); }
.voice-picker-disclosure .voice-picker { margin: 0; padding: 12px; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.voice-picker { display: grid; gap: 12px; min-width: 0; margin: 8px 0 14px; padding: 16px; border: 1px solid rgba(241, 236, 255, .28); border-radius: 18px; color: #fffaf0; background: rgba(18, 21, 49, .22); }
.voice-picker-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.voice-picker-heading h3 { margin: 0; color: #fffdf6; font-size: 18px; line-height: 1.25; }
.voice-picker-heading p { margin: 4px 0 0; color: #e1ddef; font-size: 13px; }
.voice-picker-current { align-self: center; color: #ffe89a; font-size: 13px; font-weight: 750; text-align: right; }
.voice-picker-filters { display: flex; flex-wrap: wrap; gap: 7px; }
.voice-picker-filters button { min-height: 36px; padding: 7px 11px; border: 1px solid rgba(241, 236, 255, .32); border-radius: 999px; color: #fffaf0; background: rgba(255, 255, 255, .07); font: 700 13px/1.2 var(--body, inherit); cursor: pointer; transition: background .18s ease, border-color .18s ease, transform .18s ease; }
.voice-picker-filters button:hover { transform: translateY(-1px); }
.voice-picker-filters button[aria-pressed="true"] { border-color: #ffe45c; color: #352b56; background: #ffe89a; }
.voice-options { display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px; min-width: 0; max-height: clamp(180px, 34vh, 310px); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; padding: 4px 7px 4px 2px; border: 1px solid rgba(241, 236, 255, .12); border-radius: 12px; background: rgba(10, 14, 36, .14); scroll-snap-type: y proximity; scrollbar-color: rgba(255, 232, 154, .72) rgba(255, 255, 255, .08); scrollbar-width: thin; }
.voice-variant-card { position: relative; display: grid; grid-template-columns: 16px minmax(0, 1fr) 36px; grid-template-rows: minmax(0, 1fr); align-items: center; gap: 8px; width: 100%; min-width: 0; min-height: 46px; padding: 4px 7px; border: 1px solid rgba(241, 236, 255, .27); border-radius: 11px; background: rgba(255, 255, 255, .075); scroll-snap-align: start; transition: border-color .18s ease, background .18s ease, box-shadow .18s ease; }
.voice-variant-card:hover { border-color: rgba(255, 232, 154, .72); background: rgba(255, 255, 255, .12); }
.voice-variant-card.is-selected { border-color: #ffe45c; background: rgba(255, 232, 154, .13); box-shadow: 0 0 0 2px rgba(255, 228, 92, .14); }
.voice-variant-card > input { width: 16px; height: 16px; margin: 0; justify-self: center; accent-color: #ffe45c; cursor: pointer; }
.voice-variant-card > input:focus-visible { outline: 3px solid rgba(255, 228, 92, .55); outline-offset: 3px; }
.voice-variant-choice { display: flex; grid-column: 2; grid-row: 1; align-items: baseline; gap: 8px; min-width: 0; overflow: hidden; cursor: pointer; }
.voice-variant-name { flex: 0 0 auto; color: #fffdf6; font-size: 13px; font-weight: 850; line-height: 1.2; white-space: nowrap; }
.voice-variant-style { flex: 1 1 auto; min-width: 0; overflow: hidden; color: #e5dcff; font-size: 12px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.voice-sample-button--card { display: grid; grid-column: 3; grid-row: 1; width: 36px; min-width: 36px; height: 36px; min-height: 36px; align-self: center; justify-self: center; place-items: center; padding: 0; border-radius: 50%; font-size: 0; line-height: 1; }
.voice-sample-button--card span:first-child { font-size: 12px; }
.voice-sample-button--card span:last-child { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.voice-sample-note { margin: 0; color: #e1ddef; font-size: 12px; line-height: 1.45; }
.voice-picker .voice-sample-preview { margin: 0; }
.voice-picker .voice-sample-audio { max-width: 100%; }
.voice-picker .voice-sample-status { color: #e1ddef; }
@media (max-width: 640px) {
  .consent-details { margin-left: 0; }
  .voice-picker-disclosure > summary { gap: 7px; padding-inline: 10px; }
  .voice-picker-disclosure-title { font-size: 14px; }
  .voice-picker-disclosure-current { font-size: 12px; }
  .voice-picker { padding: 13px; }
  .voice-picker-heading { flex-direction: column; }
  .voice-picker-current { align-self: flex-start; text-align: left; }
  .voice-picker-filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 3px; }
  .voice-picker-filters button { flex: 0 0 auto; }
  .voice-options { max-height: clamp(170px, 32vh, 270px); gap: 4px; }
  .voice-variant-card { min-height: 42px; grid-template-columns: 16px minmax(0, 1fr) 34px; gap: 6px; }
  .voice-variant-name { font-size: 12px; }
  .voice-variant-style { font-size: 11px; }
  .voice-sample-button--card { width: 32px; min-width: 32px; height: 32px; min-height: 32px; }
}


/* Optional one-tap ideas for the personalized story fields. */
.field-group--suggestions {
  display: grid;
  align-content: start;
  gap: 8px;
}

.field-group--suggestions > label {
  color: #29324d;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.45;
}

.field-suggestions {
  display: grid;
  gap: 7px;
  margin-top: 2px;
}

.field-suggestions-caption {
  color: #667087;
  font-size: 13px;
  line-height: 1.4;
}

.field-suggestion-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.field-suggestion {
  min-height: 35px;
  padding: 7px 11px;
  border: 1px solid #ddd5ef;
  border-radius: 999px;
  color: #3c315e;
  background: linear-gradient(135deg, #faf7ff 0%, #fff8e8 100%);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.field-suggestion:hover {
  transform: translateY(-1px);
  border-color: #b6a4db;
  box-shadow: 0 3px 9px rgba(54, 39, 92, 0.1);
}

.field-suggestion:focus-visible {
  outline: 3px solid rgba(113, 84, 210, 0.35);
  outline-offset: 2px;
}

.field-suggestions-status {
  min-height: 1em;
  color: #65527f;
  font-size: 12px;
  line-height: 1.35;
}

@media (prefers-reduced-motion: reduce) {
  .field-suggestion { transition: none; }
}
