@font-face { font-family: "Nunito"; src: url("../fonts/nunito/Nunito-Variable.woff2") format("woff2"); font-weight: 400 800; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url("../fonts/atkinson-hyperlegible-next/AtkinsonHyperlegibleNext-Variable.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Andika"; src: url("../fonts/andika/Andika-Regular.woff2") format("woff2"); font-display: swap; }

:root {
  --heading: #3d2b1f;
  --link: #9a4320;
  --primary: #b4532a;
  --primary-dark: #8c3d1c;
  --primary-soft: #fbeade;
  --accent: #e3a33b;
  --focus: #d4842a;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --paper: #fbf6ee;
  --paper-strong: #f1e5d3;
  --surface: #ffffff;
  --line: #eadfcf;
  --text: #2e2620;
  --muted: #7a6658;
  --radius: 16px;
  --topbar-height: 64px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --radius-small: 10px;
  --font: "Nunito", system-ui, sans-serif;
  --font-reading: "Atkinson Hyperlegible Next", Verdana, system-ui, sans-serif;
  --font-early: "Andika", "Atkinson Hyperlegible Next", Verdana, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  position: relative;
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font: 400 1rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; color: var(--heading); font-weight: 700; line-height: 1.2; }
p { margin: 0; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
svg[aria-hidden="true"] { width: 1.25em; height: 1.25em; flex: none; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hint { color: var(--muted); font-size: .875rem; }

.page { width: min(100% - 32px, 880px); margin: 0 auto; padding: 40px 0 80px; }
.page-wide { width: min(100% - 32px, 1120px); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-small);
  background: var(--danger-soft);
  color: var(--danger);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s;
}
.button:hover { background: var(--primary-dark); }
.button:disabled { opacity: .6; cursor: progress; }
.button-large { width: 100%; min-height: 56px; font-size: 1.125rem; }
.button-quiet { background: var(--surface); color: var(--heading); border: 1px solid var(--line); min-height: 40px; padding: 0 16px; }
.button-quiet:hover { background: var(--paper); }

.link-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font-weight: 500;
  cursor: pointer;
}
.link-button:disabled { opacity: .6; }

/* Barra superior */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-sizing: border-box;
  height: var(--topbar-height);
  padding: 0 max(16px, calc((100% - 1120px) / 2));
  background: var(--heading);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; color: #fff; text-decoration: none; }
.brand img { flex: none; }
.brand-name { overflow: hidden; max-width: 36ch; font-size: 1.0625rem; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.topnav { display: flex; align-items: center; gap: 4px; }
.topnav a, .topnav .link-button { display: inline-flex; white-space: nowrap; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; color: rgb(255 255 255 / .75); text-decoration: none; font-weight: 500; transition: background-color .15s, color .15s; }
.topnav a:hover, .topnav .link-button:hover { color: #fff; background: rgb(255 255 255 / .08); }
.topnav a.is-active { color: #fff; background: rgb(255 255 255 / .14); }
.menu-toggle {
  display: none;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgb(255 255 255 / .3);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-weight: 500;
  cursor: pointer;
}
.menu-toggle .menu-close, .menu-toggle[aria-expanded="true"] .menu-open { display: none; }
.menu-toggle[aria-expanded="true"] .menu-close { display: inline-flex; }
.menu-toggle span { display: inline-flex; }

/* Ingreso */

.login {
  display: grid;
  grid-template-columns: minmax(430px, .86fr) minmax(0, 1.24fr);
  gap: 8px;
  height: 100vh;
  height: 100dvh;
  min-height: 620px;
  padding: 8px;
  background: #fffefc;
}
.login-panel { display: flex; align-items: center; justify-content: center; padding: clamp(28px, 4vh, 52px) clamp(36px, 5vw, 76px); }
.login-content { width: min(100%, 430px); }
.login-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--heading);
  font-size: .875rem;
  font-weight: 500;
}
.login-header h1 { font-size: clamp(2rem, 2.7vw, 2.625rem); letter-spacing: -.045em; line-height: 1.02; }
.login-header p:last-child { max-width: 38ch; margin-top: 12px; color: var(--muted); }
.login-form { display: grid; gap: 20px; margin-top: 28px; }
.login-field { display: grid; gap: 7px; }
.login-field > span:first-child { font-size: .875rem; font-weight: 500; }
.login-field input {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface);
  font-size: 1rem;
  transition: border-color .16s, box-shadow .16s;
}
.login-field input::placeholder { color: var(--muted); opacity: .82; }
.login-field input:hover { border-color: var(--focus); }
.login-field input:focus { border-color: var(--link); box-shadow: 0 0 0 3px rgb(212 132 42 / .22); outline: 0; }
.login-password { position: relative; display: block; }
.login-password input { padding-right: 112px; }
.password-toggle {
  position: absolute;
  top: 5px;
  right: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 96px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--link);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
}
.password-toggle:hover { background: var(--primary-soft); }
.password-toggle svg { width: 18px; height: 18px; }
.password-toggle .eye-show { display: contents; }
.password-toggle .eye-hide, .password-toggle[aria-pressed="true"] .eye-show { display: none; }
.password-toggle[aria-pressed="true"] .eye-hide { display: contents; }
.login-button {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 6px;
  min-height: 50px;
  padding: 7px;
  border: 0;
  border-radius: var(--radius-small);
  background: linear-gradient(120deg, var(--primary), var(--primary-dark));
  box-shadow: 0 10px 24px -16px rgb(61 43 31 / .34);
  color: #fff;
  font-weight: 500;
  cursor: pointer;
}
.login-button > span:first-child { grid-column: 2; }
.login-button-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: rgb(255 255 255 / .18);
  transition: translate .12s;
}
.login-button-icon svg { width: 18px; height: 18px; }
.login-button:hover .login-button-icon { translate: 2px 0; }
.login-button:disabled { opacity: .7; cursor: progress; }
.login-alert {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  padding: 16px;
  border: 1px solid #f3c4bd;
  border-radius: var(--radius-small);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: .875rem;
}
.login-visual { position: relative; overflow: hidden; border-radius: 16px; background: var(--heading); }
.login-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 48%; }
.login-logo { position: absolute; top: clamp(24px, 4vw, 48px); right: clamp(24px, 4vw, 52px); z-index: 2; display: flex; align-items: center; gap: 12px; max-width: min(360px, 70%); margin: 0; color: #fff; font-size: 1.25rem; font-weight: 800; line-height: 1.2; text-shadow: 0 1px 12px rgb(40 26 18 / .45); }
.login-logo img { flex: none; box-shadow: 0 4px 14px rgb(40 26 18 / .3); border-radius: 8px; }
.login-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgb(40 26 18 / .46), transparent 30%), linear-gradient(90deg, rgb(61 43 31 / .09), transparent 30%);
}

