:root {
  --bg: #f4f6f9;
  --bg-soft: #ffffff;
  --card: #ffffff;
  --line: #e6eaf0;
  --text: #1b2430;
  --text-2: #5d6a7a;
  --text-3: #97a3b2;
  --accent: #3f7d6e;
  --accent-soft: #e8f2ef;
  --accent-2: #6aa7d8;
  --shadow-sm: 0 1px 2px rgba(24, 39, 55, .05);
  --shadow: 0 4px 16px rgba(24, 39, 55, .07);
  --shadow-lg: 0 18px 50px rgba(24, 39, 55, .16);
  --radius: 14px;
  --topbar-h: 108px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1000px 500px at 12% -10%, #e9f3ef 0%, transparent 60%),
    radial-gradient(900px 460px at 92% 0%, #eaf1f8 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
svg { display: block; }

/* ============ 顶部播放器 ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.brand-name { font-size: 16px; font-weight: 700; letter-spacing: .5px; }

/* 播放模式 */
.modes {
  display: flex;
  padding: 3px;
  background: #eef2f7;
  border-radius: 10px;
  gap: 2px;
  flex-shrink: 0;
}

.mode-btn {
  padding: 7px 15px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-2);
  transition: all .18s ease;
  white-space: nowrap;
}

.mode-btn:hover { color: var(--text); }

.mode-btn.active {
  background: #fff;
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(24, 39, 55, .1);
}

/* 音量 */
.volume-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px;
  color: var(--text-2);
  transition: background .18s, color .18s;
}

.icon-btn:hover { background: #eef2f7; color: var(--text); }

.ic-vol { width: 20px; height: 20px; }
.ic-vol path, .ic-vol rect { fill: currentColor; }
.ic-vol .wave { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.icon-btn.muted .ic-vol .wave { display: none; }

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 132px;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--p, 50%), #dfe5ec var(--p, 50%), #dfe5ec 100%);
  outline: none;
  cursor: pointer;
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(24, 39, 55, .22);
  transition: transform .15s;
}

.range::-webkit-slider-thumb:hover { transform: scale(1.12); }

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

.vol-num {
  width: 30px;
  text-align: right;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* 播放按钮 */
.play-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(63, 125, 110, .34);
  transition: transform .16s, background .16s;
  flex-shrink: 0;
}

.play-btn:hover { transform: scale(1.05); background: #366e60; }
.play-btn:active { transform: scale(.96); }
.play-btn svg { width: 20px; height: 20px; fill: currentColor; }
.play-btn .ic-pause { display: none; }
.play-btn.playing .ic-play { display: none; }
.play-btn.playing .ic-pause { display: block; }
.play-btn.idle { background: #aab6c3; box-shadow: 0 4px 14px rgba(120, 133, 148, .28); }

/* 当前播放信息 */
.now-playing {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
  min-height: 22px;
}

.np-label {
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
}

.np-name { color: var(--text-2); font-weight: 600; }
.np-rule { color: var(--text-3); }
.np-rule::before { content: "·"; margin-right: 6px; }

/* ============ 正文 ============ */
.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 20px 130px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

.chip {
  padding: 7px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 13px;
  transition: all .16s;
  box-shadow: var(--shadow-sm);
}

.chip:hover { border-color: #cfd8e3; color: var(--text); }

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 3px 10px rgba(63, 125, 110, .26);
}

.chip .cnt { opacity: .6; font-size: 11.5px; margin-left: 3px; }

.section { margin-bottom: 28px; }

.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.section-title { font-size: 15px; font-weight: 700; }
.section-ico { font-size: 16px; line-height: 1; }

.section-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.section-cnt { font-size: 12px; color: var(--text-3); }

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

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 14px 15px;
  text-align: left;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(150deg, rgba(63,125,110,.06), transparent 55%);
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: #d3dde8;
}

.card:hover::after { opacity: 1; }

.card.active {
  border-color: var(--accent);
  background: linear-gradient(160deg, #f2faf7, #ffffff 60%);
  box-shadow: 0 6px 22px rgba(63, 125, 110, .16);
}

.card-ico {
  font-size: 21px;
  line-height: 1;
  margin-bottom: 10px;
  opacity: .9;
}

.card-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .2px;
}

.card-meta {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-3);
}

