/* ============================================================
   LIBRARY SUBPAGE (Vollbild statt Popup)
   ============================================================ */
#library-page {
  position: fixed; inset: 0; z-index: 400;
  background: var(--bg-base);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: libFade .25s ease;
}
#library-page.hidden { display: none; }
@keyframes libFade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.lib-page-header {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 24px;
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.lib-page-title-block { flex: 1; min-width: 0; }
.lib-page-title {
  font-family: var(--font-display); font-size: 28px; font-weight: 800;
  color: var(--text-primary); margin: 0; letter-spacing: -.01em;
}
.lib-page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.lib-page-back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r-md);
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 13px; font-weight: 600;
  transition: background .12s, color .12s, transform .12s;
}
.lib-page-back-btn:hover { background: var(--bg-hover); color: var(--text-primary); transform: translateX(-2px); }

.lib-page-stats {
  display: flex; gap: 18px;
  font-size: 12px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.lib-page-stats strong { color: var(--text-primary); font-weight: 700; }

/* Hauptlayout: Sidebar (Tabs) + Content */
.lib-page-body { flex: 1; display: flex; overflow: hidden; }
.lib-page-side {
  width: 220px; flex-shrink: 0;
  background: var(--bg-surface); border-right: 1px solid var(--border);
  padding: 16px 8px; overflow-y: auto;
}
.lib-side-section {
  font-family: var(--font-display); font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted); padding: 8px 12px 4px;
}
.lib-side-btn {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 12px; border-radius: var(--r-md);
  font-size: 13px; color: var(--text-secondary);
  border: none; background: none; cursor: pointer;
  transition: background .12s, color .12s, transform .15s;
}
.lib-side-btn:hover { background: var(--bg-elevated); color: var(--text-primary); }
.lib-side-btn.active {
  background: var(--brand-subtle); color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand-glow);
}
.lib-side-btn .lib-side-count {
  margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums;
  background: var(--bg-elevated); padding: 1px 6px; border-radius: var(--r-full);
  color: var(--text-muted);
}
.lib-side-btn.active .lib-side-count { background: var(--bg-base); color: var(--brand); }

.lib-page-content {
  flex: 1; overflow-y: auto;
  padding: 20px 24px 80px;
  background: var(--bg-base);
}

.lib-toolbar {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap;
}
.lib-search {
  display: flex; align-items: center; gap: 8px;
  width: 280px; flex: 0 0 auto;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 9px 14px;
  transition: border-color .12s, box-shadow .12s;
}
.lib-search input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 14px; color: var(--text-primary);
}
.lib-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }

.lib-filter-pills { display: flex; gap: 4px; }
.lib-filter-pill {
  padding: 6px 12px; border-radius: var(--r-full);
  background: var(--bg-elevated); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  cursor: pointer; transition: background .12s, color .12s, border-color .12s;
}
.lib-filter-pill:hover { color: var(--text-primary); }
.lib-filter-pill.active {
  background: var(--brand-subtle); border-color: var(--brand);
  color: var(--brand);
}

.lib-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 18px;
}

.lib-page-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
  transition: transform .18s ease, border-color .18s, box-shadow .18s;
  cursor: pointer; display: flex; flex-direction: column;
  animation: cardPop .25s ease backwards;
}
@keyframes cardPop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.lib-page-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand-glow);
  box-shadow: 0 8px 22px rgba(0,0,0,.30);
}
/* Playbook-Karten: dezenterer Hover (große Zahl darin sonst zu unruhig) */
.lib-pb-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.lib-page-card.active { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-glow); }

.lib-page-card-thumb {
  background: var(--bg-base); aspect-ratio: 16/9;
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--border-muted); position: relative;
  overflow: hidden;
}
.lib-page-card-thumb svg { width: 100%; height: 100%; display: block; }
.lib-thumb-svg { width: 100%; height: 100%; display: block; }
.lib-thumb-svg svg { width: 100%; height: 100%; display: block; }

