:root {
  --stats-ink: #14233d;
  --stats-muted: #6f7f98;
  --stats-line: #dce4ee;
  --stats-paper: #fffdf9;
  --stats-canvas: #eef4f8;
  --stats-navy: #152743;
  --stats-teal: #0e7c77;
  --stats-coral: #ff6d51;
  --stats-blue: #2866e8;
}

* { box-sizing: border-box; }

body.listening-stats-page {
  color: var(--stats-ink);
  background:
    radial-gradient(circle at 86% 8%, rgba(14, 124, 119, .12), transparent 28rem),
    linear-gradient(180deg, #f7fafc 0, var(--stats-canvas) 100%);
}

.stats-main {
  min-width: 0;
  padding: 30px clamp(22px, 3vw, 52px) 64px;
}

.stats-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 36px 40px;
  overflow: hidden;
  border: 1px solid rgba(20, 35, 61, .12);
  border-radius: 26px;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, .97), rgba(255, 253, 249, .92)),
    repeating-linear-gradient(90deg, transparent 0 49px, rgba(20, 35, 61, .03) 50px);
  box-shadow: 0 18px 46px rgba(24, 46, 76, .08);
  position: relative;
}

.stats-heading::after {
  content: "40";
  position: absolute;
  right: 30px;
  top: -54px;
  font: 700 190px/1 Georgia, serif;
  color: rgba(20, 35, 61, .035);
  pointer-events: none;
}

.stats-heading .eyebrow,
.panel-index {
  display: block;
  margin-bottom: 12px;
  color: var(--stats-teal);
  font: 800 12px/1.2 "Microsoft YaHei", sans-serif;
  letter-spacing: .14em;
}

.stats-heading h1 {
  margin: 0;
  font: 700 clamp(34px, 4.1vw, 61px)/1.02 Georgia, "Songti SC", serif;
  letter-spacing: -.04em;
}

.stats-heading h1 span { color: var(--stats-teal); }

.stats-heading p {
  max-width: 680px;
  margin: 18px 0 0;
  color: var(--stats-muted);
  font-size: 16px;
  line-height: 1.75;
}

.stats-heading-actions {
  display: grid;
  justify-items: end;
  gap: 14px;
  min-width: 190px;
  position: relative;
  z-index: 1;
}

.sync-state {
  color: var(--stats-muted);
  font-size: 13px;
}

.stats-primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 24px;
  border-radius: 14px;
  color: #fff;
  background: var(--stats-coral);
  text-decoration: none;
  font-weight: 800;
  box-shadow: 0 12px 26px rgba(255, 109, 81, .24);
  transition: transform .2s ease, box-shadow .2s ease;
}

.stats-primary-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(255, 109, 81, .3);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.metric-card {
  min-height: 150px;
  padding: 25px;
  border: 1px solid var(--stats-line);
  border-radius: 21px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 10px 30px rgba(24, 46, 76, .045);
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--stats-muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin: 15px 0 8px;
  font: 700 34px/1 Georgia, "Songti SC", serif;
}

.metric-card-dark {
  border-color: var(--stats-navy);
  color: #fff;
  background:
    radial-gradient(circle at 90% 0, rgba(50, 205, 183, .26), transparent 44%),
    var(--stats-navy);
}

.metric-card-dark span,
.metric-card-dark small { color: rgba(255, 255, 255, .67); }
.metric-card-dark strong { font-size: 42px; }

.stats-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr);
  gap: 18px;
  margin-bottom: 18px;
}

.stats-panel {
  border: 1px solid var(--stats-line);
  border-radius: 24px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 14px 38px rgba(24, 46, 76, .055);
}

.trend-panel,
.focus-panel,
.part-panel,
.records-panel { padding: 28px; }

.part-panel,
.records-panel { margin-top: 18px; }

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.panel-heading h2 {
  margin: 0;
  font: 700 26px/1.15 Georgia, "Songti SC", serif;
}

