/* --- Search dropdown --- */
.search-wrap {
  position: relative;
  flex: 1;
}
.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface-container-low);
  border: 2px solid var(--border-primary);
  border-top: none;
  z-index: 100;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-container-high) transparent;
}
.search-dropdown::-webkit-scrollbar {
  width: 6px;
}
.search-dropdown::-webkit-scrollbar-track {
  background: transparent;
}
.search-dropdown::-webkit-scrollbar-thumb {
  background: var(--surface-container-high);
  border-radius: 3px;
}
.search-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
.search-dropdown[hidden] {
  display: none;
}
.search-suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.3;
}
.search-suggestion:hover,
.search-suggestion.active {
  background: var(--surface-container-high);
}
.search-suggestion img {
  width: 80px;
  aspect-ratio: 16/9;
  object-fit: cover;
  border: 1px solid var(--border-primary);
  flex-shrink: 0;
}
.search-suggestion .sg-info {
  flex: 1;
  min-width: 0;
}
.search-suggestion .sg-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-suggestion .sg-playlist {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: var(--track-mono);
}
.search-hl {
  color: var(--primary);
  font-weight: 700;
}
.search-suggestion .sg-dur {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* --- Grid view --- */
.playlist-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.pl-thumb-link {
  display: block;
  text-decoration: none;
}
.pl-thumb-link img,
.playlist-card img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border: 2px solid var(--border-primary);
  transition: border-color 0.15s;
}
.pl-thumb-link:hover img {
  border-color: var(--cyan);
}
.pl-title-link {
  text-decoration: none;
  color: inherit;
  transition: color 0.15s;
}
.pl-title-link:hover {
  color: var(--cyan);
}
.playlist-card .title {
  font-weight: 700;
  font-family: var(--font-headline);
  font-size: 14px;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.playlist-card .meta {
  font-size: 12px;
}
.playlist-card .expand-btn {
  width: 100%;
}
.playlist-card .action-row {
  justify-content: center;
}
.playlist-card .action-row .btn {
  font-size: 13px;
  padding: 6px 12px;
}

/* --- List view --- */
.playlist-row {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 12px;
  border: 2px solid var(--border-primary);
  background: var(--surface-container);
}
.playlist-row .row {
  width: 100%;
}
.playlist-row .pl-thumb-link img,
.playlist-row img {
  width: 160px;
  min-height: 90px;
  aspect-ratio: 16/9;
  object-fit: cover;
  border: 2px solid var(--border-primary);
  flex-shrink: 0;
  transition: border-color 0.15s;
}
.playlist-row .pl-thumb-link:hover img {
  border-color: var(--cyan);
}
.playlist-row .info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding-left: 8px;
}
.playlist-row .title {
  font-weight: 700;
  font-family: var(--font-headline);
  font-size: 16px;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.playlist-row .meta {
  font-size: 12px;
}
.playlist-row .videos {
  margin-top: 8px;
  border-top: 1px solid var(--border-primary);
  padding-top: 8px;
}
.videos {
  display: none;
  margin-top: 12px;
  border-top: 2px solid var(--border-primary);
  padding-top: 12px;
}
.videos.open {
  display: block;
}

/* --- Grid drawer: dropdown below card --- */
.grid-drawer {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  margin-top: 0;
  border: 2px solid var(--border-primary);
  border-top: none;
  background: var(--surface-container);
  padding: 12px;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-container-high) transparent;
}
.grid-drawer::-webkit-scrollbar {
  width: 5px;
}
.grid-drawer::-webkit-scrollbar-track {
  background: transparent;
}
.grid-drawer::-webkit-scrollbar-thumb {
  background: var(--surface-container-high);
  border-radius: 3px;
}

