:root {
  color-scheme: light;
  --bg: #f8f5ff;
  --bg-accent: #eee6ff;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-strong: #ffffff;
  --text: #211a31;
  --muted: #71677f;
  --line: rgba(87, 70, 120, 0.15);
  --primary: #6750a4;
  --primary-strong: #4f378b;
  --primary-soft: #eaddff;
  --good: #386a20;
  --danger: #ba1a1a;
  --shadow: 0 18px 45px rgba(63, 47, 92, 0.13);
}

body.dark {
  color-scheme: dark;
  --bg: #141119;
  --bg-accent: #211a31;
  --panel: rgba(32, 27, 39, 0.9);
  --panel-strong: #282231;
  --text: #efe7f6;
  --muted: #c9bfd5;
  --line: rgba(232, 222, 248, 0.16);
  --primary: #d0bcff;
  --primary-strong: #eaddff;
  --primary-soft: #4f378b;
  --good: #9bd67d;
  --danger: #ffb4ab;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "MiSans", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, var(--bg-accent), transparent 34rem),
    linear-gradient(135deg, var(--bg), var(--bg-accent));
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-button {
  border: 0;
  border-radius: 999px;
  padding: 0.78rem 1.1rem;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  box-shadow: 0 8px 20px rgba(103, 80, 164, 0.22);
}

button:hover,
.file-button:hover {
  transform: translateY(-1px);
  background: var(--primary-strong);
}

button.secondary,
.ghost-button {
  color: var(--primary-strong);
  background: var(--primary-soft);
  box-shadow: none;
}

.file-button input {
  display: none;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

@media (min-width: 1024px) {
  .shell {
    width: calc(100% - 200px);
    max-width: none;
  }
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.5rem;
  font-size: clamp(2rem, 6vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.subtitle {
  max-width: 760px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.input-panel {
  padding: 1rem;
}

.input-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.9rem;
}

textarea {
  display: block;
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1rem;
  color: var(--text);
  background: var(--panel-strong);
  outline: none;
  line-height: 1.55;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(103, 80, 164, 0.16);
}

.status {
  margin: 0.75rem 0 0;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.status.ok {
  color: var(--good);
}

.hidden {
  display: none;
}

.result {
  margin-top: 1.2rem;
}

.profile-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem;
}

.avatar {
  position: relative;
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  overflow: hidden;
  border-radius: 24px;
  color: var(--primary-strong);
  background: var(--primary-soft);
  font-size: 2rem;
  font-weight: 900;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar span {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
}

.profile-main h2 {
  margin-bottom: 0.2rem;
  font-size: clamp(1.55rem, 4vw, 2.5rem);
}

.profile-main p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  gap: 0.8rem;
}

.score-tile {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 0.8rem 1rem;
  background: var(--panel-strong);
  text-align: right;
}

.score-tile span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.score-tile strong {
  display: block;
  margin-top: 0.18rem;
  font-size: 1.7rem;
}

.score-tile.total {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}

.score-tile.total span {
  color: rgba(255, 255, 255, 0.78);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-top: 1rem;
  padding: 1rem;
}

.toolbar label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.toolbar input,
.toolbar select {
  min-width: min(360px, calc(100vw - 64px));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.75rem 0.9rem;
  color: var(--text);
  background: var(--panel-strong);
  outline: none;
}

.toolbar select {
  min-width: 180px;
}

.section-block {
  margin-top: 1.6rem;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.section-title h2 {
  margin: 0;
  font-size: 1.45rem;
}

.section-title span {
  color: var(--muted);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.85rem;
}

.song-card {
  position: relative;
  display: grid;
  grid-template-columns: 92px minmax(0, 52px) minmax(0, 1fr);
  gap: 0.75rem;
  min-height: 142px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 0.85rem;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(63, 47, 92, 0.08);
}

.song-card::before {
  content: "";
  position: absolute;
  inset: -24px;
  z-index: 0;
  background-image: var(--cover-image);
  background-size: cover;
  background-position: center;
  filter: blur(20px);
  opacity: 0.5;
}

.song-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--panel);
  opacity: 0.72;
}

.song-card > * {
  position: relative;
  z-index: 1;
}

.song-body {
  min-width: 0;
}

.song-cover {
  width: 92px;
  height: 92px;
  align-self: center;
  border: 1px solid var(--line);
  border-radius: 22px;
  object-fit: cover;
  background: var(--primary-soft);
}

.song-cover.missing {
  opacity: 0.2;
}

.song-rank {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 18px;
  color: var(--primary-strong);
  background: var(--primary-soft);
  font-weight: 900;
}

.song-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}

.song-title-row h3 {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1.02rem;
  line-height: 1.35;
}

.level-pill,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  border-radius: 999px;
  padding: 0.25rem 0.48rem;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
  color: var(--text);
  background: var(--primary-soft);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.15;
}

.level-pill {
  flex: 0 1 auto;
  min-width: 0;
}

.level-basic { background: #c8ead5; color: #173d2a; }
.level-advanced { background: #ffe28a; color: #4d3800; }
.level-expert { background: #ffc8c8; color: #5d1616; }
.level-master { background: #d8c4ff; color: #351c74; }
.level-remaster { background: #eee7ff; color: #4b3c70; }

.song-subtitle {
  margin: 0.25rem 0 0.7rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.song-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.song-stats span {
  min-width: 0;
  border-radius: 16px;
  padding: 0.5rem;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.song-stats b {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: clamp(0.78rem, 2.4vw, 0.98rem);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.badge.combo { color: #0f5132; background: #d1f5df; }
.badge.sync { color: #4c2c92; background: #e7ddff; }
.badge.rate { color: #7a3d00; background: #ffe4bc; }

.empty-message {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 24px;
  padding: 1.2rem;
  color: var(--muted);
  text-align: center;
}

body.embedded .input-panel {
  display: none;
}

body.embedded .result {
  margin-top: 0;
}

@media (min-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(390px, 1fr));
    gap: 0.6rem;
  }

  .section-block {
    margin-top: 1.15rem;
  }

  .song-card {
    grid-template-columns: 58px 36px minmax(0, 1fr);
    min-height: 92px;
    padding: 0.48rem;
    gap: 0.48rem;
    border-radius: 18px;
  }

  .song-cover {
    width: 58px;
    height: 58px;
    border-radius: 15px;
  }

  .song-rank {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    font-size: 0.78rem;
  }

  .song-title-row h3 {
    font-size: 0.9rem;
    line-height: 1.16;
  }

  .level-pill,
  .badge {
    padding: 0.16rem 0.36rem;
    font-size: 0.62rem;
  }

  .song-subtitle {
    margin: 0.14rem 0 0.34rem;
    font-size: 0.72rem;
  }

  .song-stats {
    gap: 0.3rem;
    margin-bottom: 0.32rem;
  }

  .song-stats span {
    border-radius: 10px;
    padding: 0.28rem 0.36rem;
    font-size: 0.6rem;
  }

  .song-stats b {
    font-size: 0.78rem;
  }

  .badges {
    gap: 0.25rem;
  }
}

@media (max-width: 820px) {
  .profile-card {
    grid-template-columns: auto 1fr;
  }

  .score-grid {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 22px;
  }

  .hero {
    align-items: center;
  }

  .score-grid,
  .song-stats {
    grid-template-columns: 1fr;
  }

  .song-card {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .song-cover {
    width: 76px;
    height: 76px;
  }

  .song-rank {
    position: absolute;
    top: 0.65rem;
    left: 0.65rem;
    width: 38px;
    height: 38px;
    background: rgba(234, 221, 255, 0.9);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  }

  .song-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}
