/* Ensure the HTML hidden attribute always wins over any display rule in this stylesheet. */
[hidden] { display: none !important; }

:root {
  --bg: #1a1b26;
  --surface: #24283b;
  --border: #3b4261;
  --text: #c0caf5;
  --muted: #565f89;
  --accent: #7aa2f7;
  --accent-hover: #a9b1d6;
  --success: #9ece6a;
  --error: #f7768e;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "DM Sans", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  min-width: 280px;
  background: color-mix(in srgb, var(--surface) 95%, var(--bg));
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, min-width 0.2s ease;
}

.sidebar--collapsed {
  width: 56px;
  min-width: 56px;
}

.sidebar--collapsed .sidebar-header,
.sidebar--collapsed .sidebar-profile,
.sidebar--collapsed .sidebar-history {
  display: none;
}

.sidebar--collapsed .sidebar-collapsed-bar {
  display: flex;
}

.sidebar-header {
  display: flex;
  justify-content: flex-end;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-close-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  line-height: 1;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
}

.sidebar-close-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.sidebar-collapsed-bar {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar--collapsed .sidebar-collapsed-bar .avatar {
  width: 36px;
  height: 36px;
  font-size: 0.95rem;
}

.sidebar-expand-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.sidebar-expand-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.sidebar-profile {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-history {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1rem;
}

.sidebar-history .history-header {
  flex-shrink: 0;
  margin-bottom: 0.5rem;
}

.sidebar-history .history-header h2 {
  font-size: 0.88rem;
  font-weight: 600;
}

.sidebar-history .hint {
  flex-shrink: 0;
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
}

.sidebar-history .history-list {
  flex: 1;
  overflow-y: auto;
  margin-top: 0;
  margin-bottom: 0;
}

.sidebar .history-item-title {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: normal;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sidebar .history-item-sub {
  font-size: 0.72rem;
  margin-top: 0.2rem;
}

.sidebar .history-item {
  padding: 0.5rem 0.6rem;
  align-items: flex-start;
}

.sidebar .btn-history {
  font-size: 0.78rem;
  padding: 0.3rem 0.6rem;
}

.sidebar-profile .auth-card-title {
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
}

.sidebar-profile .auth-input {
  font-size: 0.82rem;
  padding: 0.45rem 0.55rem;
}

.sidebar-profile .profile-email {
  font-size: 0.82rem;
  white-space: normal;
  word-break: break-word;
  line-height: 1.25;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sidebar-profile .profile-sub {
  font-size: 0.72rem;
}

.sidebar-profile .avatar {
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.sidebar-profile .btn-auth-primary,
.sidebar-profile .btn-auth-secondary,
.sidebar-profile .btn-auth-google {
  font-size: 0.82rem;
  padding: 0.4rem 0.65rem;
}

.sidebar-profile .auth-divider {
  margin: 0.5rem 0;
  font-size: 0.75rem;
}

.app {
  flex: 1;
  min-width: 0;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 2rem;
  overflow-x: hidden;
}

.app-header {
  margin-bottom: 2rem;
}

.brand {
  min-width: 260px;
}

.brand-centered {
  text-align: center;
  padding: 0.25rem 0;
}

.brand-centered h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.feedback-link {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--accent);
  background: rgba(122, 162, 247, 0.15);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  text-decoration: none;
}
.feedback-link:hover {
  background: rgba(122, 162, 247, 0.25);
  color: var(--accent-hover);
}

.auth-card {
  background: color-mix(in srgb, var(--surface) 88%, var(--bg));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.9rem;
  width: 100%;
  box-sizing: border-box;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.auth-card-title {
  font-weight: 650;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
  margin-bottom: 0.55rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.auth-input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}

.auth-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(122, 162, 247, 0.18);
}

.auth-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.15rem;
}

.btn-auth-primary {
  background: var(--accent);
  color: var(--bg);
  flex: 1;
}

.btn-auth-primary:hover {
  filter: brightness(1.08);
}

.btn-auth-secondary {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-auth-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.7rem 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.profile-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  background: var(--border);
  flex: 1;
}

.auth-divider span {
  padding: 0 0.25rem;
}

.btn-auth-google {
  width: 100%;
  background: color-mix(in srgb, var(--bg) 70%, white);
  color: #111;
  border: 1px solid color-mix(in srgb, var(--border) 35%, white);
}

.btn-auth-google:hover {
  filter: brightness(1.03);
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--bg);
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 50%, var(--success)));
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--border));
  flex: 0 0 auto;
}

.profile-meta {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
  flex: 1;
}

