/* ===========================================
   LIBRARY TAB STYLES
   =========================================== */

/* Library Layout */
.library-container {
  display: flex;
  flex: 1;
  height: 100%;
  overflow: hidden;
}

/* Library Sidebar */
.library-sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.library-sidebar-section {
  padding: 16px 12px 8px;
}

.library-sidebar-section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding: 0 8px;
}

.library-sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

.library-sidebar-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.library-sidebar-item.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-weight: 600;
}

.library-sidebar-item .sidebar-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.library-sidebar-item .sidebar-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-sidebar-item .sidebar-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-hover, rgba(255,255,255,0.05));
  padding: 2px 8px;
  border-radius: 10px;
}

/* Character avatar in sidebar */
.sidebar-char-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

/* Folder actions */
.library-sidebar-item .folder-actions {
  display: none;
  gap: 4px;
}

.library-sidebar-item:hover .folder-actions {
  display: flex;
}

.library-sidebar-item:hover .sidebar-count {
  display: none;
}

.folder-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 0.8rem;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.folder-action-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.1);
}

/* New folder button */
.library-new-folder-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s;
  border: 1px dashed var(--border-color);
  margin: 4px 12px;
  background: none;
  width: calc(100% - 24px);
  text-align: left;
}

.library-new-folder-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* New folder inline input */
.library-new-folder-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 12px;
  margin: 4px 12px;
}

.library-new-folder-input input {
  flex: 1;
  min-width: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
}

.library-new-folder-input input:focus {
  border-color: var(--accent-primary);
}

.library-new-folder-input button {
  background: var(--accent-primary);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* Library Main Content */
.library-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Library Header */
.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  gap: 16px;
  flex-shrink: 0;
}

.library-header-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.library-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 14px;
  flex: 0 1 300px;
  transition: border-color 0.2s;
}

.library-search-box:focus-within {
  border-color: var(--accent-primary);
}

.library-search-box svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.library-search-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  width: 100%;
}

.library-search-box input::placeholder {
  color: var(--text-muted);
}

.library-sort-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
}

/* Library Grid */
.library-grid-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  position: relative;
}

.library-grid {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ===========================================
   DAY GROUPS
   =========================================== */

.library-day-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.library-day-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px;
  user-select: none;
}

.library-day-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-radius: 5px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
  font-size: 0.7rem;
  color: white;
}

.library-grid.selection-mode .library-day-checkbox {
  display: flex;
}

.library-day-checkbox:hover {
  border-color: var(--accent-primary);
}

.library-day-checkbox.checked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.library-day-checkbox.checked::after {
  content: '\2713';
}

.library-day-checkbox.partial {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  opacity: 0.6;
}

.library-day-checkbox.partial::after {
  content: '\2014';
}

.library-day-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.library-day-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-hover, rgba(255,255,255,0.05));
  padding: 2px 8px;
  border-radius: 10px;
}

.library-day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

/* ===========================================
   SELECTION CHECKBOXES ON ITEMS
   =========================================== */

.lib-select-checkbox {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255,255,255,0.6);
  border-radius: 5px;
  z-index: 4;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: white;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  transition: background 0.15s, border-color 0.15s;
}

.library-grid.selection-mode .lib-select-checkbox {
  display: flex;
}

.lib-select-checkbox:hover {
  border-color: var(--accent-primary);
  background: rgba(0,0,0,0.5);
}

.lib-select-checkbox.checked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.lib-select-checkbox.checked::after {
  content: '\2713';
}

.library-item.selected {
  outline: 3px solid var(--accent-primary);
  outline-offset: -3px;
}

/* Move fav & NSFW badge right when in selection mode */
.library-grid.selection-mode .library-item .nsfw-badge {
  left: 36px;
}

/* ===========================================
   SELECTION TOGGLE BUTTON
   =========================================== */

.lib-selection-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.lib-selection-toggle:hover,
.lib-selection-toggle.active {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

/* ===========================================
   BULK ACTION TOOLBAR
   =========================================== */

/* Facelock picker banner */
.lib-facelock-picker-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(236, 72, 153, 0.15));
  border-bottom: 1px solid rgba(139, 92, 246, 0.3);
  flex-shrink: 0;
  gap: 12px;
}