@media (max-width: 980px) {
  .login { grid-template-columns: minmax(390px, .95fr) minmax(0, 1.05fr); }
  .login-panel { padding: 36px; }
}

@media (max-width: 719px) {
  .login-break { display: none; }
  .login {
    grid-template-columns: 1fr;
    grid-template-rows: clamp(220px, 30vh, 270px) auto;
    gap: 6px;
    height: auto;
    min-height: 100dvh;
    padding: 6px;
  }
  .login-panel { grid-row: 2; align-items: flex-start; padding: 28px clamp(20px, 7vw, 44px) 42px; }
  .login-visual { grid-row: 1; }
  .login-photo { object-position: 50% 30%; }
  .login-shade { background: linear-gradient(180deg, rgb(40 26 18 / .48), transparent 48%), linear-gradient(0deg, rgb(61 43 31 / .12), transparent 24%); }
  .login-logo { left: 20px; right: auto; top: 20px; font-size: 1.0625rem; }
  .login-header h1 { font-size: clamp(2rem, 9vw, 2.5rem); }
}

@media (max-width: 390px) {
  .login-password input { padding-right: 54px; }
  .password-toggle { min-width: 44px; width: 44px; padding: 0; }
  .password-toggle [data-password-label] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

@media (min-width: 720px) and (max-height: 760px) {
  .login-header h1 { font-size: 2.125rem; }
  .login-form { gap: 14px; margin-top: 20px; }
}

/* Crear */

.scenery {
  display: block;
  position: absolute;
  inset: var(--topbar-height) 0 auto;
  z-index: -1;
  height: clamp(320px, 46vw, 520px);
  overflow: hidden;
  mask-image: linear-gradient(to bottom, #000 40%, transparent);
}
.scenery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  filter: saturate(.85) brightness(1.04);
  opacity: .85;
}

.create { display: grid; gap: 28px; }
.create h1 {
  position: relative;
  isolation: isolate;
  font-size: clamp(1.75rem, 4vw, 2.375rem);
  font-weight: 500;
  text-align: center;
  text-wrap: balance;
  text-shadow: 0 0 18px rgb(255 255 255 / .9);
}
.create h1::before {
  content: "";
  position: absolute;
  inset: -28px -6%;
  z-index: -1;
  background: rgb(251 246 238 / .78);
  backdrop-filter: blur(4px);
  mask-image: radial-gradient(closest-side, #000 62%, transparent);
}
.create-card { display: grid; gap: 24px; padding: 28px; box-shadow: 0 12px 40px rgb(61 43 31 / .12); }

.sentence {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  font-size: clamp(1.375rem, 3vw, 1.75rem);
  color: var(--heading);
}
.sentence select, .sentence-probe {
  font-size: inherit;
  font-weight: 500;
}
.sentence select {
  max-width: 100%;
  padding: 0 28px 2px 2px;
  border: 0;
  border-bottom: 2px solid var(--primary);
  border-radius: 0;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23238571' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 2px center / 20px;
  color: var(--primary-dark);
  appearance: none;
  cursor: pointer;
}
.sentence-joint { margin-left: -8px; }

/* Lista desplegada con el diseño de la app en los navegadores que lo permiten; en los demás queda la nativa. */
@supports (appearance: base-select) {
  .sentence select, .sentence select::picker(select) { appearance: base-select; }
  .sentence select { display: inline-flex; align-items: center; width: auto !important; white-space: nowrap; }
  .sentence select::picker-icon { display: none; }
  .sentence select > button { display: inline-flex; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: inherit; }
  .sentence select::picker(select) {
    box-sizing: border-box;
    min-width: max(14rem, anchor-size(width));
    max-width: min(22rem, calc(100vw - 32px));
    max-height: min(26rem, calc(100% - 12px));
    position-try-order: most-block-size;
    margin-block: 6px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: var(--surface);
    box-shadow: 0 16px 36px -12px rgb(61 43 31 / .35);
    color: var(--text);
    font: 400 1rem/1.4 var(--font);
  }
  .sentence optgroup { display: grid; gap: 2px; padding-top: 4px; color: var(--muted); font: 500 .8125rem/1.4 var(--font); }
  .sentence optgroup + optgroup { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
  .sentence optgroup legend { padding: 4px 10px; }
  .sentence option {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text);
    font: 400 1rem/1.4 var(--font);
    cursor: pointer;
  }
  .sentence option::checkmark { order: 1; margin-inline-start: auto; color: var(--primary); }
  .sentence option:hover, .sentence option:focus-visible { outline: 0; background: var(--paper); }
  .sentence option:checked { background: var(--primary-soft); color: var(--primary-dark); font-weight: 500; }
}
.sentence-probe { position: absolute; visibility: hidden; white-space: nowrap; }

.field { display: grid; gap: 8px; }
.label, .legend { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--heading); }
.label svg, .legend svg, .block h2 svg { color: var(--primary); }
textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface);
  font-size: 1.0625rem;
  resize: vertical;
}

