/* OwlForge v17 — navegación y panel de trabajo adaptables. */

/* ============ Tokens ============ */
html body:not(.auth-locked)[data-of17] {
  --of17-gap: 12px;
  --of17-dock-w: 252px;
  --of17-dock-min: 76px;
  --of17-ws-w: clamp(340px, 26vw, 420px);
  --of17-side: var(--of17-ws-w);
  --of17-side-gap: 12px;
  --of17-nav-h: 76px;
  --of17-spring: cubic-bezier(.34, 1.45, .64, 1);
  --of17-ease: cubic-bezier(.22, 1, .36, 1);
  --of17-ink: #eaeef7;
  --of17-mut: #9aa8c0;
  --of17-gold: #d6b565;
  --of17-gold-hi: #f2dba0;
  --of17-on-gold: #1a1405;
  --of17-line: rgba(214, 181, 101, .22);
  --of17-glass: linear-gradient(180deg, rgba(20, 32, 58, .9), rgba(10, 17, 33, .94));
  --of17-chip: rgba(255, 255, 255, .055);
  --of17-shadow: 0 22px 60px -18px rgba(0, 0, 0, .55);
}
html body:not(.auth-locked).app-dark[data-of17], html body:not(.auth-locked)[data-of17] { color-scheme: dark; }
html body:not(.auth-locked)[data-of17].of17-collapsed { --of17-dock-w: var(--of17-dock-min); }
html body:not(.auth-locked)[data-of17].of17-ws-off { --of17-side: 0px; --of17-side-gap: 0px; }
html body:not(.auth-locked)[data-of17="desk"].of17-map-open { --of17-side: clamp(420px, 48vw, 1100px); --of17-side-gap: 12px; }
html body:not(.auth-locked)[data-of17="land"] { --of17-gap: 6px; --of17-dock-min: 58px; --of17-dock-w: 58px; --of17-side: 0px; --of17-side-gap: 0px; }
html body:not(.auth-locked)[data-of17="land"].of17-dock-open { --of17-dock-w: 208px; }
html body:not(.auth-locked)[data-of17="land"].of17-map-open { --of17-side: clamp(300px, 52vw, 600px); --of17-side-gap: 6px; }

/* Tema claro */
html[data-theme="light"] body:not(.app-dark)[data-of17],
body:not(.app-dark):not(.auth-locked)[data-of17] {
  --of17-ink: #16233b;
  --of17-mut: #5d6c87;
  --of17-gold: #b78c2c;
  --of17-gold-hi: #e9c668;
  --of17-line: rgba(150, 112, 30, .3);
  --of17-glass: linear-gradient(180deg, rgba(255, 255, 255, .92), rgba(244, 238, 224, .94));
  --of17-chip: rgba(22, 35, 59, .06);
  --of17-shadow: 0 22px 50px -22px rgba(40, 30, 10, .35);
}

/* El encabezado antiguo desaparece: sus piezas viven en el dock y en la HUD. */
html body:not(.auth-locked) #appShell[data-of17] .study-pane > .topbar,
html body:not(.auth-locked) #appShell[data-of17] .of-restore-ws-btn,
html body:not(.auth-locked) #appShell[data-of17] .of-quicknav { display: none !important; }

/* ============ Contenedor principal ============ */
html:has(> body:not(.auth-locked)[data-of17]) {
  overflow: hidden;
  overscroll-behavior: none;
}
body:not(.auth-locked)[data-of17] {
  display: flow-root;
  min-height: 100dvh;
  overflow: hidden;
}
html body:not(.auth-locked) #appShell[data-of17="desk"]:not([hidden]),
html body:not(.auth-locked) #appShell[data-of17="land"]:not([hidden]) {
  display: grid !important;
  grid-template-columns: var(--of17-dock-w) minmax(0, 1fr) var(--of17-side) !important;
  grid-template-areas: "dock stage side" !important;
  grid-template-rows: minmax(0, 1fr) !important;
  min-height: 0 !important;
  gap: 0 !important;
  align-items: stretch !important;
  width: calc(100% - 24px) !important;
  max-width: 2200px !important;
  height: calc(100vh - 24px) !important;
  height: calc(100dvh - 24px) !important;
  margin: 12px auto !important;
  box-sizing: border-box;
  transition: grid-template-columns .65s var(--of17-ease);
}
html body:not(.auth-locked) #appShell[data-of17="land"]:not([hidden]) {
  grid-template-columns: var(--of17-dock-min) minmax(0, 1fr) var(--of17-side) !important;
  width: calc(100% - 12px) !important;
  height: calc(100vh - 12px) !important;
  height: calc(100dvh - 12px) !important;
  margin: 6px auto !important;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ============ Dock ============ */
html body:not(.auth-locked) #appShell[data-of17] .of17-dock {
  grid-area: dock;
  position: relative;
  z-index: 16;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: var(--of17-dock-w);
  height: 100%;
  min-width: 0;
  margin-right: var(--of17-gap);
  padding: 12px 10px;
  box-sizing: border-box;
  background: var(--of17-glass);
  border: 1px solid var(--of17-line);
  border-radius: 22px;
  box-shadow: var(--of17-shadow), inset 0 1px 0 rgba(255, 255, 255, .06);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  transition: width .65s var(--of17-ease), box-shadow .4s ease;
  font-family: 'Manrope', system-ui, sans-serif;
}
html body:not(.auth-locked) #appShell[data-of17="land"] .of17-dock {
  gap: 8px;
  padding: 8px 6px;
  border-radius: 16px;
  margin-right: var(--of17-gap);
}
html body:not(.auth-locked).of17-dock-open #appShell[data-of17="land"] .of17-dock { box-shadow: 0 0 0 100vmax rgba(3, 8, 18, .0), 24px 0 60px -10px rgba(0, 0, 0, .6); }

