* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #09070f;
  color: white;
}

button {
  font: inherit;
}

.app,
.song-page {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 32px 20px;
}

.hidden {
  display: none !important;
}

/* Home */

.hero {
  text-align: center;
  padding: 32px 0;
}

.logo {
  font-size: 48px;
  margin-bottom: 12px;
}

.eyebrow {
  color: #b99cff;
  font-size: 12px;
  letter-spacing: 2px;
}

h1 {
  font-size: 42px;
  margin: 8px 0;
}

.subtitle {
  color: #c8bfd8;
  line-height: 1.6;
}

.progress-card {
  background: #171224;
  border: 1px solid #2d2342;
  border-radius: 24px;
  padding: 20px;
  margin-bottom: 32px;
}

.progress-card p {
  color: #b99cff;
  margin: 0 0 8px;
}

#progressText {
  display: block;
  margin-bottom: 14px;
  font-size: 20px;
  font-weight: 800;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: #2b223c;
  border-radius: 999px;
  overflow: hidden;
}

#progressBar {
  width: 0%;
  height: 100%;
  background: #8b5cf6;
  border-radius: 999px;
}

.song-section h2 {
  margin-bottom: 16px;
}

.song-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.song-item {
  width: 100%;
  background: #14101f;
  color: white;
  border: 1px solid #2a2238;
  border-radius: 18px;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 44px 1fr 32px;
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
}

.song-item:hover {
  background: #1d1730;
  transform: translateY(-1px);
}

.song-number {
  color: #b99cff;
  font-size: 13px;
  font-weight: 800;
}

.song-name {
  font-size: 17px;
  font-weight: 750;
}

.status {
  text-align: right;
}

/* Song Page */

.back-btn,
.mode-buttons button,
.practice-controls button {
  background: #171224;
  color: white;
  border: 1px solid #2d2342;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
}

.back-btn {
  margin-bottom: 24px;
}

#songTitle {
  margin-top: 8px;
}

#songNote {
  color: #b9b0c9;
  line-height: 1.6;
}

.song-actions{
    display:flex;
    flex-direction:column;
    gap:16px;
    margin:28px 0;
}

.mode-switch{
    display:flex;
    background:#191327;
    border-radius:18px;
    padding:6px;
}

.mode-switch button{
    flex:1;
    border:none;
    background:transparent;
    color:#9f96bb;
    font-weight:700;
    padding:14px 0;
    border-radius:14px;
    transition:.2s;
}

.mode-switch button.active{
    background:#7c5cff;
    color:white;
}

.done-btn{
    width:100%;
    border-radius:18px;
}

@media (max-width:768px){

    .song-actions{
        gap:12px;
    }

    .mode-switch button{
        font-size:15px;
        padding:13px 0;
    }

}

.mode-buttons button:hover,
.back-btn:hover,
.practice-controls button:hover {
  background: #241a38;
}

/* Guide */

.chant-line {
  background: #14101f;
  border: 1px solid #2a2238;
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
}

.chant-time {
  color: #b99cff;
  font-size: 13px;
  margin-bottom: 6px;
}

.chant-text {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.35;
}

.chant-line.lyrics .chant-time {
  color: #8f86a8;
}

.chant-line.lyrics .chant-text {
  color: #d8d3e3;
  font-size: 18px;
  font-weight: 500;
}

.chant-line.sing {
  border-color: #8b2d5f;
  background: #1a1020;
}

.chant-line.sing .chant-time,
.chant-line.sing .chant-text {
  color: #ff79c6;
}

.chant-line.chant {
  border-color: #3158ff;
  background: #10162b;
}

.chant-line.chant .chant-time,
.chant-line.chant .chant-text {
  color: #7aa2ff;
}

.chant-line.cheer {
  border-color: #F6C453;
  background: rgba(246, 196, 83, 0.12);
}

/* Practice */

.practice-mode {
  padding: 16px 0 40px;
}

.practice-top {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
  color: #b99cff;
  font-size: 14px;
  font-weight: 800;
}

.practice-card {
  border-radius: 28px;
  padding: 24px;
  margin-bottom: 16px;
  border: 1px solid #2d2342;
}

