/* =========================================================
   My Library (Master Library)
   - VS Code style left tree
   - Search results pin card style on the right
   - Kebab menu for actions
   ========================================================= */

/* Make Library a full-screen view so it is not constrained by main max-width */
.mylib-view{
  position: fixed;
  inset: 0;
  z-index: 5;
  background: var(--bg);
  color: var(--fg);
  display: none;
}

/* Two-pane layout */
.mylib-layout{
  height: 100vh;
  width: 100vw;
  display: flex;
  overflow: hidden;
}

/* Left sidebar */
.mylib-sidebar{
  width: 280px;
  flex: 0 0 280px;
  height: 100%;
  border-right: 1px solid var(--border-subtle);
  background: var(--card-bg);
  overflow: auto;
}

.mylib-sidebar-head{
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px 12px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-subtle);
}

.mylib-sidebar-title{
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Tree */
.mylib-tree{
  padding: 8px 6px 12px 6px;
  font-size: 14px;
}

.mylib-tree-row{
  --depth: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  border-radius: 10px;
  padding: 0 10px;
  padding-left: calc(10px + (var(--depth) * 14px));
  cursor: pointer;
  user-select: none;
}

.mylib-tree-row:hover{
  background: rgba(0,0,0,0.05);
}

.mylib-tree-row.active{
  background: rgba(0,0,0,0.08);
  border: 1px solid rgba(0,0,0,0.08);
}

.mylib-tree-chevron{
  width: 10px;
  height: 10px;
  display: inline-block;
  position: relative;
  flex: 0 0 10px;
}

.mylib-tree-chevron::before{
  content: "";
  position: absolute;
  inset: 0;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transform-origin: center;
  opacity: 0.9;
}

.mylib-tree-row.open .mylib-tree-chevron::before{
  transform: rotate(45deg);
}

.mylib-tree-chevron.placeholder::before{
  opacity: 0;
}

.mylib-tree-name{
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Main area */
.mylib-main{
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

/* Header and toolbar */
.mylib-head{
  padding: 18px 18px 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg);
}

.mylib-titlebox{
  margin-bottom: 12px;
}

.mylib-title{
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.mylib-sub{
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.mylib-actions{
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mylib-search{
  flex: 1 1 320px;
  max-width: 520px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--card-bg);
  color: var(--fg);
  outline: none;
}

.mylib-search:focus{
  border-color: rgba(0,0,0,0.25);
}

.mylib-toolbar{
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg);
}

.mylib-crumb{
  color: var(--muted);
  font-size: 13px;
}

/* Quota */
.mylib-quota{
  margin-top: 10px;
}

.mylib-quota-label{
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.mylib-quota-bar{
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0,0,0,0.10);
}

.mylib-quota-fill{
  height: 100%;
  border-radius: 999px;
  background: rgba(0,0,0,0.35);
}

/* Scrollable content */
.mylib-content{
  flex: 1 1 auto;
  overflow: auto;
  padding: 14px 18px 24px 18px;
}

/* Use pins layout (Search Results style), but tune width for library */
.mylib-grid{
  column-width: 280px;
  column-gap: 14px;
  padding: 0;
}

/* Library cards (pins) - add room for kebab menu */
.mylib-pin{
  position: relative;
}

/* Kebab button */
.mylib-kebab{
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--card-bg);
  color: var(--fg);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.mylib-kebab:hover{
  background: rgba(0,0,0,0.05);
}

/* Dropdown menu */
.mylib-menu{
  position: absolute;
  top: 44px;
  right: 12px;
  min-width: 190px;
  padding: 6px;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  box-shadow: 0 16px 34px rgba(0,0,0,0.18);
  display: none;
  z-index: 50;
}

.mylib-menu.open{
  display: block;
}

.mylib-menu button{
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--fg);
  text-align: left;
  padding: 10px 10px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
}

.mylib-menu button:hover{
  background: rgba(0,0,0,0.06);
}

.mylib-menu button.danger{
  color: #b91c1c;
}

.mylib-menu .sep{
  height: 1px;
  background: var(--border-subtle);
  margin: 6px 6px;
}

/* Simple non-image preview hero */
.mylib-file-hero{
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  background: rgba(0,0,0,0.04);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Empty state */
.mylib-empty{
  margin-top: 20px;
  border: 1px dashed var(--border-subtle);
  border-radius: 16px;
  padding: 18px;
  color: var(--muted);
}

/* Modal */
.mylib-modal{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10010;
}

.mylib-modal-card{
  width: min(540px, 92vw);
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 14px;
  color: var(--fg);
}

.mylib-modal-head{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.mylib-modal-title{
  font-size: 18px;
  font-weight: 800;
}

.mylib-modal-sub{
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.mylib-modal-close{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--card-bg);
  cursor: pointer;
}

.mylib-modal-close:hover{
  background: rgba(0,0,0,0.06);
}

.mylib-modal-body{
  padding: 8px 2px 2px 2px;
}

.mylib-modal-label{
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.mylib-modal-select{
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg);
  color: var(--fg);
}

.mylib-modal-note{
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(185, 28, 28, 0.35);
  background: rgba(185, 28, 28, 0.06);
  color: #7f1d1d;
  font-size: 13px;
}

.mylib-modal-actions{
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
