/* ── Library tab ─────────────────────────────────────────────────────────── */
.lib-wrap { padding: 20px 24px 48px; width: 100%; box-sizing: border-box; }

.lib-hdr { display: flex; align-items: center; justify-content: space-between;
           gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.lib-title { font-size: 20px; font-weight: 700; color: var(--text); margin: 0 0 3px; }
.lib-sub   { font-size: 12px; color: var(--text4); margin: 0; }

.lib-search-bar { margin-bottom: 16px; }
.lib-search-bar input { width: 100%; max-width: 420px; }

/* ── Two-column layout ───────────────────────────────────────────────────── */
.lib-layout { display: flex; gap: 20px; align-items: flex-start; }

.lib-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

.lib-cat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  transition: background .1s;
  user-select: none;
}
.lib-cat-item:hover { background: var(--border2); }
.lib-cat-item.lib-cat-active { background: rgba(14,165,233,.1); color: var(--accent); font-weight: 600; }

.lib-cat-arrow { font-size: 9px; color: var(--text4); flex-shrink: 0; width: 14px; text-align: center;
                  cursor: pointer; transition: color .1s; }
.lib-cat-arrow:hover { color: var(--accent); }
.lib-cat-name  { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-cat-count { font-size: 10px; color: var(--text4); background: var(--border2); border-radius: 8px;
                  padding: 0 5px; flex-shrink: 0; }
.lib-cat-actions { display: none; gap: 2px; flex-shrink: 0; }
.lib-cat-item:hover .lib-cat-actions { display: flex; }

.lib-cat-group { border-bottom: 1px solid var(--border2); }
.lib-cat-group:last-child { border-bottom: none; }

/* ── Card grid ───────────────────────────────────────────────────────────── */
.lib-main { flex: 1; min-width: 0; }

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

.lib-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  transition: border-color .12s, box-shadow .12s;
}
.lib-card:hover { border-color: var(--accent); box-shadow: 0 2px 12px rgba(14,165,233,.12); }

.lib-card-body { flex: 1; padding: 12px 14px; }
.lib-card-crumb { font-size: 9px; color: var(--text4); margin-bottom: 4px;
                    text-transform: uppercase; letter-spacing: .04em; }
.lib-card-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 5px;
                    line-height: 1.3; }
.lib-card-desc  { font-size: 11px; color: var(--text3); line-height: 1.5; }

.lib-card-footer { display: flex; align-items: center; gap: 6px; padding: 8px 12px;
                    border-top: 1px solid var(--border2); }

.lib-open-btn {
  flex: 1;
  background: var(--accent);
  border: none;
  border-radius: 5px;
  color: #fff;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  padding: 5px 12px;
  text-align: center;
  text-decoration: none;
  display: block;
  transition: background .12s;
}
.lib-open-btn:hover { background: var(--accent2); }

.lib-edit-btn, .lib-del-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text4);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 7px;
  transition: color .12s, border-color .12s;
}
.lib-edit-btn:hover { color: var(--accent); border-color: var(--accent); }
.lib-del-btn:hover  { color: #f87171;       border-color: #ef4444; }

.lib-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text4);
  font-size: 13px;
  font-style: italic;
}

@media (max-width: 640px) {
  .lib-layout  { flex-direction: column; }
  .lib-sidebar { width: 100%; position: static; max-height: 200px; }
}

/* ── Favourite URLs ──────────────────────────────────────────────────────── */
.lib-favs-section { margin-bottom: 20px; }
.lib-favs-title   { font-size: 11px; font-weight: 700; text-transform: uppercase;
                     letter-spacing: .07em; color: var(--text4); margin-bottom: 8px; }
.lib-favs-chips   { display: flex; flex-wrap: wrap; gap: 8px; }
.lib-favs-empty   { font-size: 12px; color: var(--text4); font-style: italic; }

.lib-fav-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 20px;
  color: var(--text2); font-size: 12px; font-weight: 500;
  padding: 5px 12px; text-decoration: none;
  transition: border-color .12s, background .12s, color .12s;
}
.lib-fav-chip:hover { border-color: var(--accent); color: var(--accent); background: rgba(14,165,233,.06); }

