/* ============ 典藏 · 古典音乐赏析 ============ */
:root {
  --bg: #12100e;
  --bg-soft: #1a1713;
  --card: #1e1a15;
  --card-border: #322b22;
  --gold: #c9a86a;
  --gold-dim: #a5875a;
  --text: #e8e0d2;
  --text-dim: #9d9484;
  --text-faint: #6f675a;
  --accent: #b08d57;
  --danger: #c96a5a;
  --shadow: 0 6px 24px rgba(0, 0, 0, .45);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background:
    radial-gradient(1200px 500px at 80% -10%, #2a2218 0%, transparent 60%),
    radial-gradient(900px 400px at -10% 110%, #1d1a15 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Serif SC", Georgia, serif;
  overflow: hidden;
}

/* ============ 顶栏 ============ */
.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--card-border);
  background: rgba(18, 16, 14, .9);
  backdrop-filter: blur(6px);
  position: relative;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #c9a86a, #8a6f42);
  color: #1a1610;
  border-radius: 8px;
  font-size: 20px;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(201, 168, 106, .35);
}
.brand h1 { font-size: 22px; letter-spacing: 2px; color: var(--gold); font-weight: 600; }
.brand-sub { font-size: 11px; color: var(--text-faint); margin-left: 8px; letter-spacing: 1px; font-style: italic; }

.btn-ghost, .btn-primary {
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all .2s;
  font-family: inherit;
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold); }
.btn-primary {
  background: linear-gradient(135deg, #c9a86a, #a5875a);
  color: #1a1610;
  border: none;
  font-weight: 600;
  padding: 12px 24px;
}
.btn-primary:hover { filter: brightness(1.1); }

/* ============ 布局 ============ */
.layout {
  display: flex;
  height: calc(100vh - 60px);
}

/* ============ 侧栏曲目库 ============ */
.library {
  width: 320px;
  min-width: 280px;
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  background: rgba(18, 16, 14, .6);
}
.library-search { padding: 14px 14px 8px; }
.library-search input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color .2s;
}
.library-search input:focus { border-color: var(--gold); }
.library-search input::placeholder { color: var(--text-faint); }

.period-filter {
  display: flex;
  gap: 6px;
  padding: 6px 14px 10px;
  flex-wrap: wrap;
}
.pf-chip {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: all .2s;
  font-family: inherit;
}
.pf-chip:hover { color: var(--gold); border-color: var(--gold-dim); }
.pf-chip.active {
  background: var(--gold);
  color: #1a1610;
  border-color: var(--gold);
  font-weight: 600;
}

