/* Music Box 樣式：深色玻璃風。
   段落順序：變數 → 底層 → 背景 → 版面 → 玻璃面板 → 按鈕與輸入 → 清單列 → 播放器 → 選單與對話框 → 視窗尺寸 */

/* ---------- 變數 ---------- */
:root {
  color-scheme: dark;
  --text: #f5f5f7;
  --dim: rgba(235, 235, 245, 0.62);
  --acc: #64d2ff;
  --on-acc: #04141c;
  --hot: #ff6b8b;
  --fill: rgba(255, 255, 255, 0.1);
  --fill-strong: rgba(255, 255, 255, 0.2);
  --edge: rgba(255, 255, 255, 0.16);
  --field: rgba(0, 0, 0, 0.25);
  --radius-panel: 22px;
  --radius-item: 12px;
}

/* ---------- 底層 ---------- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  /* 用 dvh 不用 vh：手機上 100vh 是網址列收起來時的高度，比看得到的畫面高，
     iPod 模式和迷你模式（高度設 100dvh）會被這條撐高，整個版面往下偏、底部被切掉 */
  min-height: 100dvh;
  background: #080a18;
  color: var(--text);
  font:
    15px/1.5 -apple-system,
    BlinkMacSystemFont,
    'SF Pro Text',
    'Segoe UI',
    'PingFang TC',
    'Microsoft JhengHei',
    sans-serif;
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h2 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--dim);
}

ul,
ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

/* 單行截斷、次要文字 */
.t {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.c {
  color: var(--dim);
  font-size: 12px;
}

/* ---------- 背景 ----------
   沒播放時是彩色光暈；播放時疊上那首歌封面的模糊放大版；裝了背景光擴充功能的瀏覽器改疊影片的即時畫面 */
#amb {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(60vmax 60vmax at 10% 5%, #3848d6 0%, transparent 60%),
    radial-gradient(50vmax 50vmax at 92% 15%, #a836cf 0%, transparent 60%),
    radial-gradient(60vmax 60vmax at 60% 105%, #0e9aa8 0%, transparent 60%), #080a18;
}

#art,
#live {
  position: absolute;
  inset: -15%;
  filter: blur(80px) saturate(1.8) brightness(0.45);
  opacity: 0;
  transition: opacity 1.2s;
}

#art {
  background: center / cover;
}

/* 影片的即時畫面（只有幾十個色塊，見 app.js 的「即時背景」）；有在收的時候蓋過封面 */
#live {
  width: 130%;
  height: 130%;
  object-fit: cover;
}

/* ---------- 版面 ---------- */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
}

#sleepInfo {
  margin-left: auto;
}

#ambBtn {
  padding: 4px 12px;
  font-size: 13px;
}

/* 左右兩欄的寬度可以拖（app.js 的「版面調整」把拖出來的值寫進 --col-lists、--col-side）；
   這裡再夾一次上下限，視窗變小時存下來的寬度才不會把中間那欄擠掉 */
main {
  --w-lists: clamp(160px, var(--col-lists, 280px), 30vw);
  /* 上限：扣掉左欄、兩道空隙和邊距之後，至少留 280px 給中間的歌曲欄 */
  --w-side: clamp(280px, var(--col-side, 380px), calc(100vw - var(--w-lists) - 336px));
  position: relative;
  display: grid;
  grid-template-columns: var(--w-lists) minmax(0, 1fr) var(--w-side);
  grid-template-areas:
    'lists player tracks'
    'find player tracks';
  gap: 14px;
  padding: 0 14px 14px;
  width: 100%;
}

/* iPod 模式專用的外殼、主選單和點按輪：其他尺寸下外殼不算一層（main 照舊直接排在 body 裡），另外兩個不顯示 */
#ipod {
  display: contents;
}

#ipodMenu,
#queuePanel,
#ipodGrip,
#wheel {
  display: none;
}

/* 頁尾的出處連結（迷你模式不顯示） */
footer {
  padding: 0 14px 10px;
  text-align: center;
}

footer a {
  color: inherit;
}

