:root {
  --void: #050508;
  --deep: #0b0a12;
  --card: #12101d;
  --line: #241f38;
  --uv: #8b6cff;
  --uv-dim: rgba(139, 108, 255, 0.16);
  --uv-border: rgba(139, 108, 255, 0.34);
  --ivory: #f0ead9;
  --ivory-dim: #b3ac9a;
  --gray: #6f6a7e;
  --gold: #d9b96a;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  background: var(--void);
  color: var(--ivory);
  font-family: -apple-system, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  /* Fija el viewport en iOS Safari: sin rebote del documento ni saltos por la barra de URL */
  position: fixed;
  inset: 0;
  width: 100%;
  touch-action: manipulation;
}
.serif { font-family: Georgia, 'Times New Roman', serif; }

#app { height: 100%; height: 100dvh; display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; position: relative; }

.screen { position: absolute; inset: 0; display: none; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; opacity: 0; transition: opacity 0.7s var(--ease); }
.screen.on { display: flex; }
.screen.vis { opacity: 1; }

/* ---------- Umbral ---------- */
#s-umbral { align-items: center; justify-content: center; text-align: center; padding: 32px; background: radial-gradient(ellipse 90% 55% at 50% 110%, rgba(139,108,255,0.10) 0%, transparent 65%), var(--void); }
.breath {
  width: 130px; height: 130px; margin-bottom: 44px; opacity: 0.9;
  animation: breathe 6s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { transform: scale(1); opacity: 0.55; } 50% { transform: scale(1.06); opacity: 0.95; } }
#s-umbral h1 { font-size: 15px; letter-spacing: 0.45em; font-weight: 400; color: var(--ivory-dim); text-transform: uppercase; margin-bottom: 26px; }
#s-umbral h1 b { color: var(--ivory); font-weight: 600; }
.whatif { font-size: 26px; line-height: 1.45; font-weight: 300; max-width: 320px; margin-bottom: 8px; }
.whatif em { font-style: italic; color: var(--uv); }
.umbral-sub { font-size: 14px; color: var(--gray); margin-top: 14px; max-width: 300px; line-height: 1.6; }
.umbral-link { margin-top: 22px; background: none; border: none; color: var(--gray); font-size: 13px; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; font-family: inherit; }

/* ---------- Botones ---------- */
.cta {
  margin-top: 44px; padding: 16px 44px; border-radius: 100px;
  background: transparent; color: var(--ivory);
  border: 1px solid var(--uv-border); font-size: 15px; letter-spacing: 0.08em;
  cursor: pointer; transition: all 0.5s var(--ease);
  box-shadow: 0 0 34px rgba(139,108,255,0.12), inset 0 0 18px rgba(139,108,255,0.05);
}
.cta:hover, .cta:active { border-color: var(--uv); box-shadow: 0 0 44px rgba(139,108,255,0.3); }
.cta.solid { background: var(--uv); color: #0a0714; border-color: var(--uv); font-weight: 600; }
.cta:disabled { opacity: 0.35; pointer-events: none; }

/* ---------- Datos ---------- */
#s-datos { padding: 56px 28px 40px; justify-content: center; }
.q-title { font-size: 24px; font-weight: 300; line-height: 1.4; margin-bottom: 10px; }
.q-sub { font-size: 13px; color: var(--gray); line-height: 1.6; margin-bottom: 34px; }
.field { margin-bottom: 20px; }
.field label { display: block; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ivory-dim); margin-bottom: 8px; }
.field label span { color: var(--gray); text-transform: none; letter-spacing: 0; }
.field input {
  width: 100%; padding: 15px 16px; border-radius: 12px;
  background: var(--deep); border: 1px solid var(--line);
  color: var(--ivory); font-size: 16px; outline: none;
  transition: border-color 0.4s, box-shadow 0.4s;
  color-scheme: dark;
}
.field input:focus { border-color: var(--uv); box-shadow: 0 0 0 3px var(--uv-dim); }

/* Toggle de la voz del retrato: dos pills, una elegida */
.voz-toggle { display: flex; gap: 10px; }
.voz-pill {
  flex: 1; padding: 13px 10px; border-radius: 12px;
  background: var(--deep); border: 1px solid var(--line);
  color: var(--ivory-dim); font-size: 14px; font-family: inherit;
  cursor: pointer; transition: all 0.4s var(--ease);
}
.voz-pill.act { border-color: var(--uv); color: var(--ivory); background: var(--uv-dim); box-shadow: 0 0 0 3px var(--uv-dim); }