.lib-fav-del {
  background: none; border: none; color: var(--text4); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0; margin-left: 2px;
  transition: color .1s;
}
.lib-fav-del:hover { color: #f87171; }

.lib-favs-add-btn {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: 11px; font-weight: 600; padding: 0 0 0 8px; transition: opacity .1s;
}
.lib-favs-add-btn:hover { opacity: .7; }

/* ── Favourite URL folders ───────────────────────────────────────────────── */
.lib-fav-folder { margin-bottom: 10px; }
.lib-fav-folder-hdr {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.lib-fav-folder-name {
  font-size: 11px; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: .05em;
}
.lib-fav-folder-edit, .lib-fav-folder-del {
  background: none; border: none; color: var(--text4); cursor: pointer;
  font-size: 12px; padding: 0 3px; transition: color .1s;
}
.lib-fav-folder-edit:hover { color: var(--accent); }
.lib-fav-folder-del:hover  { color: #f87171; }

/* ── Starred procedures ──────────────────────────────────────────────────── */
.lib-starred-section { margin-bottom: 20px; }

.lib-star-btn {
  background: none; border: 1px solid var(--border); border-radius: 4px;
  color: var(--text4); cursor: pointer; font-size: 14px; line-height: 1;
  padding: 3px 6px; transition: color .12s, border-color .12s;
}
.lib-star-btn:hover       { color: #f59e0b; border-color: #f59e0b; }
.lib-star-btn.lib-star-active { color: #f59e0b; border-color: #f59e0b; background: rgba(245,158,11,.08); }

/* ── Drag-and-drop visuals ───────────────────────────────────────────────── */
.lib-dragging { opacity: .35 !important; box-shadow: none !important; }

/* Categories and folders highlight on dragover */
.lib-cat-item.lib-drag-over  { background: rgba(14,165,233,.15) !important; color: var(--accent) !important; outline: 1px dashed var(--accent); border-radius: 5px; }
.lib-fav-folder.lib-drag-over,
.lib-favs-chips.lib-drag-over { outline: 1px dashed var(--accent); border-radius: 6px; background: rgba(14,165,233,.06) !important; }
#lib-all-proc.lib-drag-over   { background: rgba(14,165,233,.15) !important; color: var(--accent) !important; outline: 1px dashed var(--accent); border-radius: 5px; }

/* Card insert indicators for vendor/article reorder */
.lib-card.lib-drag-above { box-shadow: 0 -3px 0 var(--accent) !important; }
.lib-card.lib-drag-below { box-shadow: 0  3px 0 var(--accent) !important; }

/* ── Sidebar section headers ─────────────────────────────────────────────── */
.lib-sidebar-section-hdr {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text4); padding: 8px 12px 3px; border-top: 1px solid var(--border2);
}
.lib-sidebar-section-hdr:first-child { border-top: none; }

/* ── Vendor contact cards ────────────────────────────────────────────────── */
.lib-vendor-card { border-left: 3px solid #8b5cf6; }
.lib-vendor-name {
  font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 9px;
}
.lib-vendor-rows { display: flex; flex-direction: column; gap: 5px; margin-bottom: 6px; }
.lib-vendor-row  { display: flex; gap: 8px; font-size: 12px; align-items: flex-start; }
.lib-vendor-row > span:first-child { color: var(--text4); min-width: 72px; flex-shrink: 0; font-size: 11px; padding-top: 1px; }
.lib-vendor-row a { color: var(--accent); text-decoration: none; word-break: break-all; }
.lib-vendor-row a:hover { text-decoration: underline; }
.lib-vendor-copy { color: var(--text2); cursor: pointer; font-family: monospace; }
.lib-vendor-copy:hover { color: var(--accent); }
.lib-vendor-notes {
  font-size: 11px; color: var(--text3); font-style: italic; line-height: 1.5;
  border-top: 1px solid var(--border2); padding-top: 7px; margin-top: 4px;
}

/* ── Article cards ───────────────────────────────────────────────────────── */
.lib-article-card:hover { border-color: #10b981; box-shadow: 0 2px 12px rgba(16,185,129,.12); }
.lib-article-meta { font-size: 10px; color: var(--text4); margin-top: 7px; }

/* ── Article reader modal ────────────────────────────────────────────────── */
.lib-article-reader { max-width: 680px; width: 100%; max-height: 88vh; display: flex; flex-direction: column; }
.lib-article-body {
  flex: 1; overflow-y: auto; font-size: 14px; line-height: 1.7; color: var(--text2);
  padding: 20px 24px;
}
.lib-article-body h1,.lib-article-body h2,.lib-article-body h3 { color: var(--text); margin: 1.2em 0 .4em; font-weight: 700; }
.lib-article-body h1 { font-size: 20px; }
.lib-article-body h2 { font-size: 17px; }
.lib-article-body h3 { font-size: 14px; }
.lib-article-body ul,.lib-article-body ol { padding-left: 22px; margin: .6em 0; }
.lib-article-body li { margin: .25em 0; }
.lib-article-body p  { margin: .6em 0; }
.lib-article-body strong { color: var(--text); }
.lib-article-body code {
  background: var(--bg3); border-radius: 3px; padding: 1px 5px;
  font-family: monospace; font-size: 12px;
}

/* ── Article editor modal ────────────────────────────────────────────────── */
.lib-article-editor { max-width: 680px; width: 100%; max-height: 88vh; display: flex; flex-direction: column; }
.lib-editor-toolbar {
  display: flex; gap: 3px;
}
.lib-editor-toolbar button {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text2); cursor: pointer; font-size: 12px; padding: 2px 8px;
  transition: background .1s, color .1s;
}
.lib-editor-toolbar button:hover { background: var(--border2); color: var(--text); }
.lib-article-textarea {
  min-height: 260px; max-height: 400px; overflow-y: auto;
  background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
  padding: 12px 14px; font-size: 13px; line-height: 1.6; color: var(--text);
  outline: none;
}
.lib-article-textarea:focus { border-color: var(--accent); }
.lib-article-textarea h3 { font-size: 14px; font-weight: 700; margin: .8em 0 .3em; }
.lib-article-textarea ul,.lib-article-textarea ol { padding-left: 20px; margin: .4em 0; }
.lib-article-textarea p  { margin: .4em 0; }

/* ── Notepad save button ─────────────────────────────────────────────────── */
.wb-lib-save-btn {
  background: none; border: 1px solid var(--border); border-radius: 5px;
  color: var(--text3); cursor: pointer; font-size: 11px; font-weight: 600;
  padding: 3px 10px; transition: color .12s, border-color .12s;
}
.wb-lib-save-btn:hover { color: var(--accent); border-color: var(--accent); }
