:root {
  --ink: #24313f;
  --muted: #687589;
  --paper: #fffdf7;
  --line: #dfe6ee;
  --brand: #226c73;
  --brand-dark: #184d55;
  --sun: #f5b84b;
  --leaf: #77a857;
  --rose: #d9656f;
  --sky: #e8f4f6;
  --shadow: 0 16px 36px rgba(31, 49, 63, .12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f7fbfc 0%, var(--paper) 42%, #f5f0e8 100%);
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; font-weight: 700; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 54px);
  background: rgba(255, 253, 247, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 1.2rem; color: var(--ink); }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--brand);
  color: white;
}
.nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.container { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 56px; }
.footer { text-align: center; color: var(--muted); padding: 26px; border-top: 1px solid var(--line); }

.hero {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 26px;
  align-items: center;
  min-height: 460px;
}
.hero h1 { font-size: clamp(3rem, 8vw, 6rem); line-height: 1; margin: 10px 0; letter-spacing: 0; }
.subtitle { font-size: clamp(1.2rem, 3vw, 1.8rem); color: var(--muted); max-width: 620px; }
.eyebrow { color: var(--rose); text-transform: uppercase; font-weight: 800; font-size: .78rem; letter-spacing: 0; }
.hero-art {
  min-height: 320px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.hero-art span {
  display: grid;
  place-items: center;
  font-size: clamp(3.5rem, 8vw, 6rem);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  animation: floatIn .45s ease both;
}

.btn, button {
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  padding: 12px 18px;
  font-weight: 800;
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}
.btn:hover, button:hover { background: var(--brand-dark); }
.btn, button, .card, .choice span { transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease, border-color .2s ease; }
.btn:hover, button:hover, .action-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn-outline { background: white; color: var(--brand); border: 1px solid var(--brand); }
.btn-small { padding: 8px 12px; min-height: 36px; font-size: .92rem; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.steps, .cards, .stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.steps article, .card, .stats article {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 8px 22px rgba(31, 49, 63, .07);
  animation: cardIn .28s ease both;
}
.steps strong {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--sun);
}
.steps h2, .card h2 { margin-bottom: 8px; }
.form-shell { max-width: 850px; margin: 0 auto; }
.form-shell.narrow { max-width: 560px; }
.form-grid { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: var(--ink); font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
textarea { resize: vertical; line-height: 1.55; }
.password-wrap {
  position: relative;
  display: block;
}
.password-wrap input { padding-right: 52px; }
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  min-height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  box-shadow: none;
  font-size: 1.05rem;
}
.password-toggle:hover {
  background: var(--sky);
  transform: translateY(-50%);
  box-shadow: none;
}

.dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}
.dashboard-head h1 { margin: 0 0 6px; font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: 0; }
.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 22px; }
.stats article strong { display: block; font-size: 2.2rem; color: var(--brand); }
.stats article span { color: var(--muted); font-weight: 700; }
.cards { grid-template-columns: repeat(5, 1fr); }
.admin-tools { grid-template-columns: repeat(2, 1fr); margin-bottom: 18px; }
.action-card { color: var(--ink); min-height: 132px; display: grid; place-items: center; text-align: center; gap: 8px; font-size: 2rem; }
.action-card span { display: block; font-size: 1rem; }

.wizard { display: grid; gap: 16px; }
.step > span {
  display: inline-block;
  color: white;
  background: var(--leaf);
  border-radius: 8px;
  padding: 5px 10px;
  font-weight: 800;
}
.progress {
  height: 8px;
  border-radius: 8px;
  background: #edf2f4;
  overflow: hidden;
  margin: 10px 0 14px;
}
.progress i {
  display: block;
  height: 100%;
  background: var(--brand);
  transition: width .3s ease;
}
.aula-checks {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.aula-checks legend { font-weight: 800; color: var(--brand-dark); }
.aula-checks label { display: block; font-weight: 700; }
.observation {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.observation:first-of-type { border-top: 0; }
.choice-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 12px 0; }
.choice input { position: absolute; opacity: 0; }
.choice span {
  min-height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sky);
  text-align: center;
  padding: 8px;
}
.choice input:checked + span { background: var(--brand); color: white; border-color: var(--brand); }

