/* ==========================================================================
   BULLDER · ejercicios (biblioteca, detalle, selector y ejercicios propios).
   Prefijo propio: exl-  ·  Solo variables del núcleo (oscuro y claro).
   ========================================================================== */

/* ------------------------------------------------------------------ miniaturas */
/* Marcador de thumb() cuando el ejercicio no tiene portada (ejercicios propios). */
.ex-thumb.exl-ph { display: inline-grid; place-items: center; background: var(--surface-2); color: var(--text-3); }
.ex-thumb.exl-ph .ic { width: 46%; height: 46%; }
/* En las listas del módulo la portada va apaisada: las imágenes son 16:9 y así no se recorta al modelo. */
.ex-thumb.exl-thumb { width: 78px; height: 56px; border-radius: 12px; box-shadow: 0 0 0 1px var(--line); }

/* ------------------------------------------------------------------ buscador y chips */
.exl-search .input { min-height: 46px; padding-right: 46px; }
.exl-search input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.exl-search .input-suffix { width: 38px; height: 38px; color: var(--text-3); }
.chip.exl-chip-soft.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.chip.exl-chip-soft.is-active .ic { color: var(--accent); }
.chip .exl-chip-n { font: 600 12px/1 var(--font); color: var(--text-3); font-variant-numeric: tabular-nums; }
.chip.is-active .exl-chip-n { color: inherit; opacity: .7; }
.chip[disabled] { opacity: .4; pointer-events: none; }

/* ------------------------------------------------------------------ filas */
.exl-row { display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 10px 0; position: relative; color: inherit; -webkit-touch-callout: none; user-select: none; }
.exl-row-main { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.exl-row-name { font: 600 15.5px/1.25 var(--font); color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.exl-row-sub { font-size: 13px; line-height: 1.3; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exl-row-sub b { font-weight: 600; color: var(--text); }
.exl-row-end { display: flex; align-items: center; gap: 8px; flex: none; color: var(--text-3); }
.exl-fav { color: var(--accent); display: inline-flex; }
.exl-sentinel { height: 1px; grid-column: 1 / -1; }
.exl-sec { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 18px 0 6px; font: 700 11.5px/1 var(--font); letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); }
.exl-sec:first-child { padding-top: 14px; }
.exl-sec-n { letter-spacing: 0; font-variant-numeric: tabular-nums; }
.exl-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; padding-bottom: 12px; }
.exl-empty .empty { padding-bottom: 12px; }
.exl-empty.empty .btn-ghost { margin-top: 0; }

/* ------------------------------------------------------------------ biblioteca */
.exl-lib-top {
  position: sticky; top: calc(var(--topbar-h) + var(--safe-t)); z-index: 20;
  margin: calc(var(--sp-4) * -1) calc(var(--sp-4) * -1) 0; padding: 4px var(--sp-4) 10px;
  display: flex; flex-direction: column; gap: 10px;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
}
.exl-lib-quick { margin-top: 4px; }
.exl-lib-bar { margin: 8px 0 0; min-height: 36px; }
.exl-count { font: 600 13px/1.2 var(--font); color: var(--text-2); font-variant-numeric: tabular-nums; }
.exl-sort { margin-right: -10px; color: var(--text); }
.exl-sort[disabled] { opacity: 1; color: var(--text-3); }
.exl-grid .exl-row + .exl-row::before { content: ""; position: absolute; top: 0; left: 90px; right: calc(var(--sp-4) * -1); height: 1px; background: var(--line); }
.exl-card { border-radius: var(--r-sm); transition: background .15s; }
.exl-card:active { background: var(--surface); }
.exl-opts { padding-bottom: 6px; }
.exl-opts-intro { margin-bottom: 14px; }
.exl-over { margin: 18px 0 10px; }
.exl-over:first-child { margin-top: 4px; }
.sheet-foot .btn.exl-foot-min { flex: 0 0 auto; }

@media (min-width: 960px) {
  .exl-lib-top { margin: calc(var(--sp-6) * -1) calc(var(--sp-8) * -1) 0; padding: 4px var(--sp-8) 12px; }
  .exl-lib-top .exl-search { max-width: 520px; }
  .exl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); gap: var(--sp-4); margin-top: var(--sp-2); }
  .exl-grid.is-empty { display: block; }
  .exl-grid .exl-row + .exl-row::before { display: none; }
  .exl-card { flex-direction: column; align-items: stretch; gap: 0; min-height: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; transition: transform .15s var(--ease), border-color .15s, box-shadow .15s; }
  .exl-card:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
  .exl-card .ex-thumb.exl-thumb { width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 0; box-shadow: none; display: block; }
  .exl-card .ex-thumb.exl-ph { display: grid; }
  .exl-card .ex-thumb.exl-ph .ic { width: 44px; height: 44px; }
  .exl-card .exl-row-main { padding: 12px 14px 14px; }
  .exl-card .exl-row-name { font-size: 15px; min-height: 2.5em; }
  .exl-card .exl-row-end { position: absolute; top: 10px; right: 10px; }
  .exl-card .exl-chev { display: none; }
  .exl-card .exl-fav { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--navy); color: var(--accent); }
  .exl-card .badge { background: var(--navy); color: #fff; }
}