/* ---------- Revelación ---------- */
#s-reveal { align-items: center; padding: 52px 28px 40px; text-align: center; }
.rev-stage { opacity: 0; transform: translateY(18px); transition: all 1.1s var(--ease); }
.rev-stage.in { opacity: 1; transform: translateY(0); }
#rev-sigil { width: 190px; height: 190px; margin: 18px 0 6px; filter: drop-shadow(0 0 26px rgba(139,108,255,0.35)); }
.rev-eyebrow { font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--gray); }
.rev-name { font-size: 30px; font-weight: 400; margin-top: 10px; line-height: 1.25; }
.rev-kin { font-size: 14px; color: var(--uv); margin-top: 8px; letter-spacing: 0.06em; }
.rev-verse { font-size: 15px; color: var(--ivory-dim); line-height: 1.7; max-width: 310px; margin-top: 22px; font-style: italic; }

/* ---------- Home shell ---------- */
.home-head { padding: 22px 24px 12px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.home-head .brand { font-size: 11px; letter-spacing: 0.35em; text-transform: uppercase; color: var(--gray); }
.chispas-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--gold); border: 1px solid rgba(217,185,106,0.3); background: rgba(217,185,106,0.07); border-radius: 99px; padding: 5px 13px; }
.chispas-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 8px var(--gold); display: inline-block; }
.tab-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 24px 110px; -webkit-overflow-scrolling: touch; }

.tabbar {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; background: rgba(8,7,14,0.92); backdrop-filter: blur(18px);
  border-top: 1px solid var(--line); padding: 8px 6px calc(14px + env(safe-area-inset-bottom));
}
.tabbar button { flex: 1; background: none; border: none; color: var(--gray); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px 0; transition: color 0.3s; font-family: inherit; }
.tabbar button svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.4; }
.tabbar button.act { color: var(--uv); }

.tabpane { display: none; }
.tabpane.on { display: block; animation: fadeup 0.5s var(--ease); }
@keyframes fadeup { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Avatar tab ---------- */
.av-hero { text-align: center; padding: 8px 0 4px; }
.av-hero svg { width: 140px; height: 140px; filter: drop-shadow(0 0 20px rgba(139,108,255,0.3)); }
.av-arch { font-size: 22px; font-weight: 400; margin-top: 6px; }
.av-kin { font-size: 12px; color: var(--uv); letter-spacing: 0.08em; margin-top: 5px; }
.umbral-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; font-size: 12px; color: var(--ivory-dim); }
.umbral-tag { border: 1px solid var(--uv-border); color: var(--uv); border-radius: 99px; padding: 3px 12px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; }
.xpbar { height: 3px; background: var(--line); border-radius: 3px; margin: 16px 8px 4px; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--uv), #c9b8ff); border-radius: 3px; transition: width 0.9s var(--ease); }
.xplabel { font-size: 11px; color: var(--gray); text-align: center; margin-bottom: 10px; }
#radar { width: 100%; max-width: 330px; display: block; margin: 6px auto; }
.attr-list { margin-top: 8px; }
.attr-item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 15px 17px; margin-bottom: 11px; }
.attr-top { display: flex; justify-content: space-between; align-items: baseline; }
.attr-name { font-size: 14px; font-weight: 600; }
.attr-trad { font-size: 11px; color: var(--gray); margin-left: 8px; }
.attr-val { font-size: 15px; color: var(--uv); font-weight: 600; }
.attr-desc { font-size: 12.5px; color: var(--ivory-dim); line-height: 1.55; margin-top: 7px; }

/* ---------- Sendas ---------- */
.senda { background: var(--card); border: 1px solid var(--line); border-radius: 16px; margin-bottom: 13px; overflow: hidden; }
.senda-head { display: flex; align-items: center; gap: 13px; padding: 15px 17px; cursor: pointer; }
.senda-glyph { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--uv-border); display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--uv); flex-shrink: 0; font-family: Georgia, serif; }
.senda-head h3 { font-size: 15px; font-weight: 500; flex: 1; }
.senda-prog { font-size: 11px; color: var(--gray); }
.senda-body { display: none; padding: 0 17px 16px; }
.senda.open .senda-body { display: block; }
.nodo { position: relative; border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; margin-top: 10px; }
.nodo.done { border-color: rgba(217,185,106,0.35); background: rgba(217,185,106,0.05); }
.nodo.active { border-color: var(--uv-border); }
/* La niebla: el porvenir se intuye pero no se lee. Solo el siguiente paso es nítido. */
.nodo.locked { opacity: 0.35; pointer-events: none; user-select: none; -webkit-user-select: none; }
.nodo.locked h4, .nodo.locked p { filter: blur(6px); transition: filter 0.8s ease, opacity 0.8s ease; }
.nodo.locked::after { content: "◈"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 18px; color: var(--gold); opacity: 0.85; }
.nodo h4 { font-size: 13.5px; font-weight: 600; }
.nodo p { font-size: 12.5px; color: var(--ivory-dim); line-height: 1.55; margin-top: 6px; }
.nodo .nodo-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.nodo .cost { font-size: 11.5px; color: var(--gold); }
.nodo button { background: none; border: 1px solid var(--uv-border); color: var(--uv); border-radius: 99px; padding: 6px 15px; font-size: 12px; cursor: pointer; font-family: inherit; transition: all 0.3s; }
.nodo button:hover { background: var(--uv-dim); }
.nodo button:disabled { opacity: 0.35; pointer-events: none; }
.nodo .done-tag { font-size: 11px; color: var(--gold); letter-spacing: 0.1em; text-transform: uppercase; }