.table-wrap { overflow-x: auto; background: white; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
.compact-table { margin-top: 14px; }
.compact-table table { min-width: 520px; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f0f6f7; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions form { display: inline-flex; gap: 6px; align-items: center; }
.row-actions button { min-height: 34px; padding: 7px 10px; font-size: .9rem; }
.filters { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.table-search {
  max-width: 520px;
  margin: 8px 0 14px;
}
.story h2, .story h3 { color: var(--brand-dark); margin-top: 22px; }
.copy-box textarea { margin-top: 12px; }
.muted { color: var(--muted); }
.example {
  color: var(--muted);
  background: #f7fbfc;
  border-left: 4px solid var(--sun);
  border-radius: 8px;
  padding: 10px 12px;
}
.char-counter {
  margin: 6px 0 12px;
  color: var(--rose);
  font-weight: 700;
}
.char-counter.is-ok { color: var(--leaf); }
.profile p { margin: 8px 0; }

.alert {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  background: white;
  animation: alertIn .25s ease both;
}
.alert-success { background: #eaf7ee; border-color: #b8dfc4; }
.alert-danger { background: #fff0f1; border-color: #f0b8be; }
.alert-warning { background: #fff8e6; border-color: #f2d488; }
.alert-info { background: #e9f5fb; border-color: #b9dcf0; }

.image-tool {
  margin-top: 16px;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfdff;
}
.image-tool h3 { margin-top: 0; color: var(--brand-dark); }
.check-line { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.check-line input { width: auto; }
.image-preview, .preview-zone img, .story-image img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 8px 22px rgba(31, 49, 63, .08);
}
.preview-zone { margin: 12px 0; }
.story-part {
  display: grid;
  gap: 16px;
  align-items: start;
  margin: 18px 0;
}
.story-pos-izquierda { grid-template-columns: minmax(160px, 34%) 1fr; }
.story-pos-izquierda .story-image { grid-column: 1; grid-row: 1; }
.story-pos-izquierda .story-text { grid-column: 2; grid-row: 1; }
.story-pos-derecha { grid-template-columns: 1fr minmax(160px, 34%); }
.story-pos-derecha .story-text { grid-column: 1; grid-row: 1; }
.story-pos-derecha .story-image { grid-column: 2; grid-row: 1; }
.story-pos-centro, .story-pos-debajo { grid-template-columns: 1fr; }
.story-pos-centro .story-image { justify-self: center; }
.story-size-pequeno .story-image img, .image-size-pequeno { max-width: 220px; }
.story-size-mediano .story-image img, .image-size-mediano { max-width: 380px; }
.story-size-grande .story-image img, .image-size-grande { max-width: 600px; }
.story-image { margin: 0; }

.loading-overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: radial-gradient(circle at 30% 20%, rgba(245, 184, 75, .28), transparent 28%), rgba(36, 49, 63, .50);
  z-index: 1000;
  padding: 20px;
}
.loading-overlay.is-visible { display: grid; }
.loading-card {
  width: min(420px, 100%);
  text-align: center;
  background: white;
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.loading-book { font-size: 2.8rem; margin-bottom: 8px; animation: floatIn .8s ease infinite alternate; }
.spinner {
  display: inline-block;
  width: 34px;
  height: 34px;
  border: 4px solid #dbe9ec;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
.loading-bar {
  height: 12px;
  margin-top: 16px;
  border-radius: 8px;
  overflow: hidden;
  background: #edf2f4;
  border: 1px solid #dbe9ec;
}
.loading-bar i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--sun), var(--leaf), var(--brand));
  transition: width .25s ease;
}
.loading-percent {
  margin: 8px 0 0;
  color: var(--brand-dark);
  font-weight: 800;
}
.loading-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin-top: 12px;
}
.loading-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--sun);
  animation: dotBounce .65s ease-in-out infinite alternate;
}
.loading-dots span:nth-child(2) { background: var(--leaf); animation-delay: .12s; }
.loading-dots span:nth-child(3) { background: var(--brand); animation-delay: .24s; }

.footer strong { color: var(--brand-dark); }

@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes alertIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes floatIn { from { transform: translateY(0); } to { transform: translateY(-5px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes loadingBar { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
@keyframes dotBounce { from { transform: translateY(0); opacity: .55; } to { transform: translateY(-7px); opacity: 1; } }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; min-height: auto; }
  .steps, .stats, .cards { grid-template-columns: repeat(2, 1fr); }
  .choice-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-head { align-items: flex-start; flex-direction: column; }
  .story-pos-izquierda, .story-pos-derecha { grid-template-columns: 1fr; }
  .story-pos-izquierda .story-image, .story-pos-izquierda .story-text, .story-pos-derecha .story-image, .story-pos-derecha .story-text { grid-column: auto; grid-row: auto; }
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .container { width: min(100% - 22px, 1120px); padding-top: 18px; }
  .steps, .stats, .cards, .choice-grid { grid-template-columns: 1fr; }
  .hero-art { min-height: 220px; }
  .actions, .filters { width: 100%; }
  .btn, button { width: 100%; }
  .password-toggle { width: 42px; }
}

.form-grid .password-wrap {
  position: relative;
  display: block;
  width: 100%;
}
.form-grid .password-wrap input {
  padding-right: 56px;
}
.form-grid .password-wrap .password-toggle {
  position: absolute;
  top: 50%;
  right: 7px;
  width: 40px;
  min-height: 36px;
  height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  transform: translateY(-50%);
  background: transparent;
  color: var(--brand-dark);
  box-shadow: none;
}
.form-grid .password-wrap .password-toggle:hover {
  transform: translateY(-50%);
  background: var(--sky);
  box-shadow: none;
}

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