/* ════════ WIDE but not huge — soften side columns ════════ */
@media (max-width: 1280px) {
  :root {
    --panel-w: clamp(220px, 28vw, 280px);
    --sidebar-w: clamp(188px, 24vw, 240px);
  }
}

/* ════════ NARROW DESKTOP / small laptop ════════ */
@media (max-width: 1100px) {
  #player-bar {
    grid-template-columns: minmax(0, 1fr) minmax(140px, 1.4fr) auto;
    gap: 10px 14px;
  }
  #pb-vol-wrap { gap: 6px; }
  #pb-vol { width: 56px; }
}

@media (max-width: 960px) {
  #header {
    flex-wrap: wrap;
    row-gap: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
    min-height: 0;
  }
  #search-block {
    order: 2;
    flex: 1 1 100%;
    max-width: none;
  }
  #source-bar {
    order: 3;
    flex: 1 1 100%;
    padding-bottom: 2px;
  }
  #header-brand { order: 0; }
}

/* ════════ TABLET ════════ */
@media (max-width: 1024px) {
  #sidebar { display: none; }
  #player-bar {
    grid-template-columns: minmax(0, 1fr) minmax(130px, 1.5fr) auto;
  }
}

/* ════════ MOBILE ════════ */
@media (max-width: 680px) {
  :root {
    --player-h: 60px;
    --shell-pad-x: 12px;
  }

  #header {
    flex-wrap: wrap;
    padding: 8px 12px 6px;
    gap: 8px;
  }
  #header-brand #logo { font-size: 14px; }
  #header-mobile-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-left: auto;
    order: 1;
  }
  #search-block {
    order: 2;
    flex: 1 1 100%;
    max-width: none;
  }
  #source-bar {
    order: 3;
    width: 100%;
    padding: 4px 0 6px;
    flex: 1 1 100%;
  }
  #search-wrap { border-radius: 10px; }

  #search-panel {
    position: absolute;
    inset: 0;
    z-index: 10;
    width: 100% !important;
    opacity: 1 !important;
    pointer-events: none;
    display: none;
  }
  #search-panel.mobile-visible {
    display: flex;
    pointer-events: auto;
  }
  #stage.mobile-hidden { display: none; }
  #sidebar { display: none; }

  #stage-content {
    max-height: none;
    padding-top: 12px;
    padding-bottom: 12px;
    gap: 12px;
  }
  #lyric-scroll {
    max-height: min(52vh, 440px);
    min-height: 112px;
  }

  #player-bar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-rows: auto auto;
    min-height: 0;
    height: auto;
    padding: 8px 14px 0;
    padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
    gap: 0;
    align-items: center;
  }
  #pb-info {
    grid-column: 1;
    grid-row: 1;
    padding-bottom: 6px;
    min-width: 0;
  }
  #pb-cover {
    width: 36px;
    height: 36px;
    border-radius: 8px;
  }
  #pb-name { font-size: 12px; }
  #pb-singer { font-size: 10px; }
  #pb-controls {
    grid-column: 2;
    grid-row: 1;
    flex-direction: row;
    gap: 6px;
    padding-bottom: 6px;
    flex-shrink: 0;
  }
  #pb-progress { display: none; }
  #pb-btns { gap: 6px; }
  .pb-btn { font-size: 16px; padding: 6px; }
  #pb-play {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }
  #pb-extra {
    display: flex;
    grid-column: 3;
    grid-row: 1;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 6px;
    gap: 0;
  }
  #pb-mode,
  #pb-vol-wrap { display: none !important; }
  #toggle-search,
  #toggle-queue {
    padding: 8px 9px;
    min-width: 38px;
    min-height: 40px;
    font-size: 14px;
  }

  #pb-seek-mobile-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    width: 100%;
    min-width: 0;
  }
  #pb-seek-m {
    flex: 1;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
    height: 3px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    cursor: pointer;
  }
  #pb-seek-m::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
  }
  #pb-time-m {
    font-size: 10px;
    color: var(--t3);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }

  #toast {
    bottom: calc(var(--player-h) + env(safe-area-inset-bottom, 0px) + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    max-width: calc(100vw - 24px);
  }
  #toast.show {
    transform: translateX(-50%) translateY(0);
  }

  /* 手机全屏侧栏，不用左缘展开条 */
  .panel-reveal { display: none !important; }

  .kbd-modal-panel {
    max-height: min(78dvh, 520px);
  }
  .kbd-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* ════════ very short viewport — lyric steals less ════════ */
@media (max-height: 520px) and (min-width: 681px) {
  #stage-content { gap: 10px; padding-top: 12px; padding-bottom: 12px; }
  #lyric-scroll { max-height: min(36vh, 220px); min-height: 88px; }
}
