/* 12 寸平板优先：深色、大触摸目标、横屏左侧导航 / 竖屏顶部导航。
   整个布局用 position:fixed + grid，不用 vh（GeckoView 上 vh 不可靠）。 */

:root {
  --bg: #0f1218;
  --panel: #171c25;
  --panel-2: #232b38;
  --text: #eef2f8;
  --muted: #94a0b3;
  --accent: #4f9cf9;
  --accent-2: #7c5cff;
  --border: #2a3342;
  --radius: 14px;
  --danger: #ff8a9a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ------------------------------------------------------------ 布局 */

.app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr) auto;
  grid-template-areas:
    "top top"
    "nav main"
    "player player";
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(79, 156, 249, 0.10), transparent 60%),
    radial-gradient(900px 500px at 95% 0%, rgba(124, 92, 255, 0.08), transparent 55%),
    var(--bg);
}

/* ------------------------------------------------------------ 顶栏 */

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 18, 24, 0.86);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
  white-space: nowrap;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 16px rgba(79, 156, 249, 0.8);
}

.search {
  flex: 1;
  max-width: 560px;
}

.search input {
  width: 100%;
  height: 42px;
  padding: 0 18px;
  border-radius: 21px;
  border: 1px solid var(--border);
  background: var(--panel);
  outline: none;
  font-size: 15px;
}

.search input::placeholder { color: #6f7c90; }
.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 156, 249, 0.16);
}

.scan {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  white-space: nowrap;
}

.scan-status {
  font-size: 12.5px;
  color: var(--muted);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scan-status.busy { color: var(--accent); }

/* ------------------------------------------------------------ 按钮 */

.btn {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 21px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #06101f;
  font-weight: 600;
  font-size: 14px;
  transition: filter 0.15s, background 0.15s;
}

.btn:hover { filter: brightness(1.08); }

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { color: var(--danger); border-color: rgba(255, 138, 154, 0.35); }
.btn.danger:hover { background: rgba(255, 138, 154, 0.10); }

.icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.on { color: var(--accent); }
.icon-btn.fav.on, .icon-btn.fav.big.on { color: #ff5d7a; }

.icon-btn.primary {
  width: 58px;
  height: 58px;
  font-size: 23px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 22px rgba(79, 156, 249, 0.35);
}

.icon-btn.primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

/* ------------------------------------------------------------ 侧栏 */

.nav {
  grid-area: nav;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 10px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  min-height: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: var(--panel); color: var(--text); }

.nav-item.active {
  color: var(--text);
  background: linear-gradient(90deg, rgba(79, 156, 249, 0.22), rgba(124, 92, 255, 0.12));
}

.nav-icon { width: 20px; text-align: center; font-size: 16px; opacity: 0.85; }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--muted); }

.nav-sep { height: 1px; background: var(--border); margin: 10px 8px; }

.nav-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
}

.icon-btn.small { width: 32px; height: 32px; font-size: 16px; }

.nav-playlists { display: flex; flex-direction: column; gap: 2px; }
.nav-playlists .nav-item { min-height: 40px; font-size: 14px; }

.nav-foot {
  margin-top: auto;
  padding: 14px 12px 4px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ------------------------------------------------------------ 主区 */

.main {
  grid-area: main;
  overflow-y: auto;
  min-height: 0;
  padding: 22px 28px 36px;
}

.main-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.main-title h1 {
  margin: 0 0 4px;
  font-size: 28px;
  line-height: 1.2;
}

.main-title p { margin: 0; font-size: 13.5px; }
.main-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.list { display: flex; flex-direction: column; gap: 2px; }

.list-foot { padding: 18px 0 8px; text-align: center; }

.empty {
  padding: 70px 20px;
  text-align: center;
  color: var(--muted);
  line-height: 1.8;
}

.empty strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 6px; }
.empty code { background: var(--panel); padding: 2px 7px; border-radius: 6px; color: var(--text); }

/* ------------------------------------------------------------ 歌曲行 */

.track-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 56px 64px 44px 44px;
  align-items: center;
  gap: 8px;
  min-height: 62px;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}

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

.track-row.playing {
  background: linear-gradient(90deg, rgba(79, 156, 249, 0.18), rgba(79, 156, 249, 0.02));
}