/* ---------- Misión ---------- */
.mision-date { font-size: 11px; letter-spacing: 0.25em; text-transform: uppercase; color: var(--gray); text-align: center; margin: 10px 0 4px; }
.mision-kin { text-align: center; font-size: 13px; color: var(--uv); margin-bottom: 18px; }
.mision-card {
  background: linear-gradient(155deg, #171228 0%, #0d0a18 100%);
  border: 1px solid var(--uv-border); border-radius: 18px; padding: 26px 22px; text-align: center;
  box-shadow: 0 0 40px rgba(139,108,255,0.08);
}
.mision-insercion { font-size: 12px; color: var(--uv); margin-bottom: 14px; letter-spacing: 0.02em; line-height: 1.5; }
.mision-q { font-size: 20px; font-weight: 300; line-height: 1.5; }
.mision-tono { font-size: 12px; color: var(--ivory-dim); margin-top: 14px; font-style: italic; }
.mision-acts { display: flex; gap: 10px; margin-top: 22px; }
.mision-acts button { flex: 1; padding: 13px; border-radius: 99px; font-size: 13.5px; cursor: pointer; font-family: inherit; transition: all 0.3s; }
.b-cruzar { background: var(--uv); border: 1px solid var(--uv); color: #0a0714; font-weight: 600; }
.b-hoyno { background: none; border: 1px solid var(--line); color: var(--gray); }
.reflex { margin-top: 14px; }
.reflex textarea {
  width: 100%; min-height: 74px; background: var(--deep); border: 1px solid var(--line);
  border-radius: 12px; color: var(--ivory); font-size: 14px; padding: 13px 14px;
  font-family: inherit; resize: none; outline: none; transition: border-color 0.4s;
}
.reflex textarea:focus { border-color: var(--uv); }
.mision-done { text-align: center; padding: 30px 10px; }

/* ---------- La Onda ---------- */
.onda-card {
  margin-top: 18px; background: linear-gradient(155deg, #121a24 0%, #0a0f16 100%);
  border: 1px solid rgba(122, 180, 255, 0.22); border-radius: 18px; padding: 22px 20px; text-align: center;
  box-shadow: 0 0 34px rgba(122, 180, 255, 0.06);
}
.onda-head { font-size: 10.5px; letter-spacing: 0.22em; text-transform: uppercase; color: #7ab4ff; }
.onda-titulo { font-size: 17px; font-weight: 400; margin-top: 10px; }
.onda-practica { font-size: 13.5px; color: var(--ivory-dim); line-height: 1.6; margin-top: 12px; }
.onda-eco { font-size: 12px; color: #7ab4ff; font-style: italic; margin-top: 14px; line-height: 1.55; }
.onda-cerrada { font-size: 12.5px; color: var(--gold); margin-top: 12px; line-height: 1.55; }
.onda-btn { width: 100%; margin-top: 14px; padding: 13px; border-radius: 99px; font-size: 13.5px; cursor: pointer; font-family: inherit; }

/* ---------- La Espiral ---------- */
.espiral-card {
  margin: 18px 0 6px; background: linear-gradient(155deg, #1c1710 0%, #100c07 100%);
  border: 1px solid rgba(217, 185, 108, 0.3); border-radius: 18px; padding: 22px 20px; text-align: center;
  box-shadow: 0 0 34px rgba(217, 185, 108, 0.07);
}
.espiral-card.cruzada { padding: 14px 18px; }
.espiral-head { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); }
.espiral-txt { font-size: 13.5px; color: var(--ivory-dim); line-height: 1.65; margin-top: 10px; }
.espiral-card .b-cruzar { width: 100%; margin-top: 16px; padding: 13px; border-radius: 99px; font-size: 13.5px; cursor: pointer; font-family: inherit; }

/* ---------- El Libro del Caminante ---------- */
#s-diario { padding: 56px 0 40px; }
.diario-shell { padding: 0 28px 40px; display: flex; flex-direction: column; }
.diario-shell .umbral-link { align-self: center; }
.diario-mes { font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold); margin: 26px 0 6px; }
.diario-entrada { border-left: 1px solid var(--line); padding: 12px 0 12px 16px; margin-left: 2px; }
.diario-meta { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gray); }
.diario-titulo { font-size: 15px; font-weight: 300; line-height: 1.55; margin-top: 7px; }
.diario-texto { font-size: 13px; color: var(--ivory-dim); line-height: 1.6; margin-top: 8px; font-style: italic; }
.diario-vacio { font-size: 14px; color: var(--ivory-dim); line-height: 1.7; margin-top: 30px; text-align: center; }

/* ---------- Arcos de senda ---------- */
.arco-label { font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); margin: 16px 2px 8px; }
.arco-velo { font-size: 11.5px; color: var(--gray); font-style: italic; margin: 12px 2px 4px; line-height: 1.5; }

.mision-done .sigilo-mini { width: 74px; height: 74px; opacity: 0.9; }
.mision-done h3 { font-size: 19px; font-weight: 300; margin-top: 14px; }
.mision-done p { font-size: 13.5px; color: var(--ivory-dim); margin-top: 10px; line-height: 1.6; }
.gate0 { font-size: 11px; color: var(--gray); line-height: 1.6; text-align: center; margin-top: 26px; padding: 0 12px; }

/* ---------- La guía (¿Cómo se camina?) ---------- */
#s-tuto { padding: 56px 0 40px; }
.tuto-shell { padding: 0 28px 40px; display: flex; flex-direction: column; }
.tuto-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 17px 18px; margin-top: 12px; display: flex; gap: 14px; align-items: flex-start; }
.tuto-glyph { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--uv-border); color: var(--uv); display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; font-family: Georgia, serif; }
.tuto-card h3 { font-size: 14px; font-weight: 600; margin-top: 6px; }
.tuto-card p { font-size: 12.5px; color: var(--ivory-dim); line-height: 1.6; margin-top: 6px; }
.tuto-cta { align-self: center; margin-top: 34px; }