/* 拖曳把手：疊在兩欄中間那道空隙上，平常看不見，滑鼠移上去或拖的時候才出現一條線 */
.split {
  display: none;
  position: absolute;
  top: 0;
  bottom: 14px;
  width: 14px;
  cursor: col-resize;
  touch-action: none;
}

/* 換位置的把手：面板頂端中間一條短線，滑鼠移到面板上才出現；按住拖到另一個面板上，兩個交換 */
.grip {
  display: none;
  position: absolute;
  top: 0;
  left: 50%;
  width: 56px;
  height: 14px;
  padding: 0;
  border: 0;
  background: none;
  transform: translateX(-50%);
  cursor: grab;
  touch-action: none;
}

.grip::after {
  content: '';
  position: absolute;
  inset: 5px 8px;
  border-radius: 2px;
  background: #fff;
  opacity: 0;
  transition: opacity 0.15s;
}

section:hover > .grip::after {
  opacity: 0.3;
}

.grip:hover::after,
.grip:focus-visible::after,
.swap-from > .grip::after {
  opacity: 0.75;
}

.grip:focus-visible {
  outline: none;
}

.grip:active {
  cursor: grabbing;
}

/* 拖把手的期間：影片的框不接滑鼠（不然事件會被它吃掉），也不要反白到文字 */
.layout-drag {
  user-select: none;
}

.layout-drag iframe {
  pointer-events: none;
}

/* 拖的時候：被拖的面板變淡，滑鼠底下那個要交換的面板亮框 */
.swap-from {
  opacity: 0.55;
}

.swap-to {
  outline: 2px solid var(--acc);
  outline-offset: -2px;
}

.split[data-col='lists'] {
  left: calc(14px + var(--w-lists));
}

.split[data-col='side'] {
  right: calc(14px + var(--w-side));
}

.split::after {
  content: '';
  position: absolute;
  inset: 16px 5px;
  border-radius: 2px;
  background: #fff;
  opacity: 0;
  transition: opacity 0.15s;
}

.split:hover::after {
  opacity: 0.25;
}

.split:focus-visible {
  outline: none;
}

.split:focus-visible::after,
.split.dragging::after {
  opacity: 0.6;
}

section {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px;
}

#listsPanel {
  grid-area: lists;
}

#tracksPanel {
  grid-area: tracks;
}

#playerPanel {
  grid-area: player;
}

#findPanel {
  grid-area: find;
}

/* 捲軸：平常看不到，滑鼠移到那個區塊上（或鍵盤焦點在裡面）才浮出一條細的，沒有上下箭頭。
   位置一直留著，所以浮出來時內容不會被擠動。觸控裝置沒有「移過去」這回事，維持系統自己的捲軸 */
@media (hover: hover) {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track,
  ::-webkit-scrollbar-corner {
    background: transparent;
  }

  ::-webkit-scrollbar-button {
    display: none;
  }

  /* 顏色放在變數裡、由捲動的區塊傳給捲軸：直接寫 :hover::-webkit-scrollbar-thumb 的話，
     Chromium 在滑鼠移入移出時不會重畫捲軸，會停在第一次算出來的樣子 */
  ::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background: var(--bar);
  }

  html,
  .scroll {
    --bar: transparent;
  }

  html:hover,
  .scroll:hover,
  .scroll:focus-within {
    --bar: rgba(255, 255, 255, 0.3);
  }
}

/* Firefox 不認上面那組，用標準屬性做同樣的事（Chromium 不能兩組都給：給了標準屬性，上面那組就失效） */
@supports not selector(::-webkit-scrollbar) {
  .scroll {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
  }

  .scroll:hover,
  .scroll:focus-within {
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
  }
}

.head {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 10px;
}

.head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.head .pri {
  margin-left: auto;
}

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.bar > button,
.bar > .c {
  flex: none;
}

/* ---------- 玻璃面板 ---------- */
section,
dialog,
#menu {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05) 40%), rgba(16, 18, 36, 0.4);
  backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--edge);
  border-radius: var(--radius-panel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 24px 48px -24px rgba(0, 0, 0, 0.7);
  color: var(--text);
}

/* ---------- 按鈕與輸入 ---------- */
button {
  font: inherit;
  color: var(--text);
  background: var(--fill);
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.1s;
}