.lib-facelock-picker-banner.full {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(236, 72, 153, 0.15));
  border-bottom-color: rgba(239, 68, 68, 0.3);
}

.lib-facelock-picker-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.lib-facelock-picker-lock {
  font-size: 1.1rem;
}

.lib-facelock-picker-done {
  padding: 6px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.lib-facelock-picker-done:hover {
  background: var(--bg-hover);
}

/* Facelock management panel (inline in library) */
.lib-facelock-panel {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
  max-width: 600px;
}

.lib-facelock-panel-header {
  margin-bottom: 16px;
}

.lib-facelock-char-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.9rem;
  cursor: pointer;
}

.lib-facelock-panel-tabs {
  display: flex;
  background: var(--bg-elevated);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid var(--border-color);
}

.lib-facelock-panel-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.lib-facelock-panel-tab.active {
  background: linear-gradient(135deg, #00b2ff, #00e676);
  color: #fff;
}

.lib-facelock-panel-tab.nsfw.active {
  background: linear-gradient(135deg, #ff2ebb, #ff6b6b);
}

.lib-facelock-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.lib-facelock-panel-count {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 8px 0;
}

.lib-facelock-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.lib-bulk-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  gap: 12px;
  flex-wrap: wrap;
}

.lib-bulk-left,
.lib-bulk-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lib-bulk-count {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 600;
  margin-right: 4px;
}

.lib-bulk-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.lib-bulk-btn:hover:not(:disabled) {
  background: var(--bg-hover, var(--bg-tertiary));
  color: var(--text-primary);
}

.lib-bulk-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.lib-bulk-delete:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: #ef4444;
}

.lib-bulk-folder-dropdown {
  position: relative;
}

.lib-bulk-folder-dropdown .library-folder-menu {
  bottom: 100%;
  top: auto;
  margin-bottom: 4px;
}

/* ===========================================
   SEND-TO MENU ON LIBRARY CARDS
   =========================================== */

.library-item-overlay-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.lib-send-to-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.lib-send-to-btn:hover {
  background: rgba(255,255,255,0.3);
}

.library-item .send-to-container {
  position: relative;
}

.library-item .send-to-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 4px;
  min-width: 170px;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: none;
}

.library-item .send-to-menu.active {
  display: block;
}

.library-item .send-to-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
  white-space: nowrap;
}

.library-item .send-to-option:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Library Item Card */
.library-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  aspect-ratio: 1;
}

.library-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.library-item img,
.library-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Type badge */
.library-item-type {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  backdrop-filter: blur(4px);
}

/* NSFW badge on library items */
.library-item .nsfw-badge {
  position: absolute;
  top: 8px;
  right: 40px;
  z-index: 2;
}

/* Favorite heart button */
.library-item-fav {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.5);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.15s, transform 0.15s;
  z-index: 3;
  backdrop-filter: blur(4px);
  color: white;
}

.library-item-fav:hover {
  background: rgba(0,0,0,0.7);
  transform: scale(1.1);
}

.library-item-fav.favorited {
  color: #ff4d6a;
}

/* Item overlay on hover */
.library-item-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  padding: 30px 10px 10px;
  opacity: 0;
  transition: opacity 0.2s;
}

.library-item:hover .library-item-overlay {
  opacity: 1;
}

.library-item-overlay-text {
  color: white;
  font-size: 0.78rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.library-item-overlay-meta {
  color: rgba(255,255,255,0.6);
  font-size: 0.7rem;
  margin-top: 4px;
}

/* Empty state */
.library-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
}

.library-empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.library-empty-text {
  font-size: 1rem;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.library-empty-sub {
  font-size: 0.85rem;
}

/* Loading state */
.library-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
}

.library-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Load more */
.library-load-more {
  display: flex;
  justify-content: center;
  padding: 20px;
}

.library-load-more-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s;
}

.library-load-more-btn:hover {
  background: var(--bg-hover, var(--bg-tertiary));
  color: var(--text-primary);
}