.practice-card.current {
  min-height: 230px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(180deg, #1b122a, #100b18);
}

.practice-card.next {
  background: #14101f;
  opacity: 0.9;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 8px 12px;
  margin-bottom: 18px;
  font-size: 14px;
  font-weight: 850;
}

.badge.sing {
  background: rgba(255, 121, 198, 0.16);
  color: #ff79c6;
}

.badge.chant {
  background: rgba(122, 162, 255, 0.16);
  color: #7aa2ff;
}

.badge.cheer {
  background: rgba(246, 196, 83, 0.12);
  color: #F6C453;
}

.badge.lyrics,
.badge.default {
  background: rgba(216, 211, 227, 0.12);
  color: #d8d3e3;
}

.practice-text {
  font-size: 42px;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.5px;
}

.next-title {
  margin: 0 0 12px;
  color: #8f86a8;
  font-size: 14px;
  font-weight: 800;
}

.next-text,
#nextPracticeText {
  font-size: 24px;
  font-weight: 850;
  line-height: 1.25;
  color: #e7e0f3;
}

.practice-controls {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.practice-controls button {
  flex: 1;
  font-size: 22px;
  padding: 16px;
}

/* Studio */

.editor-card {
  background: #14101f;
  border: 1px solid #2a2238;
  border-radius: 24px;
  padding: 20px;
  margin-bottom: 20px;
}

.editor-card label {
  display: block;
  color: #b99cff;
  font-weight: 800;
  margin: 16px 0 8px;
}

.editor-card input,
.editor-card select,
.editor-card textarea {
  width: 100%;
  background: #09070f;
  color: white;
  border: 1px solid #2d2342;
  border-radius: 14px;
  padding: 14px;
  font: inherit;
}

.editor-card textarea {
  min-height: 120px;
  resize: vertical;
}

.editor-card button {
  width: 100%;
  background: #8b5cf6;
  color: white;
  border: none;
  border-radius: 14px;
  padding: 14px;
  margin-top: 16px;
  font-weight: 800;
  cursor: pointer;
}

#outputJson {
  min-height: 280px;
  font-family: monospace;
}

.editor-hint {
  color: #b9b0c9;
  line-height: 1.6;
}

.line-editor-item {
  background: #0f0b17;
  border: 1px solid #2a2238;
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 12px;
}

.line-editor-item.lyrics {
  border-color: #2a2238;
}

.line-editor-item.sing {
  border-color: #8b2d5f;
}

.line-editor-item.chant {
  border-color: #3158ff;
}

.line-editor-item.cheer {
  border-color: #F6C453;
}

.line-editor-text {
  font-weight: 800;
  line-height: 1.45;
  margin-bottom: 12px;
}

.line-type-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.line-type-buttons button {
  background: #171224;
  color: #cfc7dd;
  border: 1px solid #2d2342;
  border-radius: 12px;
  padding: 8px;
  font-size: 13px;
  cursor: pointer;
}

.line-type-buttons button.active {
  background: #8b5cf6;
  color: white;
  border-color: #8b5cf6;
}

/* Studio - practice text override */

.practice-text-label {
  display: block;
  color: #b99cff;
  font-size: 13px;
  font-weight: 800;
  margin: 14px 0 8px;
}

.practice-text-input {
  width: 100%;
  background: #09070f;
  color: white;
  border: 1px solid #2d2342;
  border-radius: 12px;
  padding: 12px;
  font: inherit;
}

.practice-roman {
  margin-top: 12px;
  font-size: 20px;
  font-weight: 600;
  color: #a89dbd;
  line-height: 1.4;
}

.practice-card.current.cheer {
  background:
    radial-gradient(circle at top left, rgba(246, 196, 83, 0.12), transparent 36%),
    linear-gradient(180deg, #24172f, #130d1f);
  border-color: #ffd257;
}

.practice-card.current.cheer .practice-text {
  color: #fff4c7;
}

.completed-card {
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 210, 87, 0.22), transparent 32%),
    radial-gradient(circle at 80% 10%, rgba(185, 156, 255, 0.28), transparent 34%),
    linear-gradient(180deg, #251337, #120b1c) !important;
  border-color: #b99cff !important;
}

.complete-heart {
  font-size: 56px;
  margin-bottom: 16px;
}

.complete-subtitle {
  margin-top: 12px;
  font-size: 20px;
  color: #b99cff;
  letter-spacing: 1.5px;
}

/* Layout safety */
html,
body {
  width: 100%;
  overflow-x: hidden;
}

.app,
.song-page {
  width: 100%;
  max-width: 480px;
  overflow-x: hidden;
}

input,
textarea,
select,
button {
  max-width: 100%;
}

.editor-card,
.line-editor-item {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.line-editor-text,
.chant-text,
.practice-text,
.next-text,
#nextPracticeText {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.line-type-buttons {
  width: 100%;
  min-width: 0;
}

.line-type-buttons button {
  min-width: 0;
  white-space: nowrap;
}

/* v1.1 Guide highlight rules */
.chant-line.has-highlight.sing,
.chant-line.has-highlight.chant {
  background: #14101f;
  border-color: #2a2238;
}