.ideas { display: grid; gap: 12px; margin-top: -8px; }
.ideas .link-button { justify-self: start; }
.idea-list { display: grid; gap: 8px; }
.idea {
  display: grid;
  gap: 2px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--paper);
  text-align: left;
  cursor: pointer;
}
.idea:hover { border-color: var(--primary); background: var(--primary-soft); }
.idea strong { color: var(--heading); font-weight: 500; }
.idea span { color: var(--muted); font-size: .9375rem; }

.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px 40px; padding-top: 24px; border-top: 1px solid var(--line); }
.option { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; align-content: start; }
.option legend { padding: 0; margin-bottom: 8px; }
[hidden] { display: none !important; }

.segmented { display: inline-flex; justify-self: start; border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--paper); }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; padding: 6px 16px; border-radius: 999px; color: var(--muted); cursor: pointer; }
.segmented input:checked + span { background: var(--surface); color: var(--heading); font-weight: 500; box-shadow: 0 1px 3px rgb(61 43 31 / .15); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); }

.stepper { display: inline-flex; align-items: center; gap: 4px; justify-self: start; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.stepper button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.stepper svg { width: 18px; height: 18px; }
.stepper button:hover:not(:disabled) { background: var(--primary); color: #fff; }
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper input { width: 44px; border: 0; background: transparent; color: var(--heading); font-size: 1.125rem; font-weight: 700; text-align: center; appearance: textfield; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { appearance: none; }
.stepper-small button { width: 32px; height: 32px; }
.stepper-small input { width: 32px; font-size: 1rem; }
.customize { margin-top: -8px; }
.customize summary { display: inline-flex; align-items: center; gap: 8px; color: var(--link); font-weight: 500; cursor: pointer; list-style: none; }
.customize summary::-webkit-details-marker { display: none; }
.customize summary::after { content: ""; width: 8px; height: 8px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-2px); transition: transform .2s; }
.customize[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
.customize-body { display: grid; gap: 22px; margin-top: 16px; padding: 20px; border-radius: var(--radius-small); background: var(--paper); }
.levels { display: flex; flex-wrap: wrap; gap: 12px 28px; }
.level { display: grid; gap: 6px; justify-items: start; color: var(--heading); font-size: .9375rem; font-weight: 500; }

/* Lectura */

.status { display: grid; justify-items: center; gap: 12px; padding: 56px 24px; text-align: center; }
.status-icon { color: var(--danger); font-size: 2.5rem; line-height: 0; }
.status img { width: clamp(140px, 30vw, 180px); height: auto; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.reading-text { display: grid; gap: 1em; padding: clamp(24px, 5vw, 48px); font: 1.1875rem/1.75 var(--font-reading); }
.reading-text h2 { margin-top: .5em; font: 700 1.25rem/1.3 var(--font); }
.reading-text ul, .reading-text ol { display: grid; gap: .4em; margin: 0; padding-left: 1.4em; }
.reading-text .steps { list-style: none; padding: 0; counter-reset: step; }
.reading-text .steps li { position: relative; padding-left: 2.4em; counter-increment: step; }
.reading-text .steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: .15em;
  display: grid;
  place-items: center;
  width: 1.6em;
  height: 1.6em;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font: 700 .875rem/1 var(--font);
}
.reading-text .stanza span { display: block; }
.reading-text .lead { font-weight: 700; color: var(--heading); }
.reading-text .stage { color: var(--muted); font-style: italic; }
.reading-text .dialogue strong { color: var(--heading); font-family: var(--font); font-weight: 700; }
.reading-text .place, .reading-text .signature { text-align: right; }
.reading-title { margin-bottom: .2em; font: 700 clamp(1.625rem, 3vw, 2.125rem)/1.2 var(--font); color: var(--heading); text-wrap: balance; }
.is-preschool .reading-text { font-family: var(--font-early); font-size: 1.375rem; }

.block { display: grid; gap: 16px; }
.block h2 { display: flex; align-items: center; gap: 10px; font-size: 1.375rem; }
.block-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--primary); }

.words { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 0; }
.words div { padding: 14px 16px; border-radius: var(--radius-small); background: var(--surface); border: 1px solid var(--line); }
.words dt { color: var(--heading); font-weight: 700; }
.words dd { margin: 2px 0 0; color: var(--muted); }

.questions, .moments, .home { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: item; }
.question, .moment, .home .card { padding: 20px 24px; }
.question { counter-increment: item; }
.question-level { color: var(--muted); font-size: .8125rem; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.question-prompt { margin: 4px 0 12px; color: var(--heading); font-weight: 500; }
.question-prompt::before { content: counter(item) ". "; }
.options-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.options-list li { padding: 8px 12px; border-radius: var(--radius-small); }
.options-list span { color: var(--muted); }
.open-answer { color: var(--muted); font-size: .9375rem; font-style: italic; }
.expected { display: none; margin-top: 10px; padding: 10px 14px; border-radius: var(--radius-small); background: var(--primary-soft); color: var(--primary-dark); }
.show-answers .expected { display: block; }
.show-answers .is-answer { background: var(--primary-soft); color: var(--primary-dark); font-weight: 500; }

.moment { display: grid; gap: 8px; }
.moment h3::before { content: counter(item) ". "; color: var(--primary); }
.moment { counter-increment: item; }
.moment-question { padding: 10px 14px; border-left: 3px solid var(--primary); background: var(--primary-soft); border-radius: 0 var(--radius-small) var(--radius-small) 0; color: var(--heading); }
.home .card { display: grid; gap: 6px; }
.home h3, .moment h3 { font-size: 1.0625rem; }

/* Administración */

body.admin { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.admin-sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 20px 14px;
  background: var(--heading);
  color: #fff;
}
.admin-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; color: #fff; text-decoration: none; font-weight: 700; line-height: 1.25; }
.admin-brand small { display: block; color: rgb(255 255 255 / .65); font-size: .8125rem; font-weight: 400; }
.admin-menu { display: grid; gap: 4px; }
.admin-menu a, .admin-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-small);
  background: none;
  color: rgb(255 255 255 / .78);
  font: 500 .9375rem/1.3 var(--font);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.admin-menu a:hover, .admin-menu button:hover { background: rgb(255 255 255 / .08); color: #fff; }
.admin-menu a.is-active { background: rgb(255 255 255 / .14); color: #fff; }
.admin-menu-bottom { margin-top: auto; padding-top: 16px; border-top: 1px solid rgb(255 255 255 / .12); }
.admin-main { display: flex; flex-direction: column; min-width: 0; }
.admin-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  height: var(--topbar-height);
  padding: 0 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.admin-user { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 500; }
.admin-content { display: grid; align-content: start; gap: 20px; width: min(100% - 48px, 1200px); margin: 0 auto; padding: 28px 0 64px; }
.admin-card { display: grid; gap: 20px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.admin-card-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
.admin-card-header h1 { font-size: 1.625rem; }
.admin-card-header h2 { font-size: 1.25rem; }
.admin-card-header p { margin-top: 4px; }
.admin-form { max-width: 760px; }
.admin-columns { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.admin-columns .admin-form { max-width: none; }
.admin .back-link { margin-bottom: -8px; }
.admin .stat { border: 1px solid var(--line); border-radius: var(--radius-small); }
.stat .quota-bar { grid-column: 1 / -1; margin-top: 8px; }
.button-small { min-height: 34px; padding: 0 14px; font-size: .875rem; }
.button-danger { color: var(--danger); border-color: #f3c4bd; }
.button-danger:hover { background: var(--danger-soft); }

.table-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.search-field { position: relative; display: flex; flex: 1 1 260px; align-items: center; }
.search-field svg { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search-field input, .table-filters select, .admin-form select, .import-steps select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background-color: var(--surface);
}
.search-field input { width: 100%; padding: 0 12px 0 40px; }
.table-filters select, .admin-form select, .import-steps select {
  padding: 0 36px 0 12px;
  appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d7486' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 18px;
}
.admin .table-card { border: 1px solid var(--line); border-radius: var(--radius-small); overflow-x: auto; }
.admin .table th { background: var(--paper); }
.admin .table td { vertical-align: middle; }
.admin .table td > span { display: block; }
.admin .table td .badge { display: inline-block; margin-top: 4px; }
.table-filters select { flex: 0 1 auto; }
.admin .table tbody tr:hover { background: #fdf9f3; }
.table-empty { padding: 40px 16px !important; color: var(--muted); text-align: center; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }
.pager .muted { margin-right: auto; font-size: .875rem; }

.facts { display: grid; gap: 10px; margin: 0; }
.facts div { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; color: var(--heading); font-weight: 500; }
.account-action { display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.account-action h3 { font-size: 1rem; }
.account-action .button { justify-self: start; }
.import-steps { display: grid; gap: 20px; margin: 0; padding-left: 22px; }
.import-steps li { display: grid; gap: 10px; justify-items: start; }
.import-steps select { width: min(100%, 420px); }

/* Editar: la misma lectura, con cada texto editable en su sitio */

.edit-hint { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius-small); background: var(--primary-soft); color: var(--primary-dark); font-size: .9375rem; }
.edit-hint svg { flex: none; width: 20px; height: 20px; }
:where(.editable) { color: inherit; font: inherit; }
.editable {
  display: block;
  width: calc(100% + .8em);
  min-width: 0;
  margin-inline: -.4em;
  padding: .1em .4em;
  border: 1px dashed var(--line);
  border-radius: var(--radius-small);
  background: rgb(251 246 238 / .6);
  field-sizing: content;
  resize: none;
  transition: border-color .15s, background-color .15s;
}
.editable:hover { border-color: #dccbb5; }
.editable:focus { border-style: solid; border-color: var(--link); background: var(--surface); box-shadow: 0 0 0 3px rgb(212 132 42 / .22); outline: 0; }
@supports not (field-sizing: content) {
  textarea.editable { resize: vertical; }
}
.reading-text .heading { margin-top: .5em; font: 700 1.25rem/1.3 var(--font); }
.edit-list { display: grid; gap: 2px; }
.edit-list span { color: var(--muted); font: .8125rem var(--font); }
.dialogue-edit { display: flex; align-items: start; gap: .6em; }
.dialogue-edit input { flex: none; width: auto; min-width: 5ch; max-width: 40%; margin-inline: -.4em 0; color: var(--heading); font-family: var(--font); font-weight: 700; }
.dialogue-edit textarea { flex: 1; width: auto; margin-inline: 0 -.4em; }
.word-term { color: var(--heading); font-weight: 700; }
.word-meaning { margin-top: 2px; color: var(--muted); }
.option-edit { display: grid; grid-template-columns: 20px auto minmax(0, 1fr); align-items: center; gap: 10px; }
.option-edit:has(:checked) { background: var(--primary-soft); }
.option-edit input[type="radio"] { width: 20px; height: 20px; margin: 0; accent-color: var(--primary); }
.option-edit .editable { width: calc(100% + .4em); margin-inline: -.4em 0; }
.editable.moment-question { width: 100%; margin-inline: 0; padding: 10px 14px; border-left: 3px solid var(--primary); background: var(--primary-soft); }
.home-name { color: var(--heading); font: 700 1.0625rem var(--font); }
.edit-actions {
  position: sticky;
  bottom: 0;
  display: none;
  justify-content: flex-end;
  gap: 12px;
  margin: 0 -16px;
  padding: 16px;
  background: linear-gradient(to top, var(--paper) 70%, transparent);
}

/* Lectura con su pedido al lado */

.reading-layout { display: grid; grid-template-columns: 296px minmax(0, 1fr); gap: 28px; align-items: start; }
.reading-main { display: grid; gap: 28px; min-width: 0; }
.request-summary { position: sticky; top: 24px; display: grid; gap: 12px; max-height: calc(100vh - 48px); overflow-y: auto; scrollbar-width: thin; }
@supports not (view-transition-name: none) {
  .request-summary { animation: summary-in .5s var(--ease-out) both; }
}
.request-card { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); view-transition-name: request; }
.request-card summary { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; color: var(--heading); font-weight: 700; list-style: none; pointer-events: none; }
.request-card summary::-webkit-details-marker { display: none; }
.request-short { display: none; }
.request-facts { display: grid; gap: 12px; margin: 16px 0 0; }
.request-facts div { display: grid; gap: 2px; }
.request-facts dt { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .8125rem; }
.request-facts dt svg { width: 16px; height: 16px; }
.request-facts dd { margin: 0; color: var(--heading); font-weight: 500; }
.request-facts .request-detail { color: var(--muted); font-size: .8125rem; font-weight: 400; }
.request-topic { display: grid; gap: 4px; margin-top: 18px; padding: 12px 14px; border-radius: var(--radius-small); background: var(--paper); }
.request-topic span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .8125rem; }
.request-topic span svg { width: 16px; height: 16px; }
.request-topic p { color: var(--text); font-size: .9375rem; overflow-wrap: anywhere; }
.request-date { margin-top: 14px; color: var(--muted); font-size: .8125rem; }
.request-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.request-actions .button { min-height: 40px; padding: 0 12px; font-size: .875rem; }
.reading-main > * { animation: content-in .5s .08s var(--ease-out) both; }

.generating { gap: 16px; }
.progress { width: min(100%, 360px); height: 8px; overflow: hidden; border-radius: 999px; background: var(--paper-strong); }
.progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .5s var(--ease-out); }
.progress-step { min-height: 1.5em; color: var(--heading); font-weight: 500; transition: opacity .3s; }
.progress-step.is-changing { opacity: 0; }

@keyframes summary-in { from { opacity: 0; transform: translateX(-16px); } }
@keyframes content-in { from { opacity: 0; transform: translateY(10px); } }

@view-transition { navigation: auto; }
.create-card { view-transition-name: request; }
::view-transition-group(request) { animation-duration: .5s; animation-timing-function: var(--ease-out); }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .request-summary, .reading-main > * { animation: none; }
}

/* Historial */

.history { display: grid; gap: 24px; }
.history h1 { font-size: 2rem; }
.history-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.history-item { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; padding: 16px 20px; text-decoration: none; color: inherit; }
.history-item > :not(.history-icon) { grid-column: 2; }
.history-icon { grid-row: span 3; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); color: var(--primary-dark); }
.history-item:hover { border-color: var(--primary); }
.history-title { color: var(--heading); font-weight: 500; font-size: 1.0625rem; }
.history-more { justify-self: center; min-width: 220px; }
.history-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); font-size: .875rem; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); font-weight: 500; }
.badge-error { background: var(--danger-soft); color: var(--danger); }
.empty { display: grid; justify-items: center; gap: 16px; padding: 48px 24px; }

