/* Sky Diary — una app que cambia con el cielo.
   Layout: una columna de celular (máx. 480px), tarjetas suaves, una acción clara por pantalla. */
:root {
  --sky: #EAF2F8;
  --card: #FFFFFF;
  --card2: #F6F3EA;
  --ink: #1F2A44;
  --ink2: #4A5672;
  --soft: rgba(31, 42, 68, 0.08);
  --gold: #D9A441;
  --brown: #8A6420;
  --green: #5E8350;
  --green-soft: #E4EBDF;
  --btn: #1F2A44;
  --btn-ink: #FBF7EE;
  --sun1: #F7E7BC;
  --sun2: #F2D592;
  --danger: #B5413C;
  --font: 'Nunito', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r-lg: 28px;
  --r-md: 20px;
  color-scheme: light;
}
html[data-sky="amanecer"] { --sky: #FDF3D2; --card: #FFFBEE; --card2: #FBF1D4; --ink: #3B2E14; --ink2: #6B5A30; --soft: rgba(59, 46, 20, 0.08); --btn: #3B2E14; --sun1: #FBE6A6; --sun2: #F6D57A; }
html[data-sky="atardecer"] { --sky: #FBE4EC; --card: #FFF4F7; --card2: #F9E6EC; --ink: #3F2433; --ink2: #6E4A5B; --soft: rgba(63, 36, 51, 0.08); --btn: #3F2433; --sun1: #F8CCDA; --sun2: #F3A9C0; }
html[data-sky="noche"] { --sky: #E6E8F4; --card: #FFFFFF; --card2: #EEF0F8; --ink: #1F2A44; --ink2: #4A5672; --sun1: #DCE0F0; --sun2: #F2D592; }
html[data-dark="1"] {
  --sky: #141B2E; --card: #1F2A44; --card2: #26324F; --ink: #F3EEDF; --ink2: #B9BED0;
  --soft: rgba(243, 238, 223, 0.10); --gold: #E2B65A; --brown: #E2B65A; --green: #9CC28A; --green-soft: #2E3A55;
  --btn: #E2B65A; --btn-ink: #141B2E; --danger: #E58A84; color-scheme: dark;
}
html[data-dark="1"][data-sky="amanecer"] { --sky: #1E1C1A; --card: #2B2722; --card2: #36302A; --sun1: #4A3F2A; --sun2: #C9A24F; }
html[data-dark="1"][data-sky="dia"] { --sky: #16202E; --card: #1F2C3D; --card2: #283749; --sun1: #2E3D52; --sun2: #C9A24F; }
html[data-dark="1"][data-sky="atardecer"] { --sky: #1F1720; --card: #2C2130; --card2: #372A3B; --sun1: #4A2E3E; --sun2: #C9789A; }
html[data-dark="1"][data-sky="noche"] { --sky: #141B2E; --card: #1F2A44; --card2: #26324F; --sun1: #F2D592; --sun2: #F2D592; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--sky);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  transition: background 0.6s ease;
}
* { box-sizing: border-box; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
p { margin: 0; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
  padding-block: 16px 32px;
  display: flex;
  flex-direction: column;
  position: relative;
}
.view { flex: 1; display: flex; flex-direction: column; gap: 22px; position: relative; animation: aparecer 0.35s ease; }
@keyframes aparecer { from { opacity: 0.4; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view, .sheet, .toast { animation: none !important; } body { transition: none; } }

/* Barra superior */
.top { display: flex; align-items: center; justify-content: space-between; min-height: 44px; position: relative; z-index: 2; }
.top .t { font-weight: 800; font-size: 17px; }
.icon-btn { width: 44px; height: 44px; border: 0; border-radius: 22px; background: transparent; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); }
.icon-btn:hover { background: var(--soft); }
.icon-btn svg { width: 22px; height: 22px; }
.spacer44 { width: 44px; }

/* Cielo decorativo */
.sky-art { position: absolute; inset: 0 0 auto 0; height: 300px; pointer-events: none; z-index: 0; overflow: hidden; }
.sky-art svg { position: absolute; }

/* Inicio */
.home-center { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 36px; position: relative; z-index: 1; }
.greet h1 { font-size: 34px; font-weight: 800; line-height: 1.15; }
.greet p { font-size: 17px; color: var(--ink2); margin-top: 8px; }

.door { display: flex; gap: 16px; align-items: center; width: 100%; text-align: left; background: var(--card); border: 0; border-radius: var(--r-lg); padding: 20px; transition: transform 0.15s ease; }
.door:active { transform: scale(0.98); }
.door .ic { width: 60px; height: 60px; border-radius: 18px; background: var(--card2); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.door .ic svg { width: 60px; height: 60px; }
.door .tt { font-size: 20px; font-weight: 800; }
.door .st { font-size: 15px; color: var(--ink2); }
.doors { display: flex; flex-direction: column; gap: 14px; }

/* Tarjetas */
.card { background: var(--card); border-radius: var(--r-lg); padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.card.tap { border: 0; text-align: left; width: 100%; transition: transform 0.15s ease; }
.card.tap:active { transform: scale(0.98); }
.eyebrow { font-size: 12px; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; color: var(--brown); }
.eyebrow.green { color: var(--green); }
.muted { color: var(--ink2); }
.small { font-size: 14px; }
.title-lg { font-size: 30px; font-weight: 800; line-height: 1.15; }
.title-md { font-size: 23px; font-weight: 800; line-height: 1.2; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 800; color: var(--brown); }
.chip svg { width: 16px; height: 16px; }

.btn { border: 0; border-radius: 999px; background: var(--btn); color: var(--btn-ink); font-weight: 800; font-size: 17px; padding: 15px 22px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--card); color: var(--ink); }
.btn.soft { background: var(--soft); color: var(--ink); }
.btn:disabled { opacity: 0.45; }
.btn svg { width: 20px; height: 20px; }
.link-btn { border: 0; background: none; color: var(--ink2); font-weight: 800; font-size: 15px; padding: 10px 4px; text-decoration: underline; text-underline-offset: 3px; }

.progress { height: 8px; border-radius: 4px; background: var(--green-soft); overflow: hidden; }
.progress > div { height: 100%; background: var(--green); border-radius: 4px; }

/* Emociones */
.emos { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 6px; }
.emo { border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); padding: 0; }
.emo .dot { width: 52px; height: 52px; border-radius: 26px; display: block; transition: transform 0.15s ease; }
.emo:active .dot { transform: scale(0.9); }
.emo.sel .dot { box-shadow: 0 0 0 3px var(--sky), 0 0 0 6px var(--ink); }
.emos.mini { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.emos.mini .dot { width: 30px; height: 30px; }
.emos.mini .emo { font-size: 0; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { border: 0; border-radius: 999px; background: var(--card); padding: 10px 16px; font-weight: 700; font-size: 15px; }
.pill.sel { background: var(--btn); color: var(--btn-ink); }

/* Entradas */
.entry { display: flex; gap: 12px; background: var(--card); border-radius: var(--r-md); padding: 16px; border: 0; width: 100%; text-align: left; }
.entry .d { width: 12px; height: 12px; border-radius: 6px; margin-top: 5px; flex-shrink: 0; background: var(--gold); }
.entry .meta { font-size: 13px; color: var(--ink2); }
.entry .tx { font-size: 16px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.entry img { width: 56px; height: 56px; object-fit: cover; border-radius: 12px; margin-left: auto; flex-shrink: 0; }

/* Formularios */
.field { width: 100%; border: 0; border-radius: var(--r-md); background: var(--card); padding: 16px; font-size: 17px; line-height: 1.5; resize: none; }
.field::placeholder { color: var(--ink2); opacity: 0.75; }
textarea.field { min-height: 140px; }
textarea.page { min-height: 46vh; font-size: 18px; background: transparent; padding: 4px 0; border-radius: 0; }
label.lbl { font-weight: 800; font-size: 15px; }

/* Hoja inferior (menús, Rut, matices) */
.scrim { position: fixed; inset: 0; background: rgba(10, 14, 25, 0.35); z-index: 40; animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 480px; margin: 0 auto; max-height: 88vh; overflow-y: auto;
  background: var(--card); color: var(--ink);
  border-radius: 28px 28px 0 0;
  padding: 10px max(20px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 14px;
  animation: subir 0.28s ease;
}
@keyframes subir { from { transform: translateY(40px); opacity: 0.5; } }
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--soft); margin: 0 auto 4px; }
.menu-item { display: flex; align-items: center; gap: 14px; border: 0; background: transparent; width: 100%; text-align: left; padding: 14px 6px; font-size: 17px; font-weight: 700; border-radius: 14px; }
.menu-item:hover { background: var(--soft); }
.menu-item svg { width: 22px; height: 22px; flex-shrink: 0; }
.menu-item .badge { margin-left: auto; min-width: 22px; height: 22px; border-radius: 11px; background: var(--gold); color: #1F2A44; font-size: 13px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }

/* Rut */
.rut-head { display: flex; align-items: center; gap: 10px; }
.rut-av { width: 44px; height: 44px; border-radius: 22px; background: var(--card2); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rut-av svg { width: 32px; height: 32px; }
.rut-name { font-weight: 800; color: var(--ink2); font-size: 15px; }
.rut-msg { font-size: 18px; line-height: 1.5; }
.verse { border-left: 0; background: var(--card2); border-radius: var(--r-md); padding: 16px; font-size: 17px; }
.verse .ref { display: block; margin-top: 6px; font-size: 14px; font-weight: 800; color: var(--brown); }

.toast {
  position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 50;
  max-width: 440px; margin: 0 auto; width: calc(100% - 32px);
  background: var(--card); color: var(--ink); border-radius: 22px; padding: 14px 14px 14px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 12px 32px rgba(10, 14, 25, 0.18);
  animation: subir 0.3s ease;
}
.toast .rut-av { width: 38px; height: 38px; }
.toast .rut-av svg { width: 26px; height: 26px; }
.toast p { flex: 1; min-width: 0; font-size: 15px; }

/* Devocional */
.steps { display: flex; gap: 6px; }
.steps span { flex: 1; height: 5px; border-radius: 3px; background: var(--soft); }
.steps span.on { background: var(--gold); }
.read { font-size: 18px; line-height: 1.65; display: flex; flex-direction: column; gap: 16px; max-width: 62ch; }
.big-quote { font-size: 26px; font-weight: 800; line-height: 1.3; }
.foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 12px; }
.scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.scale button { border: 0; border-radius: 16px; background: var(--card); height: 54px; font-size: 18px; font-weight: 800; }
.scale button.sel { background: var(--btn); color: var(--btn-ink); }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opts button { border: 0; border-radius: var(--r-md); background: var(--card); padding: 16px; text-align: left; font-size: 17px; font-weight: 700; }
.opts button.sel { background: var(--btn); color: var(--btn-ink); }

/* Estudio */
.sec { display: flex; flex-direction: column; gap: 10px; }
.sec h3 { font-size: 19px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.sec ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.sec p, .sec li { font-size: 17px; line-height: 1.6; }
.term { background: var(--card); border-radius: 16px; padding: 14px 16px; }
.term b { display: block; }

/* Calendario */
.seg { display: flex; background: var(--card); border-radius: 999px; padding: 4px; }
.seg button { flex: 1; border: 0; border-radius: 999px; background: transparent; padding: 10px; font-weight: 800; color: var(--ink2); }
.seg button.sel { background: var(--btn); color: var(--btn-ink); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; text-align: center; }
.cal .dl { font-size: 12px; font-weight: 800; color: var(--ink2); }
.cal .day { border: 0; background: transparent; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.cal .circ { width: 40px; height: 40px; border-radius: 20px; background: var(--card2); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px; padding: 7px; align-content: center; }
.cal .circ i { width: 8px; height: 8px; border-radius: 4px; display: block; }
.cal .day.today .circ { box-shadow: 0 0 0 2px var(--ink); }
.cal .day.sel .circ { box-shadow: 0 0 0 2px var(--gold); }
.cal .num { font-size: 12px; color: var(--ink2); font-variant-numeric: tabular-nums; }
.cal .empty { visibility: hidden; }
.habits .hrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.habits .hname { font-size: 15px; min-width: 0; overflow-wrap: anywhere; }
.habits .hdots { display: flex; gap: 5px; flex-shrink: 0; }
.habits .hdots button, .habits .hdots span { width: 26px; height: 26px; border-radius: 13px; border: 0; background: var(--green-soft); padding: 0; font-size: 11px; font-weight: 800; color: var(--ink2); display: inline-flex; align-items: center; justify-content: center; }
.habits .hdots span { background: transparent; }
.habits .hdots button.on { background: var(--green); }

/* Barras de resumen */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar { display: grid; grid-template-columns: 92px 1fr 24px; align-items: center; gap: 10px; font-size: 14px; }
.bar .track { height: 10px; border-radius: 5px; background: var(--soft); overflow: hidden; }
.bar .track div { height: 100%; border-radius: 5px; }
.bar .n { font-variant-numeric: tabular-nums; text-align: right; color: var(--ink2); }

/* Camino */
.path { display: flex; flex-direction: column; gap: 0; }
.stage { display: flex; gap: 14px; }
.stage .rail { display: flex; flex-direction: column; align-items: center; }
.stage .node { width: 22px; height: 22px; border-radius: 11px; background: var(--soft); flex-shrink: 0; }
.stage.done .node { background: var(--green); }
.stage.now .node { background: var(--gold); box-shadow: 0 0 0 5px var(--soft); }
.stage .line { width: 3px; flex: 1; min-height: 26px; background: var(--soft); }
.stage .txt { padding-bottom: 20px; }
.stage .txt b { display: block; font-size: 17px; }

.empty-state { text-align: center; padding: 30px 10px; color: var(--ink2); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.danger { color: var(--danger); }
.photo-prev { width: 100%; max-height: 240px; object-fit: cover; border-radius: var(--r-md); }
.tools { display: flex; gap: 8px; flex-wrap: wrap; }
.tool { border: 0; border-radius: 999px; background: var(--card); padding: 10px 14px; display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.tool svg { width: 18px; height: 18px; }
.tool.on { background: var(--btn); color: var(--btn-ink); }
.hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