/* Marca */
html body:not(.auth-locked) #appShell[data-of17] .of17-dock-head { position: relative; height: 64px; flex: none; }
html body:not(.auth-locked) #appShell[data-of17="land"] .of17-dock-head { height: 44px; }
html body:not(.auth-locked) #appShell[data-of17] .of17-mark,
html body:not(.auth-locked) #appShell[data-of17] .of17-brand-slot {
  position: absolute; inset: 0; display: flex; align-items: center;
  transition: opacity .35s ease, transform .6s var(--of17-ease);
}
html body:not(.auth-locked) #appShell[data-of17] .of17-mark { justify-content: center; opacity: 0; transform: scale(.8); pointer-events: none; }
html body:not(.auth-locked) #appShell[data-of17] .of17-mark img { width: 50px; height: 50px; object-fit: contain; filter: drop-shadow(0 4px 12px rgba(214, 181, 101, .25)); }
html body:not(.auth-locked) #appShell[data-of17="land"] .of17-mark img { width: 42px; height: 42px; }
html body:not(.auth-locked) #appShell[data-of17] .of17-brand-slot { justify-content: flex-start; padding-left: 6px; }
html body:not(.auth-locked) #appShell[data-of17] .of17-brand-slot .brand-lockup {
  display: flex !important; flex-direction: column; gap: 2px; margin: 0 !important; padding: 0 !important;
  min-width: 0; background: none !important; border: 0 !important; box-shadow: none !important;
}
html body:not(.auth-locked) #appShell[data-of17] .of17-brand-slot .brand-lockup > div { display: none !important; }
html body:not(.auth-locked) #appShell[data-of17] .of17-brand-slot .brand-logo { display: block !important; width: 100% !important; max-width: 196px !important; height: auto !important; max-height: 58px !important; object-fit: contain !important; }
html body:not(.auth-locked) #appShell[data-of17] .of17-brand-slot .of-brand-companion { display: none !important; }
html body:not(.auth-locked).of17-collapsed #appShell[data-of17] .of17-mark { opacity: 1; transform: none; pointer-events: auto; }
html body:not(.auth-locked).of17-collapsed #appShell[data-of17] .of17-brand-slot { opacity: 0; transform: translateX(-12px); pointer-events: none; }
html body:not(.auth-locked)[data-of17="land"] #appShell[data-of17] .of17-mark { opacity: 1; transform: none; }
html body:not(.auth-locked)[data-of17="land"] #appShell[data-of17] .of17-brand-slot { opacity: 0; pointer-events: none; }
html body:not(.auth-locked)[data-of17="land"].of17-dock-open #appShell[data-of17] .of17-mark { opacity: 0; }
html body:not(.auth-locked)[data-of17="land"].of17-dock-open #appShell[data-of17] .of17-brand-slot { opacity: 1; pointer-events: auto; transform: none; }

/* Navegación */
html body:not(.auth-locked) #appShell[data-of17] .of17-nav { position: relative; display: flex; flex-direction: column; gap: 6px; flex: none; }
html body:not(.auth-locked) #appShell[data-of17] .of17-item {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 14px;
  width: 100%; height: 46px; min-height: 0; margin: 0;
  padding: 0 0 0 16px; box-sizing: border-box;
  border: 0; border-radius: 14px; background: transparent; box-shadow: none;
  color: var(--of17-mut); font: 700 .9rem/1 'Manrope', system-ui, sans-serif; letter-spacing: 0;
  text-align: left; cursor: pointer; white-space: nowrap; overflow: visible;
  transition: color .3s ease, background-color .3s ease, transform .25s var(--of17-ease);
  -webkit-tap-highlight-color: transparent;
}
html body:not(.auth-locked) #appShell[data-of17] .of17-item svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transition: transform .45s var(--of17-spring); }
html body:not(.auth-locked) #appShell[data-of17] .of17-item:hover { color: var(--of17-ink); background: var(--of17-chip); }
html body:not(.auth-locked) #appShell[data-of17] .of17-item:hover svg { transform: scale(1.12); }
html body:not(.auth-locked) #appShell[data-of17] .of17-item:active { transform: scale(.97); }
html body:not(.auth-locked) #appShell[data-of17] .of17-item:focus-visible { outline: 2px solid var(--of17-gold-hi); outline-offset: 2px; }
html body:not(.auth-locked) #appShell[data-of17] .of17-item.is-active { color: var(--of17-on-gold); background: transparent; }
html body:not(.auth-locked) #appShell[data-of17] .of17-label { display: block; overflow: hidden; max-width: 170px; opacity: 1; transform: none; transition: opacity .3s ease .12s, transform .5s var(--of17-ease) .05s, max-width .55s var(--of17-ease); }
html body:not(.auth-locked).of17-collapsed #appShell[data-of17] .of17-label { max-width: 0; opacity: 0; transform: translateX(-8px); transition-delay: 0s; }
html body:not(.auth-locked)[data-of17="land"]:not(.of17-dock-open) #appShell[data-of17] .of17-label { max-width: 0; opacity: 0; }
html body:not(.auth-locked) #appShell[data-of17="land"] .of17-nav {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  overscroll-behavior: contain;
}
html body:not(.auth-locked) #appShell[data-of17="land"] .of17-item {
  flex: none;
  height: 38px;
  padding-left: 12px;
  gap: 12px;
}