/* Paneles */

.panel { display: grid; gap: 24px; }
.panel-header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 16px; }
.panel-header > div { display: grid; gap: 6px; }
.panel-header h1 { font-size: 2rem; }
.back-link { display: inline-flex; align-items: center; gap: 6px; justify-self: start; color: var(--muted); font-weight: 500; text-decoration: none; }
.back-link:hover { color: var(--heading); }
.notice { padding: 12px 16px; border-radius: var(--radius-small); background: var(--primary-soft); color: var(--primary-dark); }
.alert ul { margin: 8px 0 0; padding-left: 20px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.institution-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.institution-item { display: grid; gap: 6px; padding: 18px 20px; color: inherit; text-decoration: none; }
.institution-item:hover { border-color: var(--primary); }
.institution-item .badge { justify-self: start; }
.institution-name { color: var(--heading); font-size: 1.125rem; font-weight: 500; }
.quota { display: grid; gap: 6px; margin-top: 6px; color: var(--muted); font-size: .875rem; }
.quota-bar, .bar { height: 8px; overflow: hidden; border-radius: 999px; background: var(--paper-strong); }
.quota-bar { max-width: 360px; }
.quota-bar span, .bar span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }

.form-card { display: grid; gap: 16px; padding: 24px; align-content: start; }
.form-card h2 { font-size: 1.25rem; }
.form-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-field { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; }
.form-field > span, .form-field legend { padding: 0; margin-bottom: 6px; color: var(--heading); font-size: .875rem; font-weight: 500; }
.form-field-wide { grid-column: 1 / -1; }
.form-field input:not([type="radio"]) {
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: var(--surface);
}
.file-picker { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; cursor: pointer; }
.file-picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-picker:focus-within .button { outline: 3px solid var(--focus); outline-offset: 2px; }
.file-name { color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
.form-card .button, .form-card .link-button { justify-self: start; }
.checkbox { display: flex; align-items: center; gap: 10px; color: var(--text); }
.checkbox input { width: 18px; height: 18px; accent-color: var(--primary); }

.table-card { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th { padding: 12px 16px; color: var(--muted); font-size: .8125rem; font-weight: 500; text-align: left; white-space: nowrap; }
.table td { padding: 14px 16px; border-top: 1px solid var(--line); vertical-align: top; }
.table td strong { display: block; color: var(--heading); font-weight: 500; }
.table td .muted { font-size: .875rem; }
.table .is-inactive td { opacity: .55; }
.table-actions { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: flex-end; }
.table-actions .link-button { font-size: .875rem; white-space: nowrap; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.stat { display: grid; gap: 4px; padding: 20px; }
.stat strong { color: var(--heading); font-size: 2rem; line-height: 1.1; }
.stat small { color: var(--muted); font-size: 1rem; font-weight: 400; }
.stat span { color: var(--muted); }
.bars { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.bars li { display: grid; grid-template-columns: minmax(110px, 1fr) 2fr auto; align-items: center; gap: 12px; }
.bars .bar { max-width: none; }

.credentials { max-width: 520px; margin: 0 auto; }
.credential { display: grid; gap: 12px; margin: 0; }
.credential div { display: grid; gap: 2px; padding: 14px 16px; border-radius: var(--radius-small); background: var(--paper); }
.credential dt { color: var(--muted); font-size: .875rem; }
.credential dd { margin: 0; color: var(--heading); font-size: 1.125rem; font-weight: 500; }
.credential code { font: 700 1.375rem/1.2 ui-monospace, Menlo, monospace; letter-spacing: .04em; }

@media (max-width: 900px) {
  .brand-name { max-width: 28ch; }
  .reading-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .request-summary { position: static; }
  .request-card { padding: 16px 18px; }
  .request-card summary { pointer-events: auto; cursor: pointer; }
  .request-card summary::after { content: ""; width: 10px; height: 10px; margin-left: auto; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-3px); transition: transform .2s; }
  .request-card[open] summary::after { transform: rotate(-135deg); }
  .request-short { display: inline; color: var(--muted); font-size: .875rem; font-weight: 400; }
  .request-card[open] .request-short { display: none; }
  .request-actions { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .request-actions.is-editing { display: none; }
  .edit-actions { display: flex; }
  body.admin { grid-template-columns: minmax(0, 1fr); }
  .admin-sidebar { position: fixed; inset: 0 auto 0 0; width: 272px; transform: translateX(-100%); transition: transform .2s; }
  .admin-sidebar.is-open { transform: none; box-shadow: 0 0 40px rgb(61 43 31 / .35); }
  .admin-header { justify-content: space-between; padding: 0 16px; }
  .admin-toggle { display: inline-flex; border-color: var(--line); background: var(--surface); color: var(--heading); }
  .admin-content { width: min(100% - 32px, 1200px); padding-top: 20px; }
  .admin-card { padding: 18px; }
  .admin-columns { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table, .table tbody { display: block; }
  .table-card { border: 0; background: none; overflow: visible; }
  .table tbody { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
  .table tr { display: grid; align-content: start; gap: 6px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
  .table td { display: flex; justify-content: space-between; gap: 12px; padding: 0; border: 0; }
  .table td:first-child { display: block; margin-bottom: 4px; }
  .table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .875rem; }
  .table-actions { justify-content: flex-start; margin-top: 6px; }
  .admin .table-card { border: 0; }
}

@media (max-width: 600px) {
  .scenery img { height: 165%; }
  .edit-actions .button { flex: 1; padding: 0 12px; white-space: nowrap; }
  .stats { gap: 8px; }
  .stat { grid-template-columns: minmax(84px, auto) 1fr; align-items: baseline; gap: 12px; padding: 14px 16px; }
  .stat strong { font-size: 1.5rem; }
  .page { padding-top: 24px; }
  .create-card { padding: 20px; }
  .topnav { gap: 14px; }
  .topbar { position: sticky; top: 0; z-index: 20; }
  .brand img { width: 28px; height: 28px; }
  .brand-name { display: -webkit-box; max-width: 60vw; font-size: .9375rem; line-height: 1.2; white-space: normal; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .customize-body { padding: 16px; }
  .customize .segmented { display: flex; justify-self: stretch; }
  .customize .segmented label { flex: 1; }
  .customize .segmented span { padding: 6px 8px; font-size: .875rem; text-align: center; white-space: nowrap; }
  .levels { display: grid; gap: 10px; }
  .level { grid-template-columns: 1fr auto; align-items: center; justify-items: stretch; }
  .menu-toggle { display: inline-flex; }
  .topnav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 10;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px 16px 16px;
    background: var(--heading);
    border-top: 1px solid rgb(255 255 255 / .12);
    box-shadow: 0 12px 24px rgb(61 43 31 / .25);
  }
  .topnav.is-open { display: flex; }
  .topnav a, .topnav .link-button { width: 100%; min-height: 52px; gap: 12px; padding: 0 12px; border-radius: var(--radius-small); font-size: 1.0625rem; color: #fff; }
  .topnav a.is-active { background: rgb(255 255 255 / .12); }
}

@media print {
  body { background: #fff; }
  .topbar, .no-print, .request-summary { display: none !important; }
  .reading-layout { display: block; }
  .page { width: auto; padding: 0; }
  .card { border: 0; padding-left: 0; padding-right: 0; }
  .block { break-inside: avoid-page; }
  .question, .moment, .home .card { break-inside: avoid; }
}
