:root,
[data-theme="warm"] {
  --bg: #3a2418;
  --text: #fff7f0;
  --text-muted: rgba(255, 247, 240, 0.68);
  --accent: #ffd9a8;
  --accent-hover: #ffe4c0;
  --accent-dim: rgba(255, 217, 168, 0.18);
  --success: #ffd9a8;
  --glass: rgba(255, 255, 255, 0.12);
  --glass-strong: rgba(255, 255, 255, 0.18);
  --glass-border: rgba(255, 255, 255, 0.28);
  --btn-primary-bg: #12100e;
  --btn-primary-text: #fff;
  --error-bg: rgba(248, 113, 113, 0.14);
  --error-text: #fecaca;
  --radius: 28px;
  --radius-md: 20px;
  --font: "DM Sans", "Outfit", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --theme-image-warm: url("/static/themes/warm.png");
  --theme-overlay: linear-gradient(180deg, rgba(40, 22, 12, 0.18) 0%, rgba(28, 14, 8, 0.32) 50%, rgba(16, 8, 4, 0.48) 100%);
}

[data-theme="paper"] {
  --bg: #cfc6b8;
  --text: #2a241c;
  --text-muted: #6e675c;
  --accent: #b06a3a;
  --accent-hover: #c47a45;
  --accent-dim: rgba(176, 106, 58, 0.14);
  --success: #b06a3a;
  /*
    Warm glass reads because the panel is milkier/blurrier than the sharp photo.
    Paper needs a stronger white frost so the slab is visibly different from the page.
  */
  --glass: rgba(255, 255, 255, 0.4);
  --glass-strong: rgba(255, 255, 255, 0.5);
  --glass-border: rgba(90, 70, 40, 0.2);
  --btn-primary-bg: #2a241c;
  --btn-primary-text: #fff;
  --error-bg: rgba(180, 60, 50, 0.1);
  --error-text: #a33a30;
  --theme-image-paper: url("/static/themes/paper.png?v=4");
  /*
    Same idea as warm/blue/green: darken the photo so frost can “read”
    as glass. Without this, light paper + white glass looks like a solid card.
  */
  --theme-overlay: linear-gradient(
    180deg,
    rgba(62, 48, 34, 0.14) 0%,
    rgba(48, 36, 26, 0.22) 50%,
    rgba(34, 26, 18, 0.3) 100%
  );
}

[data-theme="black"] {
  --bg: #0a0a0c;
  --text: #e8eaef;
  --text-muted: #9aa3b5;
  --accent: #8aa4ff;
  --accent-hover: #a8bcff;
  --accent-dim: rgba(138, 164, 255, 0.18);
  --success: #8aa4ff;
  /* Identical frost recipe to warm/blue/green */
  --glass: rgba(255, 255, 255, 0.12);
  --glass-strong: rgba(255, 255, 255, 0.18);
  --glass-border: rgba(255, 255, 255, 0.28);
  --btn-primary-bg: #e8eaef;
  --btn-primary-text: #0c0d10;
  --error-bg: rgba(248, 113, 113, 0.12);
  --error-text: #fca5a5;
  --theme-image-black: url("/static/themes/black.png?v=4");
  /*
    Soft cool veil (similar strength to warm), not a heavy blackout —
    backdrop-filter needs the grid to stay visible under the glass.
  */
  --theme-overlay: linear-gradient(180deg, rgba(20, 24, 36, 0.16) 0%, rgba(14, 16, 26, 0.28) 50%, rgba(8, 10, 18, 0.4) 100%);
}

[data-theme="blue"] {
  --bg: #0a2a4a;
  --text: #eef6fb;
  --text-muted: rgba(220, 235, 245, 0.72);
  --accent: #a8d0ee;
  --accent-hover: #c5e2f6;
  --accent-dim: rgba(168, 208, 238, 0.18);
  --success: #a8d0ee;
  --glass: rgba(255, 255, 255, 0.12);
  --glass-strong: rgba(255, 255, 255, 0.18);
  --glass-border: rgba(200, 225, 245, 0.3);
  --btn-primary-bg: #0b2440;
  --btn-primary-text: #fff;
  --error-bg: rgba(248, 113, 113, 0.14);
  --error-text: #fecaca;
  --theme-image-blue: url("/static/themes/blue.png");
  --theme-overlay: linear-gradient(180deg, rgba(8, 30, 55, 0.22) 0%, rgba(6, 24, 45, 0.35) 50%, rgba(4, 18, 36, 0.5) 100%);
}