.piece-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
}
.piece-list::-webkit-scrollbar { width: 8px; }
.piece-list::-webkit-scrollbar-thumb { background: #2e2820; border-radius: 4px; }

.pg-group { margin-bottom: 10px; }
.pg-title {
  font-size: 12px;
  color: var(--gold-dim);
  letter-spacing: 3px;
  padding: 10px 10px 6px;
  text-transform: uppercase;
}

.piece-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
  border-left: 3px solid transparent;
}
.piece-item:hover { background: var(--bg-soft); }
.piece-item.active {
  background: linear-gradient(90deg, rgba(201, 168, 106, .16), transparent);
  border-left-color: var(--gold);
}
.pi-icon { color: var(--gold-dim); font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.pi-text { min-width: 0; }
.pi-title {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.pi-title.active { color: var(--gold); }
.pi-composer {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library-foot {
  padding: 10px 14px;
  font-size: 11px;
  color: var(--text-faint);
  border-top: 1px solid var(--card-border);
  text-align: center;
  letter-spacing: 1px;
}

/* ============ 主区 ============ */
.stage {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 60px;
  scroll-behavior: smooth;
}
.stage::-webkit-scrollbar { width: 8px; }
.stage::-webkit-scrollbar-thumb { background: #2e2820; border-radius: 4px; }

.welcome {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.welcome-inner { text-align: center; max-width: 520px; }
.welcome-mark { font-size: 64px; color: var(--gold-dim); margin-bottom: 16px; opacity: .8; }
.welcome h2 { font-size: 30px; color: var(--gold); letter-spacing: 3px; margin-bottom: 14px; font-weight: 600; }
.welcome p { color: var(--text-dim); line-height: 1.9; font-size: 15px; }
.welcome-actions { margin-top: 26px; }

.hidden { display: none !important; }

/* ============ 卡片 ============ */
.card {
  background: linear-gradient(180deg, var(--card), #1b1712);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 22px 26px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.piece-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
#a-title-cn { font-size: 30px; color: var(--gold); font-weight: 600; letter-spacing: 1px; }
.piece-en { color: var(--text-dim); font-style: italic; margin-top: 6px; font-size: 14px; }
.piece-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--card-border);
  color: var(--text-dim);
  background: var(--bg-soft);
  white-space: nowrap;
}
.badge.gold { color: var(--gold); border-color: var(--gold-dim); }

.piece-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--card-border);
  font-size: 13px;
  color: var(--text-dim);
}
.piece-meta b { color: var(--text); font-weight: 500; margin-right: 4px; }

.audio-error {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(201, 106, 90, .12);
  border: 1px solid rgba(201, 106, 90, .4);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.6;
}

/* ============ 播放器 ============ */
.player { position: sticky; top: 8px; z-index: 15; }
.player-main { display: flex; align-items: center; gap: 16px; }

.play-btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #c9a86a, #9d7d4c);
  color: #1a1610;
  font-size: 20px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(201, 168, 106, .3);
  transition: transform .15s;
  display: flex; align-items: center; justify-content: center;
}
.play-btn:hover { transform: scale(1.05); }
.play-btn.playing { font-size: 0; }
.play-btn.playing::before { content: "❚❚"; font-size: 16px; }

.player-track { flex: 1; min-width: 0; }
.now-title {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.now-title .composer-name { color: var(--text-faint); font-size: 13px; }

/* 播放按钮与加载提示 */
.play-wrap { position: relative; flex-shrink: 0; }
.play-wrap .loading-tip {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--gold-dim);
  font-size: 12px;
  white-space: nowrap;
  letter-spacing: 1px;
  z-index: 5;
}
.spinner {
  width: 12px; height: 12px;
  border: 2px solid rgba(201, 168, 106, .3);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 播放设置（倍速） */
.player-settings {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--card-border);
}
.ctl-label { color: var(--text-faint); font-size: 12px; letter-spacing: 1px; }

.seek-row { display: flex; align-items: center; gap: 10px; }
.time { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; width: 38px; text-align: center; }
.seek {
  flex: 1;
  height: 6px;
  background: #2e2820;
  border-radius: 3px;
  position: relative;
  cursor: pointer;
}
.seek-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, #c9a86a, #e0c58a);
  border-radius: 3px;
  pointer-events: none;
}
.seek-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #f0e0c0;
  box-shadow: 0 0 8px rgba(201, 168, 106, .6);
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
.seek:hover .seek-thumb { opacity: 1; }

.player-controls { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.ctl { display: flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: 13px; }
.ctl select {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  outline: none;
}
.vol-icon { font-size: 14px; }
input[type="range"] {
  width: 80px;
  accent-color: var(--gold);
  cursor: pointer;
}

/* 曲式结构时间轴 */
.structure-bar {
  display: flex;
  height: 40px;
  margin-top: 16px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  background: #17140f;
  cursor: pointer;
  position: relative;
}
.seg {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-dim);
  overflow: hidden;
  white-space: nowrap;
  border-right: 1px solid #1f1b15;
  position: relative;
  transition: filter .2s;
}
.seg:nth-child(odd) { background: #221d16; }
.seg:nth-child(even) { background: #1b1712; }
.seg:hover { filter: brightness(1.3); color: var(--text); }
.seg.current {
  background: linear-gradient(180deg, rgba(201,168,106,.45), rgba(201,168,106,.22));
  color: #fff;
  box-shadow: inset 0 0 0 1px var(--gold);
}
.seg .seg-name { padding: 0 6px; text-overflow: ellipsis; overflow: hidden; }

.structure-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-faint);
}

/* 当前段导赏 */
.now-guide { border-left: 3px solid var(--gold); }
.ng-tag { font-size: 12px; color: var(--gold-dim); letter-spacing: 1px; margin-bottom: 8px; }
.now-guide h3 { font-size: 20px; color: var(--gold); margin-bottom: 10px; font-weight: 600; }
.ng-guide { line-height: 1.9; color: var(--text-dim); font-size: 14px; }
.ng-harmony {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(201, 168, 106, .08);
  border: 1px dashed var(--gold-dim);
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
}
.ng-harmony b { color: var(--gold); font-weight: 600; }

/* 赏析段落 */
.section-title {
  font-size: 16px;
  color: var(--gold);
  letter-spacing: 2px;
  margin-bottom: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--card-border); }
.body-text { line-height: 2; color: var(--text-dim); font-size: 14.5px; text-align: justify; }

.structure-detail { display: flex; flex-direction: column; gap: 10px; }
.sd-item {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--bg-soft);
  cursor: pointer;
  transition: border-color .2s;
}
.sd-item:hover { border-color: var(--gold-dim); }
.sd-item.current { border-color: var(--gold); background: rgba(201,168,106,.06); }
.sd-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sd-name { font-size: 15px; color: var(--text); font-weight: 600; }
.sd-time { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.sd-guide { font-size: 13.5px; line-height: 1.9; color: var(--text-dim); }
.sd-harmony {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--gold-dim);
  line-height: 1.8;
  border-top: 1px dashed var(--card-border);
  padding-top: 8px;
}

.tips-list, .version-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.tips-list li, .version-list li {
  padding-left: 22px;
  position: relative;
  line-height: 1.9;
  color: var(--text-dim);
  font-size: 14px;
}
.tips-list li::before { content: "♪"; position: absolute; left: 0; color: var(--gold-dim); }
.version-list li::before { content: "◆"; position: absolute; left: 2px; color: var(--gold-dim); font-size: 10px; top: 7px; }

.card.fun { background: linear-gradient(180deg, rgba(201,168,106,.08), #1b1712); }
.card.fun .section-title { color: var(--gold); }

.page-foot {
  text-align: center;
  color: var(--text-faint);
  font-size: 11px;
  padding: 18px 0 6px;
  letter-spacing: 1px;
}

/* 响应式 */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .library { width: 100%; min-width: 0; max-height: 38vh; border-right: none; border-bottom: 1px solid var(--card-border); }
  .piece-list { max-height: 30vh; }
  .stage { padding: 14px 12px 60px; }
  .player { position: static; }
}