html body:not(.auth-locked) #appShell[data-of17] .of17-indicator {
  position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none;
  width: var(--w, 100%); height: var(--h, 46px);
  border-radius: 14px;
  background: linear-gradient(135deg, var(--of17-gold-hi), var(--of17-gold));
  box-shadow: 0 10px 28px -10px rgba(214, 181, 101, .7), inset 0 1px 0 rgba(255, 255, 255, .5);
  transform: translate3d(var(--x, 0px), var(--y, 0px), 0);
  transition: transform .6s var(--of17-spring), width .5s var(--of17-ease), height .5s var(--of17-ease);
}

/* Pie del dock */
html body:not(.auth-locked) #appShell[data-of17] .of17-dock-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; position: relative; }
html body:not(.auth-locked) #appShell[data-of17] .of17-collapse svg { transition: transform .6s var(--of17-ease); }
html body:not(.auth-locked) #appShell[data-of17] .of17-collapse.is-collapsed svg { transform: rotate(180deg); }
html body:not(.auth-locked) #appShell[data-of17] .of17-collapse:hover svg { transform: translateX(-2px); }
html body:not(.auth-locked) #appShell[data-of17] .of17-collapse.is-collapsed:hover svg { transform: rotate(180deg) translateX(-2px); }

/* Tooltips con el dock contraído */
html body:not(.auth-locked).of17-collapsed #appShell[data-of17="desk"] .of17-item[title]:hover::after {
  content: attr(title);
  position: absolute; left: calc(100% + 14px); top: 50%; transform: translateY(-50%);
  padding: 7px 11px; border-radius: 10px; background: var(--of17-ink); color: #0b1423;
  font: 700 .78rem/1 'Manrope', system-ui, sans-serif; white-space: nowrap; pointer-events: none; z-index: 40;
  animation: of17-tip .22s var(--of17-ease) both;
}
@keyframes of17-tip { from { opacity: 0; transform: translateY(-50%) translateX(-6px); } to { opacity: 1; transform: translateY(-50%); } }

/* Cuenta */
html body:not(.auth-locked) #appShell[data-of17] .of17-account { position: relative; display: flex; justify-content: center; }
html body:not(.auth-locked) #appShell[data-of17] .of17-avatar {
  display: grid; place-items: center; width: 42px; height: 42px; padding: 0; margin: 0; min-height: 0;
  border-radius: 50%; border: 1px solid var(--of17-line); cursor: pointer;
  background: linear-gradient(135deg, var(--of17-gold-hi), var(--of17-gold));
  color: var(--of17-on-gold); font: 800 .8rem/1 'Manrope', system-ui, sans-serif;
  box-shadow: 0 8px 22px -10px rgba(214, 181, 101, .8);
  transition: transform .4s var(--of17-spring);
}
html body:not(.auth-locked) #appShell[data-of17] .of17-avatar:hover { transform: scale(1.08); }
html body:not(.auth-locked) #appShell[data-of17] .of17-account .session-card {
  display: none !important; position: absolute !important; z-index: 40; width: 270px; max-width: 86vw;
  margin: 0 !important; padding: 12px !important; gap: 8px !important; grid-template-columns: 1fr !important;
  background: var(--of17-glass) !important; border: 1px solid var(--of17-line) !important; border-radius: 16px !important;
  box-shadow: var(--of17-shadow) !important; backdrop-filter: blur(18px);
  left: calc(100% + 14px); bottom: 0; top: auto; right: auto;
  color: var(--of17-ink);
}
html body:not(.auth-locked).of17-acct-open #appShell[data-of17] .of17-account .session-card { display: grid !important; animation: of17-pop .35s var(--of17-ease) both; }
@keyframes of17-pop { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
html body:not(.auth-locked):not(.of17-collapsed) #appShell[data-of17="desk"] .of17-account .session-card {
  display: grid !important; position: static !important; width: 100%; max-width: none; animation: none;
  background: var(--of17-chip) !important; box-shadow: none !important; padding: 10px !important;
}
html body:not(.auth-locked):not(.of17-collapsed) #appShell[data-of17="desk"] .of17-avatar { display: none; }
html body:not(.auth-locked) #appShell[data-of17] .of17-account .session-card strong,
html body:not(.auth-locked) #appShell[data-of17] .of17-account .session-card span { color: var(--of17-ink) !important; font-size: .82rem !important; }
html body:not(.auth-locked) #appShell[data-of17] .of17-account .session-card .of-pro-upsell-pill,
html body:not(.auth-locked) #appShell[data-of17] .of17-account .session-card .text-button { width: 100%; min-height: 34px !important; font-size: .78rem !important; }

/* Herramientas globales (idioma, sonido, tema) reubicadas */
html body:not(.auth-locked) #appShell[data-of17] .premium-global-tools,
html body:not(.auth-locked) .of17-hud .premium-global-tools {
  position: static !important; inset: auto !important; transform: none !important; margin: 0 !important;
  display: flex !important; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px !important;
  width: 100%; max-width: none !important; padding: 6px !important; box-sizing: border-box;
  background: var(--of17-chip) !important; border: 1px solid var(--of17-line) !important; border-radius: 14px !important;
  box-shadow: none !important; backdrop-filter: none !important;
}
html body:not(.auth-locked) #appShell[data-of17] .premium-global-tools button { min-width: 32px; height: 32px; min-height: 0; padding: 0 8px; font-size: .74rem; }
html body:not(.auth-locked) #appShell[data-of17] .premium-locale-group { display: inline-flex; gap: 2px; }
html body:not(.auth-locked) #appShell[data-of17] .premium-locale-option { min-width: 30px; width: 30px; height: 30px; padding: 0; font-size: .7rem; }
html body:not(.auth-locked).of17-collapsed #appShell[data-of17="desk"] .premium-global-tools { flex-direction: column; padding: 6px 3px !important; }