.track-index {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.track-main { min-width: 0; }

.track-title {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-row.playing .track-title { color: var(--accent); }

.track-sub {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.track-format {
  font-size: 10px;
  letter-spacing: 0.6px;
  color: var(--muted);
  text-align: center;
}

.track-duration {
  font-size: 13px;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.eq {
  display: inline-flex;
  gap: 2px;
  align-items: flex-end;
  font-size: 10px;
  color: var(--accent);
  letter-spacing: -1px;
}

/* ------------------------------------------------------------ 专辑 */

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 18px;
}

.album-card {
  display: block;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  text-align: left;
  color: inherit;
  transition: background 0.15s, transform 0.12s;
}

.album-card:hover { background: var(--panel-2); }
.album-card:active { transform: scale(0.985); }

.cover {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: hsl(var(--hue, 220) 36% 26%);
}

.cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-letter {
  font-size: 44px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.5);
  user-select: none;
}

.album-name {
  margin-top: 10px;
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.album-sub {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------ 艺术家 */

.artist-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 68px;
  padding: 8px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
}

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

.artist-avatar {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.72);
  background: hsl(var(--hue, 220) 36% 28%);
}

.artist-main { min-width: 0; flex: 1; }
.artist-name { font-size: 15.5px; font-weight: 600; }
.artist-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.chev { color: var(--muted); font-size: 22px; }

/* ------------------------------------------------------------ 播放器 */

.player {
  grid-area: player;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 1.25fr) minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding: 10px 22px 12px;
  border-top: 1px solid var(--border);
  background: rgba(20, 25, 34, 0.96);
  backdrop-filter: blur(14px);
}

.now { display: flex; align-items: center; gap: 12px; min-width: 0; }

.cover.small {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  border-radius: 10px;
  font-size: 22px;
}

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

.now-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.now-sub {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn.fav.big { flex: 0 0 44px; font-size: 21px; }

.controls { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.control-row { display: flex; align-items: center; justify-content: center; gap: 8px; }

.progress-row { display: flex; align-items: center; gap: 10px; }

.time {
  min-width: 40px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.extras {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

/* ------------------------------------------------------------ 滑杆 */

.range {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--fill, 0%),
    var(--border) var(--fill, 0%),
    var(--border) 100%
  );
  outline: none;
  cursor: pointer;
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}

.range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
}

.progress { flex: 1; min-width: 120px; }
.volume { width: 104px; }

/* ------------------------------------------------------------ 队列 */

.queue-panel {
  position: absolute;
  right: 16px;
  bottom: 108px;
  width: 380px;
  max-width: calc(100% - 32px);
  max-height: 62%;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  z-index: 30;
  overflow: hidden;
}

.queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 10px 18px;
  border-bottom: 1px solid var(--border);
}

.queue-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.queue-list { overflow-y: auto; padding: 8px; }

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.queue-item:hover { background: var(--panel-2); }
.queue-item.playing { background: rgba(79, 156, 249, 0.16); }
.queue-num { width: 22px; font-size: 12px; color: var(--muted); text-align: center; }
.queue-text { min-width: 0; flex: 1; }
.queue-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-dur { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ 弹窗与菜单 */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.58);
}

.modal-card {
  width: min(460px, 100%);
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.modal-card h3 { margin: 0 0 8px; font-size: 18px; }
.modal-card p { margin: 0 0 10px; font-size: 13.5px; line-height: 1.6; }

.modal-card input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
  outline: none;
}

.modal-card input:focus { border-color: var(--accent); }

.modal-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  margin: 12px 0;
  overflow-y: auto;
}

.modal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.modal-item:hover { background: var(--panel-2); }

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

.menu {
  position: fixed;
  z-index: 60;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.menu button {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
}

.menu button:hover { background: var(--panel-2); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 128px;
  z-index: 70;
  transform: translateX(-50%);
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--panel-2);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  font-size: 14px;
}

/* ------------------------------------------------------------ 竖屏 / 窄屏 */

@media (max-width: 900px), (max-aspect-ratio: 4/5) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 58px auto minmax(0, 1fr) auto;
    grid-template-areas:
      "top"
      "nav"
      "main"
      "player";
  }

  .topbar { padding: 0 14px; gap: 10px; }
  .brand { font-size: 18px; }
  .scan-status { display: none; }

  .nav {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .nav-group { display: flex; gap: 6px; }
  .nav-item { width: auto; min-height: 40px; padding: 0 12px; white-space: nowrap; }
  .nav-sep, .nav-heading, .nav-foot { display: none; }
  .nav-playlists { flex-direction: row; gap: 6px; }

  .main { padding: 16px; }
  .main-title h1 { font-size: 23px; }

  .player {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 8px 14px 10px;
  }

  .now { gap: 10px; }
  .cover.small { width: 44px; height: 44px; flex-basis: 44px; }
  .extras { display: none; }
  .control-row { gap: 14px; }

  .track-row {
    grid-template-columns: 34px minmax(0, 1fr) 56px 44px 44px;
    min-height: 58px;
  }

  .track-format { display: none; }
  .album-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .queue-panel { bottom: 150px; right: 10px; width: calc(100% - 20px); }
}

@media (max-width: 560px) {
  .search { max-width: none; }
  .brand { display: none; }
  .track-duration { display: none; }
  .track-row { grid-template-columns: 30px minmax(0, 1fr) 44px 44px; }
}