/* ------------------------------------------------------------------ selector (hoja a pantalla completa) */
.exl-picker .sheet-body { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.exl-pk { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.exl-pk-load { padding: var(--sp-2) var(--sp-4); }
.exl-pk-top { flex: none; display: flex; flex-direction: column; gap: 10px; padding: 2px var(--sp-4) 12px; border-bottom: 1px solid var(--line); }
.exl-pk-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 0 var(--sp-4) var(--sp-4); }
.exl-pk-new { color: var(--accent); gap: 5px; }
.exl-pick { gap: 2px; padding: 0 6px; margin: 0 -6px; min-height: 74px; border-radius: 14px; transition: background .15s; }
.exl-pick + .exl-pick { margin-top: 2px; }
.exl-row-hit { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; min-height: 74px; padding: 8px 0; text-align: left; border-radius: 12px; }
.exl-row-info { color: var(--text-3); width: 44px; height: 44px; }
.exl-row-info:hover { color: var(--text); }
.exl-check { position: relative; isolation: isolate; width: 40px; height: 56px; flex: none; display: grid; place-items: center; font: 700 13px/1 var(--font-display); color: var(--on-accent); font-variant-numeric: tabular-nums; }
.exl-check::before { content: ""; position: absolute; z-index: -1; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 2px solid var(--line-strong); transition: background .15s, border-color .15s, transform .15s var(--ease); }
.exl-pick.is-selected { background: var(--accent-soft); }
.exl-pick.is-selected .exl-check::before { background: var(--accent); border-color: var(--accent); transform: scale(1.08); }
.exl-pick.is-off { opacity: .45; }
.exl-pick.is-off .exl-row-hit { cursor: default; }
.exl-picker .sheet-foot .btn[disabled] { opacity: .4; }

/* ------------------------------------------------------------------ video y etiquetas */
.exl-hero { position: relative; aspect-ratio: 16 / 9; background: var(--media-bg); border-radius: var(--r-lg); overflow: hidden; box-shadow: 0 0 0 1px var(--line); }
.exl-video { width: 100%; height: 100%; object-fit: contain; display: block; background: var(--media-bg); }
video.exl-video { cursor: pointer; }
.exl-hero.is-empty { aspect-ratio: 16 / 7; background: var(--surface); }
.exl-hero.is-empty img.exl-video { background: var(--media-bg); }
.exl-hero-ph { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--text-3); font: 600 13px/1.2 var(--font); }
.exl-play { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--navy) 82%, transparent); color: #fff; transition: transform .15s var(--ease); }
.exl-play .ic { margin-left: 3px; }
.exl-play:active { transform: scale(.92); }
.exl-sex.segmented { position: absolute; right: 10px; bottom: 10px; padding: 3px; gap: 0; border: 0; border-radius: var(--r-full); background: color-mix(in srgb, var(--navy) 10%, #fff); }
.exl-sex.segmented button { min-height: 30px; padding: 0 12px; border-radius: var(--r-full); font-size: 12.5px; color: var(--navy); box-shadow: none; }
.exl-sex.segmented button.is-active { background: var(--navy); color: #fff; }
.exl-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.exl-tag { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 11px; border-radius: var(--r-full); background: var(--surface-2); color: var(--text-2); font: 600 13px/1 var(--font); white-space: nowrap; }
.exl-tag .ic { color: var(--text-3); }
.exl-tag.is-primary { background: var(--accent-soft); color: var(--text); }
.exl-tag.is-primary .ic { color: var(--accent); }
.exl-preview { display: flex; flex-direction: column; gap: 14px; }
.exl-preview .exl-over { margin: 6px 0 12px; }

/* pasos y consejos */
.exl-steps { counter-reset: exl-step; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.exl-steps li { counter-increment: exl-step; position: relative; padding-left: 40px; min-height: 28px; line-height: 1.5; }
.exl-steps li::before { content: counter(exl-step); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); color: var(--text); font: 700 13px/28px var(--font-display); text-align: center; }
.exl-tips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.exl-tips li { display: flex; gap: 12px; line-height: 1.5; }
.exl-tips .ic { color: var(--warn); margin-top: 3px; }

/* ------------------------------------------------------------------ detalle */
.exl-sk-hero { aspect-ratio: 16 / 9; border-radius: var(--r-lg); margin-bottom: var(--sp-5); }
.exl-head { padding-top: var(--sp-4); display: flex; flex-direction: column; gap: 6px; }
.exl-name { font-size: 26px; overflow-wrap: anywhere; }
.exl-name-en { font-size: 13.5px; color: var(--text-3); }
.exl-head .exl-tags { margin-top: 8px; }
.exl-tabs { position: sticky; top: calc(var(--topbar-h) + var(--safe-t)); z-index: 10; gap: 0; margin: var(--sp-4) calc(var(--sp-4) * -1) 0; padding: 0 var(--sp-4); background: var(--bg); }
.exl-tabs button { flex: 1; padding: 14px 4px; text-align: center; }
.exl-panel { padding-top: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); min-height: 240px; }
.exl-panel > .section-head { margin: var(--sp-3) 0 0; }
.exl-panel .sk-card:last-child { margin-bottom: 0; }

.exl-me { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.exl-me-cell { display: flex; flex-direction: column; gap: 5px; padding: 14px 12px; text-align: left; min-width: 0; position: relative; transition: background .15s; }
.exl-me-cell:hover { background: var(--surface-2); }
.exl-me-cell + .exl-me-cell::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 1px; background: var(--line); }
.exl-me-cell b { font: 700 20px/1.15 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exl-me-cell span { font-size: 12px; line-height: 1.25; color: var(--text-3); }
.exl-first { background: var(--surface); border: 1px solid var(--line); align-items: center; }
.exl-first .ic { color: var(--accent); margin-top: 0; }
.exl-first b { display: block; }
.exl-first span { color: var(--text-2); }
.exl-first span b { color: var(--text); }
.exl-how .card-title { margin-bottom: 16px; }
.exl-how-empty { display: flex; gap: 12px; align-items: flex-start; color: var(--text-2); font-size: 14px; }
.exl-how-empty .ic { color: var(--text-3); }
.exl-facts { padding: 4px var(--sp-4); }
.exl-facts > div { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 12px 0; }
.exl-facts > div + div { border-top: 1px solid var(--line); }
.exl-facts span { font-size: 13px; color: var(--text-3); flex: none; }
.exl-facts b { font-weight: 600; font-size: 14px; text-align: right; }

/* historial */
.exl-ses-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.exl-ses-head { display: flex; align-items: center; gap: 10px; padding: 14px 12px 12px var(--sp-4); color: var(--text-3); transition: background .15s; }
.exl-ses-head:hover { background: var(--surface-2); }
.exl-ses-title { display: block; font: 700 16px/1.25 var(--font-display); color: var(--text); }
.exl-ses-sub { display: block; margin-top: 3px; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.exl-ses-note { display: flex; gap: 8px; margin: 0 var(--sp-4) 8px; padding: 9px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13.5px; color: var(--text-2); }
.exl-ses-note .ic { margin-top: 2px; color: var(--text-3); }
.exl-sets { list-style: none; margin: 0; padding: 0 0 10px; border-top: 1px solid var(--line); }
.exl-set { display: grid; grid-template-columns: 34px minmax(0, 1fr) 58px; align-items: center; column-gap: 10px; padding: 6px var(--sp-4); min-height: 38px; }
.exl-set-main { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px; min-width: 0; }
.exl-set.is-head { min-height: 0; padding-top: 12px; padding-bottom: 4px; font: 700 10.5px/1 var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.exl-set.is-head span:first-child { text-align: center; }
.exl-set.is-head span:last-child { text-align: right; white-space: nowrap; }
.exl-set-n { width: 28px; height: 28px; margin: 0 auto; border-radius: 50%; background: var(--surface-2); font: 700 13px/28px var(--font-display); text-align: center; font-variant-numeric: tabular-nums; }
.exl-set-v { font: 600 15px/1.3 var(--font); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exl-set-v small { margin-left: 8px; font: 500 12px/1 var(--font); color: var(--text-3); }
.badge.exl-set-pr { height: 24px; }
.exl-set-pr .ic { width: 13px; height: 13px; }
.exl-set-e { text-align: right; font-size: 13.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.exl-set.is-warmup .exl-set-v { color: var(--text-2); font-weight: 500; }
.exl-more:empty { display: none; }
.exl-more .spinner { margin: 12px auto; }

/* récords */
.exl-recs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.exl-rec { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 14px var(--sp-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); transition: border-color .15s, transform .12s var(--ease); }
.exl-rec:hover { border-color: var(--line-strong); }
.exl-rec:active { transform: scale(.985); }
.exl-rec:last-child:nth-child(even) { grid-column: 1 / -1; }
.exl-rec-label { display: flex; align-items: flex-start; gap: 6px; font: 600 12px/1.3 var(--font); color: var(--text-3); min-height: 2.6em; }
.exl-rec-label .ic { color: var(--pr); flex: none; margin-top: -1px; }
.exl-rec-value { font: 700 23px/1.1 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.exl-rec-sub { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.exl-rec.is-top { grid-column: 1 / -1; background: color-mix(in srgb, var(--pr) 9%, var(--surface)); border-color: color-mix(in srgb, var(--pr) 38%, transparent); }
.exl-rec.is-top .exl-rec-label { min-height: 0; color: var(--text-2); font-size: 13px; }
.exl-rec.is-top .exl-rec-value { font-size: 36px; }
.exl-rm-row { display: grid; grid-template-columns: 46px minmax(0, 1.25fr) minmax(0, 1fr) 68px; align-items: center; column-gap: 10px; padding: 0 var(--sp-4); min-height: 44px; font-variant-numeric: tabular-nums; }
.exl-rm-row.no-est { grid-template-columns: 46px minmax(0, 1.25fr) minmax(0, 1fr); }
.exl-rm-row + .exl-rm-row { border-top: 1px solid var(--line); }
a.exl-rm-row:hover { background: var(--surface-2); }
.exl-rm-row.is-head { min-height: 38px; font: 700 10.5px/1 var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.exl-rm-row > span:last-child { text-align: right; }
.exl-rm-row.no-est > span:last-child { text-align: left; }
.exl-rm-n { font: 700 15px/1 var(--font-display); }
.exl-rm-w { font-weight: 650; }
.exl-rm-w small { font-weight: 500; color: var(--text-3); }
.exl-rm-d { font-size: 13px; color: var(--text-2); }
.exl-rm-e { font-size: 13.5px; color: var(--text-3); }
.exl-rm-row.is-none .exl-rm-n, .exl-rm-row.is-none .exl-rm-w { color: var(--text-3); font-weight: 500; }
.exl-foot-note { font-size: 12.5px; line-height: 1.45; color: var(--text-3); padding: 0 2px; }

/* gráficas */
.exl-chart-card { display: flex; flex-direction: column; gap: 14px; }
.exl-chart-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.exl-chart-head .stat-value { font-size: 28px; margin-top: 4px; }
.exl-chart-head .stat-delta { margin: 0 0 5px; font-size: 13px; gap: 5px; white-space: nowrap; }
.exl-chart-card [data-chart] { transition: opacity .15s; min-height: 220px; }
.exl-chart-card [data-chart].is-loading { opacity: .45; }
.exl-chart-none { height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text-3); font-size: 14px; }
.exl-range.segmented { background: var(--surface-2); border: 0; }
.exl-range.segmented button { min-height: 34px; padding: 0 2px; font-size: 13px; white-space: nowrap; }
.exl-chart-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
.exl-chart-stats:empty { display: none; }
.exl-chart-stats .stat { padding: 12px 12px; }
.exl-chart-stats .stat-value { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exl-stat-foot { margin-top: 4px; font-size: 12px; color: var(--text-3); }

@media (min-width: 960px) {
  .exl-detail { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--sp-8); align-items: start; }
  .exl-detail-side { position: sticky; top: calc(var(--topbar-h) + var(--sp-6)); }
  .exl-name { font-size: 30px; }
  .exl-tabs { margin: 0; padding: 0; top: var(--topbar-h); }
  .exl-tabs button { padding-top: 6px; }
}

/* ------------------------------------------------------------------ formulario de ejercicio propio */
.exl-form { display: flex; flex-direction: column; gap: var(--sp-4); }
.exl-form-page { max-width: 560px; margin: 0 auto; }
.exl-form-intro { margin-bottom: var(--sp-5); font-size: 14px; }
.exl-form-row { min-height: 64px; }
.exl-form-row .li-sub { color: var(--text-3); }
.exl-form-row .li-sub.is-set { color: var(--accent); font-weight: 600; }
.exl-form-row.is-invalid .li-sub { color: var(--danger); font-weight: 600; }
.exl-form-row.is-invalid .li-icon { background: var(--danger-soft); color: var(--danger); }
.exl-form-row[disabled] { cursor: default; }
.exl-form-row[disabled] .li-title { color: var(--text-2); }
.exl-form .field-hint { margin-top: -8px; }
.exl-form-save { margin-top: var(--sp-6); }