/* ============ Escenario de estudio ============ */
html body:not(.auth-locked) #appShell[data-of17] .study-pane {
  grid-area: stage;
  display: flex !important; flex-direction: column !important; gap: 10px !important;
  height: 100% !important; min-width: 0; min-height: 0; max-height: none !important;
  margin: 0 var(--of17-side-gap) 0 0 !important;
  padding: 14px !important; box-sizing: border-box; overflow: hidden !important;
  border-radius: 22px !important;
  transition: margin .65s var(--of17-ease), opacity .4s ease;
}
html body:not(.auth-locked) #appShell[data-of17="land"] .study-pane { padding: 8px !important; gap: 6px !important; border-radius: 16px !important; }

/* HUD */
html body:not(.auth-locked) #appShell[data-of17] .of17-hud { display: flex; align-items: center; gap: 10px; flex: none; min-height: 38px; min-width: 0; font-family: 'Manrope', system-ui, sans-serif; }
html body:not(.auth-locked) #appShell[data-of17] .of17-hud .stats {
  display: flex !important; flex-wrap: nowrap !important; flex: 1 1 auto; gap: 8px !important; min-width: 0; margin: 0 !important; padding: 0 !important;
  overflow-x: auto; scrollbar-width: none; background: none !important; border: 0 !important; box-shadow: none !important;
  grid-template-columns: none !important; grid-area: auto !important; order: 0;
}
html body:not(.auth-locked) #appShell[data-of17] .of17-hud .stats::-webkit-scrollbar { display: none; }
html body:not(.auth-locked) #appShell[data-of17] .of17-hud .stats > span {
  display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 6px; flex: none;
  height: 34px; min-height: 0 !important; padding: 0 13px !important; margin: 0 !important; box-sizing: border-box;
  border-radius: 999px !important; background: var(--of17-chip) !important; border: 1px solid var(--of17-line) !important;
  box-shadow: none !important; backdrop-filter: none !important;
  color: var(--of17-mut) !important; font: 600 .76rem/1 'Manrope', system-ui, sans-serif !important; white-space: nowrap;
}
html body:not(.auth-locked) #appShell[data-of17] .of17-hud .stats > span strong { font: 800 .98rem/1 'Manrope', system-ui, sans-serif !important; color: var(--of17-ink) !important; }
html body:not(.auth-locked) #appShell[data-of17] .of17-hud-tools { flex: none; }
.of17-hud-tools:empty { display: none; }
html body:not(.auth-locked) #appShell[data-of17="land"] .of17-hud-tools .premium-global-tools { width: auto; padding: 3px !important; flex-wrap: nowrap; }
html body:not(.auth-locked) #appShell[data-of17="land"] .of17-hud { min-height: 32px; }
html body:not(.auth-locked) #appShell[data-of17="land"] .of17-hud .stats > span { height: 28px; padding: 0 10px !important; font-size: .68rem !important; }

#appShell[data-of17] .of17-fullscreen-btn {
  display: inline-flex;
  flex: none;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-width: 40px;
  min-height: 38px;
  margin: 0 0 0 auto;
  padding: 0 10px;
  white-space: nowrap;
  font-size: .76rem;
}
.of17-fullscreen-btn svg {
  width: 19px;
  height: 19px;
  flex: none;
}
#appShell[data-of17="port"] .of17-fullscreen-btn {
  padding-inline: 8px;
}
#appShell[data-of17="port"] .of17-fullscreen-btn span {
  display: none;
}
/* Tarjeta: ocupa todo el espacio libre */
html body:not(.auth-locked) #appShell[data-of17] .flashcard:not(.is-card-fullscreen) {
  flex: 1 1 0 !important; width: 100% !important; min-height: 0 !important; height: auto !important; max-height: none !important;
  aspect-ratio: auto !important; margin: 0 !important; box-sizing: border-box;
  border-radius: 22px !important; overflow: auto; overscroll-behavior: contain;
}
html body:not(.auth-locked) #appShell[data-of17="land"] .flashcard:not(.is-card-fullscreen) { border-radius: 14px !important; padding: 12px 14px !important; }

/* Controles de repaso en una sola fila */
html body:not(.auth-locked) #appShell[data-of17] .premium-srs-controls {
  display: grid !important; flex: none;
  grid-template-columns: minmax(70px, .8fr) repeat(4, minmax(0, 1fr)) minmax(70px, .8fr) !important;
  grid-auto-rows: auto !important; gap: 8px !important; width: 100%; margin: 0 !important; padding: 0 !important; overflow: visible !important;
}
html body:not(.auth-locked) #appShell[data-of17] .premium-srs-controls > button {
  grid-row: 1 !important; grid-column: auto !important; width: auto !important; min-width: 0 !important; max-width: none !important;
  height: 46px; min-height: 0 !important; margin: 0 !important; padding: 0 6px !important; border-radius: 14px !important;
  font: 700 .86rem/1 'Manrope', system-ui, sans-serif !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: transform .25s var(--of17-ease), filter .25s ease, box-shadow .3s ease;
}
html body:not(.auth-locked) #appShell[data-of17] .premium-srs-controls > button:hover { transform: translateY(-2px); filter: brightness(1.12); }
html body:not(.auth-locked) #appShell[data-of17] .premium-srs-controls > button:active { transform: scale(.96); }
html body:not(.auth-locked) #appShell[data-of17="land"] .premium-srs-controls { gap: 5px !important; }
html body:not(.auth-locked) #appShell[data-of17="land"] .premium-srs-controls > button { height: 34px; border-radius: 10px !important; font-size: .74rem !important; padding: 0 3px !important; }