.video-row {
  display: flex;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--outline);
  align-items: center;
}
.video-row .dot {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border-primary);
  background: var(--surface-container-high);
  flex: 0 0 auto;
  cursor: pointer;
}
.video-row .dot.done {
  background: var(--primary-container);
}
.video-row a {
  flex: 1;
  min-width: 0;
}
.video-row .dur {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}
.video-row.watched-dim {
  opacity: 0.45;
}
.video-row.watched-dim a {
  text-decoration: line-through;
  color: var(--text-muted);
}
.video-row.watched-dim img {
  filter: grayscale(1);
}
.todo-row {
  display: flex;
  gap: 10px;
  padding: 10px;
  border: 2px solid var(--border-primary);
  background: var(--surface-container-low);
  margin-bottom: 8px;
  align-items: center;
}
.todo-linked-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}
.todo-linked {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--cyan);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.todo-linked:hover {
  text-decoration: underline;
}
.todo-unlink-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}
.todo-unlink-btn:hover {
  color: var(--on-surface);
}
.locked {
  opacity: 0.4;
  pointer-events: none;
}
/* --- Collection Folder Cards --- */
.col-folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.col-folder-card {
  border: 2px solid var(--border-primary);
  background: var(--surface-container);
  border-radius: var(--radius);
  overflow: hidden;
}
.col-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 15px;
  transition: background 0.12s;
}
.col-folder-header:hover {
  background: var(--surface-container-high);
}
.col-folder-header.open {
  border-bottom: 1px solid var(--border-primary);
}
.col-folder-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.col-folder-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.col-folder-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-container-high);
  padding: 2px 8px;
  border-radius: var(--radius);
}
.col-delete {
  font-size: 16px;
  padding: 0 4px !important;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.12s;
}
.col-delete:hover {
  opacity: 1;
}
.col-folder-body {
  padding: 8px 12px 12px;
}
.col-folder-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  transition: background 0.12s;
}
.col-folder-item:hover {
  background: var(--surface-container-high);
}
.col-folder-item img {
  width: 48px;
  height: 28px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border-primary);
  flex-shrink: 0;
}
.col-folder-item span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.col-folder-item .col-unassign {
  font-size: 12px;
  padding: 4px 8px;
  flex-shrink: 0;
}
.col-add-picker {
  font-size: 13px;
  cursor: pointer;
}
.col-folder-add {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
}
.col-folder-add:hover {
  background: var(--surface-container-high);
}
.col-tag {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--cyan);
  letter-spacing: var(--track-mono);
  text-transform: uppercase;
}

/* --- Select dropdown theme --- */
select.input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a8a8a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

/* --- Custom select dropdown --- */
.custom-select {
  position: relative;
}
.custom-select-trigger {
  cursor: pointer;
  text-align: left;
  width: 100%;
  background: var(--surface-container);
}
.custom-select-panel {
  display: none;
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--surface-container);
  border: var(--border-width) solid var(--border-primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow-y: auto;
}
.custom-select-panel:not([hidden]) {
  display: block;
}
.custom-select-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--on-surface);
}
.custom-select-item:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}
.custom-select-item:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}
.custom-select-item:hover {
  background: var(--surface-container-high);
}

/* --- Add playlist card (grid view) --- */
.add-playlist-card {
  border: 2px dashed var(--border-primary);
  background: transparent;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  cursor: pointer;
  position: relative;
  transition: background 0.12s;
}
.add-playlist-card:hover {
  background: var(--surface-container-high);
}
.add-playlist-card .custom-select-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}

/* --- Add playlist row (list view) --- */
.add-playlist-row {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border: 2px dashed var(--border-primary);
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: background 0.12s;
}
.add-playlist-row:hover {
  background: var(--surface-container-high);
}
.add-playlist-row .custom-select-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
}

/* --- Sync button feedback --- */
.btn-sync-ok {
  background: #2e7d32 !important;
  color: #fff !important;
  border-color: #2e7d32 !important;
}
.btn-sync-err {
  background: #c62828 !important;
  color: #fff !important;
  border-color: #c62828 !important;
}
