:root {
  --ink: #0e1a22;
  --ink-soft: #243542;
  --foam: #e8f0f4;
  --mist: #b7c9d4;
  --moon: #f2e6c9;
  --accent: #3d8b7a;
  --accent-deep: #245f53;
  --line: rgba(242, 230, 201, 0.14);
  --card: #111;
  --danger: #c4785a;
  --font-display: "Noto Serif TC", "Songti TC", serif;
  --font-ui: "Space Grotesk", "Noto Sans SC", sans-serif;
  --font-body: "Noto Sans SC", "PingFang SC", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--foam);
  font-family: var(--font-body);
  background: #000;
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  backdrop-filter: blur(12px);
  background: rgba(0, 0, 0, 0.92);
  border-bottom: 1px solid var(--line);
}

.back {
  justify-self: start;
  color: var(--mist);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

.back:hover {
  color: var(--moon);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-display);
}

.brand-mark {
  width: 1.6rem;
  height: 1.6rem;
  display: grid;
  place-items: center;
  border-radius: 0.35rem;
  background: var(--accent);
  color: #04120f;
  font-weight: 900;
  font-size: 0.95rem;
}

.brand-name {
  font-weight: 700;
  letter-spacing: 0.04em;
}

.top-note {
  justify-self: end;
  margin: 0;
  font-size: 0.72rem;
  color: var(--mist);
  opacity: 0.85;
}

main {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

.page-title {
  margin: 0.4rem 0 0.5rem;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  letter-spacing: 0.02em;
  color: var(--moon);
}

.lede {
  margin: 0 0 1rem;
  color: var(--mist);
  line-height: 1.55;
  max-width: 36em;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.song-search-wrap {
  display: block;
  margin: 0 0 1.1rem;
}

.song-search {
  width: 100%;
  box-sizing: border-box;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 0.2rem;
  background: #0a0a0a;
  color: var(--foam);
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.18s ease;
}

.song-search::placeholder {
  color: var(--mist);
  opacity: 0.65;
}

.song-search:hover,
.song-search:focus {
  border-color: rgba(61, 139, 122, 0.55);
}

.song-search:focus {
  box-shadow: 0 0 0 2px rgba(61, 139, 122, 0.22);
}

.song-search-empty {
  margin: 0.75rem 0 0;
  color: var(--mist);
  font-size: 0.9rem;
}

.song-list {
  display: grid;
  gap: 0.85rem;
}

.song-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  width: 100%;
  text-align: left;
  padding: 0.85rem 0.9rem 0.85rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 0.2rem;
  background:
    linear-gradient(135deg, rgba(61, 139, 122, 0.18), transparent 55%),
    var(--card);
  color: inherit;
  cursor: pointer;
  font: inherit;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.song-card:hover,
.song-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(242, 230, 201, 0.35);
  outline: none;
}

.song-card-body {
  flex: 1 1 auto;
  min-width: 0;
}

.song-card .t {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--moon);
}

.song-card .a {
  margin-top: 0.25rem;
  color: var(--mist);
  font-size: 0.92rem;
}

.song-card .b {
  margin-top: 0.55rem;
  color: var(--foam);
  opacity: 0.78;
  font-size: 0.86rem;
  line-height: 1.45;
}

.song-cover {
  flex: 0 0 auto;
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 0.2rem;
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(61, 139, 122, 0.28), rgba(14, 26, 34, 0.85));
}

.song-cover--missing {
  display: block;
  box-sizing: border-box;
}

@media (max-width: 480px) {
  .song-cover {
    width: 72px;
    height: 72px;
  }

  .song-card {
    gap: 0.7rem;
    padding: 0.75rem 0.75rem 0.75rem 1rem;
  }
}

.btn-text {
  border: 0;
  background: none;
  color: var(--mist);
  font: inherit;
  cursor: pointer;
  padding: 0;
  margin-bottom: 1rem;
}

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

.song-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4.5vw, 2.2rem);
  color: var(--moon);
}

