/* ============ KML Player — 移动端优先 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* SVG 元素不受 HTML UA 样式表 [hidden]{display:none} 影响，需显式声明，
   否则播放/暂停、静音、播放模式等成对图标会同时显示 */
[hidden], svg[hidden] { display: none !important; }

:root {
  --bg: #0f1222;
  --bg2: #1a1f38;
  --card: rgba(255, 255, 255, 0.06);
  --card-hover: rgba(255, 255, 255, 0.12);
  --text: #f2f4ff;
  --text-dim: #9aa3c7;
  --accent: #6c8cff;
  --accent2: #a06bff;
  --danger: #ff6b81;
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 800px at 20% -10%, #2a2f58 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  overflow: hidden;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 18px calc(10px + var(--safe-bottom));
}

/* ---------- 顶部栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 2px 8px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; letter-spacing: .5px; }
.brand-icon { font-size: 20px; }

.icon-btn {
  width: 42px; height: 42px; border: none; border-radius: 50%;
  background: var(--card); color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .2s;
  font-size: 16px;
}
.icon-btn:active { background: var(--card-hover); }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.icon-btn.small { width: 34px; height: 34px; }
.icon-btn.small svg { width: 19px; height: 19px; }

/* ---------- 主视觉区 ---------- */
.stage { flex: 1; display: flex; flex-direction: column; justify-content: center; min-height: 0; gap: 16px; }

.media-wrap {
  position: relative; width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 46dvh;
  border-radius: 24px; overflow: hidden;
  background: linear-gradient(145deg, #232948, #161a30);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center;
}
.media-wrap.video-mode { aspect-ratio: 16 / 10; }

video#media {
  width: 100%; height: 100%; object-fit: contain; background: #000;
  display: none;
}
.media-wrap.video-mode video#media { display: block; }
.media-wrap.video-mode .cover-wrap { display: none; }

.cover-wrap { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.cover-disc {
  width: 62%; aspect-ratio: 1/1; border-radius: 50%;
  background: conic-gradient(from 90deg, #2b3157, #12152a, #2b3157, #12152a, #2b3157);
  border: 10px solid rgba(255,255,255,.07);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
  animation: spin 18s linear infinite; animation-play-state: paused;
}
.media-wrap.playing .cover-disc { animation-play-state: running; }
.cover-disc img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.cover-fallback { font-size: 52px; }
@keyframes spin { to { transform: rotate(360deg); } }

.type-badge {
  position: absolute; top: 12px; right: 12px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  background: rgba(0,0,0,.45); color: #cfd8ff;
  backdrop-filter: blur(4px);
}

.track-info { text-align: center; padding: 0 8px; }
.track-title {
  font-size: 19px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.track-artist { margin-top: 5px; font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 控制区 ---------- */
.controls { padding: 6px 0 4px; }

.progress-row { display: flex; align-items: center; gap: 10px; }
.time { font-size: 12px; color: var(--text-dim); min-width: 38px; text-align: center; font-variant-numeric: tabular-nums; }

.slider {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 5px; border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--fill, 0%), rgba(255,255,255,.14) var(--fill, 0%));
  outline: none; cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.4);
  transition: transform .15s;
}
.slider:active::-webkit-slider-thumb { transform: scale(1.25); }
.slider::-moz-range-thumb { width: 16px; height: 16px; border: none; border-radius: 50%; background: #fff; }

.btn-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 6px 10px;
}
.ctl-btn {
  width: 48px; height: 48px; border: none; border-radius: 50%;
  background: transparent; color: var(--text);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background .2s, color .2s;
}
.ctl-btn:active { background: var(--card); }
.ctl-btn svg { width: 26px; height: 26px; fill: currentColor; }
.ctl-btn.mode-active { color: var(--accent); }

.play-btn {
  width: 68px; height: 68px; border: none; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 26px rgba(108, 140, 255, .4);
  transition: transform .15s;
}
.play-btn:active { transform: scale(.94); }
.play-btn svg { width: 32px; height: 32px; fill: currentColor; }

.volume-row { display: flex; align-items: center; gap: 10px; padding: 2px 4px 6px; }
.slider.vol { max-width: none; }
.vol-num { font-size: 12px; color: var(--text-dim); min-width: 26px; text-align: right; font-variant-numeric: tabular-nums; }
.rate-btn {
  border: 1px solid rgba(255,255,255,.18); background: transparent; color: var(--text-dim);
  border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; min-width: 52px;
}
.rate-btn:active { color: var(--text); border-color: var(--accent); }

/* ---------- 抽屉 / 弹窗 ---------- */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px); z-index: 40; opacity: 0; transition: opacity .25s;
}
.sheet-mask.show { opacity: 1; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-width: 520px; margin: 0 auto;
  max-height: 72dvh; display: flex; flex-direction: column;
  background: var(--bg2); border-radius: 20px 20px 0 0;
  padding: 6px 16px calc(12px + var(--safe-bottom));
  transform: translateY(105%); transition: transform .3s cubic-bezier(.32,.72,.35,1);
  box-shadow: 0 -10px 40px rgba(0,0,0,.5);
}
.sheet.show { transform: translateY(0); }