/* 播放中动画条 */
.bars {
  position: absolute;
  top: 14px;
  right: 13px;
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 13px;
}

.card.active .bars { display: flex; }

.bars i {
  width: 2.5px;
  border-radius: 2px;
  background: var(--accent);
  animation: bar 1s ease-in-out infinite;
}

.bars i:nth-child(1) { height: 6px; animation-delay: -.3s; }
.bars i:nth-child(2) { height: 12px; animation-delay: -.55s; }
.bars i:nth-child(3) { height: 8px; animation-delay: -.15s; }

@keyframes bar {
  0%, 100% { transform: scaleY(.45); }
  50% { transform: scaleY(1); }
}

.paused .bars i { animation-play-state: paused; }

/* ============ 悬浮按钮 ============ */
.fab {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  background: #1f2a37;
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(31, 42, 55, .28);
  z-index: 70;
  transition: transform .18s, background .18s, box-shadow .18s;
}

.fab:hover {
  transform: translateX(-50%) translateY(-2px);
  background: #16202b;
  box-shadow: 0 14px 36px rgba(31, 42, 55, .34);
}

.fab-ic {
  width: 17px; height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.fab-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 28, 38, .42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .18s ease;
}

.modal-mask[hidden] { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 560px;
  max-width: 100%;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 22px 24px 18px;
  animation: popIn .22s cubic-bezier(.2, .8, .3, 1);
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.modal-head h2 { margin: 0; font-size: 17px; font-weight: 700; }

.close { font-size: 15px; }

.modal-desc {
  margin: 0 0 16px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-3);
  background: #f7f9fc;
  border-radius: 10px;
  padding: 10px 12px;
}

.rule-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
  margin-bottom: 12px;
}

.rule-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color .16s, background .16s;
}

.rule-item:hover { border-color: #d3dde8; background: #fff; }

.rule-idx {
  width: 22px; height: 22px;
  flex-shrink: 0;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.rule-field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
}

.rule-field input[type="number"] {
  width: 66px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  text-align: center;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}

.rule-field input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.rule-field input[type="number"]::-webkit-outer-spin-button,
.rule-field input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.rule-field input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.rule-unit { color: var(--text-3); font-size: 12px; }

.slider-mini { width: 74px; }

.rule-del {
  margin-left: auto;
  width: 26px; height: 26px;
  border-radius: 7px;
  color: var(--text-3);
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: background .16s, color .16s;
}

.rule-del:hover { background: #fdeceb; color: #d8564b; }

.rule-empty {
  padding: 26px 0;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

.add-rule {
  width: 100%;
  padding: 10px;
  border: 1px dashed #cfd8e3;
  border-radius: 11px;
  color: var(--text-2);
  font-size: 13px;
  transition: all .16s;
  margin-bottom: 16px;
}

.add-rule:hover { border-color: var(--accent); color: var(--accent); background: #f8fcfa; }

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.btn {
  padding: 9px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  transition: all .16s;
}

.btn.ghost { background: #f1f4f8; color: var(--text-2); }
.btn.ghost:hover { background: #e8edf3; color: var(--text); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(63,125,110,.3); }
.btn.primary:hover { background: #366e60; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%) translateY(10px);
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(31, 42, 55, .94);
  color: #fff;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 200;
  white-space: nowrap;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ 响应式 ============ */
@media (max-width: 820px) {
  .topbar-inner {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px 8px;
  }
  .brand-name { display: none; }
  .modes { order: 3; width: 100%; }
  .mode-btn { flex: 1; text-align: center; padding: 8px 4px; }
  .volume-wrap { margin-left: auto; }
  .range { width: 92px; }
  .now-playing { padding: 6px 14px 8px; }
  .main { padding: 16px 14px 120px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 9px; }
  .card { padding: 13px 11px; }
  .card-ico { font-size: 18px; margin-bottom: 8px; }
  .card-name { font-size: 12.5px; }
  .card-meta { font-size: 10.5px; }
  .modal { padding: 18px 16px 14px; border-radius: 16px; max-height: 90vh; }
  .rule-item { flex-wrap: wrap; gap: 8px; }
  .rule-del { margin-left: auto; }
  .fab { bottom: 18px; padding: 11px 20px; font-size: 13px; }
}

@media (max-width: 420px) {
  .vol-num { display: none; }
  .range { width: 70px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
}