.chant-line.has-highlight.sing .chant-text,
.chant-line.has-highlight.chant .chant-text {
  color: #d8d3e3;
}

.chant-line.has-highlight.sing .chant-time {
  color: #ff79c6;
  font-weight: 900;
}

.chant-line.has-highlight.chant .chant-time {
  color: #7aa2ff;
  font-weight: 900;
}

.inline-highlight.sing {
  color: #ff79c6;
  font-weight: 950;
}

.inline-highlight.chant {
  color: #7aa2ff;
  font-weight: 950;
}

.inline-highlight.cheer {
  color: #f6c453;
  font-weight: 950;
}

/* Cheer = gold */
.chant-line.cheer {
  border-color: rgba(246, 196, 83, 0.7);
  background: rgba(246, 196, 83, 0.12);
  box-shadow: 0 0 0 1px rgba(246, 196, 83, 0.08);
}

.chant-line.cheer .chant-time,
.chant-line.cheer .chant-text {
  color: #f6c453;
}

.badge.cheer {
  background: rgba(246, 196, 83, 0.16);
  color: #f6c453;
}

/* Practice helper text */
.practice-target {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 24px;
  font-weight: 800;
  color: #ff79c6;
  line-height: 1.35;
}

.practice-card.current.chant .practice-target {
  color: #7aa2ff;
}

.practice-card.current.cheer .practice-target {
  color: #f6c453;
}

/* v1.1 Practice mode color rules */

.practice-full.sing {
  color: #ff79c6;
}

.practice-full.chant {
  color: #7aa2ff;
}

.practice-full.cheer {
  color: #f6c453;
}

/* 練習目標依 type 變色 */
.practice-target.sing {
  color: #ff79c6;
}

.practice-target.chant {
  color: #7aa2ff;
}

.practice-target.cheer {
  color: #f6c453;
}

/* 下一句弱化，不搶主卡 */
.practice-card.next {
  transform: scale(0.96);
  opacity: 0.72;
  filter: saturate(0.75);
}

.practice-card.next .badge {
  margin-bottom: 12px;
  font-size: 12px;
}

.practice-card.next .practice-target {
  margin-top: 12px;
  padding-top: 12px;
  font-size: 18px;
}

.practice-card.next .practice-roman {
  font-size: 16px;
}

#nextPracticeText {
  font-size: 20px;
  line-height: 1.3;
}

/* 下一句依 type 微調色感 */
.practice-card.next.sing {
  border-color: rgba(255, 121, 198, 0.22);
}

.practice-card.next.chant {
  border-color: rgba(122, 162, 255, 0.22);
}

.practice-card.next.cheer {
  border-color: rgba(246, 196, 83, 0.12);
}

.chant-line.has-highlight.sing .chant-text,
.chant-line.has-highlight.chant .chant-text {
  color: #d8d3e3;
  font-size: 18px;
  font-weight: 500;
}

.chant-line.has-highlight .inline-highlight {
  font-size: 22px;
  font-weight: 950;
}

.replace-original {
  display: block;
  color: #8f86a8;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: rgba(255,255,255,0.55);
  margin-bottom: 8px;
}

.replace-new {
  display: block;
  font-weight: 950;
}

.replace-new.sing {
  color: #ff79c6;
}

.replace-new.chant {
  color: #7aa2ff;
}

.replace-new.cheer {
  color: #f6c453;
}

.replace-hint {
  display: block;
  margin: 4px 0 6px;
  color: #8f86a8;
  font-size: 13px;
  font-weight: 700;
}

.replace-line {
  display: block;
  color: #d8d3e3;
}

.replace-original-inline {
  color: #8f86a8;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: rgba(255, 255, 255, 0.55);
}

.footer-credit span {
  color: #b892ff;
  font-weight: 700;
}

.footer-links a:hover {
  color: #d8bfff;
}

/* v1.2 Clean Song Header */

.song-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.song-header-row .back-btn {
  margin-bottom: 0;
}

.done-chip {
  background: transparent;
  color: #9f96bb;
  border: 1px solid #2d2342;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.done-chip.active {
  color: #d8bfff;
  background: rgba(139, 92, 246, 0.14);
  border-color: rgba(185, 156, 255, 0.42);
}

.done-chip:hover {
  background: #1b142a;
}

.done-btn {
  display: none;
}

.song-page {
  padding-bottom: 110px;
}

.song-cue {
  margin: 18px 0 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(246, 197, 83, 0);
  border: 1px solid rgba(246, 196, 83, 0.36);
  color: #f6c453;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.5;
}