.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px; }
.sheet-title { font-weight: 700; font-size: 15px; }
.count { color: var(--text-dim); font-weight: 400; font-size: 13px; margin-left: 4px; }

.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 8px; }

.group-title {
  position: sticky; top: 0; z-index: 1;
  font-size: 12px; color: var(--text-dim); font-weight: 600;
  padding: 10px 4px 6px; background: var(--bg2);
}

.track-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; border-radius: 12px; cursor: pointer;
  transition: background .15s;
}
.track-item:active { background: var(--card); }
.track-item.active { background: rgba(108, 140, 255, .14); }
.track-item.active .ti-title { color: var(--accent); }
.ti-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  background: var(--card); display: flex; align-items: center; justify-content: center;
  font-size: 17px; overflow: hidden;
}
.ti-icon img { width: 100%; height: 100%; object-fit: cover; }
.ti-main { flex: 1; min-width: 0; }
.ti-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ti-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; display: flex; gap: 6px; align-items: center; }
.ti-type {
  font-size: 10px; padding: 1px 6px; border-radius: 4px; font-weight: 700;
  background: rgba(108,140,255,.18); color: var(--accent);
}
.ti-type.mp4 { background: rgba(160,107,255,.18); color: #c39bff; }
.eq {
  display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; margin-right: 2px;
}
.eq i { width: 3px; background: var(--accent); border-radius: 2px; animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(1){ height: 60%; animation-delay: 0s; }
.eq i:nth-child(2){ height: 100%; animation-delay: .2s; }
.eq i:nth-child(3){ height: 40%; animation-delay: .4s; }
@keyframes eq { 0%,100%{ transform: scaleY(.4);} 50%{ transform: scaleY(1);} }

.empty-tip { text-align: center; color: var(--text-dim); padding: 40px 0; font-size: 14px; }

/* ---------- 导入弹窗 ---------- */
.modal {
  position: fixed; z-index: 50; left: 16px; right: 16px;
  top: 50%; transform: translateY(-46%) scale(.95); opacity: 0; pointer-events: none;
  max-width: 480px; margin: 0 auto;
  background: var(--bg2); border-radius: 20px; padding: 8px 18px 18px;
  transition: opacity .22s, transform .22s;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.modal.show { opacity: 1; transform: translateY(-50%) scale(1); pointer-events: auto; }

.tabs { display: flex; gap: 8px; margin: 4px 0 14px; }
.tab {
  flex: 1; padding: 8px 0; border: none; border-radius: 10px;
  background: var(--card); color: var(--text-dim); font-size: 13px; cursor: pointer;
}
.tab.active { background: rgba(108,140,255,.2); color: var(--accent); font-weight: 600; }

.drop-zone {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  border: 1.5px dashed rgba(255,255,255,.25); border-radius: 14px;
  padding: 30px 12px; color: var(--text-dim); font-size: 13px; cursor: pointer;
  transition: border-color .2s, background .2s;
}
.drop-zone.dragover { border-color: var(--accent); background: rgba(108,140,255,.08); }
.drop-icon { font-size: 30px; }

textarea#pasteArea {
  width: 100%; height: 130px; resize: none;
  background: rgba(0,0,0,.25); color: var(--text);
  border: 1px solid rgba(255,255,255,.15); border-radius: 12px;
  padding: 10px; font-size: 12px; font-family: ui-monospace, Menlo, monospace;
  outline: none;
}
textarea#pasteArea:focus { border-color: var(--accent); }

.text-input {
  width: 100%; background: rgba(0,0,0,.25); color: var(--text);
  border: 1px solid rgba(255,255,255,.15); border-radius: 12px;
  padding: 12px; font-size: 13px; outline: none;
}
.text-input:focus { border-color: var(--accent); }

.primary-btn {
  width: 100%; margin-top: 10px; padding: 12px 0;
  border: none; border-radius: 12px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 14px; font-weight: 600;
}
.primary-btn:active { opacity: .85; }

.hint { margin-top: 12px; font-size: 11.5px; color: var(--text-dim); line-height: 1.6; }
.hint code { background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 4px; font-size: 10.5px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%);
  background: rgba(20, 24, 46, .95); color: var(--text);
  border: 1px solid rgba(255,255,255,.12);
  padding: 10px 18px; border-radius: 999px; font-size: 13px;
  z-index: 99; white-space: nowrap; max-width: 86vw; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: toastIn .25s;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- 桌面端微调 ---------- */
@media (min-width: 700px) {
  #app { padding-left: 24px; padding-right: 24px; }
  .media-wrap { max-height: 42dvh; }
}
