/* ============ LIBRARY VIEW (full page) ============ */
.lib-view { grid-column: 2 / 4; } /* ocupa main + panel derecho */

/* Stats bar */
.lib-stats {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg-panel) 55%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.lib-stat {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  min-width: 100px;
  text-align: left;
  transition: all 0.15s;
}
.lib-stat:hover { background: var(--bg-hover); }
.lib-stat.active {
  background: var(--bg-elev);
  border-color: var(--line-strong);
}
.lib-stat-num {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.theme-cuaderno .lib-stat.active .lib-stat-num { color: var(--accent); }
.theme-cancha .lib-stat.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.theme-cancha .lib-stat.active .lib-stat-num { color: var(--accent-fg); }
.theme-playful .lib-stat.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.theme-playful .lib-stat.active .lib-stat-num { color: var(--accent-fg); }
.theme-playful .lib-stat.active .lib-stat-label { color: var(--accent-fg); opacity: 0.9; }
.theme-cancha .lib-stat.active .lib-stat-label { color: var(--accent-fg); opacity: 0.85; }

.lib-stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
  margin-top: 4px;
}
.lib-stat-spacer { flex: 1; }
.lib-search-big {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  min-width: 320px;
}
.lib-search-input {
  background: none; border: none; outline: none;
  color: var(--fg);
  font-size: 13px;
  flex: 1;
}
.lib-search-input::placeholder { color: var(--fg-muted); }

/* Drafts strip (borradores guardados desde ActivityEditor, aún sin publicar) */
.lib-drafts {
  padding: 16px 28px 4px;
  border-bottom: 1px solid var(--line);
}
.lib-drafts-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.lib-drafts-title {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--fg-muted);
  text-transform: uppercase;
}
.lib-drafts-count {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--amarillo);
  color: #1a1200;
}
.lib-drafts-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 14px;
}
.lib-draft-card {
  display: flex; align-items: center; gap: 10px;
  flex: 0 0 auto;
  min-width: 220px;
  padding: 8px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-panel);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.lib-draft-card:hover { background: var(--bg-hover); border-color: var(--fg-muted); }
.lib-draft-thumb {
  width: 32px; height: 32px; flex: 0 0 auto;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  border: 1px solid var(--line);
}
.lib-draft-main { min-width: 0; flex: 1; }
.lib-draft-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lib-draft-meta {
  font-size: 10px;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  margin-top: 1px;
}
.lib-draft-delete {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border: none; background: none;
  color: var(--fg-muted);
  border-radius: 50%;
  cursor: pointer;
}
.lib-draft-delete:hover { background: var(--bg-elev); color: var(--fg); }

/* Featured strip */
.lib-featured {
  padding: 20px 28px 4px;
  border-bottom: 1px solid var(--line);
}
.lib-featured-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.lib-featured-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.005em;
}
.theme-cancha .lib-featured-title { text-transform: uppercase; }
.theme-cuaderno .lib-featured-title { font-style: italic; font-weight: 500; }

.lib-featured-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  padding-bottom: 16px;
}
.lib-featured-card {
  display: flex; flex-direction: column;
  gap: 8px;
  cursor: pointer;
}
.lib-featured-thumb {
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  position: relative;
  display: grid; place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
}
.lib-featured-thumb::before {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, transparent 0 8px, rgba(255,255,255,0.06) 8px 9px);
}
.lib-featured-letter {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.03em;
  position: relative; z-index: 1;
}
.lib-featured-uses {
  position: absolute;
  top: 8px; right: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  z-index: 2;
}
.theme-cuaderno .lib-featured-uses { background: var(--fg); color: var(--bg-panel); }
.theme-playful .lib-featured-uses { background: var(--fg); }

.lib-featured-name {
  font-size: 13px; font-weight: 600;
  letter-spacing: -0.005em;
}
.lib-featured-meta {
  font-size: 11px;
  color: var(--fg-muted);
  font-family: var(--font-mono);
}