button:hover {
  background: var(--fill-strong);
}

button:active {
  transform: scale(0.95);
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

button:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}

button svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* 線條畫的圖示（隨機、循環、鉛筆） */
svg.line {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 圓形圖示鈕 */
button.ic {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  padding: 0;
}

/* 主要動作，以及按下去是「開著」狀態的開關 */
button.pri,
button[aria-pressed='true'] {
  background: var(--acc);
  border-color: transparent;
  color: var(--on-acc);
  font-weight: 600;
}

button.pri {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

/* 不搶眼的小鈕（刪除、改名） */
button.x {
  background: none;
  border: none;
  color: var(--dim);
  padding: 4px 8px;
}

button.x:hover {
  background: none;
  color: var(--hot);
}

#renameBtn:hover {
  color: var(--acc);
}

#renameBtn svg {
  width: 15px;
  height: 15px;
}

input,
select {
  font: inherit;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--edge);
  border-radius: var(--radius-item);
  padding: 8px 12px;
}

input {
  width: 100%;
  min-width: 0;
}

input[type='checkbox'] {
  width: auto;
  accent-color: var(--acc);
}

input::placeholder {
  color: var(--dim);
}

input:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--acc);
  box-shadow: 0 0 0 3px rgba(100, 210, 255, 0.3);
}

/* ---------- 清單列（歌單、歌曲、搜尋結果共用） ---------- */
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-item);
  transition: background 0.15s;
}

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

.row.on {
  background: var(--fill-strong);
}

.row.on .t:not(.c) {
  color: var(--acc);
  font-weight: 600;
}

.row .main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 0;
  background: none;
  border: none;
  border-radius: 8px;
  text-align: left;
}

.row .main:active {
  transform: none;
}

.row img {
  flex: none;
  width: 64px;
  height: 36px;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
}

.row .txt {
  min-width: 0;
}

.row .add {
  flex: none;
  margin-left: auto;
}

/* 貼播放清單連結時，結果最上面那顆「全部加入」 */
.row .all {
  flex: 1;
}

#lists .main {
  justify-content: space-between;
}

.empty {
  padding: 6px 8px;
  color: var(--dim);
  font-size: 13px;
}

/* 拖曳：歌曲列可以抓，放下的位置用藍線標出來；拖到歌單上整列亮起 */
#tracks .row[draggable='true'] {
  cursor: grab;
}

.dragging .row > * {
  pointer-events: none; /* 拖曳中只讓整列收事件，不然滑過子元素會一直閃 */
}

.row.drop-before {
  box-shadow: inset 0 2px 0 var(--acc);
}

.row.drop-after {
  box-shadow: inset 0 -2px 0 var(--acc);
}

.row.drop-into {
  background: var(--fill-strong);
  box-shadow: inset 0 0 0 2px var(--acc);
}

/* ---------- 播放器 ---------- */
#playerBox {
  flex: none;
  aspect-ratio: 16 / 9;
  margin-bottom: 12px;
  overflow: hidden;
  border-radius: 16px;
  background: #000;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.8);
}

#playerBox iframe {
  display: block;
  width: 100%;
  height: 100%;
}

#playerBox:fullscreen {
  border-radius: 0;
}

#nowT {
  font-size: 16px;
  font-weight: 600;
}

.ctl {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 10px 0 0;
}

/* 歌名一行，右邊是全螢幕鍵（控制列在窄面板放不下第六顆） */
.now {
  display: flex;
  align-items: center;
  gap: 10px;
}

.now > div {
  flex: 1;
  min-width: 0;
}

#toggleBtn {
  justify-content: center; /* 它同時是 .pri（橫向排列、預設靠左），要自己置中 */
  width: 52px;
  height: 52px;
}

#toggleBtn svg {
  width: 22px;
  height: 22px;
}

/* 播放鍵依狀態只顯示一個圖示 */
#toggleBtn[data-playing] .i-play,
#toggleBtn:not([data-playing]) .i-pause {
  display: none;
}

#msg {
  min-height: 1.5em;
  margin: 0 0 6px;
  color: var(--hot);
  font-size: 13px;
}

