/* «21 días para comprender lo que sientes» — Entre mis emociones
   Paleta: crema, beige cálido, verde oliva, verde salvia y tonos tierra.
   Todos los pares texto/fondo usados cumplen al menos WCAG AA (4,5:1). */

/* Lora (SIL Open Font License 1.1), incluida en /fonts para funcionar sin conexión. */
@font-face { font-family: "Lora"; src: url("../fonts/Lora-Variable.woff") format("woff"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Lora"; src: url("../fonts/Lora-Italic-Variable.woff") format("woff"); font-weight: 400 700; font-style: italic; font-display: swap; }

:root {
  --cream: #FBF7EF;
  --beige: #F3EBDD;
  --sand: #E4D6BF;
  --line: #D9CCB5;
  --olive: #5E6B3A;
  --olive-dark: #4A5530;
  --sage: #A3B18A;
  --sage-soft: #E3E8D6;
  --earth: #8A6447;
  --earth-dark: #6B4E38;
  --peach-soft: #F5E3D3;
  --text: #2F2A24;
  --muted: #5C544A;
  --danger: #9A3B2E;
  --white: #FFFDF9;

  --serif: "Lora", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(60, 50, 35, .06), 0 6px 20px rgba(60, 50, 35, .06);
  --nav-h: 68px;
  color-scheme: light;
}

html { font-size: 106.25%; -webkit-text-size-adjust: 100%; }
html[data-text-size="grande"] { font-size: 118.75%; }
html[data-text-size="muy-grande"] { font-size: 131.25%; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--cream);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

h1, h2, h3 { line-height: 1.25; color: var(--olive-dark); margin: 0 0 .5em; }
h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(2rem, 6vw, 2.75rem); letter-spacing: -.01em; }
h2 { font-family: var(--serif); font-weight: 600; font-size: 1.45rem; }
h3 { font-size: 1rem; font-weight: 650; color: var(--text); }
p { margin: 0 0 1em; }
a { color: var(--olive-dark); text-underline-offset: 3px; }
a:hover { color: var(--olive); }

:focus-visible { outline: 3px solid var(--earth); outline-offset: 3px; border-radius: 6px; }
h1:focus, main:focus { outline: none; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--olive-dark); color: #fff; padding: 10px 16px; border-radius: 10px; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- Barra superior y navegación ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  /* Sin backdrop-filter: haría que la barra inferior fija quedara anclada a la cabecera */
  background: #FBF6EE;
  border-bottom: 1px solid var(--line);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-logo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; color: var(--olive-dark); }
.brand-prog { font-size: .78rem; color: var(--muted); }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: var(--white);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(60, 50, 35, .06);
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 52px; justify-content: center;
  font-size: .74rem; color: var(--muted); text-decoration: none; border-radius: 12px;
}
.nav-ico { font-size: 1.25rem; line-height: 1; }
.nav a[aria-current="page"] { color: var(--olive-dark); font-weight: 700; background: var(--sage-soft); }

@media (min-width: 860px) {
  body { padding-bottom: 0; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 14px 32px; }
  .nav { position: static; background: none; border: 0; box-shadow: none; padding: 0; gap: 4px; }
  .nav a { flex-direction: row; gap: 8px; min-height: 44px; padding: 0 14px; font-size: .92rem; white-space: nowrap; }
  .nav-ico { font-size: 1rem; }
}

/* ---------- Contenedor principal ---------- */

.view { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; display: block; }
.page-head { margin: 8px 0 24px; }
.eyebrow { font-size: .78rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--earth-dark); margin: 0 0 6px; }
.lead { font-size: 1.08rem; color: var(--muted); }
.hint { font-size: .88rem; color: var(--muted); margin: 0 0 .6em; }
.optional { font-family: var(--sans); font-size: .85rem; font-weight: 400; color: var(--muted); }
.stack > * + * { margin-top: 16px; }

.footer { text-align: center; font-size: .8rem; color: var(--muted); padding: 8px 16px 32px; max-width: 760px; margin: 0 auto; }