/* Pie: repaso, progreso y herramientas */
html body:not(.auth-locked) #appShell[data-of17] .of17-foot { display: flex; align-items: center; gap: 10px 14px; flex: none; position: relative; min-width: 0; }
html body:not(.auth-locked) #appShell[data-of17] .of17-foot > * { margin: 0 !important; }
html body:not(.auth-locked) #appShell[data-of17] .of17-foot .premium-review-strip {
  flex: 0 0 auto; display: flex !important; align-items: center; gap: 10px; padding: 0 !important; min-height: 0 !important;
  background: none !important; border: 0 !important; box-shadow: none !important;
}
html body:not(.auth-locked) #appShell[data-of17] .of17-foot .premium-review-strip button { min-height: 32px !important; height: 32px; padding: 0 12px !important; font-size: .76rem !important; }
html body:not(.auth-locked) #appShell[data-of17] .of17-foot .progress-wrap { flex: 1 1 140px; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 0 !important; }
html body:not(.auth-locked) #appShell[data-of17] .of17-foot .progress-wrap p { margin: 0 !important; font-size: .7rem !important; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--of17-mut) !important; }
html body:not(.auth-locked) #appShell[data-of17] .of17-foot .progress-bar { height: 6px !important; }
html body:not(.auth-locked) #appShell[data-of17] .of17-foot .progress-bar span { transition: width .9s var(--of17-ease) !important; }
html body:not(.auth-locked) #appShell[data-of17] .of17-foot .of-tools-disclosure { flex: 0 0 auto; position: relative; padding: 0 !important; background: none !important; border: 0 !important; box-shadow: none !important; }
html body:not(.auth-locked) #appShell[data-of17] .of17-foot .of-disclosure-summary {
  display: inline-flex !important; align-items: center; gap: 8px; height: 34px; padding: 0 14px !important; box-sizing: border-box;
  border-radius: 999px; background: var(--of17-chip) !important; border: 1px solid var(--of17-line) !important; cursor: pointer; list-style: none;
}
html body:not(.auth-locked) #appShell[data-of17] .of17-foot .of-disclosure-title { font: 700 .76rem/1 'Manrope', system-ui, sans-serif; }
html body:not(.auth-locked) #appShell[data-of17] .of17-foot .of-disclosure-hint { display: none !important; }
html body:not(.auth-locked) #appShell[data-of17] .of17-foot .of-tools-disclosure .study-actions {
  position: absolute !important; right: 0; bottom: calc(100% + 10px); z-index: 30;
  display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; width: min(340px, 88vw); margin: 0 !important; padding: 10px !important;
  background: var(--of17-glass) !important; border: 1px solid var(--of17-line) !important; border-radius: 16px !important; box-shadow: var(--of17-shadow) !important;
  backdrop-filter: blur(18px); animation: of17-pop .35s var(--of17-ease) both;
}
html body:not(.auth-locked) #appShell[data-of17="land"] .of17-foot { gap: 6px 10px; }
html body:not(.auth-locked) #appShell[data-of17="land"] .of17-foot .progress-wrap p { display: none; }

/* ============ Panel de trabajo (escritorio: tercera columna) ============ */
html body:not(.auth-locked) #appShell[data-of17="desk"] .deck-pane.of-workspace {
  grid-area: side; display: flex !important; flex-direction: column; width: 100% !important; height: 100% !important;
  min-width: 0; max-height: none !important; margin: 0 !important; overflow: auto;
  transition: opacity .4s ease, transform .65s var(--of17-ease), visibility 0s;
}
html body:not(.auth-locked).of17-ws-off:not(.of17-map-open) #appShell[data-of17="desk"] .deck-pane.of-workspace {
  opacity: 0; visibility: hidden; pointer-events: none; transform: translateX(32px); transition-delay: 0s, 0s, .5s;
}
/* Cajón del panel en móvil */
html body:not(.auth-locked) #appShell[data-of17="land"] .deck-pane.of-workspace,
html body:not(.auth-locked) #appShell[data-of17="port"] .deck-pane.of-workspace {
  position: fixed !important; inset: 0 0 0 auto !important; z-index: 30 !important;
  display: flex !important; flex-direction: column; width: min(430px, 94vw) !important; height: 100dvh !important; max-height: none !important;
  margin: 0 !important; padding-top: max(14px, env(safe-area-inset-top)) !important; padding-bottom: max(14px, env(safe-area-inset-bottom)) !important;
  border-radius: 22px 0 0 22px !important; overflow: auto; overscroll-behavior: contain;
  transform: translateX(105%); visibility: hidden;
  transition: transform .6s var(--of17-ease), visibility 0s .6s;
}
html body:not(.auth-locked) #appShell[data-of17="land"].of17-ws-open .deck-pane.of-workspace,
html body:not(.auth-locked) #appShell[data-of17="port"].of17-ws-open .deck-pane.of-workspace {
  transform: none; visibility: visible; transition: transform .6s var(--of17-ease), visibility 0s;
  box-shadow: -30px 0 80px -20px rgba(0, 0, 0, .7);
}
.of17-scrim { position: fixed; inset: 0; z-index: 29; border: 0; padding: 0; background: rgba(3, 8, 18, .6); backdrop-filter: blur(3px); animation: of17-fade .4s ease both; }
.of17-scrim[hidden] { display: none; }
@keyframes of17-fade { from { opacity: 0; } to { opacity: 1; } }

