/* 多乐器侧边栏：悬浮面板，风格跟随 tuner.css 的紫色主题 */

.tuner-rail {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  width: 260px;
  max-width: calc(100vw - 32px);
  font-size: 13px;
  font-family: inherit;
}

.tuner-rail-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  color: #4b5563;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 6px 20px -8px rgba(76, 29, 149, .25);
  transition: border-color .18s ease, color .18s ease;
}

.tuner-rail-toggle:hover,
.tuner-rail-toggle:focus-visible {
  border-color: #c4b5fd;
  color: #6d28d9;
  outline: none;
}

.tuner-rail-toggle svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform .18s ease;
}

.tuner-rail.is-open .tuner-rail-toggle svg {
  transform: rotate(180deg);
}

.tuner-rail-panel {
  display: none;
  margin-bottom: 8px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 28px -10px rgba(76, 29, 149, .28);
}

.tuner-rail.is-open .tuner-rail-panel {
  display: block;
}

.tuner-rail-title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
}

.tuner-rail-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  max-height: 46vh;
  overflow-y: auto;
}

.tuner-rail-list li + li {
  margin-top: 2px;
}

.tuner-rail-list a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  color: #374151;
  text-decoration: none;
  transition: background-color .15s ease;
}

.tuner-rail-list a:hover,
.tuner-rail-list a:focus-visible {
  background: #f5f3ff;
  outline: none;
}

.tuner-rail-list li.is-current > a {
  background: #ede9fe;
  color: #5b21b6;
  font-weight: 600;
}

.tuner-rail-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.65;
}

.tuner-rail-list li.is-current .tuner-rail-icon,
.tuner-rail-list a:hover .tuner-rail-icon {
  opacity: 1;
}

.tuner-rail-name {
  flex-shrink: 0;
}

.tuner-rail-meta {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: #9ca3af;
}

.tuner-rail-badge {
  flex-shrink: 0;
  padding: 1px 6px;
  border-radius: 999px;
  background: #dcfce7;
  color: #15803d;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.tuner-rail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid #f3f4f6;
}

.tuner-rail-label {
  font-size: 12px;
  color: #6b7280;
}

.tuner-rail-select {
  padding: 4px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  color: #374151;
}

.tuner-rail-clear {
  width: 100%;
  margin-top: 10px;
  padding: 7px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #6b7280;
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}

.tuner-rail-clear:hover {
  border-color: #fca5a5;
  color: #dc2626;
}

/* 展开时给一层遮罩，点击外部即可收起（移动端更依赖这个） */
.tuner-rail.is-open::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.32);
  z-index: -1;
}

@media (max-width: 640px) {
  .tuner-rail {
    right: 12px;
    left: 12px;
    /* 兼容 iPhone 底部小黑条，否则悬浮栏会被 home indicator 压住 */
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    width: auto;
  }

  /* tuner.css 在窄屏给页面留了 42px 底部内边距，但悬浮栏实际高约 52px，
     不够放，会把最后一块内容挡住，这里补到 68px */
  .tuner-page {
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }

  .tuner-rail-toggle {
    padding: 9px 14px;
  }

  /* 触控目标不小于 44px，手指才点得准 */
  .tuner-rail-list a {
    min-height: 44px;
    padding: 10px 12px;
  }

  .tuner-rail-list {
    max-height: 32vh;
  }

  /* 面板限高，避免在小屏上展开后占满整个视口 */
  .tuner-rail-panel {
    max-height: 58vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tuner-rail-select,
  .tuner-rail-clear {
    min-height: 40px;
  }
}

/* 手机横放这类矮屏：面板再压一压，别顶到固定导航栏 */
@media (max-height: 540px) and (orientation: landscape) {
  .tuner-rail-panel {
    max-height: 66vh;
  }

  .tuner-rail-list {
    max-height: 38vh;
  }
}