.panel-index { margin-bottom: 8px; }

.panel-note,
.trend-legend,
.text-link {
  color: var(--stats-muted);
  font-size: 13px;
}

.trend-legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--stats-coral);
}

.text-link { text-decoration: none; }
.text-link:hover { color: var(--stats-teal); }

.trend-chart {
  min-height: 260px;
  border-radius: 18px;
  background:
    repeating-linear-gradient(0deg, rgba(20, 35, 61, .055) 0 1px, transparent 1px 52px),
    linear-gradient(180deg, #fbfcfd, #f8fafc);
  overflow: hidden;
}

.trend-chart svg { display: block; width: 100%; height: 260px; }
.trend-line { fill: none; stroke: var(--stats-teal); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.trend-area { fill: url(#trendFill); }
.trend-point { fill: #fff; stroke: var(--stats-coral); stroke-width: 4; }
.trend-label { fill: var(--stats-muted); font: 12px "Microsoft YaHei", sans-serif; }
.trend-value { fill: var(--stats-ink); font: 800 12px "Microsoft YaHei", sans-serif; }

.focus-panel {
  color: #fff;
  background:
    radial-gradient(circle at 100% 0, rgba(255, 109, 81, .3), transparent 46%),
    var(--stats-navy);
}

.focus-panel .panel-index { color: #79d6ce; }
.focus-panel .panel-heading h2 { color: #fff; }

.focus-content {
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.focus-badge {
  align-self: flex-start;
  margin-bottom: auto;
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 999px;
  color: #9de0da;
  font-size: 12px;
}

.focus-content h3 {
  margin: 30px 0 10px;
  font: 700 25px/1.25 Georgia, "Songti SC", serif;
}

.focus-content p { margin: 0; color: rgba(255, 255, 255, .68); line-height: 1.7; }

.part-performance {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.part-card {
  padding: 22px;
  border: 1px solid var(--stats-line);
  border-radius: 18px;
  background: var(--stats-paper);
}

.part-card-head,
.part-card-foot,
.record-row,
.record-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.part-card-head strong { font: 700 22px Georgia, serif; }
.part-card-head span { color: var(--stats-muted); font-size: 12px; }
.part-score { margin: 22px 0 12px; font: 700 30px Georgia, serif; }

.part-bar {
  height: 7px;
  margin-bottom: 14px;
  border-radius: 999px;
  background: #e5ebf1;
  overflow: hidden;
}

.part-bar i { display: block; height: 100%; border-radius: inherit; background: var(--stats-teal); }
.part-card.is-weak .part-bar i { background: var(--stats-coral); }
.part-card-foot { color: var(--stats-muted); font-size: 12px; }

.record-list { display: grid; gap: 10px; }

.record-row {
  padding: 16px 18px;
  border: 1px solid var(--stats-line);
  border-radius: 16px;
  background: #fff;
}

.record-kind {
  flex: 0 0 8px;
  width: 8px;
  height: 36px;
  border-radius: 999px;
  background: var(--stats-teal);
}

.record-row.is-mock .record-kind { background: var(--stats-coral); }
.record-copy { min-width: 0; flex: 1; }
.record-copy strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record-copy span { display: block; margin-top: 5px; color: var(--stats-muted); font-size: 12px; }
.record-score { flex-direction: column; align-items: flex-end; }
.record-score strong { font: 700 20px Georgia, serif; }
.record-score span { color: var(--stats-muted); font-size: 12px; }

.empty-card {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 30px;
  color: var(--stats-muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .part-performance { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .stats-heading { align-items: flex-start; flex-direction: column; }
  .stats-heading-actions { justify-items: start; }
  .stats-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .stats-main { padding: 18px 14px 40px; }
  .stats-heading { padding: 28px 24px; }
  .metric-grid,
  .part-performance { grid-template-columns: 1fr; }
  .panel-heading { flex-direction: column; }
  .record-row { align-items: flex-start; }
}