/* ============ Vista completa de mapa y texto ============ */
html body.of17-map-open #appShell {
  visibility: hidden;
}
#previewModal:not([hidden]) {
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--panel);
}
#previewModal .preview-dialog {
  grid-template-columns: minmax(0, 1fr);
  border: 0 !important;
  border-radius: 0 !important;
}
#previewModal .preview-header {
  position: relative;
  z-index: 1;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  padding: 4px clamp(6px, 1.5vw, 16px);
}
#previewModal .preview-header .eyebrow,
#previewModal[data-preview-mode="mindmap"] #previewMindMapBtn,
#previewModal[data-preview-mode="text"] #previewTextBtn {
  display: none;
}
#previewModal .preview-header h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
}
#previewModal .preview-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
#previewModal .preview-actions button {
  width: auto;
  min-height: 36px;
  margin: 0;
  padding: 0 clamp(6px, 1vw, 12px);
  font-size: .78rem;
}
#previewModal #previewMapSettingsBtn[aria-expanded="true"] {
  border-color: var(--of17-gold, #b78c2c);
}
#previewModal .preview-map-toolbar-slot {
  position: absolute;
  inset: calc(100% + 5px) 6px auto auto;
  display: block;
  width: max-content;
  max-width: calc(100% - 12px);
  max-height: 55dvh;
  overflow: auto;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
#previewModal .visualization-bar,
#previewModal .map-customization {
  flex-wrap: wrap;
}
#previewModal .visualization-bar {
  width: auto;
  padding: 8px;
}
#previewModal .map-customization {
  flex: 0 1 auto;
  max-width: 100%;
  border: 0;
  padding: 0;
}
#previewModal .visualization-bar :is(button, select, input[type="color"]) {
  min-height: 34px;
}
@media (max-width: 560px) {
  #previewModal .preview-header {
    grid-template-columns: minmax(0, 1fr);
    padding-top: 6px;
  }
  #previewModal .preview-actions button {
    padding-inline: 5px;
    font-size: .72rem;
  }
}