/* ---------- Perfil ---------- */
.pf-row { display: flex; justify-content: space-between; padding: 14px 2px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.pf-row span:first-child { color: var(--gray); }
.pf-row span:last-child { text-align: right; }
.pf-verso { font-size: 14.5px; color: var(--ivory-dim); line-height: 1.7; font-style: italic; margin: 2px 2px 16px; }
.pf-read { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 15px 17px; margin-bottom: 11px; }
.pf-read-h { font-size: 13.5px; font-weight: 600; }
.pf-read-h span { font-size: 11px; color: var(--gray); font-weight: 400; margin-left: 7px; }
.pf-read-d { font-size: 12.5px; color: var(--uv); margin-top: 6px; letter-spacing: 0.02em; }
.pf-read-t { font-size: 12.5px; color: var(--ivory-dim); line-height: 1.55; margin-top: 7px; }
.pf-note { font-size: 12px; color: var(--gray); line-height: 1.65; margin-top: 22px; }
.pf-reset { margin-top: 28px; width: 100%; padding: 13px; border-radius: 99px; background: none; border: 1px solid rgba(239,68,68,0.35); color: #ef8080; font-size: 13px; cursor: pointer; font-family: inherit; }

.toast {
  position: absolute; left: 50%; bottom: 108px; transform: translateX(-50%) translateY(20px);
  background: #1a1430; border: 1px solid var(--uv-border); color: var(--ivory);
  border-radius: 99px; padding: 11px 22px; font-size: 13px; opacity: 0; z-index: 60;
  transition: all 0.5s var(--ease); pointer-events: none; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.section-h { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gray); margin: 22px 0 12px; display: flex; align-items: center; gap: 10px; }
.section-h::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ---------- Llave de Retorno ---------- */
#s-llave { padding: 56px 28px 40px; justify-content: center; }
.field textarea {
  width: 100%; min-height: 92px; padding: 15px 16px; border-radius: 12px;
  background: var(--deep); border: 1px solid var(--line);
  color: var(--ivory); font-size: 14px; outline: none; resize: none;
  font-family: inherit; transition: border-color 0.4s, box-shadow 0.4s;
}
.field textarea:focus { border-color: var(--uv); box-shadow: 0 0 0 3px var(--uv-dim); }
.llave-acts { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.llave-btn {
  width: 100%; padding: 13px; border-radius: 99px; text-align: center;
  background: none; border: 1px solid var(--uv-border); color: var(--uv);
  font-size: 13.5px; cursor: pointer; font-family: inherit; transition: all 0.3s; display: block;
}
.llave-btn:hover { background: var(--uv-dim); }