.song-cue::before {
  content: "切入提示";
  display: block;
  margin-bottom: 6px;
  color: rgba(246, 196, 83, 0.72);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

/* v1.2 Floating Quick Menu */

.fab-menu,
.home-fab-menu {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.fab-main {
  width: 58px;
  height: 58px;
  border-radius: 999px;
  border: 1px solid rgba(185, 156, 255, 0.42);
  background: rgba(23, 18, 36, 0.9);
  color: white;
  font-size: 26px;
  cursor: pointer;
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.34);
}

.fab-action {
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  pointer-events: none;

  border: 1px solid rgba(185,156,255,.35);
  border-radius: 999px;

  background: #30204b;
  color: #f7f2ff;
  min-width: 152px;
  width: fit-content;
  justify-content: flex-start;

  padding: 10px 16px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  transition: 0.18s ease;

  text-decoration: none;

  display: flex;
  align-items: center;
  gap: 14px;
}

.fab-action svg{
    width:22px;
    height:22px;
    stroke-width:2;
    flex-shrink:0;
}

.fab-icon{
    width:22px;
    min-width:22px;
    text-align:center;
}

.social-icon {
  width: 22px;
  min-width: 22px;
  height: 22px;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}

.fab-divider {
  width: 100%;
  height: 1px;
  margin: 2px 0;
  background: rgba(185, 156, 255, 0.16);
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transition: 0.18s ease;
}

.home-fab-menu.open .fab-divider {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.fab-menu.open .fab-action,
.home-fab-menu.open .fab-action {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.fab-action:hover {
  background: #3c2a63;
}

.fab-main:hover {
  background: rgba(36, 26, 56, 0.96);
}

.song-search {
  width: 100%;
  margin: 0 0 24px;
  padding: 14px 18px;

  background: #2b2143;
  border: 1px solid #725f9c;
  border-radius: 16px;

  color: #fff;
  font-size: 16px;
  font: inherit;
  outline: none;

  display: block;
}

.song-search::placeholder{
    color:#b8aad5;
}

.song-search:focus{
    border-color:#8b5cf6;
    box-shadow:0 0 0 3px rgba(139,92,246,.18);
}

/* FIX: Floating menu buttons */
.fab-action,
.fab-action:visited,
.fab-action:link {
  color: #f7f2ff;
  text-decoration: none;
}

.fab-action span {
  color: #f7f2ff;
  text-decoration: none;
}

.fab-action img.social-icon {
  width: 22px;
  height: 22px;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}

/* FIX: home social buttons should stay pill-shaped */
.home-fab-menu .fab-action {
  min-width: 152px;
  max-width: 180px;
  justify-content: flex-start;
}

/* FIX: lyric page prev/next too long */
.song-fab-menu .fab-action,
.fab-menu .song-nav-action {
  min-width: 112px;
  max-width: 128px;
  justify-content: center;
  padding: 10px 14px;
}

/* FIX: mobile footer duplicate/too crowded */
footer,
.site-footer {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px 88px;
  text-align: center;
  color: #8f86a8;
  font-size: 12px;
  line-height: 1.6;
}

.site-footer span {
  color: #b99cff;
  font-weight: 800;
}

.fab-action.prev-song,
.fab-action.next-song {
  min-width: 112px;
  max-width: 128px;
}

/* v1.3 Song page FAB: independent from Home FAB */
.song-fab-menu .song-fab-action {
  min-width: 116px;
  max-width: 124px;
  padding: 10px 14px;
  justify-content: center;
  gap: 0;
  text-align: center;
  white-space: nowrap;
}

.song-fab-menu .fab-main {
  margin-top: 4px;
}

/* Cue audio player */

.cue-player {
  margin-top: 14px;
  padding: 14px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.03)),
    rgba(20, 15, 26, .42);
  border: 1px solid rgba(246, 196, 83, .22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

.cue-player-main {
  display: flex;
  align-items: center;
  gap: 14px;
}

.cue-play-btn {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(246, 196, 83, .42);
  background: rgba(246, 197, 83, 0);
  color: #f6c453;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  flex-shrink: 0;
}

.cue-play-btn:hover {
  background: rgba(246, 196, 83, .22);
}

.cue-player-body {
  flex: 1;
  min-width: 0;
}

.cue-player-label {
  margin-bottom: 8px;
  color: rgba(246, 196, 83, .9);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .06em;
}

.cue-seek {
  width: 100%;
  height: 6px;
  margin: 0;
  accent-color: #f6c453;
  cursor: pointer;
}

.cue-time-row {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: rgba(255,255,255,.58);
  font-size: 12px;
  font-weight: 700;
}