/* Filter toolbar */
.lib-toolbar {
  display: flex; align-items: center; gap: 20px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  background: color-mix(in oklab, var(--bg-panel) 55%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.lib-filter-group {
  display: flex; align-items: center; gap: 6px;
}
.lib-filter-right { margin-left: auto; }
.lib-filter-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-muted);
  margin-right: 4px;
}
.lib-select {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  color: var(--fg);
  font-size: 12px;
  outline: none;
  font-family: var(--font-body);
}
.lib-select:hover { background: var(--bg-hover); }

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-left: 8px;
}
.view-btn {
  padding: 6px 10px;
  color: var(--fg-muted);
  background: var(--bg-elev);
  display: grid; place-items: center;
}
.view-btn:hover { color: var(--fg); background: var(--bg-hover); }
.view-btn.active { background: var(--fg); color: var(--bg); }
.theme-cancha .view-btn.active { background: var(--accent); color: var(--accent-fg); }

/* Results head */
.lib-results-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 28px 8px;
}
.lib-results-count { font-size: 13px; color: var(--fg-dim); }
.lib-results-count {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.lib-results-count b {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--fg);
  font-weight: 700;
}
.lib-clear {
  font-size: 12px;
  color: var(--fg-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.lib-clear:hover { color: var(--fg); }

/* Grid */
.lib-scroll { flex: 1; overflow-y: auto; padding: 0 28px 24px; }
.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

/* Activity card */
.act-card {
  display: flex; flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.15s;
}
.act-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}
.theme-playful .act-card:hover { box-shadow: 0 8px 20px rgba(91,92,245,0.12); }
.theme-cuaderno .act-card { box-shadow: 1px 2px 0 rgba(63,44,20,0.05); }

.act-thumb {
  aspect-ratio: 16 / 9;
  position: relative;
  display: grid; place-items: center;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.act-thumb::before {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, transparent 0 8px, rgba(255,255,255,0.08) 8px 9px);
}
.theme-cuaderno .act-thumb::before {
  background: repeating-linear-gradient(45deg, transparent 0 8px, rgba(0,0,0,0.05) 8px 9px);
}

/* Color-tinted thumbnails */
.color-coral { background: color-mix(in oklab, var(--coral) 22%, var(--bg-panel)); }
.color-azul { background: color-mix(in oklab, var(--azul) 22%, var(--bg-panel)); }
.color-verde { background: color-mix(in oklab, var(--verde) 22%, var(--bg-panel)); }
.color-amarillo { background: color-mix(in oklab, var(--amarillo) 22%, var(--bg-panel)); }

.act-thumb-letter {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -0.04em;
  position: relative;
  z-index: 1;
  color: var(--fg);
  opacity: 0.85;
}
.act-thumb-badges {
  position: absolute;
  bottom: 8px; left: 8px;
  display: flex; gap: 4px;
  z-index: 2;
}
.act-cat-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--line);
}
.act-cat-badge.cat-calentamiento { background: var(--amarillo); color: #2b1e0e; border-color: transparent; }
.act-cat-badge.cat-principal { background: var(--verde); color: #0e1a14; border-color: transparent; }
.act-cat-badge.cat-vuelta { background: var(--azul); color: #0e1a14; border-color: transparent; }
.act-cat-badge.small { font-size: 8px; padding: 2px 5px; }

.act-own-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--fg);
  color: var(--bg);
}
.act-own-badge.small { font-size: 8px; padding: 2px 5px; }

.act-fav {
  position: absolute;
  top: 8px; right: 8px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(0,0,0,0.4);
  color: #fff;
  display: grid; place-items: center;
  z-index: 2;
  transition: all 0.15s;
}
.theme-cuaderno .act-fav { background: rgba(255,255,255,0.7); color: var(--fg-dim); }
.act-fav:hover { background: var(--coral); color: #fff; }
.act-fav.on { background: var(--coral); color: #fff; }

.act-body {
  padding: 14px 16px 16px;
  display: flex; flex-direction: column;
  gap: 10px;
}
.act-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
}
.theme-cancha .act-name { text-transform: uppercase; letter-spacing: -0.005em; }
.theme-cuaderno .act-name { font-weight: 500; }

.act-skill {
  font-size: 11px;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: -6px;
}

.act-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.act-stat {
  display: flex; flex-direction: column;
  align-items: center; text-align: center;
  gap: 2px;
}
.act-stat-num {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.act-stat-unit {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--fg-muted);
  letter-spacing: 0.12em;
}

.act-meta {
  display: flex; flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--fg-dim);
}
.act-meta span { display: inline-flex; align-items: center; gap: 5px; }

.act-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 4px;
}
.act-footer .intensity-dots {
  font-size: 10px;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.act-use {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--fg);
  color: var(--bg);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: all 0.15s;
}
.theme-cancha .act-use { background: var(--accent); color: var(--accent-fg); text-transform: uppercase; }
.theme-cuaderno .act-use { background: var(--accent); color: #fff; }
.theme-playful .act-use { background: var(--accent); color: var(--accent-fg); }
.act-use:hover { transform: translateX(2px); filter: brightness(1.1); }
.act-use.small { padding: 5px 10px; font-size: 10px; }

/* List view */
.lib-list-view {
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.act-row {
  display: grid;
  grid-template-columns: 44px 1fr auto 70px 80px 80px 60px 44px auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--line);
  transition: background 0.15s;
}
.act-row:last-child { border-bottom: none; }
.act-row:hover { background: var(--bg-hover); }
.act-row-thumb {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  color: var(--fg);
  opacity: 0.85;
  border: 1px solid var(--line);
}
.act-row-main { min-width: 0; }
.act-row-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  display: flex; align-items: center; gap: 8px;
}
.act-row-fav { color: var(--coral); font-size: 14px; }
.act-row-skill {
  font-size: 11px;
  color: var(--fg-muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}
.act-row-col {
  font-size: 12px;
  color: var(--fg-dim);
}
.act-row-col.mono { font-family: var(--font-mono); font-size: 11px; }
.act-row-col.big {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--fg);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.act-row-col.big small {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  color: var(--fg-muted);
  margin-left: 2px;
  letter-spacing: 0.08em;
}

.lib-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--fg-muted);
}
.lib-empty-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--fg-dim);
  margin-bottom: 6px;
}
.lib-empty-sub {
  font-size: 13px;
  color: var(--fg-muted);
}

