*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  :root {
    --primary:   #292e49;
    --secondary: #536976;
    --bg:        #ffffff;
    --bg-soft:   #f4f5f8;
    --border:    #e4e6ed;
    --text:      #1c1e2e;
    --muted:     #8b90a8;
    --accent-lt: #edf1f3;
    --sidebar-w: 280px;
  }



  /* ── HEADER ── */
  .lib-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    padding: 28px 32px 24px;
    position: relative;
    overflow: hidden;
  }
  .lib-header::before {
    content: '';
    position: absolute;
    top: -40px; right: -40px;
    width: 200px; height: 200px;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
  }
  .lib-header::after {
    content: '';
    position: absolute;
    bottom: -60px; right: 80px;
    width: 140px; height: 140px;
    border-radius: 50%;
    background: rgba(255,255,255,0.03);
  }

  .lib-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
  }

  .lib-header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    font-weight: 500;
    color: #fff;
    letter-spacing: 0.01em;
    line-height: 1.15;
  }
  .lib-header h1 em {
    display: block;
    font-style: italic;
    font-size: 12px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 300;
    color: rgba(255,255,255,0.55);
    margin-bottom: 4px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

  #total-badge, .badge-genre {
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.85);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 12px;
    white-space: nowrap;
    margin-top: 6px;
  }
  
  .badge-genre a{
      color:unset;
  }
  
  .badge-genre.active{
      background: rgba(255,255,255,0.9);
      color:var(--primary);
  }

  .search-wrap {
    position: relative;
    margin-top: 18px;
    max-width: 380px;
  }
  .search-wrap svg {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    color: rgba(255,255,255,0.45);
    pointer-events: none;
  }
  #search {
    width: 100%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 9px 14px 9px 36px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    color: #fff;
    outline: none;
    transition: background .2s, border-color .2s;
  }
  #search::placeholder { color: rgba(255,255,255,0.4); }
  #search:focus {
    background: rgba(255,255,255,0.16);
    border-color: rgba(255,255,255,0.4);
  }

  /* ── BODY ── */
  .lib-body {
    display: flex;
    align-items: flex-start;
    padding: 28px 32px;
  }

  /* ── SIDEBAR ── */
  aside {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 160px);
    display: flex;
    flex-direction: column;
  }

  .sidebar-inner {
    overflow-y: auto;
    flex: 1;
  }
  .sidebar-inner::-webkit-scrollbar { width: 3px; }
  .sidebar-inner::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

  .sidebar-title {
    padding: 12px 16px;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft);
  }

  .folder-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border);
    transition: background .15s;
  }
  .folder-header:hover { background: var(--bg-soft); }

  .folder-header .arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px; height: 16px;
    transition: transform .2s;
    color: var(--muted);
    flex-shrink: 0;
  }
  .folder-header.open .arrow { transform: rotate(90deg); }

  .folder-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    flex-shrink: 0;
  }

  .folder-label {
    font-weight: 500;
    font-size: 12.5px;
    color: var(--text);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .count {
    font-size: 10px;
    background: var(--bg-soft);
    color: var(--muted);
    border-radius: 10px;
    padding: 2px 7px;
    border: 1px solid var(--border);
    flex-shrink: 0;
  }

  .folder-books { display: none; background: var(--bg); }
  .folder-books.open { display: block; }

  .book-item {
    display: block;
    padding: 7px 14px 7px 36px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--muted);
    border-left: 3px solid transparent;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    transition: color .15s, background .15s, border-color .15s;
  }
  .book-item:last-child { border-bottom: none; }
  .book-item:hover { background: var(--bg-soft); color: var(--text); }
  .book-item.active {
    background: var(--accent-lt);
    border-left-color: var(--primary);
    color: var(--primary);
    font-weight: 500;
  }

  .empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
  }

  /* ── VIEWER ── */
  #viewer {
    flex: 1;
    margin-left: 24px;
  }

  #viewer-placeholder {
    border: 2px dashed var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 40px;
    color: var(--muted);
    text-align: center;
  }
  .placeholder-icon {
    width: 56px; height: 56px;
    border-radius: 14px;
    background: var(--bg-soft);
    display: flex; align-items: center; justify-content: center;
    font-size: 26px;
  }
  #viewer-placeholder h2 {
    font-family: 'Playfair Display', serif;
    font-size: 18px;
    font-weight: 500;
    color: var(--text);
    opacity: .35;
  }
  #viewer-placeholder p {
    font-size: 13px;
    color: var(--muted);
    max-width: 240px;
    line-height: 1.5;
  }

  #pdf-title {
    display: none;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 10px 16px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
  }
  #pdf-title .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    flex-shrink: 0;
  }
  #pdf-title span {
    font-weight: 500;
    font-size: 13px;
    color: var(--text);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #pdf-wrap {
    display: none;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 4px 24px rgba(41,46,73,0.08);
    height: 80vh;
  }
  #pdf-frame {
    width: 100%; height: 100%;
    border: none; display: block;
  }

  #loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 48px;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--muted);
    font-size: 13px;
  }
  .spinner {
    width: 22px; height: 22px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ── RESPONSIVE ── */
  @media (max-width: 700px) {
    .lib-body { flex-direction: column; padding: 16px; }
    aside { width: 100%; position: static; max-height: 260px; }
    #viewer { margin-left: 0; margin-top: 16px; }
    #pdf-wrap { height: 60vh; }
  }