/* ===========================================
   DETAIL PANEL (modal overlay)
   =========================================== */

.library-detail-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}

.library-detail-overlay.active {
  display: flex;
}

.library-detail-panel {
  background: var(--bg-secondary);
  border-radius: 16px;
  width: 90vw;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.library-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.library-detail-back {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.library-detail-back:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.library-detail-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.3rem;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.library-detail-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.library-detail-content {
  display: flex;
  gap: 24px;
  padding: 20px;
  flex: 1;
  overflow-y: auto;
}

.library-detail-preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  background: rgba(0,0,0,0.3);
  border-radius: 12px;
  overflow: hidden;
}

.library-detail-preview img {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 8px;
}

.library-detail-preview video {
  max-width: 100%;
  max-height: 60vh;
  border-radius: 8px;
}

.library-detail-info {
  width: 280px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Detail actions row */
.library-detail-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.library-detail-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.82rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.library-detail-action-btn:hover {
  background: var(--bg-hover, var(--bg-tertiary));
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.library-detail-action-btn.favorited {
  color: #ff4d6a;
  border-color: #ff4d6a;
}

/* Metadata section */
.library-detail-meta {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.library-detail-meta-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.library-detail-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.library-detail-meta-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.library-detail-meta-value {
  font-size: 0.82rem;
  color: var(--text-primary);
  text-align: right;
  word-break: break-word;
}

/* Prompt display */
.library-detail-prompt {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  word-break: break-word;
}

/* Bottom action bar */
.library-detail-bottom {
  display: flex;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

.library-recreate-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: opacity 0.15s, transform 0.15s;
}

.library-recreate-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.library-download-btn,
.library-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s;
}

.library-download-btn:hover {
  background: var(--bg-hover, var(--bg-tertiary));
  color: var(--text-primary);
}

.library-delete-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: #ef4444;
}

/* Folder dropdown in detail view */
.library-folder-dropdown {
  position: relative;
}

.library-folder-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px;
  min-width: 180px;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  display: none;
}

.library-folder-menu.visible {
  display: block;
}

.library-folder-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-secondary);
  transition: background 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.library-folder-menu-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.library-folder-menu-item .folder-check {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.library-folder-menu-item .folder-check.checked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* ===========================================
   DRAG AND DROP
   =========================================== */

.library-item.dragging {
  opacity: 0.35;
  transform: scale(0.97);
}

.library-sidebar-item.drag-over {
  background: var(--accent-primary) !important;
  color: white !important;
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

.library-sidebar-item.drag-over .sidebar-count,
.library-sidebar-item.drag-over .sidebar-label,
.library-sidebar-item.drag-over .sidebar-icon {
  color: white !important;
}

.library-drag-ghost {
  position: fixed;
  top: -100px;
  left: -100px;
  background: var(--accent-primary);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  z-index: 99999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* ===========================================
   MARQUEE / RUBBER-BAND SELECTION
   =========================================== */

.library-marquee {
  position: absolute;
  border: 2px solid var(--accent-primary);
  background: rgba(255, 46, 187, 0.1);
  pointer-events: none;
  z-index: 10;
  border-radius: 2px;
}

/* ===========================================
   RESPONSIVE
   =========================================== */

@media (max-width: 900px) {
  .library-container {
    flex-direction: column;
  }

  .library-sidebar {
    width: 100%;
    min-width: unset;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 8px;
    gap: 4px;
  }

  .library-sidebar-section {
    display: flex;
    gap: 4px;
    padding: 0;
  }

  .library-sidebar-section-label {
    display: none;
  }

  .library-sidebar-item {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .library-new-folder-btn {
    white-space: nowrap;
    margin: 0;
    width: auto;
  }

  .library-day-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

  .library-header {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .library-search-box {
    flex: 1 1 100%;
    order: 10;
  }

  .library-detail-content {
    flex-direction: column;
  }

  .library-detail-info {
    width: 100%;
    min-width: unset;
  }

  .library-detail-panel {
    width: 95vw;
    max-height: 95vh;
  }
}

@media (max-width: 480px) {
  .library-day-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .library-grid-wrapper {
    padding: 10px;
  }
}
