/* ---------- Sidebar tree ---------- */
.sidebar {}

.sidebar-search {
  position: relative;
  padding: 0 12px 10px;
  flex-shrink: 0;
}

.sidebar-search-ico {
  position: absolute;
  left: 22px;
  top: 17px;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--faint);
  pointer-events: none;
}

.sidebar-search-input {
  width: 100%;
  height: 34px;
  padding: 0 28px 0 32px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  font-size: var(--fs-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.sidebar-search-clear {
  position: absolute;
  right: 22px;
  top: 17px;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  border-radius: var(--r-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), color var(--dur) var(--ease), background var(--dur) var(--ease);
  padding: 0;
}

.sidebar-search-clear:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.sidebar-search-clear.visible {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-search-clear svg {
  width: 12px;
  height: 12px;
  display: block;
}

.sidebar-search-input::placeholder {
  color: var(--faint);
}

.sidebar-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tree {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 8px;
}

.tree.root-drop {
  box-shadow: inset 0 0 0 2px var(--accent);
  border-radius: var(--r-md);
}

.tree-folder {
  position: relative;
}

.tree-bm-list {
  padding-left: 0;
}

/* row (folder or bookmark) */
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--r-md);
  color: var(--ink);
  font-size: var(--fs-base);
  text-align: left;
  position: relative;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.row:hover {
  background: var(--surface-2);
}

.row.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.row.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  border-radius: var(--r-pill);
  background: var(--accent);
}

.row-chevron {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  transition: transform 0.15s var(--ease);
}

.row-chevron svg {
  width: 13px;
  height: 13px;
}

.row-ico {
  flex-shrink: 0;
  width: 17px;
  text-align: center;
  font-size: 0.95em;
  line-height: 1;
}

.row-ico svg {
  width: 16px;
  height: 16px;
  color: var(--faint);
}

.row.active .row-ico svg {
  color: var(--accent-text);
}

.row-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-fav {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
  object-fit: contain;
}

/* neutral letter tile shown when no real icon could be loaded */
.fav-letter {
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
  line-height: 1;
}

.row-fav.fav-letter {
  font-size: 10px;
}

.bm-card-fav.fav-letter {
  font-size: 14px;
  padding: 0;
}

.dial-fav.fav-letter {
  font-size: 16px;
}

.draggable {
  cursor: grab;
}

.draggable:active {
  cursor: grabbing;
}

/* <a> elements override cursor to pointer; re-assert grab */
a.draggable,
a.row.draggable {
  cursor: grab;
}

a.draggable:active,
a.row.draggable:active {
  cursor: grabbing;
}

.dragging {
  opacity: 0.4;
}

.row.drop-into {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
  color: var(--accent-text);
}

/* Browser-style drop-position indicator: a thin line + leading dot, theme-aware */
.drop-line {
  list-style: none;
  height: 0;
  margin: 1px 0;
  position: relative;
  pointer-events: none;
}

.drop-line::before {
  content: "";
  position: absolute;
  left: 6px;
  right: 4px;
  top: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
}

.drop-line::after {
  content: "";
  position: absolute;
  left: 2px;
  top: -3px;
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--ink);
}

/* hover flyout panel (fixed, set by JS) */
.flyout {
  display: none;
  position: fixed;
  z-index: var(--z-flyout);
  min-width: 220px;
  max-width: 280px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  padding: 6px;
}

#sidebar:not(.is-dragging) .tree-folder:hover>.flyout,
.tree-folder.drag-open>.flyout,
.tree-folder.menu-pinned>.flyout {
  display: block;
  animation: flyIn 0.14s var(--ease);
}

@keyframes flyIn {
  from {
    opacity: 0;
    transform: translateX(-4px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.flyout .row {
  height: 30px;
}

/* clear "drop into this folder" cue when dragging inside an open flyout */
.flyout.drop-into {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent), var(--shadow-pop);
}

.tree-empty {
  color: var(--faint);
  font-size: var(--fs-sm);
  padding: 10px 12px;
}

/* ---------- Search results: folder path + matched leaves ---------- */
/* Each row is indented (padding-left set inline per depth, capped in JS) and, when
   nested, prefixed with a right-angle connector so the folder → subfolder → bookmark
   relationship reads at a glance. */
.srch-row {
  position: relative;
}

.srch-arrow {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  margin-right: -2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
}

.srch-arrow svg {
  width: 14px;
  height: 14px;
}

/* the actual hit (matched bookmark, or a name-matched folder) — highlighted */
.row.srch-hit,
.row.srch-hit:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.row.srch-hit .row-ico svg,
.row.srch-hit .srch-arrow {
  color: var(--accent-text);
}

/* sidebar add forms */
.sidebar-add {
  flex-shrink: 0;
  padding: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
}

.add-bm {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.add-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.add-ico {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
}

.add-ico svg {
  width: 15px;
  height: 15px;
}

.add-input {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  font-size: var(--fs-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

/* In the vertical add-bookmark form, `flex:1` would collapse the title input's
   height — keep it at a fixed 32px like the other rows. */
.add-bm>.add-input {
  flex: 0 0 auto;
}

.add-input::placeholder {
  color: var(--faint);
}

.add-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.add-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--r-md);
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.add-btn:hover {
  background: var(--accent-hover);
}

.add-btn:active {
  transform: scale(0.94);
}

.add-btn svg {
  width: 16px;
  height: 16px;
}

