/* nimbus · cielo nocturno, auroras, cristal y neón */
:root {
  --bg0: #020c1b;
  --bg1: #06213a;
  --ink: #f4f1ff;
  --ink2: #bdb3e6;
  --ink3: #8b81b8;
  --glass: rgba(255, 255, 255, .07);
  --glass2: rgba(255, 255, 255, .12);
  --line: rgba(255, 255, 255, .14);
  --violet: #7c5cff;
  --pink: #ff5c8a;
  --cyan: #22d3ee;
  --lime: #a3e635;
  --yellow: #facc15;
  --orange: #fb923c;
  --good: #34d399;
  --bad: #fb7185;
  --me: var(--violet);
  --r: 22px;
  --shadow: 0 10px 40px rgba(10, 0, 40, .45);
  --font: "Nunito", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --display: "Fredoka", "Nunito", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 800px at 80% -10%, #0f4c5c 0%, transparent 60%),
              radial-gradient(900px 700px at -10% 110%, #1e1b4b 0%, transparent 60%),
              linear-gradient(180deg, var(--bg1), var(--bg0));
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  overflow-x: hidden;
}
h1, h2, h3, .display { font-family: var(--display); font-weight: 600; letter-spacing: .2px; margin: 0; }
h1 { font-size: clamp(28px, 7vw, 40px); line-height: 1.1; }
h2 { font-size: clamp(22px, 5.5vw, 28px); line-height: 1.15; }
h3 { font-size: 19px; }
a { color: var(--cyan); }
button, input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--violet); }

