:root {
  --noche: #232048;
  --alba: #D9A44A;
  --alba-suave: #E9C888;
  --pergamino: #F7F2E9;
  --pergamino-alt: #EFE7D6;
  --ciruela: #362B4A;
  --ciruela-suave: #6E6285;
  --salvia: #7C9A78;
  --salvia-suave: #E4EBDF;
  --bruma: #A79EC2;
  --font-display: 'Fraunces', serif;
  --font-body: 'Work Sans', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--pergamino);
  color: var(--ciruela);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 24px 12px;
}

.greeting {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--ciruela);
}

.day-chip {
  font-size: 12px;
  color: var(--noche);
  background: var(--pergamino-alt);
  padding: 6px 14px;
  border-radius: 20px;
  letter-spacing: 0.02em;
  font-weight: 500;
}

main {
  flex: 1;
  padding: 16px 24px 140px; /* Margen inferior ampliado para que no choque con la tabbar */
}

.screen { display: none; }
.screen.active { display: block; animation: fadein .35s ease; }

@keyframes fadein { 
  from { opacity: 0; transform: translateY(6px); } 
  to { opacity: 1; transform: none; } 
}

.lesson-card {
  background: var(--noche);
  border-radius: 24px;
  padding: 32px 24px 28px;
  text-align: center;
  margin-bottom: 20px;
  box-shadow: 0 12px 32px rgba(35, 32, 72, 0.12);
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--alba-suave);
  margin: 16px 0 12px;
  font-weight: 500;
}

.lesson-text {
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.6;
  color: var(--pergamino);
  margin: 0;
}

.btn-primary {
  width: 100%;
  border: none;
  background: var(--ciruela);
  color: var(--pergamino);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  padding: 16px;
  border-radius: 16px;
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease;
  box-shadow: 0 4px 12px rgba(54, 43, 74, 0.15);
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: .55; box-shadow: none; }

.btn-secondary {
  width: 100%;
  border: 1.5px solid var(--ciruela-suave);
  background: transparent;
  color: var(--ciruela);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: 14px;
  border-radius: 16px;
  cursor: pointer;
  margin-top: 12px;
  transition: background .2s ease;
}
.btn-secondary:active { transform: scale(0.98); background: var(--pergamino-alt); }

.nav-row {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 12px;
}
.btn-back {
  background: none;
  border: none;
  color: var(--ciruela-suave);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 0;
  cursor: pointer;
}
.btn-back:disabled { opacity: 0.3; }

.index-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.index-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  border: 1px solid var(--pergamino-alt);
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  transition: border-color .2s ease;
}
.index-item.current { border-color: var(--alba); background: var(--pergamino-alt); }
.index-day {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--noche);
  color: var(--alba);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.index-item.done .index-day { background: var(--salvia); color: #ffffff; }
.index-text {
  font-size: 14px;
  color: var(--ciruela);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hint {
  text-align: center;
  font-size: 13px;
  color: var(--ciruela-suave);
  margin-top: 14px;
}

.prompt-text {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--ciruela);
  margin: 8px 0 16px;
  line-height: 1.4;
}

textarea {
  width: 100%;
  border: 1px solid var(--pergamino-alt);
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ciruela);
  resize: none;
  margin-bottom: 14px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}
textarea:focus { outline: none; border-color: var(--salvia); }

.entries { margin-top: 24px; display: flex; flex-direction: column; gap: 12px; }

.entry-item {
  background: var(--salvia-suave);
  border-radius: 14px;
  padding: 14px 16px;
}
.entry-date { font-size: 11px; color: var(--salvia); margin: 0 0 4px; font-weight: 600; }
.entry-text { font-size: 14px; color: var(--ciruela); margin: 0; line-height: 1.5; }

.empty-note { font-size: 13px; color: var(--ciruela-suave); text-align: center; margin-top: 28px; }

/* Anillo de respiración (icono de la lección) */
.breath-ring {
  position: relative;
  margin: 10px auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.breath-ring.small { width: 64px; height: 64px; margin: 0 auto; }

.ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--alba);
}
.small .r1 { width: 55%; height: 55%; background: var(--alba); opacity: .9; animation: breathe 6s ease-in-out infinite; }
.small .r2 { width: 78%; height: 78%; opacity: .35; animation: breathe 6s ease-in-out infinite .15s; }
.small .r3 { width: 100%; height: 100%; opacity: .18; animation: breathe 6s ease-in-out infinite .3s; }

@keyframes breathe {
  0%, 100% { transform: scale(0.94); }
  50% { transform: scale(1.06); }
}

/* Tab bar */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  justify-content: space-around;
  background: #FFFFFF;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--pergamino-alt);
  border-radius: 18px 18px 0 0; /* Esquinas redondeadas en la parte superior */
  box-shadow: 0 -6px 20px rgba(35, 32, 72, 0.07);
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  z-index: 100;
}

.tab {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  color: var(--ciruela-suave);
  opacity: 0.6;
  cursor: pointer;
  padding: 4px 12px;
  transition: all .2s ease;
}
.tab svg { 
  fill: none; 
  stroke: var(--ciruela-suave); 
  stroke-width: 1.8; 
  transition: all .2s ease;
}
.tab.active { color: var(--noche); opacity: 1; font-weight: 600; }
.tab.active svg { 
  fill: var(--alba); 
  stroke: var(--noche); 
}