[data-theme="green"] {
  --bg: #1a2e1c;
  --text: #eef7ef;
  --text-muted: rgba(220, 235, 220, 0.72);
  --accent: #b5e0ba;
  --accent-hover: #d0edd3;
  --accent-dim: rgba(181, 224, 186, 0.18);
  --success: #b5e0ba;
  --glass: rgba(255, 255, 255, 0.12);
  --glass-strong: rgba(255, 255, 255, 0.18);
  --glass-border: rgba(200, 230, 200, 0.3);
  --btn-primary-bg: #0e1c12;
  --btn-primary-text: #fff;
  --error-bg: rgba(248, 113, 113, 0.14);
  --error-text: #fecaca;
  --theme-image-green: url("/static/themes/green.png");
  --theme-overlay: linear-gradient(180deg, rgba(12, 28, 16, 0.2) 0%, rgba(10, 22, 12, 0.34) 50%, rgba(6, 16, 8, 0.5) 100%);
}

/* Cover as background: light frosted overlay (style 1), not a black veil */
[data-theme="cover"],
body.using-cover {
  --text: #fff7f0;
  --text-muted: rgba(255, 247, 240, 0.66);
  --accent: var(--cover-accent, #ffd9a8);
  --accent-hover: var(--cover-accent-hover, #ffe4c0);
  --accent-dim: var(--cover-accent-dim, rgba(255, 217, 168, 0.18));
  /* Highlight for roman / tone numbers — kept distinct from cover accent */
  --success: var(--cover-highlight, #9ef0c8);
  --highlight: var(--cover-highlight, #9ef0c8);
  --glass: rgba(255, 255, 255, 0.14);
  --glass-strong: rgba(255, 255, 255, 0.2);
  --glass-border: rgba(255, 255, 255, 0.32);
  --btn-primary-bg: #12100e;
  --btn-primary-text: #fff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  position: relative;
  transition: background-color 0.35s ease, color 0.25s ease;
}

.theme-bg,
.cover-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  /* Use visibility (not opacity) so backdrop-filter can sample the photo layer */
  visibility: hidden;
  transition: visibility 0.45s step-end;
}

.theme-bg.visible {
  visibility: visible;
  transition: visibility 0s;
}

.theme-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--theme-overlay);
}

/* Image themes share one pipeline: photo on .theme-bg + frosted .glass-card */
body[data-theme="warm"] .theme-bg {
  background-image: var(--theme-image-warm);
}

body[data-theme="paper"] .theme-bg {
  background-image: var(--theme-image-paper);
}

body[data-theme="blue"] .theme-bg {
  background-image: var(--theme-image-blue);
}

body[data-theme="green"] .theme-bg {
  background-image: var(--theme-image-green);
}

body[data-theme="black"] .theme-bg {
  background-image: var(--theme-image-black);
}

.cover-bg.has-cover {
  visibility: visible;
}

.cover-bg.has-cover::before {
  content: "";
  position: absolute;
  inset: -28px;
  background-image: inherit;
  background-position: center;
  background-size: cover;
  filter: blur(20px) saturate(1.2);
  transform: scale(1.08);
  z-index: -1;
}

/* Style-1 style: soft translucent veil, cover colors still visible */
.cover-bg.has-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(var(--cover-r, 40), var(--cover-g, 24), var(--cover-b, 18), 0.16) 0%,
    rgba(var(--cover-r, 30), var(--cover-g, 18), var(--cover-b, 14), 0.26) 50%,
    rgba(var(--cover-r, 18), var(--cover-g, 12), var(--cover-b, 10), 0.38) 100%
  );
}

body.using-cover .theme-bg {
  visibility: hidden;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
  transition: max-width 0.3s ease;
}

body[data-state="loaded"] .app {
  max-width: 960px;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  border-radius: 18px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
}

h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.logo-title-row {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.15rem;
}

.brand-credit {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  opacity: 0.85;
  line-height: 1.15;
}

.theme-picker {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.55rem;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  backdrop-filter: blur(16px);
}

