.wb-library {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.wb-lib-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 10px;
  flex-shrink: 0;
}

.wb-lib-title {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.wb-lib-search-wrap {
  padding: 0 14px 10px;
  flex-shrink: 0;
}

.wb-lib-search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 7px 10px;
}

.wb-lib-search-icon {
  flex-shrink: 0;
  color: #7a7a7a;
}

.wb-lib-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text);
}

.wb-lib-search-input::placeholder {
  color: #7a7a7a;
}

.wb-lib-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.wb-lib-filters {
  display: flex;
  gap: 2px;
  padding: 0 14px 12px;
  flex-shrink: 0;
}

.wb-lib-filter {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 0;
  border-radius: 7px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: #8f8f8f;
  transition: background 0.15s, color 0.15s;
}

.wb-lib-filter--active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.wb-lib-filter--fav.wb-lib-filter--active {
  color: var(--border-active);
}

.wb-lib-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wb-lib-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 9px 6px;
  border-radius: 9px;
  cursor: grab;
  background: transparent;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
  /* Rows are grab-to-drag targets; letting the browser select the name mid-press
     flashes a caret before the drag threshold and fights the gesture. */
  user-select: none;
  -webkit-user-select: none;
}

.wb-lib-row:hover:not(.wb-lib-row--selected) {
  background: rgba(255, 255, 255, 0.04);
}

.wb-lib-row--selected {
  background: var(--surface-raised);
  border-color: var(--border);
}

.wb-lib-row--dragging {
  opacity: 0.4;
  cursor: grabbing;
}

/* During a drag, sibling presets fall back so the floating chip, Device Slots,
   and the trash target read as the only live surface. The dragged row itself
   stays a touch brighter as a placeholder for where it came from. */
body.wb-dnd-active .wb-lib-row {
  cursor: grabbing;
  pointer-events: none;
}

body.wb-dnd-active .wb-lib-row:not(.wb-lib-row--dragging) {
  opacity: 0.22;
}

body.wb-dnd-active .wb-lib-header,
body.wb-dnd-active .wb-lib-search-wrap,
body.wb-dnd-active .wb-lib-filters,
body.wb-dnd-active .wb-lib-footer {
  opacity: 0.35;
  pointer-events: none;
  transition: opacity 0.15s;
}

.wb-lib-grip {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 14px;
  color: rgba(255, 255, 255, 0.22);
  transition: color 0.12s;
  pointer-events: none;
}

.wb-lib-row:hover .wb-lib-grip,
.wb-lib-row--selected .wb-lib-grip {
  color: rgba(255, 255, 255, 0.45);
}

.wb-lib-row--dragging .wb-lib-grip {
  color: rgba(255, 255, 255, 0.55);
}

.wb-lib-grip-icon {
  display: block;
}

.wb-lib-row-main {
  flex: 1;
  min-width: 0;
}

.wb-lib-row-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wb-lib-row-name {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wb-lib-fav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  background: none;
  color: var(--border-active);
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 4px;
  transition: opacity 0.12s, color 0.12s, background 0.12s;
}

.wb-lib-fav--on {
  color: var(--border-active);
}

.wb-lib-fav--hidden {
  opacity: 0;
  color: rgba(255, 255, 255, 0.45);
}

.wb-lib-row:hover .wb-lib-fav--hidden {
  opacity: 0.7;
}

.wb-lib-fav:hover,
.wb-lib-fav:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.wb-lib-filter svg {
  display: inline-block;
  vertical-align: -1px;
  margin-right: 2px;
}

.wb-lib-row-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #8f8f8f;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wb-lib-row-time {
  font-family: var(--font-mono);
  font-size: 9px;
  color: #6a6a6a;
  flex-shrink: 0;
}

.wb-lib-empty {
  padding: 16px 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
}

.wb-lib-footer {
  display: flex;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  flex-shrink: 0;
}

.wb-lib-create {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.36);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.wb-lib-create:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

/* Create and Import are both "add to my library", but Create is by far the more
   frequent, so Import sits beside it as a narrower, dimmer sibling rather than
   an equal half — present when wanted, not competing at rest. */
.wb-lib-import {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.22);
  /* #a3a3a3 keeps Import secondary to Create while staying readable on the
     darker footer strip (~5.7:1). */
  color: #a3a3a3;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.wb-lib-import svg {
  flex-shrink: 0;
  opacity: 0.9;
}

.wb-lib-import:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.36);
  color: var(--text);
}

.wb-lib-create:focus-visible,
.wb-lib-import:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.65);
  outline-offset: 2px;
}

/* Drag-to-delete target — rises out of the footer only while a deletable
   preset is in hand, so the destructive option is never sitting around
   waiting to be misclicked. Hit-testing is done from the drag controller
   against this element's box, so it stays pointer-events: none and never
   steals the pointer capture driving the drag. */
.wb-lib-trash {
  position: absolute;
  left: 50%;
  bottom: 76px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 16px) scale(0.8);
  transition: opacity 0.16s ease, transform 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.25);
}

.wb-lib-trash--visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.wb-lib-trash-circle {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(22, 22, 22, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-secondary);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}

.wb-lib-trash--armed .wb-lib-trash-circle {
  background: rgba(224, 128, 128, 0.16);
  border-color: rgba(224, 128, 128, 0.85);
  color: #e08080;
  transform: scale(1.12);
}

.wb-lib-trash-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e08080;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.wb-lib-trash--armed .wb-lib-trash-label {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .wb-lib-trash,
  .wb-lib-trash-circle {
    transition-duration: 0.01ms;
  }

  .wb-lib-trash--armed .wb-lib-trash-circle {
    transform: none;
  }
}