/* ---------- 歌詞 ----------
   在播放器面板最下面。面板夠高（播放器在整欄高的格子）時吃掉剩下的高度，否則只露出幾行 */
#lyrics {
  position: relative;
  flex: 1 1 0;
  min-height: 168px;
  margin-top: 12px;
  /* 上下留白，第一句和最後一句才捲得到正中間 */
  padding-block: 62px;
  overflow-y: auto;
  scrollbar-width: none;
  text-align: center;
  /* 上下兩端淡出，歌詞像是從邊緣滑進來 */
  mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent);
}

#lyrics p {
  margin: 0;
  padding: 5px 10px;
  border-radius: 8px;
  color: var(--dim);
  font-size: 15px;
  line-height: 1.5;
  cursor: pointer;
  transition: color 0.3s;
}

#lyrics p:hover {
  color: var(--text);
}

#lyrics p.on {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}

/* 沒有時間軸的歌詞、和「查詢中／找不到」的提示：不能點 */
#lyrics.plain p,
#lyrics p.note {
  cursor: default;
}

#lyrics p.note {
  font-size: 13px;
}

#lyricsBar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}

#lyricsBar[hidden] {
  display: none;
}

#lyricsBar button {
  padding: 2px 10px;
  font-size: 12px;
}

/* 沒有時間軸的歌詞用不到調時間的按鈕，只留來源 */
#lyricsBar.plain button {
  display: none;
}

#lyricsBar a {
  margin-left: 6px;
}

/* ---------- 選單與對話框 ---------- */
#menu {
  inset: 58px 14px auto auto;
  width: 250px;
  margin: 0;
  padding: 10px;
}

#menu:popover-open {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#menu button {
  border-radius: var(--radius-item);
  text-align: left;
}

#menu label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0 2px 14px;
}

#menu p {
  margin: 0;
  padding: 0 14px;
}

dialog {
  width: 92vw;
  max-width: 440px;
  padding: 20px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
}

dialog ol {
  list-style: decimal;
  padding-left: 1.4em;
  color: var(--dim);
  font-size: 13px;
}

dialog a {
  color: var(--acc);
}

dialog code {
  white-space: nowrap;
}

/* 「儲存」在原始碼裡排第一個，按 Enter 才會是儲存；畫面上用反向排列放回右邊 */
.actions {
  display: flex;
  flex-direction: row-reverse;
  gap: 8px;
  margin: 12px 0 0;
}

/* ---------- 視窗尺寸 ---------- */
/* 有滑鼠時，刪除鈕移上去才出現 */
@media (hover: hover) {
  .row .x {
    opacity: 0;
    transition: opacity 0.15s;
  }

  .row:hover .x,
  .row .x:focus-visible {
    opacity: 1;
  }
}

/* 寬視窗：整頁不捲，三塊玻璃各自捲，播放器永遠看得到 */
@media (min-width: 901px) {
  body {
    display: flex;
    flex-direction: column;
    height: 100vh;
  }

  main {
    flex: 1;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
  }

  .split {
    display: block;
  }

  /* 播放器在上下疊的那一欄、欄又拉得很寬時，畫面不要高到把同欄另一個面板擠不見 */
  #playerBox {
    max-height: 62vh;
  }
}

/* 寬視窗（迷你模式除外）：四個面板可以互換位置。格子是 a 左欄上、b 左欄下、c 中欄、d 右欄，
   每個面板在哪一格由 app.js 的「版面調整」寫在 data-slot；左欄上下怎麼分高度寫在 --rows */
@media (min-width: 901px) and (min-height: 521px) {
  main {
    grid-template-areas:
      'a c d'
      'b c d';
    grid-template-rows: var(--rows, minmax(0, 2fr) minmax(0, 3fr));
  }

  :is(#listsPanel, #tracksPanel, #playerPanel, #findPanel)[data-slot='a'] {
    grid-area: a;
  }

  :is(#listsPanel, #tracksPanel, #playerPanel, #findPanel)[data-slot='b'] {
    grid-area: b;
  }

  :is(#listsPanel, #tracksPanel, #playerPanel, #findPanel)[data-slot='c'] {
    grid-area: c;
  }

  :is(#listsPanel, #tracksPanel, #playerPanel, #findPanel)[data-slot='d'] {
    grid-area: d;
  }

  .grip {
    display: block;
  }

  /* 播放器放到整欄高的格子時：畫面照 16:9 盡量放大，欄不夠高才壓扁（影片本身不會變形，只是上下留黑） */
  #playerPanel:is([data-slot='c'], [data-slot='d']) #playerBox {
    flex: 0 1 auto;
    min-height: 120px;
    max-height: none;
  }
}