.lib-page-card-side {
  position: absolute; top: 8px; left: 8px;
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase;
  padding: 3px 8px; border-radius: var(--r-full);
  background: rgba(13,17,23,0.85); backdrop-filter: blur(4px);
}
.lib-page-card-side.offense { color: #4ADE80; }
.lib-page-card-side.defense { color: #EF4444; }

.lib-page-card-body {
  padding: 10px 12px 12px; flex: 1;
  display: flex; flex-direction: column; gap: 4px;
}
.lib-page-card-name {
  font-size: 14px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lib-page-card-meta { font-size: 11px; color: var(--text-muted); }
.lib-page-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.lib-page-card-tag {
  font-size: 10px; padding: 1px 6px; border-radius: var(--r-full);
  background: var(--bg-elevated); color: var(--text-secondary);
}
.lib-page-card-actions {
  display: flex; gap: 6px; margin-top: 10px;
  border-top: 1px solid var(--border-muted); padding-top: 10px;
}
.lib-page-card-actions .lib-mini-btn {
  flex: 0 0 auto; font-size: 12px; padding: 7px 10px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-secondary); border-radius: var(--r-sm);
  cursor: pointer; transition: background .12s, color .12s, border-color .12s;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  font-weight: 500;
}
.lib-page-card-actions .lib-action-primary {
  flex: 1 1 auto; background: var(--brand-subtle); color: var(--brand);
  border-color: var(--brand-glow); font-weight: 600;
}
.lib-page-card-actions .lib-action-primary:hover {
  background: var(--brand); color: white; border-color: var(--brand);
}
.lib-page-card-actions .lib-mini-btn.active {
  background: var(--brand-subtle); color: var(--brand);
  border-color: var(--brand-glow);
}
.lib-page-card-actions .lib-mini-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.lib-page-card-actions .lib-mini-btn.danger:hover { background: var(--danger); color: white; border-color: var(--danger); }

.lib-page-empty {
  text-align: center; padding: 80px 24px;
  color: var(--text-muted);
}
.lib-page-empty-icon {
  width: 56px; height: 56px;
  margin: 0 auto 14px; opacity: .35;
}
.lib-page-empty-title { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.lib-page-empty-sub { font-size: 13px; }


/* ============================================================
   LIBRARY HEADER TOOLS (Theme + BG-Toggle + New-Play)
   ============================================================ */
.lib-page-header-tools {
  display: flex; align-items: center; gap: 8px;
}
.lib-page-header-tools .btn-icon {
  width: 32px; height: 32px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-secondary);
}
.lib-page-header-tools .btn-icon:hover {
  background: var(--bg-hover); color: var(--text-primary);
  border-color: var(--brand-glow);
}
.lib-bg-toggle:hover svg, .lib-theme-toggle:hover svg { transform: scale(1.08); transition: transform .15s; }

/* ============================================================
   PROMINENTE SIDE-TABS (All / Offense / Defense)
   ============================================================ */
.lib-side-tabs {
  display: flex; gap: 8px;
  margin-bottom: 14px;
  padding: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  width: fit-content;
}
.lib-side-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  background: none; border: none; cursor: pointer;
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--r-sm);
  transition: background .12s, color .12s, transform .12s;
}
.lib-side-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.lib-side-tab.active {
  background: var(--bg-base); color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}
