/* ═══════════════════════════════════════════════════════════════════════════
   ═══ ★ NEW : Template Library Modal ★ ═══
   ═══════════════════════════════════════════════════════════════════════════ */

.lib-backdrop{position:fixed;inset:0;background:rgba(6,5,14,0.5);backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);z-index:200;opacity:0;pointer-events:none;
  transition:opacity .3s cubic-bezier(.4,0,.2,1);}
.lib-backdrop.open{opacity:1;pointer-events:auto;}

.lib-modal{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%) scale(.96);
  width:min(920px,90vw);height:min(620px,85vh);
  background:var(--glass-strong);backdrop-filter:blur(24px) saturate(1.4);-webkit-backdrop-filter:blur(24px) saturate(1.4);
  border:1px solid var(--glass-border);border-radius:20px;
  box-shadow:0 24px 80px rgba(0,0,0,0.2),var(--glow-lg);
  z-index:201;display:flex;flex-direction:column;overflow:hidden;
  opacity:0;pointer-events:none;transition:all .3s cubic-bezier(.16,1,.3,1);}
.dark .lib-modal{box-shadow:0 24px 80px rgba(0,0,0,0.7),var(--glow-lg);}
.lib-modal.open{opacity:1;transform:translate(-50%,-50%) scale(1);pointer-events:auto;}

.lib-head{display:flex;align-items:center;justify-content:space-between;padding:1rem 1.25rem;
  border-bottom:1px solid var(--glass-border);flex-shrink:0;}
.lib-head-l{display:flex;align-items:center;gap:.7rem;}
.lib-head-title{font-size:.95rem;font-weight:800;color:var(--text);letter-spacing:-.01em;}
.lib-head-sub{font-size:.6rem;color:var(--text-muted);}
.lib-search{display:flex;align-items:center;gap:.5rem;padding:.45rem .75rem;border-radius:10px;
  background:var(--surface);border:1px solid var(--glass-border);width:280px;}
.lib-search input{flex:1;border:none;background:transparent;color:var(--text);font-size:.7rem;
  font-family:inherit;outline:none;}
.lib-search input::placeholder{color:var(--text-muted);}
.lib-search svg{width:13px;height:13px;color:var(--text-muted);}
.lib-close{width:30px;height:30px;border-radius:9px;border:1px solid var(--glass-border);
  background:var(--surface);color:var(--text-muted);cursor:pointer;display:flex;align-items:center;
  justify-content:center;transition:all .2s;}
.lib-close:hover{border-color:var(--red);color:var(--red);}

.lib-body{display:flex;flex:1;overflow:hidden;}

.lib-cats{width:160px;flex-shrink:0;background:var(--glass);border-right:1px solid var(--glass-border);
  padding:.7rem .5rem;overflow-y:auto;display:flex;flex-direction:column;gap:1px;}
.lib-cats .cat-sec{font-size:.5rem;font-weight:700;text-transform:uppercase;letter-spacing:.1em;
  color:var(--text-muted);padding:.7rem .55rem .25rem;}
.lib-cat{display:flex;align-items:center;gap:.5rem;padding:.45rem .55rem;border-radius:9px;
  font-size:.68rem;font-weight:500;color:var(--text-sec);cursor:pointer;transition:all .2s;}
.lib-cat:hover{background:var(--surface-hover);color:var(--text);}
.lib-cat.on{background:linear-gradient(135deg,rgba(108,92,231,.12),rgba(108,92,231,.04));
  color:var(--primary);font-weight:600;}
.dark .lib-cat.on{background:linear-gradient(135deg,rgba(162,155,254,.12),rgba(162,155,254,.04));}
.lib-cat .ic{font-size:.85rem;}

.lib-grid{flex:1;overflow-y:auto;padding:1rem 1.25rem;}
.lib-tags{display:flex;flex-wrap:wrap;gap:.35rem;margin-bottom:.85rem;}
.lib-tag{padding:.2rem .55rem;border-radius:999px;font-size:.55rem;font-weight:600;
  border:1px solid var(--glass-border);background:var(--surface);color:var(--text-muted);cursor:pointer;transition:all .15s;}
.lib-tag:hover{border-color:var(--primary);color:var(--primary);}
.lib-tag.on{background:var(--primary);color:white;border-color:transparent;}

.lib-grid-title{font-size:.65rem;font-weight:700;color:var(--text-muted);text-transform:uppercase;
  letter-spacing:.08em;margin-bottom:.6rem;}
.lib-cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:.7rem;}
.lib-card{padding:.85rem;border-radius:13px;background:var(--glass);border:1px solid var(--glass-border);
  cursor:pointer;transition:all .25s;display:flex;flex-direction:column;gap:.4rem;}
.lib-card:hover{border-color:var(--primary);transform:translateY(-2px);box-shadow:var(--glow-md);}
.lib-card-icon{width:34px;height:34px;border-radius:10px;display:flex;align-items:center;justify-content:center;
  font-size:1.15rem;background:linear-gradient(135deg,rgba(108,92,231,.15),rgba(0,206,201,.08));
  border:1px solid rgba(108,92,231,.15);}
.lib-card-name{font-size:.78rem;font-weight:700;color:var(--text);}
.lib-card-desc{font-size:.55rem;color:var(--text-muted);line-height:1.4;}
.lib-card-tags{display:flex;flex-wrap:wrap;gap:.2rem;margin-top:auto;}
.lib-card-tag{font-size:.48rem;padding:.1rem .35rem;border-radius:5px;background:rgba(108,92,231,.08);
  color:var(--primary);font-weight:600;}
.dark .lib-card-tag{background:rgba(162,155,254,.1);}
.lib-card.dim{opacity:.5;pointer-events:none;}
.lib-card .lib-card-bdg-soon{font-size:.45rem;font-weight:700;color:var(--text-muted);
  text-transform:uppercase;letter-spacing:.05em;margin-left:auto;}

/* Theme fade */
.theme-fade{position:fixed;inset:0;z-index:9999;pointer-events:none;opacity:0;transition:opacity .4s;}
.theme-fade.in{opacity:1;}

/* Preview tag */
.preview-tag{position:fixed;top:0;left:50%;transform:translateX(-50%);z-index:10000;
  background:linear-gradient(135deg,var(--primary),var(--cyan));color:white;font-size:.55rem;
  font-weight:700;padding:.2rem 1.2rem;border-radius:0 0 10px 10px;letter-spacing:.06em;
  box-shadow:0 4px 15px var(--primary-glow);}

/* Mode fade */
.mode-fade{position:fixed;inset:0;z-index:9998;pointer-events:none;opacity:0;
  background:radial-gradient(ellipse at center,var(--primary-glow),transparent 70%);
  transition:opacity .5s cubic-bezier(.4,0,.2,1);}
.mode-fade.in{opacity:1;}