/* 窄視窗與手機：單欄。播放器黏在畫面上方，下面的歌單怎麼捲它都在 */
@media (max-width: 900px) {
  main {
    grid-template-columns: 1fr;
    grid-template-areas:
      'player'
      'find'
      'lists'
      'tracks';
  }

  #playerPanel {
    position: sticky;
    top: 8px;
    z-index: 1;
  }

  /* 播放器黏在上面佔位置，歌詞只露兩行，調時間的按鈕收掉 */
  #lyrics {
    min-height: 68px;
    padding-block: 18px;
  }

  #lyricsBar {
    display: none;
  }
}

/* 觸控裝置：iPhone 會在字小於 16px 的輸入框自動把整頁放大，所以把字放到 16px */
@media (pointer: coarse) {
  input,
  select {
    font-size: 16px;
  }

  /* 手機和平板的瀏覽器裝不了擴充功能 */
  #ambBtn {
    display: none;
  }
}

/* 迷你模式：視窗高度很矮時只留畫面、歌名和控制鈕 */
@media (max-height: 520px) {
  header,
  footer,
  main > .split,
  main > section:not(#playerPanel) {
    display: none;
  }

  body {
    display: flex;
    flex-direction: column;
    height: 100dvh;
  }

  main {
    flex: 1;
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: 'player';
    padding: 8px;
  }

  #playerPanel {
    position: static;
    padding: 10px;
  }

  #playerBox {
    flex: 1;
    min-height: 0;
    aspect-ratio: auto;
    margin-bottom: 8px;
  }

  #lyrics,
  #lyricsBar {
    display: none;
  }

  .ctl {
    margin: 6px 0 0;
  }
}

/* ---------- iPod 模式 ----------
   視窗窄又夠高（手機直向，或把電腦上的視窗縮窄）時整頁變成一台 iPod：外殼 #ipod、螢幕 main、點按輪 #wheel。
   螢幕最上面一條標題列，接著是 MV，下面一次只顯示一頁（主選單、播放中的前後三首、歌單、歌曲、找歌，或歌名加歌詞）；
   顯示哪一頁看 main 的 data-ipod。這條媒體查詢要跟 app.js 的 IPOD_MEDIA 一致 */