/* ---------- fondo animado ---------- */
#sky { position: fixed; inset: 0; z-index: -2; pointer-events: none; }
.aurora { position: fixed; inset: -20%; z-index: -3; pointer-events: none; filter: blur(70px); opacity: .55; }
.aurora i { position: absolute; width: 50vmax; height: 50vmax; border-radius: 50%; mix-blend-mode: screen; animation: drift 22s ease-in-out infinite alternate; }
.aurora i:nth-child(1) { background: #0d9488; left: 0; top: 10%; }
.aurora i:nth-child(2) { background: #4f46e5; right: 0; top: 0; animation-duration: 28s; animation-delay: -6s; }
.aurora i:nth-child(3) { background: #65a30d; left: 25%; bottom: 0; animation-duration: 34s; animation-delay: -12s; }
@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(8vw, -6vh) scale(1.15); }
  100% { transform: translate(-6vw, 8vh) scale(.9); }
}

/* ---------- layout ---------- */
#app { max-width: 760px; margin: 0 auto; padding: 0 16px calc(110px + env(safe-area-inset-bottom)); min-height: 100vh; }
.view { animation: viewIn .45s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }

.topbar { display: flex; align-items: center; gap: 12px; padding: calc(14px + env(safe-area-inset-top)) 0 10px; }
.topbar .brand { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 24px; font-weight: 700; text-decoration: none; color: var(--ink); }

.brand b { background: linear-gradient(90deg, #fff, #c4b5fd, #67e8f9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar .sp { flex: 1; }
.back { width: 42px; height: 42px; border-radius: 14px; border: 1px solid var(--line); background: var(--glass); display: grid; place-items: center; cursor: pointer; font-size: 20px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); font-weight: 800; font-size: 14px; white-space: nowrap; }
.chip.xp { color: var(--yellow); }
.chip.fire { color: var(--orange); }
.avatar { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; background: var(--me); box-shadow: 0 0 0 2px rgba(255,255,255,.25) inset, 0 6px 20px color-mix(in srgb, var(--me) 50%, transparent); cursor: pointer; border: 0; flex: none; }
.avatar.sm { width: 34px; height: 34px; font-size: 19px; border-radius: 11px; }
.avatar.lg { width: 76px; height: 76px; font-size: 44px; border-radius: 24px; }

/* ---------- tarjetas de cristal ---------- */
.card {
  background: linear-gradient(160deg, rgba(255,255,255,.10), rgba(255,255,255,.04));
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  position: relative;
}
.card + .card { margin-top: 14px; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink2); }
.dim { color: var(--ink3); font-size: 14px; }
.center { text-align: center; }
.hide { display: none !important; }
.gap { height: 14px; }

/* ---------- botones ---------- */
.btn {
  --c1: var(--violet); --c2: #a855f7;
  appearance: none; border: 0; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 22px; border-radius: 18px; font-weight: 800; font-size: 17px;
  color: #fff; background: linear-gradient(135deg, var(--c1), var(--c2));
  box-shadow: 0 8px 24px color-mix(in srgb, var(--c1) 45%, transparent), inset 0 1px 0 rgba(255,255,255,.35), inset 0 -3px 0 rgba(0,0,0,.18);
  transition: transform .12s, box-shadow .2s, filter .2s;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.95) translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.block { width: 100%; }
.btn.big { padding: 18px 24px; font-size: 19px; border-radius: 22px; }
.btn.pink { --c1: #ff5c8a; --c2: #f97316; }
.btn.cyan { --c1: #06b6d4; --c2: #3b82f6; }
.btn.green { --c1: #10b981; --c2: #84cc16; }
.btn.yellow { --c1: #f59e0b; --c2: #facc15; color: #2b1600; }
.btn.ghost { background: var(--glass); box-shadow: none; border: 1px solid var(--line); color: var(--ink); }
.btn.small { padding: 9px 14px; font-size: 15px; border-radius: 14px; }
.btn.icon { padding: 0; width: 52px; height: 52px; border-radius: 18px; font-size: 22px; flex: none; }

/* ---------- formularios ---------- */
.field { display: block; }
.field > span { display: block; font-weight: 800; font-size: 14px; color: var(--ink2); margin: 0 0 6px 4px; }
.input {
  width: 100%; padding: 15px 16px; border-radius: 16px; border: 1px solid var(--line);
  background: rgba(10, 4, 30, .45); color: var(--ink); outline: none; font-size: 17px;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus { border-color: var(--violet); box-shadow: 0 0 0 4px rgba(124, 92, 255, .25); }
textarea.input { resize: vertical; min-height: 90px; }
.err { color: var(--bad); font-weight: 700; min-height: 1.2em; font-size: 15px; }

/* ---------- héroe con nimbus ---------- */
.hero { display: flex; align-items: center; gap: 14px; padding: 6px 0 4px; }
.hero .nimbus { width: 118px; flex: none; }
.bubble {
  position: relative; background: #fff; color: #1e1340; border-radius: 22px; padding: 14px 16px; font-weight: 700;
  box-shadow: 0 10px 30px rgba(0,0,0,.35); animation: pop .5s cubic-bezier(.2, 1.4, .4, 1) both; line-height: 1.35;
}
.bubble::before { content: ""; position: absolute; left: -9px; top: 26px; border: 10px solid transparent; border-right-color: #fff; border-left: 0; }
.bubble.top::before { left: 40px; top: -9px; border: 10px solid transparent; border-bottom-color: #fff; border-top: 0; }
@keyframes pop { from { opacity: 0; transform: scale(.6) rotate(-4deg); } to { opacity: 1; transform: none; } }

/* ---------- menú inferior ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 40;
  display: flex; gap: 4px; padding: 7px; border-radius: 26px; width: min(520px, calc(100% - 24px));
  background: rgba(4, 22, 44, .78); border: 1px solid var(--line); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
}
.tabbar a { flex: 1; text-align: center; text-decoration: none; color: var(--ink3); padding: 8px 4px; border-radius: 19px; font-weight: 800; font-size: 12px; transition: background .2s, color .2s; }
.tabbar a i { display: block; font-style: normal; font-size: 22px; line-height: 1.1; transition: transform .25s cubic-bezier(.3, 1.8, .5, 1); }
.tabbar a.on { color: #fff; background: linear-gradient(135deg, rgba(124, 92, 255, .55), rgba(255, 92, 138, .4)); }
.tabbar a.on i { transform: scale(1.18) translateY(-2px); }

/* ---------- inicio ---------- */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.action {
  border: 0; cursor: pointer; text-align: left; color: #fff; border-radius: 26px; padding: 18px; min-height: 150px;
  display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
  box-shadow: var(--shadow); transition: transform .15s;
}
.action:active { transform: scale(.96); }
.action .em { font-size: 44px; line-height: 1; filter: drop-shadow(0 6px 10px rgba(0,0,0,.3)); }
.action b { font-family: var(--display); font-size: 21px; font-weight: 600; display: block; }
.action small { opacity: .85; font-weight: 700; font-size: 13px; }
.action.a1 { background: linear-gradient(140deg, #7c3aed, #db2777); }
.action.a2 { background: linear-gradient(140deg, #0891b2, #4f46e5); }
.action::after { content: ""; position: absolute; width: 140px; height: 140px; right: -40px; top: -40px; border-radius: 50%; background: rgba(255,255,255,.14); }

.plan-item { display: flex; gap: 14px; align-items: center; cursor: pointer; transition: transform .15s; }
.plan-item:active { transform: scale(.98); }
.plan-item .em { font-size: 34px; width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; background: var(--glass2); flex: none; }
.plan-item .title { font-family: var(--display); font-size: 19px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.count { text-align: center; flex: none; min-width: 64px; }
.count b { display: block; font-family: var(--display); font-size: 28px; line-height: 1; }
.count span { font-size: 12px; font-weight: 800; color: var(--ink3); }
.count.hot b { color: var(--pink); animation: throb 1s infinite; }
@keyframes throb { 50% { transform: scale(1.12); } }
.bar { height: 10px; border-radius: 999px; background: rgba(255,255,255,.1); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--violet), var(--pink)); transition: width .6s cubic-bezier(.2, .9, .3, 1); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .5px; }
.badge.ready { background: linear-gradient(90deg, #10b981, #84cc16); color: #052e16; }
.badge.work { background: rgba(124, 92, 255, .3); color: #ddd6fe; }
.badge.wait { background: rgba(250, 204, 21, .2); color: var(--yellow); }

/* ---------- asistente de plan ---------- */
.steps { display: flex; gap: 6px; margin: 4px 0 18px; }
.steps i { flex: 1; height: 6px; border-radius: 9px; background: rgba(255,255,255,.12); }
.steps i.on { background: linear-gradient(90deg, var(--cyan), var(--violet)); }
.drop {
  border: 2px dashed rgba(196, 181, 253, .45); border-radius: 24px; padding: 26px 16px; text-align: center; cursor: pointer;
  background: rgba(124, 92, 255, .08); transition: background .2s, border-color .2s, transform .15s;
}
.drop:hover, .drop.over { background: rgba(124, 92, 255, .18); border-color: var(--violet); }
.drop .em { font-size: 50px; display: block; animation: bob 2.6s ease-in-out infinite; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin-top: 14px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 16px; overflow: hidden; background: var(--glass2); display: grid; place-items: center; font-size: 34px; animation: pop .4s both; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .x { position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 14px; }
.thumb .spin { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(11, 6, 32, .6); }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.levels { display: grid; gap: 12px; }
.level {
  display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: 22px; cursor: pointer; border: 2px solid var(--line);
  background: var(--glass); transition: border-color .2s, transform .15s, background .2s; text-align: left; color: var(--ink); width: 100%;
}
.level .em { font-size: 40px; }
.level b { font-family: var(--display); font-size: 21px; font-weight: 600; }
.level .n { margin-left: auto; text-align: center; font-family: var(--display); font-size: 28px; font-weight: 700; color: var(--ink2); }
.level .n small { display: block; font-size: 11px; font-family: var(--font); font-weight: 800; }
.level.on { border-color: var(--violet); background: rgba(124, 92, 255, .2); transform: scale(1.02); }
.level.on.l-intenso { border-color: var(--pink); background: rgba(255, 92, 138, .18); }
.level.on.l-flojillo { border-color: var(--cyan); background: rgba(34, 211, 238, .14); }

/* ---------- cargando ---------- */
.loading { text-align: center; padding: 30px 10px; }
.loading .nimbus { width: 170px; margin: 0 auto 10px; }
.loading .msg { font-family: var(--display); font-size: 21px; min-height: 2.6em; }
.loading .joke { color: var(--ink2); font-weight: 700; min-height: 3em; transition: opacity .4s; }
.dots::after { content: ""; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* ---------- plan ---------- */
.plan-head { display: flex; gap: 14px; align-items: center; }
.plan-head .em { font-size: 46px; filter: drop-shadow(0 8px 14px rgba(0,0,0,.4)); }
.ring { --p: 0; --c: var(--violet); width: 74px; height: 74px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), rgba(255,255,255,.1) 0); position: relative; }
.ring::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: #071b33; }
.ring > * { position: relative; text-align: center; line-height: 1; }
.ring b { font-family: var(--display); font-size: 22px; display: block; }
.ring small { font-size: 10px; font-weight: 900; color: var(--ink3); text-transform: uppercase; }
.seg { display: flex; gap: 4px; padding: 5px; background: rgba(0,0,0,.25); border-radius: 18px; border: 1px solid var(--line); }
.seg button { flex: 1; border: 0; background: none; padding: 11px; border-radius: 14px; font-weight: 900; cursor: pointer; color: var(--ink3); transition: background .2s, color .2s; }
.seg button.on { background: linear-gradient(135deg, var(--violet), #a855f7); color: #fff; box-shadow: 0 6px 18px rgba(124, 92, 255, .4); }

.theory-nav { display: flex; gap: 6px; justify-content: center; margin: 4px 0 12px; }
.theory-nav i { width: 9px; height: 9px; border-radius: 9px; background: rgba(255,255,255,.2); transition: width .3s, background .3s; cursor: pointer; }
.theory-nav i.on { width: 28px; background: linear-gradient(90deg, var(--cyan), var(--violet)); }
.theory-nav i.seen { background: rgba(196, 181, 253, .6); }
.sec-title { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.sec-title .num { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-family: var(--display); font-weight: 700; background: linear-gradient(135deg, var(--cyan), var(--violet)); flex: none; }
.prose { font-size: 18px; }
.prose p { margin: 0 0 10px; }
.prose strong { color: #fde68a; }
.example { margin-top: 14px; border-radius: 18px; padding: 14px 16px; background: rgba(34, 211, 238, .08); border: 1px solid rgba(34, 211, 238, .3); }
.example h4 { margin: 0 0 6px; font-family: var(--display); font-weight: 600; color: var(--cyan); }
.example ol { margin: 8px 0 0; padding-left: 22px; }
.example li { margin: 6px 0; animation: viewIn .4s both; }
.example .result { margin-top: 10px; font-weight: 900; font-size: 19px; color: var(--lime); animation: pop .5s both; }
.tip { margin-top: 12px; border-radius: 18px; padding: 12px 14px; background: linear-gradient(135deg, rgba(250, 204, 21, .16), rgba(251, 146, 60, .12)); border: 1px solid rgba(250, 204, 21, .35); font-weight: 700; }
.reexplain { margin-top: 12px; border-radius: 18px; padding: 14px 16px; background: rgba(255, 92, 138, .1); border: 1px solid rgba(255, 92, 138, .35); animation: pop .4s both; }
.list-check { list-style: none; padding: 0; margin: 0; }
.list-check li { padding: 10px 0 10px 34px; position: relative; border-bottom: 1px solid rgba(255,255,255,.06); }
.list-check li::before { content: "✅"; position: absolute; left: 0; top: 9px; }
.list-check.warn li::before { content: "⚠️"; }

/* manos libres */
.handsfree { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(circle at 50% 35%, rgba(124, 92, 255, .35), rgba(11, 6, 32, .96) 60%); backdrop-filter: blur(10px); animation: viewIn .4s both; text-align: center; }
.handsfree .nimbus { width: min(300px, 70vw); }
.handsfree .said { font-family: var(--display); font-size: 21px; max-width: 560px; min-height: 4em; margin: 12px 0; }
.handsfree .heard { color: var(--cyan); font-weight: 800; min-height: 1.5em; }
.mic { width: 92px; height: 92px; border-radius: 50%; border: 0; font-size: 38px; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--violet)); box-shadow: 0 0 0 0 rgba(255, 92, 138, .6); transition: transform .15s; }
.mic.rec { animation: ping 1.2s infinite; }
.mic.small { width: 52px; height: 52px; font-size: 22px; border-radius: 18px; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(255, 92, 138, .65); } 100% { box-shadow: 0 0 0 26px rgba(255, 92, 138, 0); } }
.wave { display: flex; gap: 4px; align-items: center; height: 40px; justify-content: center; }
.wave i { width: 6px; border-radius: 6px; background: var(--cyan); height: 8px; transition: height .08s; }

/* ---------- práctica ---------- */
.ex-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ex-dots { display: flex; gap: 5px; flex-wrap: wrap; flex: 1; }
.ex-dots i { width: 22px; height: 8px; border-radius: 6px; background: rgba(255,255,255,.14); cursor: pointer; }
.ex-dots i.bien { background: var(--good); }
.ex-dots i.rendido { background: var(--bad); }
.ex-dots i.cur { outline: 2px solid #fff; outline-offset: 2px; }
.statement { font-size: 21px; font-weight: 700; line-height: 1.45; padding: 6px 0 14px; }
.statement .katex { font-size: 1.15em; }
.keys { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 10px 0; }
.keys button { padding: 10px 0; border-radius: 12px; border: 1px solid var(--line); background: var(--glass); font-weight: 900; font-size: 17px; cursor: pointer; color: var(--ink); }
.keys button:active { transform: scale(.92); background: var(--glass2); }
.answer-row { display: flex; gap: 8px; }
.answer-row .input { font-size: 22px; font-weight: 800; text-align: center; letter-spacing: 1px; }
.preview { min-height: 1.6em; text-align: center; color: var(--ink2); font-size: 20px; }
.feedback { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; }
.feedback .nimbus { width: 64px; flex: none; }
.feedback .bubble { flex: 1; }
.feedback.good .bubble { background: linear-gradient(135deg, #d1fae5, #ecfccb); }
.feedback.bad .bubble { background: linear-gradient(135deg, #ffe4e6, #fef3c7); }
.feedback.hint .bubble { background: linear-gradient(135deg, #fef9c3, #fde68a); }
.solution { margin-top: 12px; padding: 14px; border-radius: 18px; background: rgba(0,0,0,.25); border: 1px solid var(--line); }
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-9px); } 40%, 80% { transform: translateX(9px); } }
.xpfloat { position: fixed; z-index: 90; pointer-events: none; font-family: var(--display); font-weight: 700; font-size: 34px; color: var(--yellow);
  text-shadow: 0 4px 20px rgba(250, 204, 21, .7); animation: xpup 1.6s ease-out forwards; }
@keyframes xpup { 0% { opacity: 0; transform: translate(-50%, 0) scale(.5); } 20% { opacity: 1; transform: translate(-50%, -30px) scale(1.2); } 100% { opacity: 0; transform: translate(-50%, -160px) scale(1); } }

/* ---------- celebración ---------- */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 95; }
.celebrate { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px; text-align: center;
  background: radial-gradient(circle, rgba(124, 92, 255, .45), rgba(11, 6, 32, .94) 65%); animation: viewIn .4s both; }
.celebrate h1 { font-size: clamp(38px, 11vw, 64px); background: linear-gradient(90deg, #fde68a, #f472b6, #67e8f9, #a3e635); background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: shine 3s linear infinite; }
@keyframes shine { to { background-position: 300% 0; } }
.celebrate .nimbus { width: min(280px, 64vw); margin: 0 auto; }
.stamp { display: inline-block; margin: 10px 0; padding: 8px 18px; border: 4px solid var(--lime); color: var(--lime); border-radius: 14px; font-family: var(--display);
  font-weight: 700; font-size: 26px; transform: rotate(-8deg); animation: stamp .6s .3s cubic-bezier(.3, 1.8, .5, 1) both; }
@keyframes stamp { from { transform: rotate(-8deg) scale(3); opacity: 0; } to { transform: rotate(-8deg) scale(1); opacity: 1; } }

/* ---------- chat de dudas ---------- */
.chat { display: flex; flex-direction: column; gap: 12px; padding-bottom: 150px; }
.msg { display: flex; gap: 8px; align-items: flex-end; animation: viewIn .35s both; }
.msg .who { width: 46px; flex: none; }
.msg .txt { max-width: 82%; padding: 12px 15px; border-radius: 20px; line-height: 1.45; overflow-wrap: anywhere; }
.msg.ai .txt { background: #fff; color: #1e1340; border-bottom-left-radius: 6px; font-weight: 600; }
.msg.me { flex-direction: row-reverse; }
.msg.me .txt { background: linear-gradient(135deg, var(--violet), #a855f7); border-bottom-right-radius: 6px; font-weight: 700; }
.msg img.att { display: block; max-width: 220px; border-radius: 14px; margin-bottom: 6px; }
.msg .txt p { margin: 0 0 6px; } .msg .txt p:last-child { margin: 0; }
.composer { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 30; width: min(740px, calc(100% - 24px));
  display: flex; gap: 8px; align-items: flex-end; padding: 8px; border-radius: 24px; background: rgba(4, 22, 44, .9); border: 1px solid var(--line); backdrop-filter: blur(16px); }
.composer textarea { flex: 1; min-height: 52px; max-height: 140px; resize: none; border: 0; background: transparent; padding: 14px 8px; outline: none; color: var(--ink); font-size: 17px; }
.composer .att-prev { position: absolute; bottom: 100%; left: 10px; margin-bottom: 8px; }
.composer .att-prev img { width: 70px; height: 70px; object-fit: cover; border-radius: 14px; border: 2px solid var(--violet); }
.typing i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #7c5cff; margin: 0 2px; animation: typing 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 50% { transform: translateY(-6px); opacity: .4; } }
.solved-banner { text-align: center; padding: 14px; border-radius: 20px; background: linear-gradient(135deg, rgba(16, 185, 129, .25), rgba(132, 204, 22, .2)); border: 1px solid rgba(132, 204, 22, .5); font-weight: 900; animation: pop .5s both; }

/* ---------- ranking ---------- */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 10px; align-items: end; margin: 10px 0 18px; }
.podium .p { text-align: center; }
.podium .p .avatar { margin: 0 auto 6px; }
.podium .p .block { border-radius: 18px 18px 8px 8px; padding: 12px 6px; font-family: var(--display); font-weight: 700; font-size: 26px; }
.podium .p1 .block { height: 130px; background: linear-gradient(180deg, #facc15, #b45309); }
.podium .p2 .block { height: 100px; background: linear-gradient(180deg, #cbd5e1, #475569); }
.podium .p3 .block { height: 80px; background: linear-gradient(180deg, #fdba74, #9a3412); }
.podium .crown { font-size: 30px; display: block; animation: bob 2s infinite; }
.rank-row { display: flex; gap: 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid rgba(255,255,255,.06); }
.rank-row .pos { width: 28px; text-align: center; font-family: var(--display); font-weight: 700; color: var(--ink3); }
.rank-row.me { background: rgba(124, 92, 255, .16); border-radius: 14px; }

/* ---------- perfil / admin ---------- */
.pick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.pick button { aspect-ratio: 1; border-radius: 16px; border: 2px solid transparent; background: var(--glass); font-size: 28px; cursor: pointer; transition: transform .15s; }
.pick button.on { border-color: #fff; transform: scale(1.1); background: var(--glass2); }
.colors { display: flex; gap: 10px; flex-wrap: wrap; }
.colors button { width: 40px; height: 40px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.colors button.on { border-color: #fff; transform: scale(1.12); }
.link-box { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 16px; background: rgba(0,0,0,.3); border: 1px dashed var(--violet); font-family: ui-monospace, monospace; font-size: 13px; overflow-wrap: anywhere; }
.user-row { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.07); }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 30px; background: rgba(255,255,255,.18); transition: background .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::before { transform: translateX(20px); }

/* ---------- toast ---------- */
#toasts { position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(440px, calc(100% - 24px)); pointer-events: none; }
.toast { padding: 13px 16px; border-radius: 16px; background: rgba(4, 22, 44, .96); border: 1px solid var(--line); box-shadow: var(--shadow); font-weight: 800; animation: pop .35s both; }
.toast.bad { border-color: var(--bad); }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 30px 0; }
.auth .nimbus { width: min(170px, 40vw); margin: 0 auto 6px; }
.auth h1 { text-align: center; font-size: clamp(46px, 14vw, 72px); background: linear-gradient(90deg, #fff, #c4b5fd, #67e8f9, #f9a8d4); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: shine 6s linear infinite; }
.auth .tag { text-align: center; color: var(--ink2); font-weight: 800; margin: 2px 0 22px; }

/* KaTeX en burbujas blancas */
.bubble .katex, .msg.ai .katex { color: #1e1340; }
.katex-display { margin: .4em 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

@media (min-width: 640px) {
  .actions .action { min-height: 170px; }
  .hero .nimbus { width: 140px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