.theme-picker-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0.15rem 0 0.3rem;
  font-weight: 600;
}

.theme-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  outline: none;
  cursor: pointer;
  box-shadow: none;
  padding: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  -webkit-appearance: none;
  appearance: none;
}

.theme-swatch:hover { transform: scale(1.08); }

.theme-swatch.active {
  box-shadow: 0 0 0 2px var(--text);
}

/* Solid dots — same format as paper swatch, no gradients / borders */
.theme-swatch[data-theme="paper"] { background: #f2f0ec; }
.theme-swatch[data-theme="black"] {
  background: #0a0a0c url("/static/themes/black.png?v=4") center / cover no-repeat;
}
.theme-swatch[data-theme="warm"] { background: #b86a3a; }
.theme-swatch[data-theme="blue"] { background: #2a6ea8; }
.theme-swatch[data-theme="green"] { background: #4a8f52; }
.theme-swatch-cover {
  background: #888;
  position: relative;
}
.theme-swatch-cover::after {
  content: "♪";
  font-size: 10px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.glass-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  backdrop-filter: blur(28px) saturate(1.35);
  -webkit-backdrop-filter: blur(28px) saturate(1.35);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
  padding: 1.75rem;
}

/*
  Paper panels: paint the paper texture into the card (fixed), then frost it.
  This matches the warm/blue/green “see the photo through glass” look even on
  a light texture where backdrop-filter alone can read as a solid slab.
*/
[data-theme="paper"] .glass-card,
[data-theme="paper"] .logo-icon,
[data-theme="paper"] .theme-picker,
[data-theme="paper"] .tone-panel {
  background-color: transparent;
  /* Paper texture aligned to the page, then a light frost veil (like warm glass) */
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.34)),
    linear-gradient(rgba(62, 48, 34, 0.1), rgba(34, 26, 18, 0.16)),
    var(--theme-image-paper);
  background-attachment: scroll, scroll, fixed;
  background-size: auto, auto, cover;
  background-position: 0 0, 0 0, center;
  background-repeat: no-repeat, no-repeat, no-repeat;
  backdrop-filter: blur(8px) saturate(1.08);
  -webkit-backdrop-filter: blur(8px) saturate(1.08);
}

[data-theme="paper"] .glass-card {
  box-shadow: 0 16px 40px rgba(60, 45, 30, 0.14);
}

[data-theme="paper"] .tone-panel {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0.42)),
    linear-gradient(rgba(62, 48, 34, 0.08), rgba(34, 26, 18, 0.12)),
    var(--theme-image-paper);
}

/*
  Black: fine grid disappears under blur alone. Paint the texture into glass
  (paper technique) so panels stay slightly see-through to the background.
*/
[data-theme="black"] .glass-card,
[data-theme="black"] .logo-icon,
[data-theme="black"] .theme-picker,
[data-theme="black"] .tone-panel {
  background-color: transparent;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.11)),
    var(--theme-image-black);
  background-attachment: scroll, fixed;
  background-size: auto, cover;
  background-position: 0 0, center;
  background-repeat: no-repeat, no-repeat;
  background-blend-mode: normal, normal;
  backdrop-filter: blur(8px) saturate(1.1);
  -webkit-backdrop-filter: blur(8px) saturate(1.1);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 16px 48px rgba(0, 0, 0, 0.3);
}

[data-theme="black"] .tone-panel {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.13)),
    var(--theme-image-black);
}

.input-section { margin-bottom: 0; }

.dropzone {
  border: 1.5px dashed var(--glass-border);
  border-radius: var(--radius-md);
  padding: 2.25rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone:hover,
.dropzone:focus,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-dim);
  outline: none;
}

.drop-icon { font-size: 2.2rem; margin-bottom: 0.6rem; opacity: 0.9; }
.drop-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.3rem; }
.drop-hint { color: var(--text-muted); font-size: 0.82rem; margin-bottom: 1.3rem; }

.file-btn {
  display: inline-block;
  padding: 0.65rem 1.6rem;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.35rem 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--glass-border);
}

.url-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.url-field {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.url-field input {
  width: 100%;
  padding: 0.55rem 0;
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--glass-border);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
}