/* ============ Móvil vertical ============ */
html body:not(.auth-locked) #appShell[data-of17="port"]:not([hidden]) {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  grid-template-areas: "head foot" "stage stage" !important;
  gap: 6px 8px !important; align-items: center !important; min-height: 0 !important;
  width: 100% !important; max-width: none !important; margin: 0 !important; box-sizing: border-box;
  height: 100vh !important; height: 100dvh !important;
  padding: calc(env(safe-area-inset-top) + 6px) calc(8px + env(safe-area-inset-right)) calc(var(--of17-nav-h) + 8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left)) !important;
  transition: padding-bottom .6s var(--of17-spring);
}
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-dock { display: contents; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-dock-head { grid-area: head; height: 46px; min-width: 0; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-mark { opacity: 0 !important; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-brand-slot { opacity: 1 !important; transform: none !important; pointer-events: auto !important; padding-left: 2px; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-brand-slot .brand-logo { max-width: 166px !important; max-height: 46px !important; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-dock-foot { grid-area: foot; flex-direction: row; align-items: center; gap: 6px; margin: 0; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-collapse { display: none; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-tools-slot { order: 1; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-account { order: 2; }
html body:not(.auth-locked) #appShell[data-of17="port"] .premium-global-tools { width: auto; padding: 3px !important; gap: 3px !important; flex-wrap: nowrap; }
html body:not(.auth-locked) #appShell[data-of17="port"] .premium-global-tools button { min-width: 30px; height: 30px; }
html body:not(.auth-locked) #appShell[data-of17="port"] .premium-locale-option { width: 28px; min-width: 28px; height: 28px; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-avatar { width: 38px; height: 38px; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-account .session-card { left: auto; right: 0; top: calc(100% + 10px); bottom: auto; }

html body:not(.auth-locked) #appShell[data-of17="port"] .of17-nav {
  position: fixed; left: calc(8px + env(safe-area-inset-left)); right: calc(8px + env(safe-area-inset-right));
  bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 18;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; height: 64px; padding: 6px; box-sizing: border-box;
  background: var(--of17-glass); border: 1px solid var(--of17-line); border-radius: 22px;
  box-shadow: var(--of17-shadow), inset 0 1px 0 rgba(255, 255, 255, .06);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
}
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-item { flex-direction: column; justify-content: center; align-items: center; gap: 4px; height: 100%; padding: 0; border-radius: 16px; font-size: .64rem; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-item svg { width: 21px; height: 21px; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-label { max-width: 100% !important; opacity: 1 !important; transform: none !important; text-overflow: ellipsis; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-indicator { border-radius: 16px; }
html body:not(.auth-locked) #appShell[data-of17="port"] .study-pane { margin: 0 !important; padding: 10px !important; border-radius: 20px !important; gap: 8px !important; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-hud .stats { gap: 5px !important; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-hud .stats > span { height: 30px; padding: 0 9px !important; gap: 4px; font-size: .68rem !important; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-hud .stats > span strong { font-size: .9rem !important; }
@media (max-width: 500px) {
  html body:not(.auth-locked) #appShell[data-of17="port"] .of17-hud .stats {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  html body:not(.auth-locked) #appShell[data-of17="port"] .of17-hud .stats > span {
    justify-content: center;
    font-size: clamp(.55rem, 1.85vw, .68rem) !important;
  }
}

html body:not(.auth-locked) #appShell[data-of17="port"] .premium-srs-controls { gap: 5px !important; grid-template-columns: minmax(52px, .75fr) repeat(4, minmax(0, 1fr)) minmax(52px, .75fr) !important; }
html body:not(.auth-locked) #appShell[data-of17="port"] .premium-srs-controls > button { height: 42px; font-size: .7rem !important; padding: 0 2px !important; border-radius: 12px !important; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-foot { flex-wrap: wrap; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-foot .progress-wrap { flex: 1 1 100%; order: 3; }
html body:not(.auth-locked) #appShell[data-of17="port"] .of17-foot .of-tools-disclosure { margin-left: auto !important; }

/* ============ Movimiento ============ */
@keyframes of17-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes of17-card-in { from { opacity: 0; transform: translateY(18px) scale(.965); filter: blur(8px); } to { opacity: 1; transform: none; filter: none; } }
html body:not(.auth-locked) #appShell.of17-enter .of17-dock { animation: of17-rise .8s var(--of17-ease) both; }
html body:not(.auth-locked) #appShell.of17-enter .of17-item { animation: of17-rise .75s var(--of17-ease) both; animation-delay: calc(var(--i, 0) * 70ms + 200ms); }
html body:not(.auth-locked) #appShell.of17-enter .of17-hud { animation: of17-rise .7s .15s var(--of17-ease) both; }
html body:not(.auth-locked) #appShell.of17-enter .flashcard { animation: of17-card-in 1s .3s var(--of17-ease) both; }
html body:not(.auth-locked) #appShell.of17-enter .premium-srs-controls { animation: of17-rise .8s .55s var(--of17-ease) both; }

@keyframes of17-pulse { 0% { box-shadow: 0 0 0 0 var(--of17-pc); } 100% { box-shadow: 0 0 0 22px transparent; } }
html body:not(.auth-locked) #appShell .flashcard.of17-pulse-again { --of17-pc: rgba(239, 83, 80, .55); animation: of17-pulse .6s var(--of17-ease); }
html body:not(.auth-locked) #appShell .flashcard.of17-pulse-hard { --of17-pc: rgba(240, 180, 60, .55); animation: of17-pulse .6s var(--of17-ease); }
html body:not(.auth-locked) #appShell .flashcard.of17-pulse-good { --of17-pc: rgba(46, 196, 140, .55); animation: of17-pulse .6s var(--of17-ease); }
html body:not(.auth-locked) #appShell .flashcard.of17-pulse-easy { --of17-pc: rgba(80, 150, 255, .55); animation: of17-pulse .6s var(--of17-ease); }
@keyframes of17-swipe-in-l { from { opacity: .2; transform: translateX(44px); } to { opacity: 1; transform: none; } }
@keyframes of17-swipe-in-r { from { opacity: .2; transform: translateX(-44px); } to { opacity: 1; transform: none; } }
html body:not(.auth-locked) #appShell .flashcard.of17-swipe-l { animation: of17-swipe-in-l .45s var(--of17-ease); }
html body:not(.auth-locked) #appShell .flashcard.of17-swipe-r { animation: of17-swipe-in-r .45s var(--of17-ease); }

@media (prefers-reduced-motion: reduce) {
  html body:not(.auth-locked)[data-of17] *, html body:not(.auth-locked)[data-of17] *::before, html body:not(.auth-locked)[data-of17] *::after,
  html body:not(.auth-locked) #previewModal *, .of17-scrim {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important;
  }
}

html body:not(.auth-locked) #appShell[data-of17="land"] .of17-hud-tools .premium-global-tools { padding: 2px !important; border-radius: 10px !important; }
html body:not(.auth-locked) #appShell[data-of17="land"] .of17-hud-tools .premium-global-tools button { height: 26px; min-width: 26px; }
html body:not(.auth-locked) #appShell[data-of17="land"] .of17-hud-tools .premium-locale-option { width: 24px; min-width: 24px; height: 24px; }
html body:not(.auth-locked) #appShell[data-of17] .of17-hud .stats { justify-content: flex-start !important; }
html body:not(.auth-locked).of17-collapsed #appShell[data-of17="desk"] .premium-locale-group { flex-direction: column; }
html body:not(.auth-locked).of17-collapsed #appShell[data-of17="desk"] .premium-global-tools { padding: 6px 2px !important; }
html body:not(.auth-locked) .of-restore-ws-btn { display: none !important; }

/* La tarjeta conserva los mismos controles en pantalla completa nativa y en el diálogo. */
.card-fullscreen-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}
.card-fullscreen-dialog::backdrop {
  background: var(--panel, #101827);
}
#appShell .flashcard.is-card-fullscreen {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0 !important;
  border-radius: 0 !important;
  padding-top: max(64px, calc(env(safe-area-inset-top) + 56px));
}
#appShell .flashcard #fsExitBtn {
  display: none;
}
#appShell .flashcard.is-card-fullscreen #fsExitBtn {
  position: absolute;
  z-index: 2;
  inset: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) auto auto;
  display: grid;
  place-items: center;
  min-height: 40px;
  max-width: 47%;
  margin: 0;
  padding: 4px 10px;
  font-size: .76rem;
  line-height: 1.2;
}
#appShell .flashcard.is-card-fullscreen .card-title {
  top: max(22px, calc(env(safe-area-inset-top) + 36px));
}
@media (max-width: 720px) {
  #appShell .flashcard.is-card-fullscreen {
    padding-bottom: max(96px, calc(env(safe-area-inset-bottom) + 88px));
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  #appShell .flashcard.is-card-fullscreen .fullscreen-controls {
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
  }
}

/* Resultados separa la cabecera del contenido desplazable. */
#studentDashboard:not([hidden]) {
  --results-width: 1120px;
  --results-gutter: clamp(18px, 5.5vw, 28px);
  --results-surface: #f5f6f8;
  --results-shadow: 0 6px 20px rgba(29, 47, 73, .09);
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  align-content: stretch;
  gap: 0;
  inset: 0;
  inline-size: auto;
  min-block-size: 0;
  padding: 0;
  overflow: hidden;
}
#studentDashboard.dashboard-dark {
  --results-surface: #0c1322;
  --results-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}
