:root {
  color-scheme: light;
  --ink: #1c2430;
  --muted: #687385;
  --line: #d9e0e8;
  --paper: #f7f8fa;
  --panel: #ffffff;
  --accent: rgb(96, 25, 134);
  --accent-soft: rgba(96, 25, 134, 0.55);
  --accent-wash: rgba(96, 25, 134, 0.1);
  --accent-ink: #ffffff;
  --teal: #157a6e;
  --gold: #b7791f;
  --shadow: 0 12px 30px rgba(24, 35, 52, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 248, 250, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.brand:hover h1,
.brand:focus-visible h1 {
  color: var(--accent);
}

.brand:focus-visible {
  border-radius: 8px;
  outline: 3px solid var(--accent-wash);
  outline-offset: 4px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 24px;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.1;
}

.brand p,
.artist,
.stats,
.result-count,
.eyebrow {
  color: var(--muted);
}

.stats {
  white-space: nowrap;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 14px;
}

.theme-menu {
  position: relative;
}

.theme-menu summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 48px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  cursor: pointer;
  list-style: none;
  box-shadow: 0 8px 18px rgba(24, 35, 52, 0.08);
}

.theme-menu summary::-webkit-details-marker {
  display: none;
}

.theme-menu summary::after {
  width: 5px;
  height: 5px;
  margin-top: -2px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  content: "";
  transform: rotate(45deg);
}

.theme-current {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.44);
}

.theme-options {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  display: flex;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  padding: 8px;
  box-shadow: var(--shadow);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 28px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.home-page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 34px 28px 22px;
}

.home-hero {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 10px 0 30px;
}

.home-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  width: min(680px, 100%);
  height: 50px;
  border: 2px solid var(--accent-soft);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(24, 35, 52, 0.1);
  overflow: hidden;
}

.home-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-wash), 0 12px 28px rgba(24, 35, 52, 0.12);
}

.home-search input {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  outline: 0;
  padding: 0 16px;
}

.home-search button {
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.home-search button:hover {
  color: var(--accent);
}

.home-search svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.home-search-results {
  display: grid;
  width: min(680px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.home-search-results button {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 11px 14px;
  text-align: left;
  cursor: pointer;
}

.home-search-results button:last-child {
  border-bottom: 0;
}

.home-search-results button:hover {
  background: var(--accent-wash);
}

.home-search-results span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.hot-searches {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.small-label {
  color: var(--muted);
  font-size: 13px;
}

.hot-pill {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
  padding: 0 10px;
  cursor: pointer;
}

.hot-pill:hover {
  border-color: var(--accent-soft);
  color: var(--accent);
}

.home-section {
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.home-section h2 {
  margin-bottom: 14px;
  font-size: 20px;
  line-height: 1.3;
}

.alphabet-list {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.alphabet-button {
  min-width: 26px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 19px;
  line-height: 1.4;
  padding: 0 2px 4px;
}

.alphabet-button:hover,
.alphabet-button.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

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

.artist-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  grid-template-areas:
    "avatar name"
    "avatar count";
  align-items: center;
  column-gap: 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.artist-card:hover .artist-name {
  color: var(--accent);
}

.artist-avatar {
  grid-area: avatar;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--avatar-color);
  color: #fff;
  font-weight: 800;
}

.artist-name {
  grid-area: name;
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artist-count {
  grid-area: count;
  color: var(--muted);
  font-size: 13px;
}

.latest-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 42px;
  margin: 0;
  padding-left: 20px;
}

.latest-list li {
  padding-left: 4px;
}

.latest-list button {
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.latest-list button:hover {
  color: var(--accent);
}

.home-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  padding-top: 12px;
  text-align: center;
}

.home-footer a {
  color: inherit;
  text-decoration: none;
}

.home-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.library,
.viewer,
.related-sidebar {
  min-height: calc(100vh - 106px);
}

.library {
  border-right: 1px solid var(--line);
  padding-right: 20px;
}

.search-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.search-panel label {
  font-size: 14px;
  font-weight: 700;
}

#searchInput {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--ink);
  outline: none;
}

#searchInput:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(21, 122, 110, 0.14);
}

.filters,
.song-actions,
.view-switch {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-button,
.copy-button,
.mode-button,
.script-button,
.voice-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

.filter-button.active,
.mode-button.active,
.script-button.active,
.voice-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.copy-button {
  border-color: var(--teal);
  color: var(--teal);
}

.continuous-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px 0 8px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}

.continuous-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.continuous-toggle span {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #c9d1dc;
  transition: background 0.18s ease;
}

.continuous-toggle span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(24, 35, 52, 0.22);
  content: "";
  transition: transform 0.18s ease;
}

.continuous-toggle input:checked + span {
  background: var(--accent);
}

.continuous-toggle input:checked + span::after {
  transform: translateX(14px);
}

.continuous-toggle:has(input:focus-visible) {
  outline: 3px solid rgba(21, 122, 110, 0.22);
  outline-offset: 2px;
}

.result-count {
  min-height: 22px;
  margin: 8px 0 12px;
  font-size: 13px;
}

.song-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 248px);
  overflow: auto;
  padding-right: 6px;
}

.song-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.song-item:hover,
.song-item.active {
  border-color: var(--accent-soft);
  box-shadow: 0 6px 16px rgba(24, 35, 52, 0.08);
}

