/* ==================== OratorIA · tema claro premium + modo oscuro ==================== */
:root {
  --bg: #F4F5FA;
  --card: #FFFFFF;
  --card2: #F1F2F8;
  --border: #E5E7F2;
  --text: #1B1D2A;
  --muted: #6B7186;
  --accent1: #6D5EF5;   /* violeta principal */
  --accent2: #4B8CFF;   /* azul eléctrico */
  --good: #18A957;      /* verde progreso */
  --warn: #E08A00;      /* ámbar */
  --bad: #E5484D;
  --gold: #F5B90F;      /* amarillo recompensas */
  --shadow: 0 6px 24px rgba(27, 29, 60, .07);
  --shadow-lg: 0 12px 40px rgba(109, 94, 245, .18);
}
:root[data-theme="dark"] {
  --bg: #0E1018;
  --card: #171A26;
  --card2: #1F2333;
  --border: #2A2F45;
  --text: #ECEEF8;
  --muted: #98A0B8;
  --good: #2DD4A7;
  --warn: #FBBF24;
  --bad: #FB7185;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 12px 40px rgba(109, 94, 245, .30);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  transition: background-color .3s, color .3s;
}
.container { max-width: 800px; margin: 0 auto; padding: 20px 16px 70px; }

/* Header */
header { display: flex; align-items: center; justify-content: space-between; padding: 8px 0 18px; gap: 10px; }
.logo {
  font-size: 24px; font-weight: 800;
  background: linear-gradient(90deg, var(--accent1), var(--accent2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.logo small { font-size: 12px; -webkit-text-fill-color: var(--muted); font-weight: 500; display: block; }
.header-right { display: flex; gap: 8px; align-items: center; }
.streak {
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  padding: 8px 14px; font-weight: 700; font-size: 14px; white-space: nowrap; box-shadow: var(--shadow);
}

/* Tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 22px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1; min-width: fit-content; padding: 11px 14px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--card); color: var(--muted); font-weight: 700; font-size: 13.5px;
  cursor: pointer; transition: all .18s; white-space: nowrap;
}
.tab:hover { transform: translateY(-1px); }
.tab.active {
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  border-color: transparent; color: #fff; box-shadow: var(--shadow-lg);
}

.screen { display: none; }
.screen.active { display: block; animation: fadeIn .28s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
h2 { font-size: 18px; margin-bottom: 10px; }
h3 { font-size: 15px; margin-bottom: 6px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.55; }

.banner {
  background: rgba(224,138,0,.10); border: 1px solid rgba(224,138,0,.35);
  color: var(--warn); border-radius: 14px; padding: 12px 16px; font-size: 14px;
  margin-bottom: 16px; line-height: 1.5;
}

/* Buttons & inputs */
.btn {
  display: inline-block; padding: 13px 24px; border-radius: 14px; border: none;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: #fff; font-weight: 800; font-size: 15px; cursor: pointer;
  box-shadow: 0 5px 18px rgba(109,94,245,.35);
  transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 26px rgba(109,94,245,.45); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.secondary { background: var(--card2); border: 1px solid var(--border); color: var(--text); box-shadow: none; }
.btn-icon {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 9px 13px; cursor: pointer; font-size: 14px; transition: transform .12s;
}
.btn-icon:hover { border-color: var(--accent1); transform: translateY(-1px); }
input[type="text"], input[type="password"], select {
  background: var(--card2); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 11px 13px; font-size: 14px; width: 100%;
}
label { font-size: 13px; color: var(--muted); display: block; margin: 12px 0 5px; font-weight: 600; }

/* Topic & reading */
.topic-row { display: flex; gap: 10px; align-items: center; }
.topic-text { flex: 1; font-size: 17px; font-weight: 700; line-height: 1.45; }
.reading-box {
  background: var(--card2); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px; font-size: 16px; line-height: 1.8;
}

/* Recorder */
.recorder { text-align: center; padding: 24px 20px; display: flex; flex-direction: column; align-items: center; }
.rec-btn {
  width: 104px; height: 104px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: #fff; font-size: 38px; box-shadow: 0 10px 34px rgba(109,94,245,.45);
  transition: transform .15s;
}
.rec-btn:hover { transform: scale(1.06); }
.rec-btn.recording { background: linear-gradient(135deg, var(--bad), #ff9f6b); animation: pulse 1.4s infinite; }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(229,72,77,.40); }
  50% { box-shadow: 0 0 0 22px rgba(229,72,77,0); }
}
.timer { font-size: 32px; font-weight: 800; margin: 14px 0 4px; font-variant-numeric: tabular-nums; }
.live-transcript {
  margin-top: 12px; min-height: 40px; font-size: 14px; color: var(--muted);
  text-align: left; background: var(--card2); border-radius: 12px; padding: 12px;
  max-height: 100px; overflow-y: auto; width: 100%;
}

/* Medidor de tono en vivo */
.pitch-meter { margin-top: 14px; width: 100%; text-align: left; }
.pitch-bar { height: 12px; background: var(--card2); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.pitch-fill { height: 100%; width: 0%; background: var(--good); border-radius: 8px; transition: width .2s, background .3s; }

/* Score & criteria */
.score-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.score-ring {
  --pct: 0; width: 132px; height: 132px; border-radius: 50%; position: relative;
  background: conic-gradient(var(--ring-color, var(--accent2)) calc(var(--pct) * 1%), var(--card2) 0);
  display: grid; place-items: center; flex-shrink: 0;
}
.score-ring::before { content: ''; position: absolute; width: 106px; height: 106px; border-radius: 50%; background: var(--card); }
.score-ring span { position: relative; font-size: 36px; font-weight: 800; }
.score-label { font-size: 19px; font-weight: 800; margin-bottom: 6px; }
.criteria { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
@media (max-width: 560px) { .criteria { grid-template-columns: 1fr; } }
.criterion { background: var(--card2); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.criterion .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 8px; }
.criterion .name { font-weight: 700; font-size: 14px; }
.chip { font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.chip.good { background: rgba(24,169,87,.13); color: var(--good); }
.chip.warn { background: rgba(224,138,0,.13); color: var(--warn); }
.chip.bad { background: rgba(229,72,77,.12); color: var(--bad); }
.criterion .val { font-size: 13px; color: var(--muted); line-height: 1.5; }

.tips li { margin: 8px 0 8px 20px; font-size: 14px; line-height: 1.55; }
.transcript-box {
  background: var(--card2); border-radius: 14px; padding: 14px;
  font-size: 14px; line-height: 1.7; max-height: 220px; overflow-y: auto;
}
.filler-hl { background: rgba(229,72,77,.15); color: var(--bad); border-radius: 4px; padding: 0 3px; font-weight: 700; }
audio { width: 100%; margin-top: 10px; }

/* Objetivo del día */
.goal-card { border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-top: 14px; background: var(--card2); }
.goal-card.met { border-color: rgba(24,169,87,.5); background: rgba(24,169,87,.08); }
.goal-card.miss { border-color: rgba(224,138,0,.45); }

/* Test wizard */
.tw-opts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tw-opt {
  background: var(--card2); border: 1.5px solid var(--border); color: var(--text);
  border-radius: 20px; padding: 9px 15px; cursor: pointer; font-size: 13px; transition: all .15s;
}
.tw-opt:hover { transform: translateY(-1px); }
.tw-opt.sel { border-color: var(--accent1); background: rgba(109,94,245,.12); font-weight: 800; color: var(--accent1); }

/* Shadowing */
.orator-card { display: flex; gap: 14px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--border); }
.orator-card:last-child { border-bottom: none; }

/* Progreso */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px; text-align: center; box-shadow: var(--shadow); }
.stat .num { font-size: 25px; font-weight: 800; }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 600; }
.metric-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.metric-chip {
  background: var(--card2); border: 1.5px solid var(--border); color: var(--muted);
  border-radius: 18px; padding: 7px 13px; cursor: pointer; font-size: 13px; font-weight: 700; transition: all .15s;
}
.metric-chip.active { border-color: var(--accent2); color: var(--accent2); background: rgba(75,140,255,.10); }
.session-item { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--border); }
.session-item:last-child { border-bottom: none; }
.session-score {
  font-weight: 800; font-size: 17px; width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center; flex-shrink: 0;
}
.s-good { background: rgba(24,169,87,.13); color: var(--good); }
.s-warn { background: rgba(224,138,0,.13); color: var(--warn); }
.s-bad { background: rgba(229,72,77,.12); color: var(--bad); }
.mode-tag { font-size: 11px; color: var(--accent2); border: 1px solid rgba(75,140,255,.35); border-radius: 10px; padding: 1px 8px; margin-left: 6px; font-weight: 700; }

/* Metas */
.target-row { margin: 12px 0; }
.target-head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }
.target-bar { height: 10px; background: var(--card2); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.target-fill { height: 100%; background: linear-gradient(90deg, var(--accent1), var(--accent2)); border-radius: 8px; }

/* Plan */
.day-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 16px; margin-bottom: 12px; display: flex; gap: 14px; align-items: flex-start; box-shadow: var(--shadow);
}
.day-card.done { opacity: .55; }
.day-num {
  width: 42px; height: 42px; border-radius: 14px; flex-shrink: 0;
  background: linear-gradient(135deg, rgba(109,94,245,.18), rgba(75,140,255,.14));
  display: grid; place-items: center; font-weight: 800; color: var(--accent1);
}
.day-body { flex: 1; min-width: 0; }
.day-title { font-weight: 800; margin-bottom: 4px; }
.day-focus { font-size: 11px; color: var(--accent2); border: 1px solid rgba(75,140,255,.35); border-radius: 10px; padding: 1px 8px; margin-left: 8px; font-weight: 700; }
.day-desc { font-size: 13px; color: var(--muted); line-height: 1.55; margin-top: 4px; }
.day-goal { font-size: 13px; color: var(--good); margin-top: 8px; font-weight: 700; }
.day-tip { font-size: 13px; color: var(--accent2); margin-top: 6px; line-height: 1.5; }
.day-theory { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; font-style: italic; }
.day-check {
  width: 26px; height: 26px; border-radius: 9px; border: 2px solid var(--border);
  background: transparent; cursor: pointer; flex-shrink: 0; font-size: 15px;
  color: var(--good); display: grid; place-items: center;
}
.day-card.done .day-check { border-color: var(--good); background: rgba(24,169,87,.12); }

/* Modal */
.modal-back {
  display: none; position: fixed; inset: 0; background: rgba(15,17,30,.55);
  z-index: 50; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto;
}
.modal-back.open { display: flex; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 22px; max-width: 520px; width: 100%; box-shadow: var(--shadow-lg); }

/* IA feedback */
.ai-box { background: rgba(109,94,245,.07); border: 1px solid rgba(109,94,245,.30); border-radius: 14px; padding: 14px; margin-top: 12px; font-size: 14px; line-height: 1.6; }
.ai-score { font-size: 30px; font-weight: 800; }
.crit-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.crit-row:last-child { border-bottom: none; }

/* Toast */
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(90px);
  background: var(--card); border: 1.5px solid var(--accent1); color: var(--text);
  border-radius: 14px; padding: 12px 20px; font-size: 14px; font-weight: 700;
  z-index: 100; transition: transform .3s; box-shadow: var(--shadow-lg); max-width: 90vw;
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ===== INICIO: perfil + Nova + misiones + tablero ===== */
.profile-card {
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  border-radius: 22px; padding: 22px; margin-bottom: 16px; color: #fff;
  box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}
.profile-card .row { display: flex; gap: 16px; align-items: center; }
.profile-hello { font-size: 22px; font-weight: 800; }
.profile-rank { font-size: 13px; font-weight: 700; opacity: .92; margin-top: 2px; }
.xp-bar { height: 12px; background: rgba(255,255,255,.25); border-radius: 8px; overflow: hidden; margin-top: 12px; }
.xp-fill { height: 100%; background: linear-gradient(90deg, var(--gold), #ffe27a); border-radius: 8px; transition: width .6s ease; }
.xp-text { font-size: 12px; font-weight: 700; opacity: .95; margin-top: 6px; }
.profile-chips { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.profile-chip { background: rgba(255,255,255,.18); border-radius: 20px; padding: 5px 12px; font-size: 12.5px; font-weight: 700; }

.nova { width: 84px; height: 84px; flex-shrink: 0; animation: floaty 3.2s ease-in-out infinite; }
@keyframes floaty { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-7px) rotate(3deg); } }
.nova-bubble {
  background: var(--card); color: var(--text); border-radius: 16px; padding: 12px 14px;
  font-size: 14px; line-height: 1.5; margin-top: 14px; position: relative; box-shadow: var(--shadow);
}
.nova-bubble::before {
  content: ''; position: absolute; top: -8px; left: 34px;
  border-left: 9px solid transparent; border-right: 9px solid transparent; border-bottom: 9px solid var(--card);
}

.mission-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.mission-item:last-child { border-bottom: none; }
.mission-check {
  width: 30px; height: 30px; border-radius: 10px; border: 2px solid var(--border);
  background: var(--card2); cursor: pointer; flex-shrink: 0; font-size: 16px;
  color: #fff; display: grid; place-items: center; transition: all .18s;
}
.mission-item.done .mission-check { background: var(--good); border-color: var(--good); }
.mission-item.done .mission-label { text-decoration: line-through; color: var(--muted); }
.mission-label { flex: 1; font-size: 14.5px; font-weight: 600; line-height: 1.4; }
.mission-xp { font-size: 12px; font-weight: 800; color: var(--gold); white-space: nowrap; }

/* Tablero (oca) */
.stats-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 480px) { .stats-4 .num { font-size: 19px; } .stats-4 .stat { padding: 10px 6px; } }
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin-top: 4px; }
.cell {
  aspect-ratio: 1; border-radius: 16px; background: var(--card2);
  border: 2px solid var(--border); position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: pointer; font-family: inherit; color: var(--text); padding: 0; transition: transform .12s;
}
.cell:hover { transform: translateY(-2px); }
.cell.start, .cell.meta {
  background: linear-gradient(135deg, rgba(109,94,245,.16), rgba(75,140,255,.12));
  font-weight: 800; font-size: 11px; letter-spacing: .08em; color: var(--accent1); cursor: default;
}
.cell.meta.won { background: linear-gradient(135deg, rgba(245,185,15,.30), rgba(255,140,60,.18)); border-color: var(--gold); color: #b8860b; animation: cellpulse 2s infinite; }
.cell.done { background: rgba(24,169,87,.12); border-color: rgba(24,169,87,.5); }
.cell.done .cell-ico { color: var(--good); font-weight: 800; }
.cell.current {
  border-color: var(--accent1); background: var(--card);
  box-shadow: 0 0 0 4px rgba(109,94,245,.20), 0 8px 20px rgba(109,94,245,.25);
  animation: cellpulse 2s infinite;
}
.cell.todo { opacity: .5; }
.cell-num { font-size: 10px; color: var(--muted); font-weight: 800; position: absolute; top: 6px; left: 8px; }
.cell-ico { font-size: 20px; line-height: 1; }
.token { position: absolute; top: -15px; font-size: 25px; animation: hop 1s infinite; filter: drop-shadow(0 5px 7px rgba(0,0,0,.35)); z-index: 2; }
@keyframes hop { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes cellpulse { 0%,100% { box-shadow: 0 0 0 4px rgba(109,94,245,.18); } 50% { box-shadow: 0 0 0 8px rgba(109,94,245,.08); } }
#tileDetail { margin-top: 12px; }

/* ===== MUNDOS (árbol de progreso) ===== */
.world-card {
  border-radius: 20px; padding: 18px; margin-bottom: 14px; border: 1px solid var(--border);
  background: var(--card); box-shadow: var(--shadow);
}
.world-head { display: flex; align-items: center; gap: 14px; }
.world-ico {
  width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; font-size: 26px;
  background: linear-gradient(135deg, rgba(109,94,245,.16), rgba(75,140,255,.12)); flex-shrink: 0;
}
.world-card.locked { opacity: .55; }
.world-prog { font-size: 12px; font-weight: 800; color: var(--accent2); }
.lesson-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.lesson-node {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: none; border: none; cursor: pointer; font-family: inherit; color: var(--text); width: 76px;
}
.lesson-bubble {
  width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; font-size: 24px;
  background: var(--card2); border: 3px solid var(--border); transition: transform .15s;
  box-shadow: 0 4px 0 var(--border);
}
.lesson-node:hover .lesson-bubble { transform: translateY(-2px); }
.lesson-node.done .lesson-bubble { background: rgba(24,169,87,.14); border-color: var(--good); box-shadow: 0 4px 0 rgba(24,169,87,.5); }
.lesson-node.next .lesson-bubble { background: rgba(109,94,245,.12); border-color: var(--accent1); box-shadow: 0 4px 0 var(--accent1); animation: cellpulse 2s infinite; }
.lesson-node.locked { opacity: .45; cursor: default; }
.lesson-name { font-size: 11.5px; font-weight: 700; text-align: center; line-height: 1.2; }

/* Quiz player */
.quiz-q { font-size: 18px; font-weight: 800; line-height: 1.4; margin: 8px 0 16px; }
.quiz-opt {
  display: block; width: 100%; text-align: left; background: var(--card2);
  border: 2px solid var(--border); border-radius: 16px; padding: 15px 16px;
  font-size: 15px; font-weight: 600; color: var(--text); cursor: pointer; margin-bottom: 10px;
  font-family: inherit; transition: all .15s; line-height: 1.45;
}
.quiz-opt:hover { border-color: var(--accent2); transform: translateY(-1px); }
.quiz-opt.right { border-color: var(--good); background: rgba(24,169,87,.12); }
.quiz-opt.wrong { border-color: var(--bad); background: rgba(229,72,77,.10); }
.quiz-explain { background: var(--card2); border-radius: 14px; padding: 13px; font-size: 14px; line-height: 1.55; margin-top: 6px; }
.quiz-progress { display: flex; gap: 6px; margin-bottom: 14px; }
.quiz-dot { height: 6px; flex: 1; border-radius: 4px; background: var(--card2); }
.quiz-dot.on { background: linear-gradient(90deg, var(--accent1), var(--accent2)); }

/* Confetti */
#confettiCanvas { position: fixed; inset: 0; pointer-events: none; z-index: 200; }

.empty { text-align: center; color: var(--muted); padding: 26px 0; font-size: 14px; }
footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 30px; line-height: 1.6; }
#chartSvg { width: 100%; height: 170px; }