/* ============================================================ */
/* ============ RESPONSIVE — TABLET (768px – 1279px) ========== */
/* ============================================================ */
@media (max-width: 1279px) {
  /* .app pasa a 2 columnas (76px 1fr) — .lib-view ya no debe intentar
     ocupar un 3er tramo que no existe */
  .lib-view { grid-column: 2; }

  .lib-featured-row { grid-template-columns: repeat(3, 1fr); }
  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

  /* La fila de lista con 9 columnas fijas no cabe: se reduce a lo esencial
     (miniatura, nombre, fase, intensidad, duración, acción). Hijos de
     .act-row en orden: 1 thumb, 2 main, 3 cat, 4 edad, 5 espacio,
     6 intensidad, 7 duración, 8 usos, 9 botón. Ocultamos 4, 5 y 8. */
  .act-row {
    grid-template-columns: 40px 1fr auto 44px 60px auto;
  }
  .act-row > :nth-child(4),
  .act-row > :nth-child(5),
  .act-row > :nth-child(8) {
    display: none;
  }
}

/* ============================================================ */
/* ============ RESPONSIVE — MOBILE (< 768px) ================== */
/* ============================================================ */
@media (max-width: 767px) {
  /* .app pasa a display:block en móvil (ver styles.css) — .lib-view ocupa
     todo el ancho a pantalla completa */
  .lib-view { grid-column: auto; width: 100%; height: 100vh; }

  .lib-stats { flex-wrap: wrap; padding: 12px 16px; gap: 8px; }
  .lib-search-big { min-width: 0; width: 100%; order: 10; }
  .lib-stat { padding: 8px 10px; min-width: 0; }

  .lib-featured { padding: 14px 16px 4px; }
  .lib-featured-row { grid-template-columns: repeat(2, 1fr); }

  .lib-drafts { padding: 12px 16px 4px; }
  .lib-draft-card { min-width: 180px; }

  .lib-toolbar { padding: 10px 16px; gap: 10px; }
  .lib-filter-right { margin-left: 0; }

  .lib-results-head { padding: 12px 16px 6px; }
  .lib-scroll { padding: 0 16px 20px; }

  .lib-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }

  /* La vista de lista con columnas tabulares no es viable en móvil:
     se reduce a miniatura + nombre + duración (3 columnas). El botón
     "Usar" ya no cabe con comodidad, se oculta y basta con pulsar la fila. */
  .act-row {
    grid-template-columns: 40px 1fr auto;
    gap: 10px;
    padding: 10px 12px;
  }
  .act-row > :nth-child(3),
  .act-row > :nth-child(4),
  .act-row > :nth-child(5),
  .act-row > :nth-child(6),
  .act-row > :nth-child(8),
  .act-row > :nth-child(9) {
    display: none;
  }
}