.song-meta,
.song-credit {
  margin: 0.35rem 0 0;
  color: var(--mist);
  font-size: 0.92rem;
  line-height: 1.5;
}

.song-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.btn-primary,
.btn-ghost,
.btn-sec {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #04120f;
}

.btn-primary:hover {
  background: #4aa392;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--foam);
}

.btn-ghost:hover {
  border-color: var(--mist);
}

.btn-sec,
.btn-orig {
  background: rgba(242, 230, 201, 0.08);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--moon);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}

.btn-sec.is-active,
.btn-orig.is-active {
  background: rgba(61, 139, 122, 0.35);
  border-color: var(--accent);
}

.btn-orig:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.clip-hint {
  margin-left: 0.35rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--mist);
  opacity: 0.8;
}

.media-status {
  margin: 0.75rem 0 0;
  padding: 0.55rem 0.75rem;
  border-radius: 0.2rem;
  font-size: 0.84rem;
  line-height: 1.4;
}

.media-status.ok {
  background: rgba(61, 139, 122, 0.18);
  color: var(--foam);
}

.media-status.miss {
  background: rgba(196, 120, 90, 0.16);
  color: #f0d2c4;
}

.sections {
  display: grid;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.section {
  border: 1px solid var(--line);
  border-radius: 0.2rem;
  background: var(--card);
  overflow: hidden;
}

.section.is-playing {
  border-color: rgba(61, 139, 122, 0.55);
  box-shadow: 0 0 0 1px rgba(61, 139, 122, 0.25);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: rgba(0, 0, 0, 0.22);
  border-bottom: 1px solid var(--line);
}

.section-label {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--moon);
}

.lines {
  display: grid;
}

.line {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: start;
  padding: 0.85rem 0.9rem;
  border-bottom: 1px solid rgba(242, 230, 201, 0.07);
}

.line:last-child {
  border-bottom: 0;
}

.line.is-active {
  background: rgba(61, 139, 122, 0.16);
}

.line-play {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(242, 230, 201, 0.06);
  color: var(--moon);
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
}

.line-play:hover,
.line.is-active .line-play,
.line-play.is-playing {
  background: var(--accent);
  color: #04120f;
  border-color: var(--accent);
}

.line-play.is-paused {
  background: rgba(242, 230, 201, 0.18);
  border-color: var(--moon);
  color: var(--moon);
}

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

.line-zh {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.2rem 0.35rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.line-unit {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 1.1em;
  cursor: pointer;
  border-radius: 0.25rem;
  padding: 0.12rem 0.1rem 0.08rem;
  transition: background 0.12s ease, color 0.12s ease;
}

.line-unit:hover {
  background: rgba(242, 230, 201, 0.12);
}

.line-unit.is-speaking {
  background: rgba(61, 139, 122, 0.42);
  color: var(--moon);
}

.line-syl {
  display: block;
  min-height: 0.95em;
  margin-bottom: 0.1rem;
  color: rgba(232, 240, 244, 0.62);
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
}

.line-tok {
  display: block;
  text-align: center;
  line-height: 1.25;
}

.line-punct {
  align-self: flex-end;
  padding-bottom: 0.1rem;
  opacity: 0.75;
}

.line-note {
  margin-top: 0.35rem;
  color: var(--mist);
  font-size: 0.86rem;
  line-height: 1.4;
}

.hint {
  margin: 1.25rem 0 0;
  color: var(--mist);
  font-size: 0.82rem;
  opacity: 0.85;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(92vw, 28rem);
  padding: 0.65rem 0.95rem;
  border-radius: 999px;
  background: rgba(14, 26, 34, 0.92);
  border: 1px solid var(--line);
  color: var(--foam);
  font-size: 0.86rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

@media (max-width: 560px) {
  .top {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
  }
  .top-note {
    grid-column: 1 / -1;
    justify-self: start;
  }
  .line-zh {
    font-size: 1.08rem;
  }
}