.profile-email {
  font-weight: 650;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 820px) {
  .app-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    min-width: 0;
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-history .history-list {
    max-height: 20vh;
  }
  .auth-actions {
    flex-direction: column;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}

.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.history-header h2 {
  margin: 0;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.history-item:hover {
  border-color: var(--accent);
}

.history-item-meta {
  min-width: 0;
  flex: 1;
}

.history-item-title {
  font-weight: 650;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-sub {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-actions {
  display: flex;
  gap: 0.5rem;
  flex: 0 0 auto;
}

.btn-history {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.hint {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.chord-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.chord-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.chord-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.chord-item input {
  width: 5rem;
  padding: 0.5rem 0.5rem;
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.chord-item input:focus {
  outline: none;
  border-color: var(--accent);
}

.chord-item .remove-chord {
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
  line-height: 1;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
}

.chord-item .remove-chord:hover {
  color: var(--error);
  border-color: var(--error);
}

.btn {
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-add {
  background: var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
}

.btn-add:hover {
  background: var(--muted);
}

.btn-generate {
  background: var(--accent);
  color: var(--bg);
}

.btn-generate:hover {
  filter: brightness(1.1);
}

.btn-generate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-print {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-print:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.presets {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.presets span {
  color: var(--muted);
  font-size: 0.85rem;
}

.presets button {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.presets button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.status {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

.status.success { color: var(--success); }
.status.error { color: var(--error); }

.viewer-placeholder,
.viewer-active {
  padding: 0.5rem 0;
}

.viewer-placeholder p {
  margin: 0;
  color: var(--muted);
}

.transpose-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.transpose-row > label {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
  margin-right: 0.25rem;
}

.transpose-options {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.transpose-option {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  transition: border-color 0.15s, background 0.15s;
}

.transpose-option:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.transpose-option input[type="radio"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.transpose-option:has(input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}

.transpose-option:has(input:disabled) input {
  cursor: not-allowed;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.btn-play,
.btn-stop {
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
}

.btn-stop {
  background: var(--border);
}

.btn-stop:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.piano-roll {
  min-height: 120px;
  background: var(--bg);
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.piano-roll .note {
  display: inline-block;
  margin: 0 2px 4px 0;
  padding: 2px 6px;
  background: var(--surface);
  border-radius: 4px;
  color: var(--text);
}

.standard-row {
  margin-bottom: 0.75rem;
}

.standard-row label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.standard-select-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.standard-select {
  flex: 1;
  min-width: 180px;
  max-width: 320px;
  padding: 0.5rem 0.65rem;
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.standard-select:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-new-custom {
  background: transparent;
  border: 1px dashed var(--accent);
  color: var(--accent);
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-new-custom:hover {
  background: rgba(122, 162, 247, 0.1);
}

/* ── Custom chord editor ── */

.custom-editor {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.custom-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.custom-name-input {
  flex: 1;
  min-width: 140px;
  max-width: 280px;
  padding: 0.45rem 0.6rem;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.custom-name-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(122, 162, 247, 0.15);
}

.custom-editor-bar-count {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  flex-shrink: 0;
}

.custom-bars-select {
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.custom-bars-select:focus {
  outline: none;
  border-color: var(--accent);
}

.custom-bars-input {
  width: 4.2rem;
  padding: 0.3rem 0.4rem;
  font-size: 0.8rem;
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.custom-bars-input:focus {
  outline: none;
  border-color: var(--accent);
}

.bar-ctrl-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.bar-ctrl-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.custom-editor-tempo {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  flex-shrink: 0;
}

.custom-tempo-input {
  width: 4.2rem;
  padding: 0.3rem 0.4rem;
  font-size: 0.8rem;
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.custom-tempo-input:focus {
  outline: none;
  border-color: var(--accent);
}

.custom-editor-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  margin-left: auto;
}

.custom-style-sections {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.custom-style-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.custom-style-rows {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.custom-style-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.custom-style-row input[type=\"number\"] {
  width: 3.2rem;
  padding: 0.2rem 0.35rem;
  font-size: 0.8rem;
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.custom-style-row input[type=\"number\"]:focus {
  outline: none;
  border-color: var(--accent);
}

.custom-style-select {
  min-width: 9rem;
  max-width: 14rem;
  padding: 0.25rem 0.45rem;
  font-size: 0.8rem;
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}

.custom-style-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Bar grid */

.bar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  overflow-y: auto;
  max-height: 60vh;
  padding-right: 2px;
}

.bar-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.45rem 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.12s;
  position: relative;
}

.bar-cell:hover {
  border-color: var(--accent);
}

.bar-cell--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(122, 162, 247, 0.2);
}

.bar-cell-number {
  font-size: 0.6rem;
  color: var(--muted);
  line-height: 1;
  user-select: none;
}

.bar-cell-chords {
  display: flex;
  gap: 4px;
  flex: 1;
  min-height: 1.8rem;
}

.chord-slot {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  cursor: pointer;
  border-radius: 4px;
  padding: 0 4px;
  transition: background 0.1s;
}

.chord-slot:hover {
  background: rgba(122, 162, 247, 0.08);
}

.chord-slot-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  pointer-events: none;
}

.chord-slot-label.is-repeat {
  color: var(--muted);
  font-weight: 500;
  font-style: italic;
}

.chord-slot-label.is-empty {
  color: var(--muted);
  font-weight: 400;
}

.chord-slot input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--accent);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  padding: 0 2px;
  outline: none;
  min-width: 0;
}

.bar-cell-controls {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 2px;
}

.bar-ctrl-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.65rem;
  padding: 1px 5px;
  cursor: pointer;
  line-height: 1.4;
  white-space: nowrap;
}

.bar-ctrl-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 640px) {
  .bar-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.chord-display {
  margin-top: 0.5rem;
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.95rem;
  color: var(--muted);
  min-height: 2.5rem;
}

.chord-display-visible {
  color: var(--text);
}

.chord-display .chord-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.chord-display .chord-line {
  font-family: var(--mono);
}

.sheet-music {
  position: relative;
  margin-top: 1rem;
  padding: 1rem;
  background: #fff;
  border-radius: 6px;
  overflow-x: auto;
}

@media print {
  @page {
    margin: 0.5in;
  }

  body {
    background: #fff;
  }

  /* Hide non-viewer UI for printing */
  .sidebar,
  .app-header,
  .chord-panel,
  .generate-panel {
    display: none !important;
  }

  .app {
    max-width: none;
    padding: 0;
  }

  .viewer-panel {
    margin: 0;
  }

  .player-controls {
    display: none !important;
  }

  .sheet-music {
    background: #fff;
    width: 100%;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }

  .sheet-music-wrapper,
  .alphatab-container {
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible;
  }

  .alphatab-container canvas,
  .alphatab-container svg {
    width: 100% !important;
    height: auto !important;
  }
}

.sheet-music-wrapper {
  position: relative;
  width: 100%;
  min-width: 0;
}

.chord-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  min-height: 100px;
  pointer-events: none;
  overflow: visible;
  z-index: 2;
}

/* Tie and tuplet bracket SVG overlay - must be on top of AlphaTab canvas */
.sheet-music-wrapper svg.tie-bracket-overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 3;
}

.chord-overlay-label {
  position: absolute;
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alphatab-container {
  min-height: 200px;
  background: #fff;
}

.alphatab-container canvas,
.alphatab-container svg {
  background: #fff;
  display: block;
}

.raw-output-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #ddd;
}

.btn-raw-output {
  font-size: 0.9rem;
  padding: 0.35rem 0.6rem;
  background: #f5f5f5;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
}

.btn-raw-output:hover {
  background: #eee;
}

.btn-download-ls, .btn-download-midi {
  font-size: 0.9rem;
  padding: 0.35rem 0.6rem;
  background: #f5f5f5;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 0.5rem;
}

.btn-download-ls:hover, .btn-download-midi:hover {
  background: #eee;
}

.raw-output-content {
  margin-top: 0.75rem;
}

.raw-output-block {
  margin-bottom: 1rem;
}

.raw-output-block label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 0.25rem;
}

.raw-output-pre {
  margin: 0;
  padding: 0.75rem;
  font-size: 0.8rem;
  font-family: ui-monospace, monospace;
  background: #f8f8f8;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  max-height: 20rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── Chord picker popup ─────────────────────────────────────── */

.chord-picker {
  position: fixed;
  z-index: 300;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  width: 320px;
  max-width: calc(100vw - 16px);
  padding: 0.6rem 0.7rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

/* Preview row */
.cp-preview-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cp-preview-label {
  font-size: 0.75rem;
  color: var(--muted);
  flex-shrink: 0;
}

.cp-preview {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  flex: 1;
  min-width: 2.5rem;
  letter-spacing: -0.01em;
}

.cp-action-btn {
  font-size: 0.78rem;
  padding: 0.25rem 0.55rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}

.cp-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cp-close-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
  border-radius: 4px;
}

.cp-close-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.07);
}

/* Root note row */
.cp-roots {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 3px;
}

.cp-root-btn {
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
  padding: 0.3rem 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  transition: background 0.1s, border-color 0.1s;
}

.cp-root-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cp-root-btn--active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

/* Quality groups */
.cp-qualities {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid var(--border);
  padding-top: 0.45rem;
}

.cp-quality-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.cp-group-label {
  font-size: 0.65rem;
  color: var(--muted);
  min-width: 44px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cp-quality-btn {
  font-size: 0.75rem;
  font-family: inherit;
  padding: 0.22rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, border-color 0.1s;
}

.cp-quality-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cp-quality-btn--active {
  background: color-mix(in srgb, var(--accent) 20%, var(--surface));
  border-color: var(--accent);
  color: var(--accent);
}

/* Advanced text input */
.cp-advanced {
  border-top: 1px solid var(--border);
  padding-top: 0.45rem;
}

.cp-text-input {
  width: 100%;
  padding: 0.38rem 0.6rem;
  font-size: 0.82rem;
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  box-sizing: border-box;
}

.cp-text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(122, 162, 247, 0.18);
}
