:root {
  --violet-900: #2e1065;
  --violet-800: #4c1d95;
  --violet-700: #6d28d9;
  --violet-500: #8b5cf6;
  --violet-100: #ede9fe;
  --ink: #111827;
  --muted: #6b7280;
  --bubble-in: #ffffff;
  --bubble-out: #e3f7d4;
  --chat-bg: #efe7dd;
  --g: #16a34a;
  --y: #eab308;
  --r: #dc2626;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Color Emoji", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: radial-gradient(circle at 20% 10%, #7c3aed 0, transparent 45%), radial-gradient(circle at 90% 90%, #db2777 0, transparent 40%), var(--violet-900);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.app {
  position: relative;
  height: 100dvh;
  max-width: 460px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--violet-900);
  box-shadow: 0 0 60px rgb(0 0 0 / .45);
}
@media (min-width: 520px) {
  .app { height: min(100dvh - 32px, 900px); margin-top: 16px; border-radius: 28px; border: 6px solid #0b0716; }
}
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  border: 0; border-radius: 999px; padding: .85em 1.4em; font-weight: 700; text-decoration: none;
  transition: transform .12s ease, filter .12s ease;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible, .btn-judge:focus-visible, .choice:focus-visible, .lock-inner:focus-visible { outline: 3px solid #facc15; outline-offset: 2px; }
.btn-primary { background: #fff; color: var(--violet-800); }
.btn-big { font-size: 1.15rem; padding: 1em 2em; width: 100%; box-shadow: 0 8px 30px rgb(0 0 0 / .3); }
.btn-wa { background: #25d366; color: #052e16; }
.btn-ghost { background: transparent; color: #fff; border: 2px solid rgb(255 255 255 / .5); }

/* ---------- Portada ---------- */
.screen-start, .screen-results { color: #fff; overflow-y: auto; }
.start-inner, .results-inner { padding: 28px 24px 32px; display: flex; flex-direction: column; gap: 14px; }
.badge { margin: 0; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; opacity: .85; font-weight: 700; }
.logo { margin: 4px 0 0; white-space: nowrap; font-size: clamp(2.2rem, 10.5vw, 3.2rem); line-height: 1; letter-spacing: -.03em; }
.checks { color: #38bdf8; display: inline-block; animation: checks 2.4s ease-in-out infinite; }
@keyframes checks { 0%, 40% { color: rgb(255 255 255 / .55); } 55%, 100% { color: #38bdf8; } }
.tagline { margin: 0; font-size: 1.2rem; font-weight: 600; line-height: 1.3; }
.challenge { margin: 0; background: #facc15; color: #422006; border-radius: var(--radius); padding: 10px 14px; font-weight: 700; }
.howto { margin: 6px 0 0; padding-left: 1.2em; line-height: 1.5; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.legend li { display: grid; grid-template-columns: 2em auto; column-gap: 6px; align-items: center; background: rgb(255 255 255 / .1); border-radius: 12px; padding: 8px 12px; }
.legend .dot { grid-row: span 2; font-size: 1.4rem; }
.legend small { opacity: .8; }
.howto-extra { margin: 0; opacity: .9; }
.best { margin: 0; text-align: center; opacity: .85; font-size: .9rem; }
.warning { margin: 6px 0 0; font-size: .78rem; line-height: 1.45; opacity: .8; }
.footer-links { margin: 0; font-size: .8rem; opacity: .75; text-align: center; }

/* ---------- Pantalla de bloqueo ---------- */
.screen-lock { background: linear-gradient(160deg, #1e1b4b, #4c1d95 55%, #831843); }
.lock-inner {
  all: unset; box-sizing: border-box; flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 64px 20px 32px; color: #fff; cursor: pointer; text-align: center;
}
.lock-time { font-size: 4.2rem; font-weight: 300; letter-spacing: -.02em; }
.lock-owner { font-weight: 700; font-size: 1.05rem; margin-top: 4px; }
.lock-context { opacity: .85; margin-top: 10px; max-width: 30ch; line-height: 1.4; }
.notif {
  margin-top: 36px; width: 100%; display: flex; gap: 12px; align-items: center; text-align: left;
  background: rgb(255 255 255 / .9); color: var(--ink); border-radius: 18px; padding: 12px 14px;
  box-shadow: 0 10px 30px rgb(0 0 0 / .25); animation: drop .45s cubic-bezier(.2, 1.4, .4, 1) both .25s;
}
@keyframes drop { from { opacity: 0; transform: translateY(-24px) scale(.96); } }
.notif-body { display: flex; flex-direction: column; min-width: 0; }
.notif-title { font-weight: 700; }
.notif-text { color: #374151; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lock-hint { margin-top: auto; opacity: .7; font-size: .9rem; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- Chat ---------- */
.screen-chat { background: var(--chat-bg); }
.chat-header { background: var(--violet-800); color: #fff; padding: 6px 12px 0; flex-shrink: 0; }
.progress { display: flex; gap: 3px; padding: 4px 0 8px; }
.progress i { flex: 1; height: 4px; border-radius: 2px; background: rgb(255 255 255 / .25); }
.progress i.done-g { background: #4ade80; }
.progress i.done-m { background: #facc15; }
.progress i.done-b { background: #f87171; }
.progress i.now { background: #fff; }
.chat-header-row { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--av, var(--violet-500)); color: #fff; font-weight: 700; font-size: 1.1rem;
}
.avatar-sm { width: 38px; height: 38px; }
.chat-header-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.chat-title { font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-status { font-size: .8rem; opacity: .85; min-height: 1.1em; }
.score-pill { background: rgb(255 255 255 / .18); border-radius: 999px; padding: 4px 10px; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-pill.bump { animation: bump .4s ease; }
@keyframes bump { 40% { transform: scale(1.35); background: #facc15; color: #422006; } }
.chat-owner { margin: 0 -12px; padding: 5px 12px; background: var(--violet-900); font-size: .78rem; font-weight: 600; }

.messages {
  flex: 1; overflow-y: auto; padding: 12px 10px 16px; display: flex; flex-direction: column; gap: 6px;
  background-image: radial-gradient(rgb(0 0 0 / .045) 1px, transparent 1px);
  background-size: 18px 18px; scroll-behavior: smooth;
}
.msg {
  max-width: 82%; padding: 7px 10px 6px; border-radius: 10px; line-height: 1.35; position: relative;
  box-shadow: 0 1px 1px rgb(0 0 0 / .12); animation: pop .22s ease-out both; word-wrap: break-word;
  font-size: .98rem;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.msg.in { background: var(--bubble-in); align-self: flex-start; border-top-left-radius: 2px; }
.msg.out { background: var(--bubble-out); align-self: flex-end; border-top-right-radius: 2px; }
.msg .from { display: block; font-size: .78rem; font-weight: 700; margin-bottom: 1px; }
.msg .meta { float: right; margin: 6px 0 -4px 10px; font-size: .68rem; color: var(--muted); }
.msg.out .meta::after { content: ' ✓✓'; color: #0ea5e9; }
.msg.sys { align-self: center; background: #fff8dc; color: #57534e; font-size: .78rem; padding: 4px 10px; border-radius: 8px; box-shadow: none; }
.msg.img { padding: 4px; }
.msg.img .ph {
  width: 200px; height: 150px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 700; text-align: center;
  background: linear-gradient(135deg, #f9a8d4, #a78bfa 50%, #fdba74); filter: saturate(.7);
}
.msg.img .ph span { backdrop-filter: blur(6px); background: rgb(0 0 0 / .35); padding: 6px 10px; border-radius: 8px; font-size: .85rem; }
.msg.target { outline: 3px solid var(--violet-500); outline-offset: 2px; animation: pop .22s ease-out both, glow 1.4s ease-in-out infinite .3s; }
@keyframes glow { 50% { outline-color: rgb(139 92 246 / .25); } }
.msg.judged { outline: 3px solid var(--lvl); outline-offset: 2px; }
.tag {
  display: block; margin-top: 6px; padding: 3px 8px; border-radius: 6px; font-size: .74rem; font-weight: 700;
  background: color-mix(in srgb, var(--lvl) 14%, white); color: color-mix(in srgb, var(--lvl) 75%, black);
}
.typing { align-self: flex-start; background: #fff; border-radius: 10px; padding: 10px 12px; display: flex; gap: 4px; box-shadow: 0 1px 1px rgb(0 0 0 / .12); }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #9ca3af; animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 50% { opacity: .25; transform: translateY(-2px); } }

.composer { flex-shrink: 0; display: flex; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
.composer-input { flex: 1; background: #fff; border-radius: 999px; padding: 10px 14px; color: #9ca3af; }
.composer-mic { width: 42px; height: 42px; border-radius: 50%; background: var(--violet-700); display: grid; place-items: center; }

/* ---------- Paneles ---------- */
.panel {
  flex-shrink: 0; background: #fff; border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgb(0 0 0 / .14); animation: up .25s ease-out both;
}
@keyframes up { from { transform: translateY(40%); opacity: 0; } }
.panel-q { margin: 0 0 10px; font-weight: 700; text-align: center; }
.judge-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.btn-judge {
  border: 2px solid transparent; border-radius: 14px; padding: 12px 4px 10px; font-weight: 700; font-size: .92rem;
  display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; transition: transform .1s;
}
.btn-judge span { font-size: 1.6rem; line-height: 1; }
.btn-judge kbd { position: absolute; top: 4px; right: 6px; font: 600 .62rem var(--font); opacity: .4; }
@media (hover: none) { .btn-judge kbd { display: none; } }
.btn-judge:active { transform: scale(.95); }
.btn-judge.g { background: #dcfce7; color: #14532d; border-color: #86efac; }
.btn-judge.y { background: #fef9c3; color: #713f12; border-color: #fde047; }
.btn-judge.r { background: #fee2e2; color: #7f1d1d; border-color: #fca5a5; }
.choice-options { display: flex; flex-direction: column; gap: 8px; }
.choice {
  text-align: left; border: 2px solid var(--violet-100); background: #faf5ff; border-radius: 14px; padding: 11px 14px;
  line-height: 1.35; color: var(--ink);
}
.choice:active { transform: scale(.98); }
.panel-feedback { display: flex; flex-direction: column; gap: 6px; border-top: 6px solid var(--lvl, var(--violet-500)); }
.fb-verdict { margin: 0; font-weight: 800; font-size: 1.15rem; }
.fb-term { margin: 0; font-weight: 700; color: var(--violet-700); }
.fb-why { margin: 0 0 6px; line-height: 1.45; color: #374151; font-size: .95rem; }
.panel-feedback .btn-primary { background: var(--violet-700); color: #fff; }

/* ---------- Resultados ---------- */
.score-ring {
  --p: 0; width: 170px; height: 170px; border-radius: 50%; margin: 6px auto 0; display: grid; place-content: center; text-align: center;
  background: radial-gradient(closest-side, var(--violet-900) 80%, transparent 81%), conic-gradient(#facc15 calc(var(--p) * 1%), rgb(255 255 255 / .15) 0);
}
.res-score { font-size: 3.4rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.score-ring small { opacity: .7; }
.res-profile { margin: 4px 0 0; text-align: center; font-size: 1.7rem; }
.res-text, .res-bias, .res-challenge { margin: 0; text-align: center; line-height: 1.45; }
.res-bias { background: rgb(255 255 255 / .1); border-radius: var(--radius); padding: 10px 12px; font-size: .95rem; }
.res-challenge { background: #facc15; color: #422006; border-radius: var(--radius); padding: 10px 12px; font-weight: 700; }
.share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-row .btn { padding: .85em .6em; font-size: .95rem; }
.results-inner h3 { margin: 14px 0 0; font-size: 1.05rem; }
.res-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.res-list li { background: rgb(255 255 255 / .08); border-left: 5px solid var(--lvl); border-radius: 10px; padding: 9px 12px; font-size: .9rem; line-height: 1.4; }
.res-list b { display: block; }
.res-list .q { opacity: .75; font-style: italic; display: block; margin: 2px 0; }
.res-list .you { font-size: .8rem; opacity: .85; }
.help { background: #fff; color: var(--ink); border-radius: var(--radius); padding: 4px 16px 12px; margin-top: 8px; }
.help ul { padding-left: 1.1em; margin: 6px 0 0; line-height: 1.6; font-size: .92rem; }
.help h3 { color: var(--violet-800); }

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

/* ---------- Guía docente ---------- */
.doc-body { background: #faf7ff; }
.doc { max-width: 760px; margin: 0 auto; padding: 24px 20px 64px; line-height: 1.6; color: var(--ink); }
.doc h1 { color: var(--violet-800); line-height: 1.15; }
.doc h2 { color: var(--violet-700); margin-top: 2em; }
.doc .lead { font-size: 1.1rem; }
.doc dt { font-weight: 700; margin-top: .6em; }
.doc dd { margin-left: 0; color: #374151; }
.doc a { color: var(--violet-700); }
.doc .small { font-size: .85rem; color: var(--muted); margin-top: 2em; }