.song-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.song-item span {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer {
  min-width: 0;
  padding: 2px 0 40px;
}

.related-sidebar {
  display: grid;
  align-content: start;
  gap: 18px;
  border-left: 1px solid var(--line);
  padding: 4px 0 40px 24px;
}

.related-panel {
  display: grid;
  gap: 10px;
}

.related-panel h2 {
  font-size: 18px;
  line-height: 1.3;
}

.related-list,
.chart-list {
  display: grid;
  gap: 8px;
}

.chart-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.related-list,
.chart-list {
  max-height: 304px;
  overflow-y: hidden;
  padding-right: 4px;
}

.related-list:hover,
.related-list:focus-within,
.chart-list:hover,
.chart-list:focus-within {
  overflow-y: auto;
}

.related-song {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 11px 12px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.related-song:hover {
  border-color: var(--accent-soft);
  background: var(--accent-wash);
}

.related-song.mock {
  cursor: default;
  opacity: 0.72;
}

.related-song.mock:hover {
  border-color: var(--line);
  background: var(--panel);
}

.related-song strong,
.related-song span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.related-song strong {
  font-size: 14px;
}

.related-song span,
.related-empty {
  color: var(--muted);
  font-size: 13px;
}

.song-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 0 20px;
  border-bottom: 1px solid var(--line);
}

.song-identity {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.artist-photo-placeholder {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--artist-photo-color, var(--accent)), var(--accent));
  color: #ffffff;
  font-size: 42px;
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(24, 35, 52, 0.12);
}

.eyebrow {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
}

h2 {
  font-size: 34px;
  line-height: 1.16;
  overflow-wrap: anywhere;
}

.artist {
  margin-top: 8px;
}

.empty-state {
  display: grid;
  gap: 10px;
  margin-top: 28px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.lyrics-view {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.line {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 14px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  border-radius: 8px;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.line.playing {
  border-bottom-color: transparent;
  background: var(--accent-wash);
}

.time {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  padding-top: 6px;
}

.text {
  font-size: 22px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.script-switch,
.voice-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  padding: 3px;
}

.theme-button {
  width: 22px;
  height: 22px;
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 0;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42);
}

.theme-button[data-theme="purple"] {
  background: rgb(96, 25, 134);
}

.theme-button[data-theme="teal"] {
  background: rgb(15, 118, 110);
}

.theme-button[data-theme="blue"] {
  background: rgb(37, 99, 235);
}

.theme-button[data-theme="rose"] {
  background: rgb(190, 18, 60);
}

.theme-button[data-theme="brown"] {
  background: rgb(133, 77, 14);
}

.theme-button.active {
  border-color: var(--ink);
  outline: 2px solid var(--panel);
}

.theme-button:focus-visible {
  outline: 3px solid rgba(21, 122, 110, 0.22);
  outline-offset: 2px;
}

.script-button,
.voice-button {
  min-width: 34px;
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  padding: 0 8px;
}

.aligned-lyric {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  column-gap: 2px;
  row-gap: 18px;
  overflow-wrap: normal;
}

.char-token {
  appearance: none;
  display: grid;
  grid-template-rows: 18px 40px 40px;
  align-items: center;
  justify-items: center;
  width: 44px;
  min-width: 44px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  cursor: pointer;
  text-align: center;
}

.char-token b,
.char-token .token-homophone {
  display: block;
  width: 100%;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 30px;
  line-height: 1;
}

.char-token b {
  color: var(--ink);
  font-weight: 500;
}

.char-token span {
  display: block;
  width: 100%;
  min-height: 16px;
  color: #7a86a0;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 12px;
  font-style: normal;
  line-height: 1.2;
  white-space: nowrap;
}

.char-token .token-homophone {
  color: var(--accent);
  font-size: 30px;
  font-weight: 500;
}

.char-token.has-reading {
  border-color: transparent;
  background: transparent;
}

.char-token:hover .token-text,
.char-token:focus-visible .token-text {
  color: var(--teal);
}

.char-token:focus-visible,
.line-play-button:focus-visible {
  outline: 3px solid rgba(21, 122, 110, 0.22);
  outline-offset: 2px;
}

.line-play-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: #8a96aa;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(24, 35, 52, 0.08);
}

.line-play-button:hover {
  border-color: rgba(21, 122, 110, 0.4);
  color: var(--teal);
}

.line-play-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.hidden {
  display: none;
}

@media (max-width: 860px) {
  .topbar {
    align-items: center;
    padding: 16px;
  }

  .topbar-tools {
    margin-left: auto;
  }

  .home-page {
    padding: 24px 16px 18px;
  }

  .home-search {
    height: 48px;
  }

  .home-search input {
    font-size: 16px;
  }

  .alphabet-list {
    gap: 10px;
  }

  .artist-grid,
  .latest-list {
    grid-template-columns: 1fr;
  }

  .artist-grid {
    gap: 14px;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .related-sidebar {
    min-height: 0;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 18px 0 28px;
  }

  .library {
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-right: 0;
    padding-bottom: 16px;
  }

  .song-list {
    max-height: 42vh;
  }

  .song-head {
    flex-direction: column;
  }

  .song-identity {
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 14px;
  }

  .artist-photo-placeholder {
    width: 84px;
    height: 84px;
    border-radius: 14px;
    font-size: 32px;
  }

  h2 {
    font-size: 28px;
  }

  .line {
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 4px;
  }

  .time {
    grid-column: 1 / -1;
  }
}