#studentDashboard > :is(.dashboard-top, .dashboard-scroll) {
  inline-size: 100%;
  max-inline-size: none;
  min-inline-size: 0;
  padding-inline:
    max(var(--results-gutter), env(safe-area-inset-left))
    max(var(--results-gutter), env(safe-area-inset-right));
}
#studentDashboard .dashboard-top {
  padding-block: calc(10px + env(safe-area-inset-top)) 10px;
  background: var(--results-surface);
  border-bottom: 1px solid var(--border-subtle);
  container: results / inline-size;
}
#studentDashboard .dashboard-scroll {
  min-block-size: 0;
  padding-block: 14px max(24px, env(safe-area-inset-bottom));
  overflow: hidden auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-gutter: stable both-edges;
  scrollbar-color: color-mix(in srgb, var(--brand-gold) 72%, var(--border-subtle)) transparent;
}
#studentDashboard .dashboard-scroll:focus-visible {
  outline: 2px solid var(--brand-gold);
  outline-offset: -2px;
}
@media (prefers-reduced-motion: reduce) {
  #studentDashboard .dashboard-scroll { scroll-behavior: auto; }
}
#studentDashboard :is(.dashboard-hero, .dashboard-content) {
  max-inline-size: var(--results-width);
  min-inline-size: 0;
  margin-inline: auto;
}
#studentDashboard .dashboard-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  container: results / inline-size;
}
#studentDashboard .dashboard-top .dashboard-hero,
#studentDashboard .dashboard-content :is(.dashboard-panel, .dashboard-encouragement, .dashboard-metrics article) {
  box-shadow: var(--results-shadow) !important;
}
#studentDashboard .dashboard-top .dashboard-hero {
  grid-template-columns: minmax(0, 1fr) minmax(0, auto);
  padding: 10px;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
#studentDashboard:not(.dashboard-dark) .dashboard-top .dashboard-hero {
  background: #fff !important;
}
#studentDashboard.dashboard-dark .dashboard-top .dashboard-hero {
  background: #111929 !important;
}
#studentDashboard .student-profile-card::after {
  opacity: .2 !important;
}
#studentDashboard .student-profile-card > * {
  position: relative;
  z-index: 1;
}
#studentDashboard .student-profile-card {
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
  overflow-wrap: anywhere;
}
#studentDashboard .student-avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
}
#studentDashboard .student-profile-card h2 {
  font-size: clamp(1rem, 2vw, 1.32rem);
  line-height: 1.2;
}
#studentDashboard .student-profile-card p {
  font-size: .78rem;
  line-height: 1.25;
}
#studentDashboard .student-profile-card .eyebrow {
  font-size: .67rem;
}
#studentDashboard .dashboard-hero-actions {
  min-width: 0;
  gap: 6px;
}
#studentDashboard .dashboard-hero-actions > * {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
}
#studentDashboard .of-dashboard-intro {
  padding-top: 0;
  line-height: 1.35;
  flex-wrap: wrap;
  gap: 6px;
}
#studentDashboard .dashboard-panel-head {
  flex-wrap: wrap;
}
#studentDashboard .dashboard-panel-head > * {
  min-inline-size: 0;
  max-inline-size: 100%;
  overflow-wrap: anywhere;
}
#studentDashboard :is(.dashboard-metrics, .dashboard-grid, .dashboard-visual-grid) > * {
  min-width: 0;
  overflow-wrap: anywhere;
}
#studentDashboard .dashboard-visual-grid {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, .85fr) minmax(0, 1fr);
}
#studentDashboard .dashboard-grid {
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
}
#studentDashboard .dashboard-encouragement {
  grid-template-columns: 52px minmax(0, 1fr) minmax(0, auto);
  gap: 10px;
  margin-block: 0;
  padding: 12px;
  min-height: 0;
}
#studentDashboard .dashboard-encouragement-copy p {
  margin-top: 4px;
  font-size: .88rem;
}
#studentDashboard .dashboard-encouragement-chip {
  margin-top: 8px;
  padding: 5px 9px;
  font-size: .78rem;
}
#studentDashboard .dashboard-encouragement-action {
  grid-column: auto;
  max-width: min(100%, 170px);
  white-space: normal;
}
@container results (max-width: 1080px) {
  #studentDashboard .dashboard-visual-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #studentDashboard .dashboard-visual-grid > :last-child {
    grid-column: 1 / -1;
  }
}
@container results (max-width: 725px) {
  #studentDashboard .dashboard-top .dashboard-hero {
    grid-template-columns: minmax(0, 1fr);
  }
  #studentDashboard .dashboard-hero-actions {
    justify-content: flex-start;
  }
  #studentDashboard :is(.dashboard-visual-grid, .dashboard-grid) {
    grid-template-columns: minmax(0, 1fr);
  }
  #studentDashboard .dashboard-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #studentDashboard .dashboard-metrics > :first-child {
    grid-column: 1 / -1;
  }
}
@container results (max-width: 608px) {
  #studentDashboard .dashboard-encouragement {
    grid-template-columns: 46px minmax(0, 1fr);
  }
  #studentDashboard .dashboard-encouragement-action {
    grid-column: 2;
    justify-self: start;
  }
}

.games-dialog {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--bg-primary);
  overflow: hidden;
}
#gamesFrame { display: block; width: 100%; height: 100%; border: 0; }