.url-field input:focus {
  outline: none;
  border-bottom-color: var(--accent);
}

.url-field input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.yt-search-wrap {
  position: relative;
  width: 100%;
}

.yt-search-dropdown {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  z-index: 60;
  max-height: min(18rem, 52vh);
  overflow-y: auto;
  padding: 0.35rem;
  border-radius: var(--radius-md, 16px);
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.28);
}

.yt-search-dropdown.hidden {
  display: none;
}

.yt-search-option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 0.45rem 0.55rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  background: transparent;
}

.yt-search-option:hover {
  background: var(--glass);
}

.yt-search-thumb {
  flex-shrink: 0;
  width: 2.75rem;
  height: 1.55rem;
  object-fit: cover;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
}

.yt-search-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.yt-search-title {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.yt-search-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.yt-search-empty {
  padding: 0.55rem 0.65rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.input-compact {
  padding: 1.15rem 1.25rem;
  margin-bottom: 1.1rem;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

.file-or {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.file-link {
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.45);
  padding-bottom: 1px;
  user-select: none;
}

[data-theme="paper"] .file-link {
  border-bottom-color: rgba(42, 36, 28, 0.35);
}

.file-link:hover,
.file-link:focus,
.file-link.dragover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  outline: none;
}

.btn {
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 999px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: filter 0.2s, opacity 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.btn.primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
}

.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
}

.btn.ghost:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.btn.small {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.loading {
  text-align: center;
  padding: 3rem 1rem;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-note {
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.55;
  max-width: 22rem;
  margin: 0.65rem auto 0;
  opacity: 0.88;
}

.error {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--error-bg);
  color: var(--error-text);
  border-radius: var(--radius-md);
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.hidden { display: none !important; }

.results {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

body[data-state="loaded"] .results {
  margin-top: 1.25rem;
}

/* Black theme: chord cells use blue accents, never leftover green */
[data-theme="black"] .timeline-seg {
  background: rgba(138, 164, 255, 0.18);
}

[data-theme="black"] .timeline-seg .seg-roman {
  color: #8aa4ff;
}

[data-theme="black"] .timeline-seg.revealed:not(.active) {
  background: rgba(138, 164, 255, 0.22);
}

[data-theme="black"] .timeline-seg.active {
  background: #8aa4ff;
  color: #0c0d10;
}

[data-theme="black"] .now-roman,
[data-theme="black"] .tone-panel-value {
  color: #8aa4ff;
}

.player-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.audio-player {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.audio-player audio {
  display: none;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.play-btn {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 50%;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: filter 0.15s ease;
}

.play-btn:hover { filter: brightness(1.08); }

.seek-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.seek-bar {
  width: 100%;
  height: 1.25rem;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

.seek-bar::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: var(--glass-border);
}

.seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.seek-bar::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--glass-border);
  border: none;
}

.seek-bar::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.audio-times {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0 0.15rem 0 3.25rem;
}

.key-capo-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.15rem;
}

.key-block,
.capo-block {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.capo-block {
  align-items: flex-end;
  margin-left: auto;
}

.key-capo-row .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.lyrics-panel {
  text-align: center;
  padding: 0.15rem 0.5rem 0.35rem;
  min-height: 5.5rem;
}

.lyrics-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.55rem;
}

.lyrics-line {
  transition: color 0.2s ease, opacity 0.2s ease;
  word-break: break-word;
}

.lyrics-prev,
.lyrics-next {
  font-size: 0.9rem;
  color: var(--text-muted);
  opacity: 0.55;
  min-height: 1.35em;
}

.lyrics-current {
  font-size: 1.3rem;
  font-weight: 650;
  color: var(--text);
  margin: 0.35rem 0;
  min-height: 1.6em;
  line-height: 1.35;
}

.lyrics-status {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 1.2em;
}

.chord-strip-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chord-strip-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.strip-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#earTrainingBtn.active {
  background: var(--accent-dim);
  color: var(--text);
  border-color: var(--accent);
}

.chord-strip {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(52px, auto));
  gap: 6px;
}

.chord-strip.strip-scroll-up {
  animation: strip-scroll-up 0.32s ease;
}

@keyframes strip-scroll-up {
  from { opacity: 0.45; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.timeline-seg {
  position: relative;
  border: 1px solid transparent;
  margin: 0;
  padding: 0.35rem 0.25rem;
  background: var(--accent-dim);
  color: var(--text);
  font-size: 0.92rem;
  font-family: var(--mono);
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  border-radius: 12px;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  min-height: 52px;
  isolation: isolate;
}

.timeline-seg .seg-progress {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: color-mix(in srgb, var(--accent) 45%, transparent);
  z-index: 0;
  pointer-events: none;
  transition: width 0.08s linear;
}

.timeline-seg.active .seg-progress { background: rgba(255, 255, 255, 0.28); }
.timeline-seg.revealed:not(.active) .seg-progress {
  background: color-mix(in srgb, var(--success) 35%, transparent);
}

.timeline-seg .seg-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.08rem;
  max-width: 100%;
}

.timeline-seg.upcoming-line { opacity: 0.72; }
.timeline-seg.phrase-break { box-shadow: inset 3px 0 0 #f0b429; }
.timeline-seg.is-rest { font-style: italic; opacity: 0.65; }
.timeline-seg.mode-both { white-space: normal; font-size: 0.82rem; }
.timeline-seg .seg-chord { font-weight: 700; line-height: 1.15; }
.timeline-seg .seg-roman {
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0.85;
  color: var(--highlight, var(--success));
  line-height: 1.1;
}
.timeline-seg.active .seg-roman { color: rgba(0, 0, 0, 0.65); opacity: 1; }
.timeline-seg:hover:not(.empty) { filter: brightness(1.08); }
.timeline-seg.active {
  background: var(--accent);
  color: #1a120c;
  font-weight: 700;
  transform: translateY(-1px);
}
.timeline-seg.empty {
  background: transparent;
  border: 1px dashed var(--glass-border);
  cursor: default;
  pointer-events: none;
}
.timeline-seg.hidden-ear {
  background: rgba(139, 147, 167, 0.18);
  color: var(--text-muted);
  font-weight: 500;
}
.timeline-seg.revealed:not(.active) {
  background: color-mix(in srgb, var(--success) 18%, transparent);
}

.strip-page {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.key-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.capo-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.capo-value {
  min-width: 1.75rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 700;
}

.capo-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.capo-btn {
  min-width: 2rem;
  font-size: 0.75rem;
  line-height: 1;
}

.now-playing {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.now-playing-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.now-playing-body {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.now-chord { font-size: 1.5rem; font-weight: 700; }
.now-roman {
  font-family: var(--mono);
  color: var(--highlight, var(--success));
  font-size: 1.15rem;
}

.tone-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.tone-panel {
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 0.7rem 0.85rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
}

.tone-panel-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.tone-panel-value {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--highlight, var(--accent));
  letter-spacing: 0.04em;
  word-break: break-word;
}

/* Piano: always black/white */
.piano {
  position: relative;
  width: 100%;
  height: 118px;
  user-select: none;
}

.piano.piano-sm {
  height: 110px;
  margin-top: 0.15rem;
}

.piano-whites {
  display: flex;
  height: 100%;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #c8c8c0;
  background: #1a1d26;
}

.piano-key.white {
  flex: 1;
  position: relative;
  background: linear-gradient(180deg, #f7f7f4 0%, #e4e4df 100%);
  border-right: 1px solid #c8c8c0;
  color: #333;
}

.piano-key.white:last-child { border-right: none; }

.piano-key.white.active {
  background: linear-gradient(180deg, #9eb6ff 0%, #6c8cff 100%);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}

.piano-key.white.active.root {
  background: linear-gradient(180deg, #ffb4b4 0%, #e85d5d 100%);
  box-shadow: inset 0 -4px 0 rgba(120, 0, 0, 0.2);
}

.piano-key-label {
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.55rem;
  font-family: var(--mono);
  color: #666;
  pointer-events: none;
}

.piano-deg-label {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-40%);
  text-align: center;
  font-size: 0.72rem;
  font-family: var(--mono);
  font-weight: 700;
  color: transparent;
  pointer-events: none;
}

.piano-key.active .piano-deg-label { color: #0f1117; }
.piano-key.black .piano-deg-label { top: 55%; font-size: 0.62rem; }
.piano-key.black.active .piano-deg-label { color: #fff; }
.piano-key.white.active .piano-key-label { color: #0f1117; font-weight: 600; }
.piano-key.white.active.root .piano-deg-label,
.piano-key.white.active.root .piano-key-label { color: #3b0000; }

.piano-blacks {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 58%;
  pointer-events: none;
}

.piano.piano-sm .piano-blacks { height: 55%; }

.piano-key.black {
  position: absolute;
  top: 0;
  height: 100%;
  background: linear-gradient(180deg, #3a3f4d 0%, #151820 100%);
  border-radius: 0 0 4px 4px;
  border: 1px solid #0a0c10;
  z-index: 2;
  pointer-events: none;
}

.piano-key.black.active {
  background: linear-gradient(180deg, #8aa4ff 0%, #4a6cf0 100%);
  box-shadow: 0 0 10px rgba(108, 140, 255, 0.45);
}

.piano-key.black.active.root {
  background: linear-gradient(180deg, #ff8e8e 0%, #d63b3b 100%);
  box-shadow: 0 0 10px rgba(232, 93, 93, 0.5);
}

.now-time {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.summary-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

body[data-state="empty"] .summary-card,
body:not([data-state="loaded"]) .summary-card,
body[data-state="loaded"] .summary-card {
  grid-template-columns: 1fr;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.summary-item .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.summary-item .value {
  font-size: 1rem;
  font-weight: 500;
}

.key-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 999px;
  font-weight: 600;
  width: fit-content;
}

.key-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.key-picker {
  position: relative;
  display: inline-block;
  max-width: min(100%, 15.5rem);
}

.key-select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.3rem 1.85rem 0.3rem 0.65rem;
  cursor: pointer;
  border-radius: 999px;
  max-width: 100%;
  width: max-content;
  text-align: left;
  /* Match adjacent .btn.ghost.small (♯ / ♭) */
  background-color: transparent;
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  box-shadow: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 14px) calc(50% - 2px), calc(100% - 9px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.key-select:hover {
  color: var(--text);
  border-color: var(--text-muted);
  background-color: transparent;
}

.key-select:focus-visible {
  outline: 2px solid var(--text-muted);
  outline-offset: 2px;
}

.key-select-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 50;
  min-width: 100%;
  width: max-content;
  max-width: min(18rem, calc(100vw - 2rem));
  max-height: min(16rem, 48vh);
  overflow-y: auto;
  padding: 0.35rem;
  border-radius: var(--radius-md, 16px);
  background: var(--glass-strong);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.28);
}

.key-select-menu.hidden {
  display: none;
}

.key-select-option {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.42rem 0.7rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  background: transparent;
  white-space: nowrap;
}

.key-select-option:hover {
  background: var(--glass);
  color: var(--text);
}

.key-select-option.active {
  color: var(--accent);
  background: var(--accent-dim);
  font-weight: 600;
}

.key-hint {
  margin: 0.28rem 0 0;
  max-width: 22rem;
  font-size: 0.68rem;
  line-height: 1.45;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.01em;
}

[data-theme="cover"] .key-hint,
body.using-cover .key-hint {
  color: rgba(255, 247, 240, 0.88);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.footer {
  margin-top: 2.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer-brand {
  margin-top: 0.45rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.footer-by {
  font-size: 0.7rem;
  opacity: 0.85;
}

@media (max-width: 700px) {
  .app,
  body[data-state="loaded"] .app {
    max-width: 100%;
    padding: 1.4rem 1rem 2.5rem;
  }

  .header {
    flex-direction: column;
    align-items: center;
  }

  .theme-picker {
    align-self: center;
  }

  .logo {
    flex-direction: column;
    text-align: center;
  }

  .logo-title-row {
    justify-content: center;
  }

  .logo-icon { border-radius: 50%; }

  .url-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn.primary { width: 100%; }

  .summary-card,
  body[data-state="empty"] .summary-card,
  body[data-state="loaded"] .summary-card {
    grid-template-columns: 1fr;
  }

  .tone-panels { grid-template-columns: 1fr; }

  .audio-times {
    padding-left: 3.25rem;
  }

  .key-capo-row {
    align-items: center;
  }

  .chord-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(4, minmax(46px, auto));
  }

  .piano,
  .piano.piano-sm { height: 96px; }
}