@media (max-width: 600px) and (min-height: 521px) {
  body {
    display: grid;
    place-items: center;
    height: 100dvh;
    overflow: hidden;
  }

  header,
  footer {
    display: none;
  }

  /* 外殼：預設黑色，主選單的「外殼顏色」可以換成銀色（<html data-skin>） */
  #ipod {
    --shell: linear-gradient(165deg, #5d5f65, #3a3c41 45%, #26272b);
    --wheel-bg: #131416;
    --wheel-ink: #f2f2f4;
    --ok: linear-gradient(160deg, #5a5c62, #3b3d42);
    --gap: min(3dvh, 28px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--gap);
    width: min(100vw, 430px);
    height: min(100dvh, 900px);
    padding: 16px 16px var(--gap);
    border-radius: 36px;
    background: var(--shell);
    box-shadow:
      inset 0 1px 1px rgba(255, 255, 255, 0.35),
      inset 0 0 0 1px rgba(255, 255, 255, 0.08),
      0 30px 60px -20px rgba(0, 0, 0, 0.8);
  }

  [data-skin='silver'] #ipod {
    --shell: linear-gradient(165deg, #f4f5f7, #d3d6da 45%, #b4b8be);
    --wheel-bg: #fbfbfc;
    --wheel-ink: #a3a6ad;
    --ok: linear-gradient(160deg, #e3e5e8, #c2c5cb);
  }

  /* 螢幕 */
  main {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0;
    min-height: 0;
    padding: 0;
    overflow: clip;
    border: 4px solid #050506;
    border-radius: 12px;
    background: linear-gradient(#151829, #0a0c18);
  }

  /* 標題列：字是現在這一頁的名字；有在播放時左邊多一個小三角 */
  main::before {
    content: attr(data-title);
    flex: none;
    padding: 3px 30px;
    overflow: hidden;
    border-bottom: 1px solid rgba(0, 0, 0, 0.5);
    background: linear-gradient(rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.06));
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    order: -2; /* 排在播放器（order -1）前面 */
  }

  main:has(#toggleBtn[data-playing])::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 11px;
    border-block: 5px solid transparent;
    border-left: 8px solid var(--acc);
  }

  /* 螢幕裡的面板不再是一塊塊玻璃，一次只顯示一頁 */
  main > section {
    display: none;
    padding: 8px 8px 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    backdrop-filter: none;
  }

  main[data-ipod='menu'] #ipodMenu,
  main[data-ipod='queue'] #queuePanel,
  main[data-ipod='lists'] #listsPanel,
  main[data-ipod='tracks'] #tracksPanel,
  main[data-ipod='find'] #findPanel {
    display: flex;
    flex: 1;
    min-height: 0;
  }

  .scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
  }

  /* 面板自己的標題跟螢幕標題列重複；歌曲頁上面那排（改名、從頭播放）也收掉，把高度留給歌曲列：
     播放用點按輪，改歌單名稱到寬版面去改 */
  main > section > h2,
  #tracksPanel .head {
    display: none;
  }

  main .bar {
    margin-bottom: 6px;
  }

  main .bar input {
    padding-block: 4px;
  }

  .row .txt {
    line-height: 1.3;
  }

  /* 播放器：MV 固定在螢幕最上面（標題列下面），照正常比例佔滿螢幕寬；下面剩多少高度就給那一頁的清單。
     控制鈕由點按輪代替，歌名和歌詞只在「歌詞」那一頁顯示 */
  #playerPanel {
    position: relative;
    display: flex;
    flex: none;
    order: -1;
    padding: 0;
    border-bottom: 1px solid var(--edge);
  }

  #playerBox {
    margin: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .now,
  .ctl,
  #lyrics {
    display: none;
  }

  /* 「歌詞」那一頁（data-ipod='now'）：MV 下面是歌名和歌詞，佔滿剩下的高度 */
  main[data-ipod='now'] #playerPanel {
    flex: 1;
    min-height: 0;
    border: 0;
  }

  main[data-ipod='now'] .now {
    display: flex;
    padding: 8px 10px 0;
  }

  main[data-ipod='now'] #lyrics {
    display: block;
    min-height: 0;
    margin-top: 4px;
    padding-block: 40px;
  }

  /* 「播放中」頁每一列右邊的小字（上一首、播放中、下一首） */
  #queue .c {
    flex: none;
  }

  /* 清單列排緊一點；點按輪選到的那一列是 iPod 的藍色反白 */
  .row {
    padding: 4px 6px;
    border-radius: 6px;
  }

  .row img {
    width: 48px;
    height: 27px;
    border-radius: 4px;
  }

  .row.sel {
    background: linear-gradient(#58a6f7, #2a7be0);
  }

  .row.sel .t:not(.c),
  .row.sel .c {
    color: #fff;
  }

  #ipodMenu .main {
    justify-content: space-between;
    padding: 2px 4px;
    font-size: 15px;
    font-weight: 600;
  }

  #ipodMenu :is([data-go], [popovertarget])::after {
    content: '›';
    color: var(--dim);
  }

  #ipodMenu .sel .main::after {
    color: #fff;
  }

  /* 「設定」開的是原本右上角那個選單，這裡放到畫面正中間 */
  #menu {
    inset: 0;
    height: fit-content;
    margin: auto;
  }

  /* 點按輪：四顆鍵貼在輪子的上下左右，中間一顆圓鍵。手指在輪子上的移動全部交給 app.js，不讓瀏覽器拿去捲頁面 */
  #wheel {
    position: relative;
    display: block;
    flex: none;
    width: min(60vw, 250px, 36dvh);
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--wheel-bg);
    box-shadow:
      inset 0 2px 3px rgba(255, 255, 255, 0.25),
      inset 0 -3px 8px rgba(0, 0, 0, 0.25),
      0 1px 1px rgba(255, 255, 255, 0.2);
    touch-action: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  #wheel button {
    position: absolute;
    padding: 10px 14px;
    border: 0;
    background: none;
    color: var(--wheel-ink);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
  }

  #whMenu {
    top: 3%;
    left: 50%;
    translate: -50% 0;
  }

  #whPlay {
    bottom: 3%;
    left: 50%;
    translate: -50% 0;
  }

  #whPrev {
    top: 50%;
    left: 2%;
    translate: 0 -50%;
  }

  #whNext {
    top: 50%;
    right: 2%;
    translate: 0 -50%;
  }

  #wheel #whOk {
    inset: 31%;
    padding: 0;
    border-radius: 50%;
    background: var(--ok);
    box-shadow:
      inset 0 1px 1px rgba(255, 255, 255, 0.4),
      0 0 0 1px rgba(0, 0, 0, 0.25);
  }

  /* 沒有標題列的視窗（安裝成 App、桌面外殼）：螢幕和點按輪以外的地方都能抓著拖視窗，
     包括外殼的邊、視窗比 iPod 大時外面那一圈，還有螢幕最上面那條標題列（習慣抓視窗的位置）。
     標題列是 main::before，偽元素設 app-region 沒有作用，所以蓋一個真的元素 #ipodGrip 在上面，高度跟標題列一樣。
     drag 只設在 body：可拖區域是照文件順序疊出來的，#ipod 再設一次會把排在它前面的 #menu 的 no-drag 蓋回去 */
  :where(.wco) :is(body, #ipodGrip) {
    -webkit-app-region: drag;
    app-region: drag;
  }

  :where(.wco) :is(main, #wheel, #menu, dialog) {
    -webkit-app-region: no-drag;
    app-region: no-drag;
  }

  :where(.wco) #ipodGrip {
    position: absolute;
    inset: 0 0 auto;
    display: block;
    height: 27px;
  }
}

