:root {
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: #293f37; background: #e9eee6; font-synthesis: none;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  --border: #d4ddd1; --ink: #53695b; --tint: #e8eee5; --wash: #f0f3ed; --accent: #8da18a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .3; cursor: default; }
button:focus-visible { outline: 3px solid #568cbb; outline-offset: -3px; }
button:active:not(:disabled) { filter: brightness(.95); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.singer-app {
  width: 100%; height: 100dvh; display: grid;
  grid-template-rows: 50px 32px 127px minmax(0, 1fr) 40px; gap: 6px;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: #f4f5ef; overflow: hidden;
}
.song-heading { display: flex; align-items: center; gap: 7px; min-width: 0; }
.icon-button { display: grid; place-items: center; border: 1px solid var(--border); border-radius: 9px; background: #ffffff8c; width: 36px; height: 36px; padding: 0; flex-shrink: 0; }
.song-arrow { width: 25px; border: 0; background: none; }
.song-title { flex: 1; min-width: 0; }
.heading-meta { display: flex; align-items: center; gap: 9px; font-size: 9px; color: #7d897c; letter-spacing: .6px; }
.heading-meta > span:first-child { font-size: 12px; font-weight: 800; color: #41614a; }
.song-title h1 { margin: 1px 0 0; font-size: 28px; line-height: 1.25; letter-spacing: .7px; }
.song-tabs { display: grid; grid-template-columns: .9fr 1.25fr 1fr; gap: 5px; }
.song-tab { position: relative; border: 1px solid #d8dfd2; border-radius: 8px; background: #f8f9f3; color: #6e7c6a; font-size: 12px; font-weight: 700; white-space: nowrap; padding: 0 3px; }
.song-tab.viewing { background: #e1eadb; border-color: #aabb9e; color: #34543b; }
.song-tab.playing:after, .song-tab.queued:before { content: ""; position: absolute; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: #438359; top: 5px; }
.song-tab.queued:before { top: auto; bottom: 5px; background: #b99c5b; }
.route-panel { display: grid; grid-template-rows: 28px 54px 29px; gap: 4px; min-width: 0; min-height: 0; padding: 3px 0; border-top: 1px solid #d7dfd0; border-bottom: 1px solid #d7dfd0; overflow: hidden; }
.route-row { display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 0; }
.row-label { flex: 0 0 34px; font-size: 10px; color: #8c9685; }
.route-strip { display: flex; gap: 5px; align-items: center; overflow-x: auto; overflow-y: hidden; min-width: 0; height: 100%; flex: 1; scrollbar-width: none; overscroll-behavior-x: contain; }
.route-strip::-webkit-scrollbar, .lyrics-pages::-webkit-scrollbar { display: none; width: 0; height: 0; }
.route-item { position: relative; flex-shrink: 0; display: flex; align-items: center; gap: 4px; white-space: nowrap; border: 1px solid var(--accent); background: var(--wash); color: var(--ink); border-radius: 6px; padding: 4px 7px; min-height: 26px; }
.route-item strong { font-size: 12px; line-height: 1.2; }
.route-item small { font-size: 8px; font-weight: 600; color: var(--ink); }
.route-item small:empty { display: none; }
.route-item.visited { border: 1px solid transparent; border-bottom: 3px solid var(--accent); background: transparent; color: color-mix(in srgb, var(--ink) 50%, #f4f5ef); border-radius: 4px; }
.route-item.current { background: var(--tint); border: 2px solid var(--ink); color: var(--ink); }
.route-item.queued { border: 2px solid var(--accent); background: var(--wash); }
.route-item.prepared { outline: 2px solid var(--ink); outline-offset: -2px; }
.route-empty { font-size: 10px; color: #9aa38f; white-space: nowrap; }
.route-window { display: grid; grid-template-columns: .78fr 1.08fr 1fr .94fr; gap: 5px; min-width: 0; min-height: 0; }
.route-slot { flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px; min-width: 0; padding: 5px 6px; overflow: hidden; }
.route-slot strong { font-size: 15px; white-space: nowrap; }
.route-slot small { font-size: 9px; }
.cue-track { position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: color-mix(in srgb, var(--accent) 20%, transparent); }
.cue-track > span { display: block; width: 100%; height: 100%; background: var(--accent); transform-origin: left; transition: transform .1s linear; }
.verse { --ink: #305681; --tint: #d7e7f5; --wash: #ebf2fa; --accent: #86a9c7; }
.prechorus { --ink: #5a518d; --tint: #e2def4; --wash: #f1eefb; --accent: #a59acb; }
.chorus { --ink: #794580; --tint: #e9d6ed; --wash: #f5eefa; --accent: #bb95c1; }
.tag { --ink: #91652b; --tint: #f6e3c8; --wash: #fcf3e6; --accent: #cfb17a; }
.instrumental { --ink: #5a725e; --tint: #e0e8da; --wash: #eef2e8; --accent: #a0b193; }
.ending { --ink: #8f6155; --tint: #eddad2; --wash: #f6ede7; --accent: #c0a192; }
/* Every card gets an equal share of the remaining height, including short screens. */
.section-buttons { display: grid; grid-template-rows: repeat(var(--section-count, 5), minmax(0, 1fr)); gap: 6px; overflow: hidden; min-width: 0; min-height: 0; }
.section-card { container-type: size; display: grid; grid-template-columns: 77px minmax(0, 1fr); gap: 4px; min-height: 0; min-width: 0; border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); background: var(--wash); border-radius: 11px; color: var(--ink); padding: 4px; overflow: hidden; }
.section-card.current-section { border: 2px solid var(--ink); padding: 3px; }
.section-card.next-section { box-shadow: inset 0 0 0 1px var(--accent); }
.section-name { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 5px; border: 0; background: none; color: var(--ink); padding: 3px 5px; min-width: 0; min-height: 0; overflow: hidden; text-align: left; }
.section-name strong { font-size: clamp(12px, 30cqh, 23px); line-height: 1.12; letter-spacing: -.8px; white-space: nowrap; }
.section-name small { font-size: clamp(8px, 11cqh, 11px); font-weight: 700; white-space: nowrap; }
.section-name small:empty { display: none; }
.lyrics-content { position: relative; min-width: 0; min-height: 0; display: flex; overflow: hidden; }
.lyrics-pages { width: 100%; height: 100%; display: flex; align-items: stretch; gap: 6px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; position: relative; min-height: 0; touch-action: pan-x; }
.lyrics-page { position: relative; display: flex; align-items: center; text-align: left; color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: 7px; padding: 4px 8px; min-width: 0; min-height: 0; height: 100%; flex: 0 0 100%; scroll-snap-align: start; white-space: pre-line; overflow: hidden; }
.lyrics-page.live-page { background: var(--tint); border: 2px solid var(--ink); padding: 3px 7px; }
.lyrics-page.next-page { border: 2px solid var(--accent); background: color-mix(in srgb, var(--tint) 45%, var(--wash)); padding: 3px 7px; }
.lyrics-page.live-page.next-page { box-shadow: inset 0 0 0 2px var(--accent); }
.lyrics-text { display: block; max-height: 100%; width: 100%; overflow: hidden; font-size: clamp(10px, 22cqh, 22px); font-weight: 650; line-height: 1.4; overflow-wrap: anywhere; }
.page-number { position: absolute; bottom: 3px; right: 5px; font-size: clamp(8px, 11cqh, 11px); line-height: 1; font-weight: 750; color: var(--ink); opacity: .8; pointer-events: none; }
.utility-buttons { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; min-width: 0; }
.utility-button { border: 1px solid #cbd7c5; background: #e8eee2; border-radius: 8px; color: #597156; font-size: 17px; font-weight: 750; padding: 3px; }
.utility-button.current { border: 2px solid #46744f; background: #dfe9d8; }
.utility-button.queued { box-shadow: inset 0 0 0 2px #adb993; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (min-width: 700px) {
  .singer-app { padding: 12px 20px; grid-template-rows: 56px 36px 131px minmax(0, 1fr) 44px; gap: 8px; }
  .song-title h1 { font-size: 32px; }
  .song-tabs { grid-template-columns: repeat(3, 1fr); }
  .song-tab { font-size: 14px; }
  .route-panel { grid-template-rows: 28px 58px 29px; }
  .route-strip { gap: 7px; }
  .route-item strong { font-size: 13px; }
  .route-slot strong { font-size: 19px; }
  .route-window { grid-template-columns: repeat(4, 1fr); }
  .section-card { grid-template-columns: 108px minmax(0, 1fr); gap: 10px; }
  .section-name strong { font-size: clamp(12px, 30cqh, 28px); }
  .lyrics-page { flex-basis: calc((100% - 6px) / 2); padding-left: 12px; padding-right: 12px; }
}
@media (min-width: 1100px) {
  .singer-app { max-width: 1480px; margin: auto; padding-left: 28px; padding-right: 28px; }
  .lyrics-page { flex-basis: calc((100% - 12px) / 3); }
  .section-card { grid-template-columns: 125px minmax(0, 1fr); }
  .route-item { padding-left: 10px; padding-right: 10px; }
}
@media (max-width: 370px) {
  .singer-app { padding-left: 7px; padding-right: 7px; }
  .song-title h1 { font-size: 25px; }
  .heading-meta { font-size: 8px; gap: 5px; }
  .icon-button { width: 32px; height: 32px; }
  .song-arrow { width: 20px; }
  .song-tab { font-size: 11px; }
  .route-slot strong { font-size: 13px; }
  .route-slot { padding-left: 4px; padding-right: 4px; }
  .section-card { grid-template-columns: 70px minmax(0, 1fr); }
  .section-name strong { font-size: clamp(12px, 30cqh, 20px); }
  .utility-button { font-size: 16px; }
}
@media (max-height: 700px) {
  .singer-app { grid-template-rows: 44px 28px 112px minmax(0, 1fr) 34px; gap: 4px; padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .route-panel { grid-template-rows: 24px 47px 25px; }
  .route-item { min-height: 23px; padding-top: 2px; padding-bottom: 2px; }
  .song-title h1 { font-size: 25px; }
  .section-buttons { gap: 4px; }
  .utility-button { font-size: 16px; }
}
@media (orientation: landscape) and (max-height: 550px) {
  .singer-app { grid-template-columns: 270px minmax(0, 1fr); grid-template-rows: 46px 30px minmax(0, 1fr) 32px; gap: 6px 10px; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .song-heading { grid-column: 1; grid-row: 1; }
  .song-tabs { grid-column: 1; grid-row: 2; }
  .route-panel { grid-column: 1; grid-row: 3 / 5; grid-template-rows: 26px minmax(0, 1fr) 28px; gap: 6px; }
  .route-window { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); }
  .section-buttons { grid-column: 2; grid-row: 1 / 4; }
  .utility-buttons { grid-column: 2; grid-row: 4; }
  .section-card { grid-template-columns: 74px minmax(0, 1fr); gap: 4px; }
  .section-name strong { font-size: clamp(12px, 30cqh, 22px); }
  .lyrics-page { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