/* ---------- Botones ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px;
  font: 600 1rem/1.2 var(--sans);
  border-radius: 999px; border: 1.5px solid transparent;
  text-decoration: none; cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.btn-lg { min-height: 56px; padding: 0 28px; font-size: 1.05rem; }
.btn-sm { min-height: 40px; padding: 0 16px; font-size: .9rem; }
.btn-primary { background: var(--olive); color: #fff; }
.btn-primary:hover { background: var(--olive-dark); color: #fff; }
.btn-ghost { background: transparent; color: var(--olive-dark); border-color: var(--sage); }
.btn-ghost:hover { background: var(--sage-soft); color: var(--olive-dark); }
.btn-done { background: var(--sage-soft); color: var(--olive-dark); border-color: var(--olive); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #7f2f24; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.link-btn { background: none; border: 0; padding: 8px 0; font: inherit; font-size: .9rem; color: var(--olive-dark); text-decoration: underline; cursor: pointer; }
.file-btn { cursor: pointer; }
.file-btn:focus-within { outline: 3px solid var(--earth); outline-offset: 3px; }

/* ---------- Tarjetas ---------- */

.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 20px; margin: 16px 0; box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.card-soft { background: var(--beige); box-shadow: none; }
.card-note { background: var(--peach-soft); border-color: #E8CDB6; box-shadow: none; font-size: .92rem; }
.card-alert { background: #F7E1DA; border-color: #E3B6A8; }
.card-danger { border-color: #E3B6A8; }
.card-danger h2 { color: var(--danger); }

.plain-list { padding-left: 1.2em; margin: 0 0 1em; }
.plain-list li + li { margin-top: .5em; }
.week-list { padding-left: 1.2em; }

/* ---------- Bienvenida ---------- */

.hero { text-align: center; padding: 32px 4px 16px; position: relative; }
.leaf-deco { color: var(--sage); display: flex; justify-content: center; margin-bottom: 8px; }
.hero h1 { font-size: clamp(2.3rem, 8vw, 3.4rem); max-width: 14ch; margin: 0 auto .3em; }
.hero-sub { font-family: var(--serif); font-style: italic; font-size: 1.35rem; color: var(--earth-dark); }
.hero .lead { max-width: 52ch; margin: 0 auto 8px; }
.hero .btn-row { justify-content: center; }
.author { margin-top: 28px; font-size: .9rem; color: var(--muted); }

/* ---------- Progreso ---------- */

.progress { height: 10px; background: var(--sand); border-radius: 999px; overflow: hidden; margin-top: 12px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--sage), var(--olive)); border-radius: 999px; transition: width .4s; }
.progress-text { font-size: .9rem; color: var(--muted); margin-top: 6px; }
.backup-note { font-size: .9rem; background: var(--beige); border-radius: var(--radius-sm); padding: 10px 14px; }

/* ---------- Panel de días ---------- */

.week { margin-top: 32px; }
.week-title { font-size: 1.35rem; }
.week-title span { display: block; font-family: var(--sans); font-size: .78rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--earth-dark); }
.day-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .day-grid { grid-template-columns: 1fr 1fr; } }
.day-card {
  display: flex; flex-direction: column; gap: 4px; height: 100%;
  padding: 16px 18px; min-height: 92px;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-sm);
  text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s;
}
.day-card:hover { border-color: var(--olive); transform: translateY(-1px); }
.day-card.state-completed { background: var(--sage-soft); border-color: var(--sage); }
.day-num { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--earth-dark); }
.day-topic { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; line-height: 1.25; color: var(--olive-dark); }
.day-title { font-family: var(--serif); font-style: italic; font-size: .98rem; color: var(--earth-dark); line-height: 1.35; }
.day-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.badge { font-size: .74rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.badge-completed { background: var(--olive); color: #fff; }
.badge-started { background: var(--peach-soft); color: var(--earth-dark); }
.badge-soon { background: var(--beige); color: var(--muted); }

/* ---------- Sesión ---------- */

.day-label { font-weight: 600; color: var(--muted); margin: 0 0 4px; font-size: .95rem; }
h1 .day-label { display: block; font-family: var(--sans); font-size: .95rem; }
.time-estimate { font-size: .92rem; color: var(--muted); }
.prose { font-size: 1.06rem; margin: 24px 0; }
.prose p { margin-bottom: 1.1em; }
.section-title { margin-top: 32px; }
.scene { background: var(--beige); border-left: 4px solid var(--sage); box-shadow: none; }
.scene p { font-family: var(--serif); font-size: 1.18rem; line-height: 1.55; }
.exercise { border-top: 4px solid var(--olive); }
.steps { padding-left: 1.3em; }
.steps li { margin-bottom: .7em; }
.note { background: var(--sage-soft); border-radius: var(--radius-sm); padding: 12px 14px; font-size: .92rem; }
.takeaway { background: var(--sage-soft); border-color: var(--sage); box-shadow: none; }
.takeaway-q { font-family: var(--serif); font-size: 1.3rem; font-style: italic; color: var(--olive-dark); }
.closing { margin: 36px 0; text-align: center; }
.closing p { font-family: var(--serif); font-size: 1.45rem; font-style: italic; color: var(--earth-dark); max-width: 30ch; margin: 0 auto; }
.closing::before { content: "❦"; display: block; color: var(--sage); font-size: 1.4rem; margin-bottom: 8px; }

.answer { margin: 18px 0 24px; }
.field-label { display: block; font-weight: 600; margin-bottom: 8px; }
.q-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.7em; height: 1.7em; border-radius: 50%; margin-right: 4px;
  background: var(--olive); color: #fff; font-size: .85em;
}
.answer-input, .text-input {
  width: 100%; font: inherit; font-size: 1rem; color: var(--text);
  background: var(--cream); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.answer-input { min-height: 160px; resize: vertical; line-height: 1.6; }
.answer-input:focus, .text-input:focus { border-color: var(--olive); outline: 3px solid rgba(94, 107, 58, .25); outline-offset: 0; background: #fff; }

.complete-row { text-align: center; margin: 24px 0; }
.save-status { font-size: .85rem; color: var(--olive-dark); min-height: 1.4em; }
.save-status.error { color: var(--danger); font-weight: 600; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 24px; border-top: 1px solid var(--line); padding-top: 20px; }

/* Selector de emoción */
.chips { border: 0; padding: 0; margin: 8px 0 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.chips input, .intensity input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  border: 1.5px solid var(--line); border-radius: 999px; background: var(--cream);
  cursor: pointer; font-size: .95rem; user-select: none;
}
.chip:hover { border-color: var(--sage); }
.chips input:checked + .chip { background: var(--olive); border-color: var(--olive); color: #fff; }
.chips input:focus-visible + .chip, .intensity input:focus-visible + .int-dot { outline: 3px solid var(--earth); outline-offset: 2px; }
.other-wrap { margin-bottom: 12px; }
.intensity { border: 0; padding: 0; margin: 8px 0 0; }
.intensity-row { display: flex; gap: 10px; }
.int-dot {
  width: 48px; height: 48px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1.5px solid var(--line); background: var(--cream); cursor: pointer; font-weight: 600;
}
.intensity input:checked + .int-dot { background: var(--olive); border-color: var(--olive); color: #fff; }
.int-scale { display: flex; justify-content: space-between; max-width: 280px; font-size: .78rem; color: var(--muted); margin: 4px 0 0; }

/* ---------- Diario ---------- */

.journal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.journal-answer h3 { margin-top: 16px; color: var(--olive-dark); }
.journal-answer p { white-space: normal; }
.emotion-line { background: var(--beige); padding: 8px 12px; border-radius: 10px; font-size: .92rem; }

/* ---------- Calendario ---------- */

.mini-grid { list-style: none; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.mini {
  display: flex; align-items: center; justify-content: center; aspect-ratio: 1; min-height: 40px;
  border-radius: 12px; text-decoration: none; font-weight: 600; color: var(--text);
  background: var(--cream); border: 1.5px solid var(--line);
}
.mini.state-started { background: var(--peach-soft); border-color: #E2C3A8; }
.mini.state-completed { background: var(--olive); border-color: var(--olive); color: #fff; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: .82rem; color: var(--muted); }
.lg { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line); }
.lg-completed { background: var(--olive); border-color: var(--olive); }
.lg-started { background: var(--peach-soft); }
.lg-empty { background: var(--cream); }

.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-month { margin: 0; text-transform: capitalize; }
.cal-weekdays, .cal-grid { list-style: none; padding: 0; margin: 8px 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-weekdays li { font-size: .78rem; font-weight: 700; color: var(--muted); }
.cal-cell { position: relative; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 10px; font-size: .9rem; }
.cal-done { background: var(--olive); color: #fff; font-weight: 700; }
.cal-edited { background: var(--peach-soft); }
.cal-today { box-shadow: inset 0 0 0 2px var(--earth); }
.cal-mark { width: 5px; height: 5px; border-radius: 50%; background: currentColor; margin-top: 2px; }

/* ---------- Resumen ---------- */

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 10px; text-align: center; }
.stat-num { display: block; font-family: var(--serif); font-size: 2rem; font-weight: 600; color: var(--olive-dark); line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--muted); }
.freq, .int-list { list-style: none; padding: 0; margin: 0; }
.freq li, .int-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--beige); }
.freq-count { color: var(--muted); font-size: .9rem; }
.int-day { font-weight: 600; min-width: 4.5em; }
.int-name { flex: 1; }
.int-bar { display: inline-flex; gap: 4px; }
.int-bar span { width: 14px; height: 14px; border-radius: 50%; background: var(--sand); }
.int-bar span.on { background: var(--olive); }

/* ---------- Mis datos ---------- */

.action-list { display: grid; gap: 4px; }
.action { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--beige); }
.action:last-child { border-bottom: 0; }
.action h3 { margin: 0 0 2px; }
.action .hint { margin: 0; }
@media (max-width: 520px) { .action { flex-direction: column; align-items: stretch; } }
.seg { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.seg-btn { min-height: 48px; padding: 0 18px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--cream); font: 600 .95rem var(--sans); color: var(--text); cursor: pointer; }
.seg-btn[aria-checked="true"] { background: var(--olive); border-color: var(--olive); color: #fff; }

/* ---------- Diálogo y avisos ---------- */

.dialog {
  border: 0; border-radius: var(--radius); padding: 0; max-width: min(480px, calc(100vw - 32px));
  background: var(--white); color: var(--text); box-shadow: 0 20px 60px rgba(40, 30, 20, .25);
}
.dialog::backdrop { background: rgba(47, 42, 36, .45); }
.dialog-inner { padding: 24px 22px 20px; }
.dialog-body { margin-bottom: 12px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 50;
  background: var(--olive-dark); color: #fff; padding: 12px 20px; border-radius: 14px;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow); font-size: .95rem;
}
@media (min-width: 860px) { .toast { bottom: 24px; } }
.noscript { padding: 24px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .topbar, .nav, .pager, .complete-row, .emotion-card, .footer, .btn { display: none !important; }
  body { background: #fff; padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}
.session[data-day="21"] #ans-ejercicio { min-height: 380px; }

/* ---------- Logotipo ---------- */
/* Se muestra el archivo original sin recortes ni filtros, siempre sobre fondo crema. */
.brand-logo { width: 44px; height: 44px; border-radius: 0; object-fit: contain; flex-shrink: 0; }
.hero-logo { display: block; width: min(220px, 60vw); height: auto; margin: 0 auto 12px; }
.final-screen { text-align: center; padding: 16px 4px 0; }
.final-logo { display: block; width: min(170px, 46vw); height: auto; margin: 0 auto 8px; }
.closing-card { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--text); margin-top: 32px; background: var(--cream); }
.closing-card img { width: 64px; height: 64px; flex-shrink: 0; }
.closing-card strong { font-family: var(--serif); font-size: 1.15rem; color: var(--olive-dark); }
.letter-card { background: var(--cream); }
.letter-card p { font-family: var(--serif); font-size: 1.08rem; line-height: 1.75; }
.signature { font-style: italic; color: var(--olive-dark); }
.btn-row.center { justify-content: center; margin: 8px 0 0; }

/* ---------- Activación ---------- */
.activar-form .text-input { font-size: 1.05rem; letter-spacing: .03em; }
.form-error { margin-top: 12px; background: #F7E1DA; color: #7f2f24; border-radius: 10px; padding: 10px 14px; font-weight: 600; }
.demo-banner .btn-row { margin-top: 10px; }