/* 安裝成 App 後視窗的標題列會收掉：頂列兼當拖曳視窗的把手，並讓出右上角的視窗按鈕。
   .wco 由 app.js 掛在 <html> 上（不用 display-mode 媒體查詢：Electron 這類外殼也有這種視窗，但那個查詢在它裡面不成立）；
   包在 :where() 裡是為了不墊高優先度，規則的強弱跟原本一樣 */
:where(.wco) {
  header {
    -webkit-app-region: drag;
    app-region: drag;
    padding-right: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw) + 12px);
  }

  header button {
    -webkit-app-region: no-drag;
    app-region: no-drag;
  }

  /* 右上角視窗按鈕那一塊只能是單色（app.js 的「視窗配色」算給瀏覽器的），背景卻是漸層：
     在它周圍鋪一片同色、往左往下淡出，接縫才不會露出來 */
  #amb::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: calc(var(--wco-w, 0px) + 160px);
    height: calc(var(--wco-h, 0px) + 90px);
    background: var(--tint, transparent);
    mask-image:
      linear-gradient(to right, transparent, #000 160px),
      linear-gradient(to bottom, #000 var(--wco-h, 0px), transparent);
    mask-composite: intersect;
  }
}

/* 迷你模式下頂列原本整個藏起來，但沒有標題列時視窗會沒地方抓，所以留一條細的 */
@media (max-height: 520px) {
  :where(.wco) {
    header {
      display: flex;
      min-height: env(titlebar-area-height, 32px);
      padding-block: 0;
    }

    #menuBtn,
    #sleepInfo {
      display: none;
    }

    h1 {
      font-size: 13px;
    }
  }
}

/* 系統設定了「減少透明度」時改成不透明面板 */
@media (prefers-reduced-transparency: reduce) {
  section,
  dialog,
  #menu {
    background: #161a30;
    backdrop-filter: none;
  }
}
