:root {
  /* Paleta derivada del logo: esmeralda sobre bosque profundo */
  --bg-deep: #0A1712;
  --bg: #0E1F17;
  --surface: #12291F;
  --surface-2: #163326;
  --line: #1E4232;
  --line-soft: #17352655;

  --mint: #3EE08A;      /* acento brillante (destellos del logo) */
  --emerald: #23B26E;   /* verde medio */
  --emerald-deep: #148A55;
  --amber: #E0B33E;     /* advertencias */
  --red: #E06A5A;       /* errores */

  --ink: #E8F5EE;       /* texto principal */
  --ink-soft: #B7D2C4;
  --muted: #6F9280;     /* texto secundario / salvia */

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px -20px rgba(0,0,0,.7);

  --font-display: "Chakra Petch", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 700px at 80% -10%, #12442c22, transparent 60%),
    radial-gradient(900px 600px at -10% 10%, #0f5c3a1a, transparent 55%),
    var(--bg-deep);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

img { display: block; max-width: 100%; }
button { font-family: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px calc(12px);
  padding-top: calc(12px + env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--bg-deep) 40%, #0a171200);
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand__logo { border-radius: 9px; box-shadow: 0 0 0 1px var(--line); }
.brand__text { display: flex; flex-direction: column; line-height: 1; }
.brand__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: .14em;
  color: var(--ink);
}
.brand__tag { font-size: 11px; color: var(--muted); letter-spacing: .04em; margin-top: 3px; }

/* ---------- Layout ---------- */
.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 6px 16px 40px;
}

/* ---------- Etapa / escenario ---------- */
.stage__frame {
  position: relative;
  aspect-ratio: 3 / 4;
  max-height: 62dvh;
  margin: 0 auto;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background:
    repeating-linear-gradient(0deg, #ffffff05 0 1px, transparent 1px 26px),
    repeating-linear-gradient(90deg, #ffffff05 0 1px, transparent 1px 26px),
    var(--bg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.stage__video { display: none; }
.stage__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.stage__empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 26px;
  gap: 6px;
  color: var(--ink-soft);
}
.stage__glyph { width: 46px; height: 46px; color: var(--emerald); margin-bottom: 8px; opacity: .9; }
.stage__empty-title { font-family: var(--font-display); font-weight: 600; font-size: 17px; margin: 0; letter-spacing: .02em; }
.stage__empty-sub { margin: 0; max-width: 34ch; font-size: 13.5px; color: var(--muted); line-height: 1.5; }

/* HUD */
.hud {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #08120db3;
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  font-size: 12.5px;
}
.hud__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 0 #3ee08a80;
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 #3ee08a66; }
  70% { box-shadow: 0 0 0 8px #3ee08a00; }
  100% { box-shadow: 0 0 0 0 #3ee08a00; }
}
.hud__text { color: var(--ink); letter-spacing: .02em; }
.hud__pct { font-family: var(--font-mono); font-weight: 700; color: var(--mint); }

/* Progreso */
.progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 4px;
  background: #ffffff10;
}
.progress__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--emerald), var(--mint));
  transition: width .12s linear;
}

/* ---------- Controles ---------- */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
  color: var(--ink);
  background: var(--surface);
}
.btn .ic { width: 18px; height: 18px; }
.btn:active { transform: translateY(1px) scale(.995); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn--primary {
  grid-column: 1 / -1;
  color: #05130C;
  background: linear-gradient(180deg, var(--mint), var(--emerald));
  border-color: #4fe996;
  box-shadow: 0 10px 30px -12px #23b26e88;
}
.btn--outline { background: var(--surface); border-color: var(--line); }
.btn--outline:not(:disabled):hover { border-color: var(--emerald); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn--ghost:hover { color: var(--ink); }
.btn--sm { padding: 8px 12px; font-size: 12.5px; }

.status-line {
  min-height: 18px;
  margin: 12px 2px 0;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}
.status-line.is-error { color: var(--red); }

/* ---------- Resultados ---------- */
.results { margin-top: 26px; display: grid; gap: 16px; }

.panel {
  background: linear-gradient(180deg, var(--surface), var(--bg));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.panel__title { font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: .04em; text-transform: uppercase; margin: 0; color: var(--ink); }
.panel__hint { font-size: 11.5px; color: var(--muted); }

/* Score */
.panel--score {
  background:
    radial-gradient(600px 200px at 90% -40%, #23b26e2b, transparent 70%),
    linear-gradient(180deg, var(--surface-2), var(--bg));
  border-color: var(--line);
}
.score { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.score__value { display: flex; align-items: baseline; gap: 6px; }
.score__num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 58px;
  line-height: .9;
  color: var(--mint);
  letter-spacing: -.01em;
}
.score__of { font-family: var(--font-mono); font-size: 15px; color: var(--muted); }
.score__label { font-size: 13px; color: var(--ink-soft); text-align: right; max-width: 12ch; line-height: 1.35; }

.score__break { margin-top: 16px; display: grid; gap: 2px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.brk {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 7px 0;
  font-size: 13px;
  align-items: baseline;
  border-bottom: 1px dashed var(--line-soft);
}
.brk:last-child { border-bottom: 0; }
.brk__label { color: var(--ink-soft); }
.brk__label small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.brk__val { font-family: var(--font-mono); font-weight: 700; }
.brk__val.pos { color: var(--mint); }
.brk__val.neg { color: var(--amber); }

.disclaimer {
  margin: 14px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
  border-left: 2px solid var(--line);
  padding-left: 10px;
}

/* Métricas */
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.metric {
  background: linear-gradient(180deg, var(--surface), var(--bg));
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 15px 15px 14px;
}
.metric__label { font-size: 11.5px; color: var(--muted); letter-spacing: .03em; text-transform: uppercase; }
.metric__value { display: flex; align-items: baseline; gap: 5px; margin-top: 8px; }
.metric__num { font-family: var(--font-mono); font-weight: 700; font-size: 27px; color: var(--ink); letter-spacing: -.01em; }
.metric__unit { font-family: var(--font-mono); font-size: 13px; color: var(--emerald); }
.metric__sub { margin-top: 6px; font-size: 11.5px; color: var(--muted); }

/* Chart */
.chart { width: 100%; height: 190px; display: block; }

/* Barras de posición corporal */
.bars { display: grid; gap: 15px; }
.bar__top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.bar__name { font-size: 13.5px; color: var(--ink-soft); }
.bar__val { font-family: var(--font-mono); font-size: 13px; color: var(--ink); }
.bar__track { height: 8px; border-radius: 999px; background: #ffffff0f; overflow: hidden; }
.bar__fill { height: 100%; border-radius: 999px; transition: width .6s cubic-bezier(.2,.7,.2,1); }
.bar__fill.good { background: linear-gradient(90deg, var(--emerald), var(--mint)); }
.bar__fill.mid { background: linear-gradient(90deg, #b58a1f, var(--amber)); }
.bar__fill.low { background: linear-gradient(90deg, #a8443a, var(--red)); }
.bar__note { margin-top: 6px; font-size: 11.5px; color: var(--muted); }

/* Hallazgos */
.findings { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.finding {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px;
  align-items: start;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
}
.finding__ic {
  width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  flex: none;
}
.finding__ic.warn { background: #4a3a12; color: var(--amber); }
.finding__ic.err { background: #4a2420; color: var(--red); }
.finding__ic.ok { background: #123726; color: var(--mint); }
.finding__body { font-size: 13.5px; line-height: 1.5; color: var(--ink-soft); }
.finding__body b { color: var(--ink); font-weight: 600; }

/* Footer */
.foot {
  margin-top: 28px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
}
.foot__engine { font-family: var(--font-mono); }

/* ---------- Responsive ---------- */
@media (min-width: 620px) {
  .metrics { grid-template-columns: repeat(4, 1fr); }
  .stage__frame { aspect-ratio: 16 / 10; max-height: 56dvh; }
}

/* Accesibilidad: foco visible */
:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; border-radius: 6px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ==================== VISTAS Y NAVEGACIÓN (v1.1) ==================== */

/* Garantiza que el atributo hidden siempre oculte, pese a display en clases */
[hidden] { display: none !important; }

.topbar__left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.iconbtn {
  width: 38px; height: 38px; flex: none;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  transition: transform .08s ease, border-color .15s ease;
}
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn:hover { border-color: var(--emerald); }
.iconbtn:active { transform: scale(.95); }

/* ---------- Inicio ---------- */
.home {
  max-width: 460px;
  margin: 0 auto;
  padding: 8px 4px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.home__logo {
  width: min(78%, 300px);
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  margin-top: 10px;
}
.home__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 26px 0 18px;
}
.home__profiles { width: 100%; display: grid; gap: 12px; }
.profile {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), var(--bg));
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform .08s ease, border-color .15s ease, background .15s ease;
}
.profile:hover { border-color: var(--emerald); background: linear-gradient(180deg, var(--surface-2), var(--bg)); }
.profile:active { transform: translateY(1px) scale(.997); }
.profile__ic {
  width: 44px; height: 44px; flex: none;
  border-radius: 12px;
  display: grid; place-items: center;
  background: #123726;
  color: var(--mint);
  border: 1px solid var(--line);
}
.profile__ic svg { width: 24px; height: 24px; }
.profile__txt { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.profile__txt b { font-family: var(--font-display); font-weight: 600; font-size: 16px; letter-spacing: .02em; }
.profile__txt small { color: var(--muted); font-size: 12.5px; }
.profile__arrow { width: 20px; height: 20px; color: var(--muted); flex: none; }
.home__note { margin-top: 20px; font-size: 12px; color: var(--muted); }

/* ---------- Encabezados de sección (tutor) ---------- */
.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin: 6px 2px 4px;
}
.section-sub { margin: 0 2px 16px; font-size: 13px; color: var(--muted); }

/* ---------- Avatar ---------- */
.avatar {
  width: 40px; height: 40px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 700; font-size: 14px; letter-spacing: .02em;
  color: #05130C;
  background: linear-gradient(180deg, var(--mint), var(--emerald));
}
.avatar--lg { width: 48px; height: 48px; font-size: 16px; }

/* ---------- Acordeón (tutor) ---------- */
.accordion-list { display: grid; gap: 12px; }
.acc {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), var(--bg));
  overflow: hidden;
}
.acc__head {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 14px;
  background: transparent; border: 0;
  color: var(--ink); cursor: pointer; text-align: left;
}
.acc__id { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.acc__name { font-family: var(--font-display); font-weight: 600; font-size: 15.5px; }
.acc__sub { font-size: 12px; color: var(--muted); }
.acc__score { font-family: var(--font-mono); font-weight: 700; font-size: 18px; color: var(--mint); }
.acc__score small { font-size: 11px; color: var(--muted); font-weight: 500; }
.acc__chev { width: 20px; height: 20px; color: var(--muted); transition: transform .25s ease; flex: none; }
.acc.is-open .acc__chev { transform: rotate(180deg); }
.acc__body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s ease; }
.acc.is-open .acc__body { grid-template-rows: 1fr; }
.acc__inner { overflow: hidden; min-height: 0; }
.acc__inner .sheet { display: grid; gap: 14px; padding: 2px 14px 16px; }

/* ---------- Cabecera de estudiante ---------- */
.user-head {
  display: flex; align-items: center; gap: 13px;
  padding: 14px; margin-bottom: 16px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface-2), var(--bg));
  border: 1px solid var(--line);
}
.user-head__id { display: flex; flex-direction: column; gap: 3px; }
.user-head__name { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.user-head__sub { font-size: 12.5px; color: var(--muted); }

/* ---------- Informe montado en el analizador ---------- */
#reportMount .sheet { display: grid; gap: 16px; }

/* ---------- Fila de compartir ---------- */
.share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.share-row .btn { font-size: 13.5px; padding: 12px 12px; line-height: 1.25; text-align: center; }
.share-row .btn .ic { flex: none; }
/* En pantallas muy angostas se apilan para no cortar el texto */
@media (max-width: 340px) { .share-row { grid-template-columns: 1fr; } }