.lib-side-tab.side-off.active { color: #16A34A; }
.lib-side-tab.side-def.active { color: #DC2626; }
[data-theme="light"] .lib-side-tab.side-off.active { color: #15803D; }
[data-theme="light"] .lib-side-tab.side-def.active { color: #B91C1C; }

.lib-side-tab-count {
  font-size: 11px; font-variant-numeric: tabular-nums;
  background: var(--bg-elevated); padding: 1px 7px;
  border-radius: var(--r-full); color: var(--text-muted);
  min-width: 20px; text-align: center;
}
.lib-side-tab.active .lib-side-tab-count {
  background: var(--brand-subtle); color: var(--brand);
}

/* ============================================================
   TOOLBAR (Suche + Filter + Größe/Ratio)
   ============================================================ */
.lib-toolbar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 18px; flex-wrap: wrap;
}
.lib-search {
  display: flex; align-items: center; gap: 8px;
  width: 280px;             /* fixe Breite — schmaler als zuvor */
  flex: 0 0 auto;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 8px 12px;
  transition: border-color .15s, box-shadow .15s;
}
.lib-search input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 14px; color: var(--text-primary);
}
.lib-search:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.lib-select {
  appearance: none;
  -webkit-appearance: none;
  height: 42px;
  padding: 0 40px 0 16px;
  background-color: var(--bg-surface);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'><path d='M1 1L5 5L9 1' stroke='%23888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color .12s, border-color .12s, box-shadow .12s;
  min-width: 220px;
}
.lib-select:hover { background-color: var(--bg-elevated); border-color: var(--text-muted); }
.lib-select:focus {
  border-color: var(--brand); outline: none;
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.lib-toolbar-divider {
  width: 1px; height: 24px; background: var(--border);
  margin: 0 4px;
}

.lib-size-group, .lib-ratio-group {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 2px;
}
.lib-size-btn, .lib-ratio-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  padding: 6px 10px;
  border-radius: calc(var(--r-md) - 2px);
  color: var(--text-muted);
  font-size: 12px; font-weight: 600;
  transition: background .12s, color .12s;
}
.lib-size-btn { width: 30px; height: 28px; padding: 0; }
.lib-size-btn:hover, .lib-ratio-btn:hover { color: var(--text-primary); }
.lib-size-btn.active, .lib-ratio-btn.active {
  background: var(--bg-surface); color: var(--brand);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   GRID-GRÖSSEN + RATIO
   ============================================================ */
.lib-page-grid.lib-grid-size-sm { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.lib-page-grid.lib-grid-size-md { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.lib-page-grid.lib-grid-size-lg { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.lib-page-grid.lib-grid-size-xl { grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); }

.lib-page-grid.lib-grid-ratio-16-9 .lib-page-card-thumb { aspect-ratio: 16/9; }
.lib-page-grid.lib-grid-ratio-4-3  .lib-page-card-thumb { aspect-ratio: 4/3; }
.lib-page-grid.lib-grid-ratio-field .lib-page-card-thumb { aspect-ratio: auto; height: auto; }
.lib-page-grid.lib-grid-ratio-field .lib-page-card-thumb svg { width: 100%; height: auto; }

/* ============================================================
   IN-CARD ANIMATION PLAY-BUTTON
   ============================================================ */
.lib-page-card-thumb { position: relative; overflow: hidden; }
.lib-thumb-svg { width: 100%; height: 100%; }
.lib-thumb-svg svg { width: 100%; height: 100%; display: block; }

.lib-thumb-play-btn {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(.85);
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(13,17,23,0.78);
  border: 1.5px solid rgba(255,255,255,0.4);
  color: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  backdrop-filter: blur(6px);
  transition: opacity .2s, transform .2s, background .15s;
  z-index: 3;
}
.lib-page-card:hover .lib-thumb-play-btn {
  opacity: 1; pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
.lib-thumb-play-btn:hover { background: var(--brand); border-color: white; }

.lib-page-card.lib-anim-running .lib-thumb-play-btn {
  opacity: 0.7;
  background: var(--brand);
  animation: libAnimPulse 1.6s ease-in-out infinite;
}
@keyframes libAnimPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(249,115,22,0.5); }
  50%      { box-shadow: 0 0 0 10px rgba(249,115,22,0); }
}


/* Playbook-Karten: große Plays-Anzahl statt generisches Buch-Icon */
.lib-pb-thumb {
  background:
    radial-gradient(ellipse at 50% 30%, var(--brand-subtle), transparent 60%),
    linear-gradient(180deg, var(--bg-base), var(--bg-elevated));
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
}
.lib-pb-count {
  display: flex; flex-direction: column; align-items: center; line-height: 1;
}
.lib-pb-count-num {
  font-family: var(--font-display);
  font-size: 56px; font-weight: 900;
  color: var(--brand);
  letter-spacing: -.02em;
  line-height: 1.1;
  padding: 4px 0;
  text-shadow: 0 0 24px var(--brand-glow);
}
.lib-pb-count-label {
  font-family: var(--font-display);
  font-size: 13px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-muted);
  margin-top: 4px;
}
.lib-pb-split {
  display: flex; gap: 8px; align-items: center;
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  font-family: var(--font-display);
}
.lib-pb-split-off { color: var(--success); }
.lib-pb-split-def { color: var(--danger); }
.lib-pb-split-sep { color: var(--text-muted); opacity: 0.5; }

/* ── Anim-Button in Action-Row (statt Hover-Center) ── */
.lib-action-anim {
  background: var(--brand-2-subtle);
  color: var(--brand-2);
  border-color: var(--brand-2-glow);
}
.lib-action-anim:hover {
  background: var(--brand-2);
  color: white;
  border-color: var(--brand-2);
}
.lib-page-card.lib-anim-running .lib-action-anim {
  background: var(--brand-2);
  color: white;
  animation: libAnimPulse 1.4s ease-in-out infinite;
}

/* ── Tooltip für Icon-only Buttons (data-tooltip) ── */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  font-size: 11px; font-weight: 500;
  padding: 5px 9px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  box-shadow: var(--shadow-md);
  transition: opacity .15s, transform .15s;
  z-index: 100;
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
