:root {
  color-scheme: light;
  --ink: #0f1b2d;
  --muted: #66758a;
  --line: #cddceb;
  --panel: #ffffff;
  --paper: #fffdf8;
  --soft: #eef6fb;
  --blue: #235f9f;
  --blue-dark: #184a7d;
  --green: #20876d;
  --orange: #f59a1b;
  --pink: #d84d89;
  --shadow: 0 24px 70px rgba(25, 62, 101, 0.14);
  font-family: Montserrat, Arial, sans-serif;
}

@font-face {
  font-family: "Montserrat";
  src: url("../palabras-cruzadas/assets/Montserrat-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("../palabras-cruzadas/assets/Montserrat-Bold.ttf") format("truetype");
  font-weight: 700 900;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(32, 135, 109, 0.12), transparent 34rem),
    linear-gradient(180deg, #eef6fb 0%, #f8fbfe 42%, #edf4f9 100%);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.app-shell {
  padding: 18px;
}

.workspace {
  width: min(1560px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.control-panel,
.account-widget,
.preview-heading,
.story-summary,
.personalization-form,
.reader-sheet {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 14px 38px rgba(35, 95, 159, 0.08);
}

.control-panel {
  position: sticky;
  top: 14px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  max-height: calc(100vh - 28px);
  padding: 18px;
  scrollbar-width: thin;
  scrollbar-color: #9db7d5 transparent;
}

.control-panel::-webkit-scrollbar {
  width: 8px;
}

.control-panel::-webkit-scrollbar-track {
  background: transparent;
}

.control-panel::-webkit-scrollbar-thumb {
  background: #c7d7ea;
  border-radius: 999px;
}

.control-panel::-webkit-scrollbar-thumb:hover {
  background: #9db7d5;
}

.activity-panel {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.library-link {
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #164a7d;
  font-weight: 500;
  font-size: 0.84rem;
  text-decoration: none;
  text-shadow: 0.14px 0 0 currentColor;
}

.library-link svg,
.button-stack svg,
.primary-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.brand-block {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  align-items: center;
  margin: 14px 0 18px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(135deg, #fffdf8, #f4f9fd);
}

.brand-mark {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 18px rgba(15, 27, 45, 0.12);
  padding: 6px;
}

.brand-block p {
  color: #00836b;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.brand-block h1 {
  margin: 2px 0;
  font-size: 1.42rem;
  line-height: 1.05;
}

.brand-block span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.25;
}

.control-card {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid #cddceb;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 250, 254, 0.98)),
    #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.field-kicker,
.eyebrow {
  display: block;
  color: #00836b;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.control-card h2 {
  font-size: 1rem;
  line-height: 1.15;
}

.control-card p {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.4;
}

.selected-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: block;
  object-fit: cover;
  border-radius: 8px;
  background: var(--soft);
}

.button-stack {
  display: grid;
  gap: 9px;
}

.button-stack button,
.primary-btn {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--blue-dark);
  font-weight: 900;
  line-height: 1;
  padding: 0 16px;
}

.button-stack .primary-btn,
.personalization-form .primary-btn {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  box-shadow: 0 12px 22px rgba(35, 95, 159, 0.2);
}

#pdf-btn,
#print-btn {
  border-color: #f1c27a;
  background: #fffaf2;
  color: #7a4100;
}

#pdf-btn:not(:disabled),
#print-btn:not(:disabled) {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.64);
}

.screen {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.preview-heading {
  min-height: 76px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
}

.preview-heading p {
  color: #00836b;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.preview-heading h2 {
  margin-top: 3px;
  font-size: 1.45rem;
  line-height: 1.1;
}

.preview-heading span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #fff4df;
  color: #805000;
  font-size: 0.8rem;
  font-weight: 900;
  padding: 0 12px;
  white-space: nowrap;
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.story-card {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(35, 95, 159, 0.08);
}

.story-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: block;
  object-fit: cover;
  background: var(--soft);
}

.story-card-body {
  display: grid;
  gap: 10px;
  padding: 15px;
}

.story-card h2 {
  font-size: 1.05rem;
  line-height: 1.15;
}

.story-card p {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.45;
}

.moral-pill {
  display: block;
  padding: 9px 11px;
  border-radius: 8px;
  background: #eff8f4;
  color: #17624e;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.35;
}

.story-card button {
  min-height: 44px;
  margin: 0 15px 15px;
  border: 0;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
}

.story-summary {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 18px;
}

.story-summary img {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: block;
  object-fit: cover;
  border-radius: 8px;
  background: var(--soft);
}

.story-summary h2 {
  margin-top: 4px;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  line-height: 1.05;
}

.story-summary p:last-child,
.form-head p {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

.personalization-form {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.form-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

#field-count {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #fff4df;
  color: #805000;
  font-weight: 900;
  padding: 0 13px;
  white-space: nowrap;
}

.locale-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.locale-control select {
  min-height: 38px;
  padding: 0 38px 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.locale-control select,
.select-field select {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #235f9f 50%),
    linear-gradient(135deg, #235f9f 50%, transparent 50%);
  background-position:
    calc(100% - 19px) 50%,
    calc(100% - 13px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.field-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field-list label,
.field-label {
  display: grid;
  gap: 8px;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 900;
}

.field-question {
  display: block;
}

.field-list input:not([type="radio"]),
.select-field select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #cfe0ec;
  border-radius: 8px;
  background-color: #fbfdff;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 750;
}

.select-field {
  position: relative;
  display: block;
}

.select-field select {
  padding-right: 44px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95);
  cursor: pointer;
}

.field-list input:not([type="radio"]):hover,
.select-field select:hover {
  border-color: #9fc0da;
  background-color: #ffffff;
}

.field-list input:not([type="radio"]):focus,
.select-field select:focus {
  border-color: var(--blue);
  outline: 3px solid rgba(35, 95, 159, 0.14);
}

.choice-field {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 4px;
  border: 1px solid #cfe0ec;
  border-radius: 10px;
  background: #f4f8fc;
}

.choice-option {
  min-width: 0;
  position: relative;
  display: block;
}

.choice-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.choice-option span {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #52667b;
  font-family: Montserrat, Arial, sans-serif;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.choice-option input:checked + span {
  border-color: rgba(35, 95, 159, 0.28);
  background: #ffffff;
  color: var(--blue-dark);
  box-shadow: 0 8px 18px rgba(35, 95, 159, 0.12);
}

.choice-option input:focus-visible + span {
  outline: 3px solid rgba(35, 95, 159, 0.16);
  outline-offset: 2px;
}

.choice-option:hover span {
  color: var(--blue);
}

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

.example-btn {
  min-height: 46px;
  border: 1px solid #cfe0ec;
  border-radius: 999px;
  background: #ffffff;
  color: var(--blue);
  padding: 0 18px;
  font-weight: 900;
  cursor: pointer;
}

.example-btn:hover {
  border-color: rgba(35, 95, 159, 0.45);
  background: #f7fbff;
}

.reader-screen {
  justify-items: center;
}

.reader-sheet {
  width: min(100%, 760px);
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #fffef9 0%, #ffffff 46%, #fffdf8 100%);
  box-shadow:
    0 28px 80px rgba(14, 32, 52, 0.14),
    inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

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

.reader-sheet::before {
  inset: 18px;
  border: 1px solid rgba(205, 220, 235, 0.8);
  border-radius: 8px;
}

.reader-sheet::after {
  display: none;
}

.story-header {
  padding: clamp(44px, 6vw, 64px) clamp(42px, 7vw, 78px) 0;
  text-align: center;
}

.story-header .eyebrow {
  color: #9b5b00;
}

.story-header h2 {
  max-width: 15ch;
  margin: 10px auto 0;
  font-size: clamp(2.4rem, 5vw, 3.85rem);
  line-height: 1;
  letter-spacing: 0;
  text-wrap: balance;
}

.cover-subtitle {
  max-width: 520px;
  margin: 14px auto 0;
  color: #495d70;
  font-size: clamp(0.94rem, 1.8vw, 1.08rem);
  font-weight: 750;
  line-height: 1.45;
}

.edition-strip {
  width: min(100%, 390px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-top: 28px;
  border: 1px solid rgba(205, 220, 235, 0.95);
  border-radius: 8px;
  background: #d8e5f1;
}

.edition-strip span {
  min-height: 42px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.82);
  color: #52667b;
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.cover-art {
  position: relative;
  margin: 0;
  width: min(100%, 300px);
  justify-self: end;
  padding: 12px;
  border: 1px solid rgba(205, 220, 235, 0.95);
  border-radius: 12px;
  background: #ffffff;
  box-shadow:
    0 24px 48px rgba(25, 62, 101, 0.16),
    inset 0 0 0 6px #fff8e8;
}

.cover-art::after {
  content: "";
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  pointer-events: none;
}

.book-cover img {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  border-radius: 8px;
  object-fit: cover;
}

.story-divider {
  display: grid;
  place-items: center;
  padding: 30px 0 4px;
}

.story-divider span {
  width: 112px;
  height: 14px;
  border-top: 2px solid #f1c27a;
  border-bottom: 2px solid #b9dfd2;
}

.story-text {
  max-width: 620px;
  margin: 0 auto;
  padding: clamp(20px, 3.6vw, 32px) clamp(34px, 6vw, 72px) 12px;
}

.story-text p {
  color: #1e2f43;
  font-size: var(--reader-font-size, clamp(1.08rem, 1.75vw, 1.28rem));
  font-weight: 500;
  line-height: var(--reader-line-height, 1.92);
  margin-bottom: var(--reader-paragraph-gap, 0.68em);
  text-align: justify;
  text-align-last: left;
  hyphens: auto;
  break-inside: avoid;
}

.story-text .lead-paragraph::first-letter {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.final-activities {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px clamp(34px, 6vw, 72px) clamp(38px, 5vw, 56px);
}

.final-activities article {
  min-width: 0;
  display: grid;
  gap: 4px;
  align-content: start;
  min-height: 92px;
  padding: 10px;
  overflow: hidden;
  border: 1px solid rgba(220, 231, 239, 0.95);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.22)),
    #fffdf8;
}

.final-activities article:nth-child(2) {
  background: #f2fbf7;
}

.final-activities article:nth-child(3) {
  background: #f3f7ff;
}

.final-activities article:nth-child(4) {
  background: #fff4f9;
}

.activity-icon {
  display: none;
}

.final-activities h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
}

.final-activities p {
  color: #4b5d72;
  font-size: 0.68rem;
  font-weight: 650;
  line-height: 1.32;
  overflow: hidden;
}

.status-text {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .button-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 10px;
  }

  .brand-block,
  .story-summary,
  .story-header,
  .field-list,
  .final-activities {
    grid-template-columns: 1fr;
  }

  .cover-art {
    width: min(100%, 340px);
    justify-self: center;
  }

  .story-header h2,
  .cover-subtitle,
  .edition-strip {
    max-width: 100%;
  }

  .preview-heading,
  .form-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .button-stack,
  .button-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .button-stack button,
  .primary-btn,
  .library-link {
    width: 100%;
  }
}

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

  *,
  *::before,
  *::after {
    box-shadow: none !important;
  }

  body {
    background: #fff;
    color: #18283a;
    width: 210mm;
    height: 297mm;
    overflow: hidden;
  }

  .control-panel,
  .account-widget,
  .library-screen,
  .customizer-screen,
  .preview-heading {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .workspace,
  .activity-panel {
    display: block;
    width: 100%;
  }

  .reader-screen {
    display: block !important;
  }

  .reader-sheet {
    box-sizing: border-box;
    width: 210mm;
    height: 297mm;
    min-height: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    overflow: hidden;
    position: relative;
    padding: 19mm 14mm 12mm;
    border: 1px solid #cddceb;
    border-radius: 3mm;
    background: #fffef9;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .reader-sheet::before {
    display: block;
    inset: 7mm;
    border-color: #f0dfb7;
    border-radius: 2mm;
  }

  .reader-sheet::after {
    display: none;
  }

  .story-header {
    padding: 0 8mm;
    text-align: center;
  }

  .story-header .eyebrow {
    font-size: 7.4pt;
  }

  .story-header h2 {
    max-width: 120mm;
    margin-top: 3mm;
    font-size: 30pt;
    line-height: 1;
  }

  .cover-subtitle {
    max-width: 118mm;
    margin-top: 3mm;
    font-size: 10pt;
    line-height: 1.35;
  }

  .edition-strip {
    display: none;
  }

  .story-divider {
    display: grid;
    padding: 5mm 0 4mm;
    break-after: avoid;
  }

  .story-text {
    max-width: 132mm;
    margin: 0 auto;
    padding: 0;
    align-self: start;
    overflow: hidden;
  }

  .story-text p {
    color: #18283a;
    font-size: var(--reader-print-font-size, 11.8pt);
    line-height: var(--reader-line-height, 1.48);
    margin-bottom: var(--reader-paragraph-gap, 0.62em);
    text-align: justify;
    text-align-last: left;
    hyphens: auto;
    orphans: 3;
    widows: 3;
  }

  .story-text .lead-paragraph::first-letter {
    float: none;
    margin: 0;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
  }

  .final-activities {
    grid-template-columns: repeat(4, 1fr);
    gap: 2.2mm;
    padding: 3mm 0 0;
    break-inside: avoid;
    page-break-inside: avoid;
    border-top: 0;
  }

  .final-activities article {
    height: 23mm;
    min-height: 0;
    padding: 2mm;
    overflow: hidden;
    border-color: #d9e5ef;
  }

  .activity-icon {
    width: 9mm;
    height: 9mm;
    font-size: 11pt;
  }

  .final-activities h3 {
    font-size: 5.8pt;
  }

  .final-activities p {
    font-size: var(--reader-notes-size, 6pt);
    line-height: 1.12;
    max-height: 14mm;
    overflow: hidden;
  }
}
