:root {
  --text: #6b6375;
  --text-h: #08060d;
  --bg: #fff;
  --border: #e5e4e7;
  --code-bg: #f4f3ec;
  --accent: #aa3bff;
  --accent-bg: rgba(170, 59, 255, 0.1);
  --accent-border: rgba(170, 59, 255, 0.5);
  --social-bg: rgba(244, 243, 236, 0.5);
  --shadow:
    rgba(0, 0, 0, 0.1) 0 10px 15px -3px, rgba(0, 0, 0, 0.05) 0 4px 6px -2px;

  --sans: system-ui, 'Segoe UI', Roboto, sans-serif;
  --heading: system-ui, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, Consolas, monospace;

  font: 18px/145% var(--sans);
  letter-spacing: 0.18px;
  color-scheme: light dark;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  @media (max-width: 1024px) {
    font-size: 16px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #9ca3af;
    --text-h: #f3f4f6;
    --bg: #16171d;
    --border: #2e303a;
    --code-bg: #1f2028;
    --accent: #c084fc;
    --accent-bg: rgba(192, 132, 252, 0.15);
    --accent-border: rgba(192, 132, 252, 0.5);
    --social-bg: rgba(47, 48, 58, 0.5);
    --shadow:
      rgba(0, 0, 0, 0.4) 0 10px 15px -3px, rgba(0, 0, 0, 0.25) 0 4px 6px -2px;
  }

  #social .button-icon {
    filter: invert(1) brightness(2);
  }
}

body {
  margin: 0;
}

#root {
  width: 1126px;
  max-width: 100%;
  margin: 0 auto;
  text-align: center;
  border-inline: 1px solid var(--border);
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

h1,
h2 {
  font-family: var(--heading);
  font-weight: 500;
  color: var(--text-h);
}

h1 {
  font-size: 56px;
  letter-spacing: -1.68px;
  margin: 32px 0;
  @media (max-width: 1024px) {
    font-size: 36px;
    margin: 20px 0;
  }
}
h2 {
  font-size: 24px;
  line-height: 118%;
  letter-spacing: -0.24px;
  margin: 0 0 8px;
  @media (max-width: 1024px) {
    font-size: 20px;
  }
}
p {
  margin: 0;
}

code,
.counter {
  font-family: var(--mono);
  display: inline-flex;
  border-radius: 4px;
  color: var(--text-h);
}

code {
  font-size: 15px;
  line-height: 135%;
  padding: 4px 8px;
  background: var(--code-bg);
}
.app {
  width: 100%;
  max-width: min(1200px, calc(100vw - 1.25rem));
  margin: 0 auto;
  padding: 0.65rem clamp(0.65rem, 2vw, 1.25rem);
  display: grid;
  gap: 0.65rem;
  color: #1f2937;
  box-sizing: border-box;
}

.child-practice-sync-status {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
}

.app-footer-sync-status {
  margin: 10px auto 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
}

.app-footer-sync-status .child-practice-sync-status {
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid #dbe3ef;
  background: #f1f5f9;
  color: #64748b;
}

.app-footer-sync-status .child-practice-sync-status--synced {
  color: #166534;
  background: #ecfdf5;
  border-color: rgba(22, 101, 52, 0.22);
}

.app-footer-sync-status .child-practice-sync-status--warning,
.app-footer-sync-status .child-practice-sync-status--waiting {
  color: #9a3412;
  background: #fffbeb;
  border-color: rgba(180, 83, 9, 0.28);
}

.app-footer-sync-status .child-practice-sync-status--syncing,
.app-footer-sync-status .child-practice-sync-status--saved {
  color: #475569;
  background: #f1f5f9;
  border-color: rgba(71, 85, 105, 0.22);
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  box-sizing: border-box;
}

.auth-card {
  width: 100%;
  max-width: 28rem;
  display: grid;
  gap: 0.7rem;
}

/* Login card is always light; global `h1` uses `--text-h` which is light in dark mode. */
.auth-card h1 {
  margin: 0 0 0.35rem;
  color: #111827;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-size: clamp(1.45rem, 4.2vw, 1.85rem);
  line-height: 1.2;
}

.auth-subtitle {
  margin: 0;
  color: #4b5563;
}

.auth-setup-message {
  margin: 0;
  padding: 0.55rem;
  border-radius: 8px;
  border: 1px solid #fcd34d;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.95rem;
  line-height: 1.4;
}

.auth-form {
  display: grid;
  gap: 0.45rem;
}

.auth-form label {
  font-weight: 400;
  color: #1f2937;
}

.auth-form input {
  min-height: 44px;
  border: 1px solid #9ca3af;
  border-radius: 8px;
  padding: 0 0.6rem;
  font-size: 1rem;
  color: #111827;
  background: #ffffff;
}

.auth-submit-button {
  margin-top: 0.2rem;
  min-height: 44px;
  border: none;
  border-radius: 8px;
  background: #1d4ed8;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.auth-submit-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.auth-error {
  margin: 0;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 0.5rem;
  line-height: 1.35;
}

.auth-status {
  width: 100%;
  max-width: min(1200px, calc(100vw - 1.25rem));
  margin: 0.5rem auto 0;
  padding: 0.4rem 0.6rem;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.7rem;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
}

.auth-status-main {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.auth-status-email {
  margin: 0;
  color: #374151;
  font-size: 0.9rem;
}

.auth-status-warning {
  margin: 0;
  color: #92400e;
  font-size: 0.84rem;
  line-height: 1.35;
}

.auth-status-ok {
  margin: 0;
  color: #166534;
  font-size: 0.84rem;
  line-height: 1.35;
}

.auth-status-actions {
  display: inline-flex;
}

.auth-status-button {
  min-height: 36px;
  border: none;
  border-radius: 8px;
  padding: 0 0.75rem;
  background: #374151;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.auth-status-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.sync-status-panel {
  width: 100%;
  max-width: min(1200px, calc(100vw - 1.25rem));
  margin: 0.35rem auto 0;
  padding: 0.65rem 0.75rem;
}

.sync-status-panel h2 {
  margin: 0 0 0.45rem;
  font-size: 0.98rem;
}

.sync-status-grid {
  display: grid;
  gap: 0.2rem;
}

.sync-status-grid p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.35;
  color: #374151;
}

.sync-status-actions {
  margin-top: 0.45rem;
  display: grid;
  gap: 0.35rem;
}

.sync-status-actions button {
  min-height: 38px;
  width: fit-content;
  border: 1px solid #9ca3af;
  border-radius: 8px;
  background: #f9fafb;
  color: #1f2937;
  font-weight: 600;
  padding: 0 0.7rem;
  cursor: pointer;
}

.sync-status-actions button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.sync-status-muted {
  margin: 0;
  font-size: 0.83rem;
  color: #4b5563;
}

.sync-status-error {
  margin: 0;
  font-size: 0.83rem;
  color: #b91c1c;
}

.sync-status-ok {
  color: #2a6b30;
  font-weight: 500;
}

.sync-status-warn {
  color: #7a5800;
  font-weight: 500;
}

.sync-prep-panel {
  width: 100%;
  max-width: min(1200px, calc(100vw - 1.25rem));
  margin: 0.35rem auto 0;
  padding: 0.65rem 0.75rem;
}

.admin-tools-dashboard {
  display: grid;
  gap: 0.55rem;
  text-align: left;
}

.admin-tool-section {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  text-align: left;
}

.admin-tool-section-summary {
  cursor: pointer;
  list-style: none;
  padding: 0.6rem 0.75rem;
  font-size: 1.08rem;
  font-weight: 700;
  color: #1f2937;
  text-align: left;
}

.admin-tool-section-summary::-webkit-details-marker {
  display: none;
}

.admin-tool-section-body {
  border-top: 1px solid #e5e7eb;
  padding: 0.6rem 0.7rem 0.65rem;
  display: grid;
  gap: 0.55rem;
  text-align: left;
}

.admin-health-grid {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  text-align: left;
}

.admin-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-start;
}

.admin-tools-dashboard > h2 {
  margin: 0 0 0.35rem;
  font-size: 1.24rem;
  font-weight: 700;
  text-align: left;
}

.admin-tools-dashboard .sync-prep-list-block,
.admin-tools-dashboard .sync-prep-status-list,
.admin-tools-dashboard .sync-prep-user-grid,
.admin-tools-dashboard .sync-prep-user-card,
.admin-tools-dashboard .sync-prep-seed-results,
.admin-tools-dashboard .sync-status-panel,
.admin-tools-dashboard .sync-status-grid,
.admin-tools-dashboard .sync-status-actions,
.admin-tools-dashboard .progress-backup-panel,
.admin-tools-dashboard .progress-backup-summary,
.admin-tools-dashboard .progress-backup-actions,
.admin-tools-dashboard .progress-backup-import-options,
.admin-tools-dashboard .progress-backup-preview,
.admin-tools-dashboard .music-data-check-card,
.admin-tools-dashboard .music-data-check,
.admin-tools-dashboard .music-data-grid,
.admin-tools-dashboard .music-data-row,
.admin-tools-dashboard .user-profile-debug-card,
.admin-tools-dashboard .user-profile-debug-body,
.admin-tools-dashboard .user-profile-debug-dl,
.admin-tools-dashboard .user-profile-debug-row {
  text-align: left;
}

.admin-tools-dashboard .sync-prep-list-block h3,
.admin-tools-dashboard .sync-status-panel h2,
.admin-tools-dashboard .progress-backup-panel > h2,
.admin-tools-dashboard .music-data-check-toggle,
.admin-tools-dashboard .user-profile-debug-toggle {
  font-weight: 700;
}

.admin-tools-dashboard .sync-prep-list-block h3 {
  font-size: 1.02rem;
}

.two-hand-test-lab-wrap {
  padding-top: 0.55rem;
}

.two-hand-test-lab {
  margin: 0;
  padding: 0.75rem;
}

.two-hand-test-lab > h3 {
  margin: 0 0 0.45rem;
  font-size: 1.02rem;
}

.two-hand-test-lab-note {
  margin: 0 0 0.65rem;
  color: #334155;
  font-size: 0.88rem;
}

.two-hand-test-lab-grid {
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.two-hand-test-lab-row {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr;
  gap: 0.5rem;
  align-items: start;
}

.two-hand-test-lab-row dt {
  font-weight: 700;
  color: #1f2937;
}

.two-hand-test-lab-row dd {
  margin: 0;
  color: #0f172a;
}

.two-hand-test-lab-actions {
  margin-top: 0.7rem;
}

.number-stepper {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.number-stepper-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: #334155;
}

.number-stepper-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.number-stepper-button {
  height: 2.6rem;
  width: 2.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #f8fafc;
  color: #0f172a;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
  touch-action: manipulation;
  user-select: none;
}

.number-stepper-button:disabled {
  opacity: 0.55;
}

.number-stepper-value {
  height: 2.6rem;
  width: clamp(4.5rem, 18vw, 5.2rem);
  padding: 0 0.35rem;
  border: 1px solid #dbe2ea;
  border-radius: 9px;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.86rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.number-stepper__controls {
  display: inline-grid;
  grid-template-columns: 42px minmax(64px, 82px) 42px;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: 100%;
}

.number-stepper__button {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  touch-action: manipulation;
}

.number-stepper__value {
  min-width: 64px;
  max-width: 82px;
  width: auto;
  height: 42px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-prep-panel h2 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
}

.sync-prep-status-list {
  display: grid;
  gap: 0.2rem;
  margin: 0 0 0.55rem;
}

.sync-prep-status-list p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.35;
}

.sync-prep-list-block {
  margin: 0.55rem 0 0;
  padding-top: 0.45rem;
  border-top: 1px solid #e5e7eb;
}

.sync-prep-list-block h3 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  color: #1f2937;
}

.sync-prep-list-block ul {
  margin: 0;
  padding-left: 1.1rem;
}

.sync-prep-list-block li {
  margin: 0.15rem 0;
  font-size: 0.84rem;
  line-height: 1.35;
  color: #374151;
}

.sync-prep-note {
  margin: 0;
  font-size: 0.83rem;
  color: #4b5563;
  line-height: 1.35;
}

.sync-prep-warning {
  color: #92400e;
}

.sync-prep-ok {
  color: #166534;
}

.sync-prep-user-grid {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.sync-prep-user-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fafafa;
  padding: 0.45rem 0.5rem;
  display: grid;
  gap: 0.18rem;
}

.sync-prep-user-card p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.3;
  color: #374151;
}

.sync-prep-actions {
  margin-top: 0.6rem;
  display: grid;
  gap: 0.35rem;
}

.sync-prep-actions button {
  min-height: 38px;
  width: fit-content;
  border: 1px solid #9ca3af;
  border-radius: 8px;
  background: #f9fafb;
  color: #1f2937;
  font-weight: 600;
  padding: 0 0.7rem;
  cursor: pointer;
}

.sync-prep-actions button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.sync-prep-file-label {
  display: inline-flex;
  flex-direction: column;
  gap: 0.3rem;
  width: fit-content;
  font-size: 0.84rem;
  color: #374151;
}

.sync-prep-file-label input[type='file'] {
  font-size: 0.82rem;
}

.sync-prep-checkbox-row {
  margin-top: 0.35rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.84rem;
  color: #374151;
}

.sync-prep-checkbox-row input[type='checkbox'] {
  width: 1rem;
  height: 1rem;
}

.sync-prep-seed-results {
  margin-top: 0.5rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fafafa;
  display: grid;
  gap: 0.2rem;
}

.sync-prep-seed-results p {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.35;
}

.sync-prep-seed-results h4 {
  margin: 0 0 0.2rem;
  font-size: 0.85rem;
  color: #1f2937;
}

.sync-prep-seed-results button {
  margin-top: 0.25rem;
  min-height: 36px;
  width: fit-content;
  border: 1px solid #9ca3af;
  border-radius: 8px;
  background: #f9fafb;
  color: #1f2937;
  font-weight: 600;
  padding: 0 0.65rem;
  cursor: pointer;
}

.sync-prep-seed-results ul {
  margin: 0.2rem 0 0;
  padding-left: 1rem;
}

.account-profile-gate {
  min-height: calc(100vh - 5rem);
  display: grid;
  place-items: center;
  padding: 0.75rem;
  box-sizing: border-box;
}

.account-profile-card {
  width: 100%;
  max-width: 34rem;
  display: grid;
  gap: 0.6rem;
}

.account-profile-card h2,
.account-profile-card p {
  margin: 0;
}

.account-profile-gate-button {
  min-height: 42px;
  width: fit-content;
  border: none;
  border-radius: 8px;
  background: #1d4ed8;
  color: #ffffff;
  font-weight: 600;
  padding: 0 0.8rem;
  cursor: pointer;
}

.account-profile-gate-error {
  margin: 0;
  color: #b91c1c;
  font-size: 0.84rem;
}

.user-profile-locked-note {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: #4b5563;
}

/* Title card (left) + welcome card (right) on wide screens */
.app-top-row {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 12px;
  align-items: stretch;
  min-width: 0;
}

.app-top-row .app-header {
  min-width: 0;
}

.app-top-row .welcome-panel {
  min-width: 0;
}

@media (min-width: 768px) {
  .app-top-row {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 12px;
  }

  .app-top-row .welcome-panel {
    margin: 0;
    max-width: none;
  }
}

.welcome-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-align: left;
}

.welcome-panel__message-row {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: nowrap;
  overflow: hidden;
}

.welcome-panel-title,
.welcome-panel__title {
  margin: 0;
  line-height: 1;
  font-size: 1rem;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}

.welcome-panel-message,
.welcome-panel__phrase {
  margin: 0;
  line-height: 1;
  font-size: 0.95rem;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.welcome-panel__actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  justify-self: end;
  flex-shrink: 0;
}

.welcome-panel-signout,
.welcome-panel__signout {
  justify-self: end;
  align-self: center;
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 0;
  padding: 7px 14px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 10px;
  background: #f8fafc;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.welcome-panel-signout:hover,
.welcome-panel__signout:hover {
  background: #f1f5f9;
}

.welcome-panel-signout:disabled,
.welcome-panel__signout:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

@media (max-width: 380px) {
  .welcome-panel__message-row {
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .welcome-panel-message,
  .welcome-panel__phrase {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
}

.card {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* Top header cards: equal height, compact, beat global `.card` on this row */
.app-top-row > .app-header.app-header--compact.app-title-card.card,
.app-top-row > .welcome-panel.card {
  box-sizing: border-box;
  min-height: 52px;
  padding: 6px 14px;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.app-top-row > .app-header.app-header--compact.app-title-card.card {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef4ff 0%, #e9fff6 55%, #fff3df 100%);
  border: 1px solid rgba(135, 156, 205, 0.35);
}

.app-top-row > .welcome-panel.card {
  background: #fafbfc;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.app-header h1 {
  margin: 0;
  font-size: 2rem;
  color: #111827;
}

.app-header--compact {
  padding: 0;
}

/* Override global index.css `h1` (large size / letter-spacing / margins) for title card */
.app-top-row .app-header.app-title-card h1,
.app-header.app-title-card h1 {
  margin: 0;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(95deg, #4f46e5 0%, #0d9488 42%, #c026d3 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  text-rendering: geometricPrecision;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

@media (max-width: 1024px) {
  .app-top-row .app-header.app-title-card h1,
  .app-header.app-title-card h1 {
    font-size: 1.3rem;
    letter-spacing: -0.03em;
  }
}

/* Welcome colour themes (class set once per sign-in in App.jsx) */
.app-top-row > .welcome-panel.welcome-panel--theme-blue .welcome-panel__title,
.app-top-row > .welcome-panel.welcome-panel--theme-blue .welcome-panel-title {
  color: #1d4ed8;
}

.app-top-row > .welcome-panel.welcome-panel--theme-blue .welcome-panel__phrase,
.app-top-row > .welcome-panel.welcome-panel--theme-blue .welcome-panel-message {
  color: #475569;
}

.app-top-row > .welcome-panel.welcome-panel--theme-blue.card {
  background: linear-gradient(180deg, #fbfdff 0%, #f4f8ff 100%);
  border-color: rgba(29, 78, 216, 0.22);
}

.app-top-row > .welcome-panel.welcome-panel--theme-green .welcome-panel__title,
.app-top-row > .welcome-panel.welcome-panel--theme-green .welcome-panel-title {
  color: #047857;
}

.app-top-row > .welcome-panel.welcome-panel--theme-green .welcome-panel__phrase,
.app-top-row > .welcome-panel.welcome-panel--theme-green .welcome-panel-message {
  color: #4b5563;
}

.app-top-row > .welcome-panel.welcome-panel--theme-green.card {
  background: linear-gradient(180deg, #fbfffd 0%, #f0fdf7 100%);
  border-color: rgba(4, 120, 87, 0.22);
}

.app-top-row > .welcome-panel.welcome-panel--theme-orange .welcome-panel__title,
.app-top-row > .welcome-panel.welcome-panel--theme-orange .welcome-panel-title {
  color: #c2410c;
}

.app-top-row > .welcome-panel.welcome-panel--theme-orange .welcome-panel__phrase,
.app-top-row > .welcome-panel.welcome-panel--theme-orange .welcome-panel-message {
  color: #5b4b36;
}

.app-top-row > .welcome-panel.welcome-panel--theme-orange.card {
  background: linear-gradient(180deg, #fffdfb 0%, #fff7ed 100%);
  border-color: rgba(194, 65, 12, 0.2);
}

.app-top-row > .welcome-panel.welcome-panel--theme-rose .welcome-panel__title,
.app-top-row > .welcome-panel.welcome-panel--theme-rose .welcome-panel-title {
  color: #be185d;
}

.app-top-row > .welcome-panel.welcome-panel--theme-rose .welcome-panel__phrase,
.app-top-row > .welcome-panel.welcome-panel--theme-rose .welcome-panel-message {
  color: #52525b;
}

.app-top-row > .welcome-panel.welcome-panel--theme-rose.card {
  background: linear-gradient(180deg, #fffafc 0%, #fdf2f8 100%);
  border-color: rgba(190, 24, 93, 0.2);
}

.app-top-row > .welcome-panel.welcome-panel--theme-indigo .welcome-panel__title,
.app-top-row > .welcome-panel.welcome-panel--theme-indigo .welcome-panel-title {
  color: #4338ca;
}

.app-top-row > .welcome-panel.welcome-panel--theme-indigo .welcome-panel__phrase,
.app-top-row > .welcome-panel.welcome-panel--theme-indigo .welcome-panel-message {
  color: #475569;
}

.app-top-row > .welcome-panel.welcome-panel--theme-indigo.card {
  background: linear-gradient(180deg, #fafbff 0%, #eef2ff 100%);
  border-color: rgba(67, 56, 202, 0.22);
}

.stage-label {
  margin: 0.5rem 0 0;
  font-size: 1.1rem;
  color: #4b5563;
}

h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
}

.card h2 {
  color: #111827;
}

.status-text {
  margin: 0;
}

.status-ok {
  margin: 0.5rem 0 0;
  color: #166534;
  font-weight: 600;
}

.status-muted {
  margin: 0.5rem 0 0;
  color: #4b5563;
}

.status-error {
  margin: 0.5rem 0 0;
  color: #b91c1c;
  font-weight: 600;
}

.status-warn {
  margin: 0.5rem 0 0;
  color: #b45309;
  font-weight: 600;
}

/* Compact MIDI panel (Status + Controls + Key state) */
.midi-panel-card {
  padding: 0.55rem 0.65rem;
}

.midi-panel-title {
  margin: 0;
  font-size: 1.1rem;
  color: #111827;
  flex: 0 0 auto;
}

.midi-panel-row--compact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem 0.45rem;
}

.midi-panel-status {
  flex: 0 1 auto;
  margin: 0;
  max-width: 100%;
  font-size: 0.88rem;
  line-height: 1.35;
  color: #374151;
}

.midi-panel-connect {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 0 0.65rem;
}

.midi-panel-input-group {
  flex: 1 1 13rem;
  min-width: 0;
  max-width: 100%;
}

.midi-panel-select-with-selected {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.3rem;
}

.midi-panel-select {
  flex: 1 1 13rem;
  min-width: min(100%, 11rem);
  max-width: 100%;
  box-sizing: border-box;
  min-height: 48px;
}

.midi-panel-error {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
}

.midi-panel-key {
  margin: 0;
  flex: 0 0 auto;
}

.midi-panel-active-notes {
  margin: 0;
  flex: 1 1 12rem;
  min-width: 0;
  font-size: 0.88rem;
  line-height: 1.35;
  word-break: break-word;
}

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

.music-data-check-card {
  padding: 0.5rem 0.65rem;
}

/* Phase 14 — Progress backup panel polish */
.progress-backup-panel {
  display: grid;
  gap: 0.65rem;
  min-width: 0;
}

.progress-backup-panel > h2 {
  margin: 0;
  font-size: 1.05rem;
}

.progress-backup-panel > p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.35;
  color: #374151;
}

.progress-backup-summary {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  padding: 0.5rem 0.55rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fafafa;
  min-width: 0;
}

.progress-backup-summary p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.3;
  word-break: break-word;
}

.progress-backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: stretch;
}

.progress-backup-actions button {
  flex: 1 1 11rem;
  min-width: min(100%, 10.5rem);
  min-height: 46px;
  padding: 0.28rem 0.65rem;
  font-size: 0.93rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid #9ca3af;
  color: #ffffff;
  background: #1d4ed8;
  cursor: pointer;
}

.progress-backup-actions button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.progress-backup-import-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.7rem;
  padding: 0.42rem 0.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
  min-width: 0;
}

.progress-backup-import-options p {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 600;
  color: #374151;
}

.progress-backup-import-options label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 40px;
  font-size: 0.86rem;
  color: #1f2937;
  min-width: 0;
}

.progress-backup-import-options input[type='radio'] {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.progress-backup-message {
  margin: 0.25rem 0 0;
  padding: 0.36rem 0.45rem;
  border-radius: 8px;
  font-size: 0.84rem;
  line-height: 1.32;
}

.progress-backup-warning {
  margin: 0;
  padding: 0.45rem 0.52rem;
  border-radius: 8px;
  border: 1px solid #fcd34d;
  background: #fffbeb;
  color: #92400e;
  display: grid;
  gap: 0.32rem;
  min-width: 0;
}

.progress-backup-warning p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.35;
}

.progress-backup-warning label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  min-height: 40px;
  font-size: 0.84rem;
  line-height: 1.3;
}

.progress-backup-preview {
  margin: 0;
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  border: 1px solid #dbeafe;
  background: #f8fbff;
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.progress-backup-preview h3 {
  margin: 0 0 0.1rem;
  font-size: 0.92rem;
  color: #1e3a8a;
}

.progress-backup-preview p {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.3;
  word-break: break-word;
}

.progress-backup-preview button {
  margin-top: 0.2rem;
  min-height: 46px;
  width: 100%;
  padding: 0.28rem 0.65rem;
  font-size: 0.93rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  color: #ffffff;
  background: #1d4ed8;
  cursor: pointer;
}

.progress-backup-preview button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (min-width: 768px) {
  .progress-backup-actions button {
    flex: 0 1 auto;
    min-width: 12.5rem;
  }

  .progress-backup-preview button {
    width: fit-content;
    min-width: 12rem;
  }
}

.music-data-check-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.35rem 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
  color: #111827;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
}

.music-data-check-toggle:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}

.music-data-check-chevron {
  color: #6b7280;
  font-weight: 400;
}

.music-data-check-body {
  margin-top: 0.45rem;
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fafafa;
}

.controls {
  display: grid;
  gap: 0.75rem;
  align-items: center;
}

.connect-button,
select {
  min-height: 48px;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid #9ca3af;
  padding: 0 0.75rem;
}

.connect-button {
  background: #1d4ed8;
  color: #ffffff;
  border: none;
  font-weight: 600;
  cursor: pointer;
}

.connect-button:disabled,
select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.audio-controls {
  margin-top: 0.75rem;
}

.web-audio-status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  margin: 0 0 0.5rem;
}

.web-audio-status-card .web-audio-state-text {
  margin: 0;
  font-size: 0.95rem;
  flex: 0 1 auto;
}

.web-audio-status-card .web-audio-hint-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.35;
  flex: 1 1 12rem;
  min-width: 0;
}

.web-audio-status-line .status-ok,
.web-audio-status-line .status-muted {
  margin: 0;
}

.audio-controls--inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: stretch;
  margin-top: 0.35rem;
}

.audio-controls--inline .connect-button {
  flex: 1 1 auto;
  min-width: min(10rem, 100%);
  min-height: 48px;
}

@media (min-width: 900px) {
  .web-audio-status-card .audio-controls--inline {
    flex-wrap: nowrap;
  }

  .web-audio-status-card .audio-controls--inline .connect-button {
    flex: 1 1 0;
    min-width: 0;
  }
}

.selected-input,
.active-notes,
.empty-state {
  margin: 0.75rem 0 0;
}

.key-indicator {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  font-weight: 700;
}

.key-indicator.up {
  background: #e5e7eb;
  color: #374151;
}

.key-indicator.down {
  background: #dcfce7;
  color: #166534;
}

.message-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.message-list li {
  display: grid;
  gap: 0.25rem;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.75rem;
  background: #f9fafb;
}

.midi-messages-card .message-list--compact {
  gap: 0;
  max-height: 11rem;
  overflow-y: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fafafa;
}

.midi-messages-card .message-list--compact li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.65rem;
  padding: 0.28rem 0.45rem;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid #e5e7eb;
  background: transparent;
  font-size: 0.82rem;
  line-height: 1.25;
}

.midi-messages-card .message-list--compact li:last-child {
  border-bottom: none;
}

.midi-messages-card .midi-msg-type {
  font-weight: 700;
  min-width: 4.25rem;
}

.midi-messages-card .midi-msg-note {
  font-weight: 600;
  color: #1d4ed8;
}

.midi-messages-card .midi-msg-meta {
  color: #6b7280;
  font-variant-numeric: tabular-nums;
  flex: 1 1 auto;
  min-width: 0;
}

.midi-messages-card .empty-state--compact {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
}

.music-data-check .music-data-grid {
  display: grid;
  gap: 0.5rem;
}

.music-data-check .music-data-row {
  display: grid;
  gap: 0.25rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #e5e7eb;
}

.music-data-check .music-data-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.music-data-check .music-data-row-full {
  grid-template-columns: 1fr;
}

.music-data-check .music-data-label {
  font-weight: 600;
  color: #374151;
  font-size: 0.95rem;
}

.music-data-check .music-data-value {
  color: #1f2937;
  font-size: 0.95rem;
  word-break: break-word;
}

@media (min-width: 700px) {
  .app {
    padding: 1.5rem;
  }

  .controls {
    grid-template-columns: 220px 1fr;
  }

  .controls label {
    grid-column: 1 / -1;
  }

  .music-data-check .music-data-row:not(.music-data-row-full) {
    grid-template-columns: 1fr auto;
    align-items: baseline;
    gap: 0.75rem;
  }

  .music-data-check .music-data-row-full .music-data-value {
    padding-left: 0;
  }
}

/* Stage 6 — User profile panel (readable on dark page background) */
.user-profile-panel {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  background: #ffffff;
  color: #1f2937;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  text-align: left;
}

.user-profile-panel--compact {
  padding: 0.35rem 0.55rem;
  border-radius: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
}

.user-profile-panel-title {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  color: #111827;
}

.user-profile-panel-title--inline {
  margin: 0;
  flex: 0 0 auto;
  font-size: 0.92rem;
  line-height: 1.2;
}

.user-profile-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.user-profile-toolbar--single-row {
  flex: 1 1 14rem;
  min-width: 0;
}

.user-profile-active-select--compact {
  flex: 1 1 12rem;
  min-width: 0;
  min-height: 44px;
  font-size: 0.95rem;
  border-radius: 8px;
  border: 1px solid #9ca3af;
  padding: 0.35rem 0.5rem;
  color: #111827;
  background: #ffffff;
  box-sizing: border-box;
}

.user-profile-add-bottom {
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  border-style: dashed;
  border-color: #cbd5e1;
  background: #f8fafc;
}

.user-profile-add-bottom-toggle {
  width: 100%;
  min-height: 44px;
  padding: 0.35rem 0.55rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.user-profile-add-bottom-toggle:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}

.user-profile-add-bottom .user-profile-inline-add {
  margin-top: 0.4rem;
}

.user-profile-inline-add {
  margin-top: 0.45rem;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  display: grid;
  gap: 0.4rem;
}

.user-profile-new-name-input--compact {
  width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  font-size: 0.95rem;
  border-radius: 8px;
  border: 1px solid #9ca3af;
  padding: 0.35rem 0.5rem;
}

.user-profile-inline-add-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.user-profile-save-user-button {
  min-height: 44px;
  padding: 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffffff;
  background: #1d4ed8;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.user-profile-cancel-button {
  min-height: 44px;
  padding: 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #374151;
  background: #e5e7eb;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

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

.user-profile-debug-card {
  padding: 0.5rem 0.65rem;
}

.user-profile-debug-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.35rem 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
  color: #111827;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  cursor: pointer;
}

.user-profile-debug-toggle:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}

.user-profile-debug-chevron {
  color: #6b7280;
  font-weight: 400;
}

.user-profile-debug-body {
  margin-top: 0.45rem;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fafafa;
}

.user-profile-debug-dl {
  margin: 0;
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.user-profile-debug-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
}

.user-profile-debug-row dt {
  margin: 0;
  font-weight: 600;
  color: #4b5563;
}

.user-profile-debug-row dd {
  margin: 0;
  color: #111827;
  font-variant-numeric: tabular-nums;
  text-align: right;
  word-break: break-all;
}

/* Stage 7 Chord Trainer — compact layout for iPad landscape + desktop */
.chord-trainer-panel {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  background: #ffffff;
  color: #1f2937;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 0.4rem 0.5rem 0.45rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  text-align: left;
}

.chord-trainer-panel h2 {
  color: #111827;
  margin: 0 0 0.16rem;
  font-size: 1.08rem;
  line-height: 1.15;
}

/* Stage 9 — MIDI target radio in panel title (compact, shared name with Scale Trainer) */
.trainer-panel-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  min-height: 0;
  font-size: 1.08rem;
  line-height: 1.15;
}

.trainer-panel-title-label {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  margin: 0;
  cursor: pointer;
  user-select: none;
  color: #111827;
}

.trainer-panel-title-label input[type='radio'] {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  margin: 0;
  accent-color: #4f46e5;
  vertical-align: middle;
}

.trainer-panel-title-label:focus-within {
  outline: none;
}

.trainer-panel-title-label:focus-within input[type='radio'] {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}

.trainer-panel-title-text {
  display: inline;
  font-weight: inherit;
}

.chord-trainer-panel h3 {
  color: #111827;
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
}

.chord-trainer-controls {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  margin: 0.16rem 0 0.2rem;
}

.chord-trainer-controls-primary,
.chord-trainer-controls-secondary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.28rem 0.4rem;
  min-width: 0;
}

.chord-trainer-field {
  display: grid;
  gap: 0.16rem;
  min-width: 0;
}

.chord-trainer-field > label:first-child,
.chord-trainer-panel .chord-trainer-field > label[for] {
  font-weight: 600;
  color: #374151;
  font-size: 0.8rem;
  line-height: 1.2;
}

.chord-trainer-panel fieldset.chord-trainer-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: flex-start;
  gap: 0.18rem 0.35rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.22rem 0.32rem 0.28rem;
  margin: 0;
  min-width: 0;
}

.chord-trainer-panel fieldset.chord-trainer-field legend {
  font-weight: 600;
  color: #374151;
  font-size: 0.78rem;
  line-height: 1.2;
  padding: 0 0.15rem;
  flex: 1 0 100%;
  width: 100%;
}

.chord-trainer-panel fieldset.chord-trainer-field label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.86rem;
  color: #1f2937;
  margin: 0;
  min-height: 40px;
  padding: 0.1rem 0.22rem;
  flex: 1 1 auto;
  min-width: min(7.5rem, 100%);
  cursor: pointer;
  box-sizing: border-box;
}

.chord-trainer-panel fieldset.chord-trainer-field input[type='checkbox'],
.chord-trainer-panel fieldset.chord-trainer-field input[type='radio'] {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.chord-trainer-field--hand-radios label,
.chord-trainer-field--display-mode label {
  min-height: 40px;
}

.chord-display-options.chord-trainer-field--display-mode {
  gap: 0.15rem 0.3rem;
}

.chord-display-option {
  min-width: min(7rem, 100%);
}

.chord-trainer-panel select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  font-size: 0.92rem;
  line-height: 1.25;
  color: #111827;
  background: #ffffff;
  border: 1px solid #9ca3af;
  border-radius: 8px;
  padding: 0.3rem 0.45rem;
}

.chord-trainer-message {
  margin: 0.2rem 0;
  padding: 0.32rem 0.42rem;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  font-size: 0.85rem;
  line-height: 1.35;
}

/* Chord Trainer inactive (MIDI routed to Scale) — matches Scale Trainer paused banner look */
.chord-trainer-banner {
  margin: 0.12rem 0 0.22rem;
}

.chord-trainer-banner--paused {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}

.chord-trainer-question-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.45rem;
  margin: 0.16rem 0 0.2rem;
  min-width: 0;
  align-items: start;
}

.chord-trainer-question-main {
  min-width: 0;
}

.chord-trainer-question-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
  width: 100%;
}

.chord-trainer-question-row .chord-trainer-question,
.chord-trainer-question-row .chord-question-card {
  margin: 0;
}

.chord-trainer-question,
.chord-question-card {
  margin: 0.18rem 0;
  padding: 0.45rem 0.55rem 0.5rem;
  border-radius: 10px;
  border: 2px solid #c7d2fe;
  background: #eef2ff;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

.chord-trainer-question-row .chord-trainer-question {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  box-sizing: border-box;
}

.chord-trainer-question-content {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: 0.28rem 0.65rem;
  min-width: 0;
  width: 100%;
  flex: 1 1 auto;
}

.chord-trainer-question-content .chord-trainer-question-main-text {
  margin: 0;
  flex: 0 1 auto;
  justify-content: center;
  min-width: 0;
}

.chord-trainer-question-subtext {
  margin: 0;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  text-align: center;
  font-size: clamp(0.92rem, 2vw, 1.08rem);
  font-weight: 500;
  line-height: 1.22;
  color: #4338ca;
}

.chord-question-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.35rem 0.65rem;
  margin: 0;
}

.chord-question-main--name,
.chord-question-main--roman {
  justify-content: center;
}

.chord-question-main--both {
  gap: 0.45rem 0.85rem;
  /* Roman size in "Both"; chord name uses calc(var * 1.5) so name is 1.5x roman. */
  --chord-roman-fs: clamp(1.85rem, 4.8vw, 2.85rem);
}

.chord-name-large {
  font-size: clamp(3.2rem, 6vw, 5rem);
  font-weight: 800;
  line-height: 1;
  color: #1e1b4b;
  letter-spacing: -0.02em;
}

.chord-question-main--both .chord-name-large.chord-roman {
  font-size: var(--chord-roman-fs);
}

.chord-question-main--both .chord-name-large:not(.chord-roman) {
  font-size: calc(var(--chord-roman-fs) * 1.5);
}

.chord-roman.chord-name-large {
  font-weight: 800;
}

.chord-question-subtitle {
  margin: 0;
  font-weight: 600;
  color: #4338ca;
  line-height: 1.28;
  text-align: center;
}

.chord-question-subtitle.chord-trainer-question-subtext {
  font-weight: 500;
  line-height: 1.22;
}

.chord-trainer-feedback-inline {
  margin: 0.2rem 0 0;
  text-align: center;
  font-size: clamp(0.8rem, 1.9vw, 0.95rem);
  font-weight: 700;
  line-height: 1.3;
  color: #312e81;
}

.chord-question-placeholder {
  margin: 0.15rem 0 0;
  text-align: center;
}

.chord-trainer-question.chord-trainer-question--wrong {
  background: #fef2f2;
  border-color: #f87171;
}

.chord-trainer-question.chord-trainer-question--wrong .chord-name-large,
.chord-trainer-question.chord-trainer-question--wrong .chord-question-subtitle,
.chord-trainer-question.chord-trainer-question--wrong .chord-trainer-question-subtext,
.chord-trainer-question.chord-trainer-question--wrong .chord-trainer-feedback-inline {
  color: #991b1b;
}

.chord-trainer-question.correct {
  background: #dcfce7;
  border-color: #22c55e;
}

.chord-trainer-question.correct .chord-name-large,
.chord-trainer-question.correct .chord-question-subtitle,
.chord-trainer-question.correct .chord-trainer-question-subtext,
.chord-trainer-question.correct .chord-trainer-feedback-inline {
  color: #14532d;
}

.chord-trainer-answer-controls {
  margin: 0;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0.4rem;
  align-items: stretch;
  width: 100%;
}

.chord-trainer-answer-controls button {
  min-height: 52px;
  min-width: 0;
  width: 100%;
  font-size: 0.98rem;
  font-weight: 600;
  color: #ffffff;
  background: #1d4ed8;
  border: none;
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  flex: 0 0 auto;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chord-trainer-answer-controls button:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}

.chord-trainer-next-button {
  background: #ffffff;
  color: #1d4ed8;
  border: 2px solid #1d4ed8;
}

.chord-trainer-next-button:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}

.chord-trainer-answer {
  margin-top: 0.25rem;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #f8fafc;
}

.chord-trainer-inline-answer {
  margin: 0;
  padding: 0.32rem 0.42rem;
  max-height: min(52vh, 20rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.chord-trainer-inline-answer h3 {
  margin: 0 0 0.18rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.chord-trainer-answer p {
  margin: 0.14rem 0;
  font-size: 0.85rem;
  color: #334155;
  line-height: 1.3;
}

.chord-trainer-inline-answer p {
  margin: 0.08rem 0;
  font-size: 0.78rem;
  line-height: 1.28;
  color: #334155;
}

.chord-trainer-answer strong {
  color: #0f172a;
}

.chord-trainer-inline-answer strong {
  color: #0f172a;
  font-weight: 600;
}

.chord-trainer-answer-beside-diagram.chord-trainer-inline-answer {
  max-height: min(42vh, 18rem);
}

/* Tablet+: Root / Scale / Mode on one row */
@media (min-width: 600px) {
  .chord-trainer-controls-primary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.3rem 0.45rem;
  }

  .chord-trainer-panel fieldset.chord-trainer-field label {
    flex: 1 1 0;
    min-width: 0;
  }
}

/* iPad landscape + desktop: second row = positions | hand | display in three columns */
@media (min-width: 768px) {
  .chord-trainer-question-row {
    grid-template-columns: minmax(0, 1fr) minmax(12rem, 16rem);
    column-gap: 0.65rem;
    row-gap: 0.45rem;
    margin: 0.12rem 0 0.18rem;
    align-items: start;
  }

  .chord-trainer-question-row .chord-trainer-question {
    min-height: 0;
    padding: clamp(0.5rem, 1.2vw, 0.75rem) clamp(0.65rem, 1.6vw, 0.9rem);
  }

  .chord-trainer-question-content {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-end;
    justify-content: center;
    gap: clamp(0.75rem, 2.2vw, 1.2rem);
  }

  .chord-trainer-question-content .chord-trainer-question-main-text {
    align-items: baseline;
  }

  .chord-trainer-question-content .chord-trainer-question-subtext {
    width: auto;
    max-width: min(38%, 14rem);
    text-align: left;
    align-self: flex-end;
    line-height: 1.18;
    margin-bottom: 0.2rem;
  }

  .chord-trainer-panel {
    padding: 0.45rem 0.55rem 0.5rem;
  }

  .chord-trainer-controls-secondary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.28rem 0.4rem;
    align-items: stretch;
  }

  .chord-trainer-controls-secondary .chord-trainer-field {
    min-height: 100%;
  }

  .chord-trainer-panel fieldset.chord-trainer-field {
    flex-direction: row;
    flex-wrap: nowrap;
    padding: 0.2rem 0.28rem 0.26rem;
  }

  .chord-trainer-panel fieldset.chord-trainer-field legend {
    flex: 1 0 100%;
  }

  .chord-trainer-panel fieldset.chord-trainer-field label {
    flex: 0 1 auto;
    min-width: 0;
    white-space: nowrap;
  }

  .chord-display-options.chord-trainer-field--display-mode {
    gap: 0.12rem 0.25rem;
  }

  .chord-display-option {
    min-width: 0;
    flex: 1 1 auto;
  }
}

@media (min-width: 900px) {
  .chord-trainer-panel {
    padding: 0.48rem 0.6rem 0.52rem;
  }
}

@media (max-width: 599px) {
  .chord-trainer-panel fieldset.chord-trainer-field label {
    flex: 1 1 100%;
  }
}

/* Tighter gap before embedded Chord Progress inside trainer panel */
.chord-trainer-panel .chord-progress-section {
  margin: 0.35rem 0 0.2rem;
}

/* Chord progress bars (Stage 8) — reusable; not tied to ChordTrainer layout */
.chord-progress-section {
  margin: 0.65rem 0;
  padding: 0.6rem 0.7rem;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  max-width: 100%;
  box-sizing: border-box;
}

.chord-progress-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem 0.75rem;
}

.chord-progress-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #374151;
  line-height: 1.25;
}

.progress-panel-title,
.chord-progress-header h2.progress-panel-title,
.chord-progress-header h3.progress-panel-title,
.scale-progress-header h2.progress-panel-title,
.scale-progress-header h3.progress-panel-title {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.progress-panel-top-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: min(100%, 17rem);
}

.progress-panel-stats {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.28rem;
  min-width: min(100%, 18.5rem);
}

.progress-panel-stat-pill {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.22rem;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 8px;
  padding: 0.38rem 0.72rem;
  white-space: nowrap;
  box-sizing: border-box;
}

.progress-panel-stat-label {
  font-size: 0.875rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
  font-weight: 600;
  color: #0f172a;
}

.progress-panel-stat-value {
  font-size: clamp(0.9rem, 1.55vw, 0.98rem);
  line-height: 1.2;
  color: #0b1220;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.progress-panel-stat-line {
  display: inline-flex;
  align-items: baseline;
  gap: 0.14rem;
}

.chord-progress-header--trainer {
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
}

.chord-progress-header--trainer h2 {
  flex: 0 1 auto;
  min-width: 0;
}

.chord-progress-session-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 1rem;
  margin: 0;
  font-size: clamp(0.92rem, 2vw, 1.08rem);
  line-height: 1.3;
  color: #374151;
  flex: 1 1 auto;
  justify-content: center;
  min-width: min(100%, 12rem);
}

.chord-progress-session-stat {
  white-space: nowrap;
}

.chord-progress-session-stat strong {
  color: #1f2937;
  font-weight: 700;
}

.chord-progress-session-stat-num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #111827;
}

.chord-progress-header--trainer .chord-progress-toggle-row {
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: min(100%, 10.5rem);
}

@media (min-width: 720px) {
  .chord-progress-header--trainer {
    flex-wrap: nowrap;
  }

  .chord-progress-session-stats {
    flex: 0 1 auto;
    justify-content: flex-start;
    min-width: 0;
  }

  .chord-progress-header--trainer .chord-progress-toggle-row {
    flex: 0 0 auto;
    min-width: 0;
  }
}

.chord-progress-toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  flex: 1 1 auto;
  justify-content: flex-end;
}

.chord-progress-toggle {
  min-width: 5rem;
  min-height: 32px;
  padding: 0.2rem 0.65rem;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  box-sizing: border-box;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.chord-progress-toggle:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.chord-progress-toggle:active {
  transform: scale(0.98);
}

.chord-progress-toggle-active,
.chord-progress-toggle-active:hover {
  border-color: #172554;
  background: #1e3a8a;
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(23, 37, 84, 0.45);
}

/* Compact horizontal bar chart — all chords visible in one band */
.chord-progress-chart {
  margin-top: 0.5rem;
  padding: 0.45rem 0.3rem 0.35rem;
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}

.chord-progress-grid {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.3rem 0.35rem;
  min-width: 0;
  max-width: 100%;
}

.chord-progress-y-axis {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-bottom: 0.15rem;
}

.chord-progress-y-axis-spacer {
  flex-shrink: 0;
  height: calc(1.15rem + 0.12rem);
}

.chord-progress-y-axis-labels {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 6.75rem;
  padding-right: 0.35rem;
  border-right: 1px solid #e5e7eb;
  box-sizing: border-box;
}

.chord-progress-y-tick {
  font-size: 0.65rem;
  line-height: 1;
  color: #9ca3af;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.chord-progress-columns-wrap {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: visible;
}

.chord-progress-bars.chord-progress-columns {
  list-style: none;
  margin: 0;
  padding: 0 0.05rem 0.1rem 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  column-gap: 0.28rem;
  row-gap: 0.35rem;
  width: 100%;
  min-width: 0;
  align-items: end;
  box-sizing: border-box;
}

.chord-progress-column {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-sizing: border-box;
}

.chord-progress-column-pct {
  font-size: 0.72rem;
  line-height: 1.15;
  min-height: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #4b5563;
}

.chord-progress-column-bar,
.chord-progress-bar-track {
  width: 100%;
  max-width: 100%;
  height: 6.75rem;
  margin: 0.12rem 0 0.28rem;
  position: relative;
  background-color: #e5e7eb;
  background-image: linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(50% - 0.5px),
    rgba(255, 255, 255, 0.65) calc(50% - 0.5px),
    rgba(255, 255, 255, 0.65) calc(50% + 0.5px),
    transparent calc(50% + 0.5px),
    transparent 100%
  );
  border-radius: 7px;
  overflow: hidden;
  box-sizing: border-box;
}

.chord-progress-column-fill,
.chord-progress-bar-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to top, #4f46e5, #a5b4fc);
  border-radius: 0 0 5px 5px;
  min-height: 0;
  transition: height 0.25s ease;
}

.chord-progress-column-label {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
  color: #1f2937;
  word-break: break-word;
  max-width: 100%;
  hyphens: auto;
}

.chord-progress-column-meta {
  margin-top: 0.12rem;
  font-size: 0.68rem;
  line-height: 1.2;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}

.chord-progress-empty {
  margin: 0.65rem 0 0.15rem;
  padding: 0.55rem 0.5rem;
  font-size: 0.98rem;
  line-height: 1.4;
  color: #6b7280;
  background: #ffffff;
  border-radius: 8px;
  border: 1px dashed #d1d5db;
}

@media (min-width: 600px) {
  .chord-progress-bars.chord-progress-columns {
    column-gap: 0.38rem;
    row-gap: 0.4rem;
  }

  .chord-progress-column-bar,
  .chord-progress-bar-track {
    height: 7.25rem;
  }

  .chord-progress-y-axis-labels {
    height: 7.25rem;
  }
}

/* Last-resort horizontal scroll only on very narrow widths */
@media (max-width: 319px) {
  .chord-progress-columns-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .chord-progress-bars.chord-progress-columns {
    min-width: 16.5rem;
  }

  .chord-progress-column-pct {
    font-size: 0.65rem;
  }

  .chord-progress-column-label {
    font-size: 0.74rem;
  }

  .chord-progress-column-meta {
    font-size: 0.62rem;
  }
}

/* Stage 9 — Scale Trainer panel (Chord Trainer–like, touch-friendly) */
.scale-trainer-panel {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  color: #1f2937;
  text-align: left;
}

.scale-trainer-panel.card {
  padding: 0.4rem 0.5rem 0.45rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.scale-trainer-panel h2 {
  margin: 0 0 0.14rem;
  font-size: 1.06rem;
  line-height: 1.15;
  color: #111827;
}

.scale-trainer-banner {
  margin: 0.12rem 0 0.22rem;
}

.scale-trainer-banner--paused {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}

.scale-trainer-quarter-note-note {
  margin: 0 0 0.28rem;
  padding: 0.28rem 0.4rem;
  font-size: 0.78rem;
  line-height: 1.32;
  color: #1e3a8a;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
}

/* Stage 11 — Scale Trainer metronome + timing feedback */
.metronome-controls {
  margin: 0.12rem 0 0.22rem;
  padding: 0.45rem 0.5rem 0.5rem;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fafafa;
  display: grid;
  gap: 0.45rem;
}

.metronome-controls-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.65rem;
  margin-bottom: 0.22rem;
}

.metronome-controls-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: #111827;
}

.metronome-use-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  user-select: none;
}

.metronome-use-toggle input {
  width: 1rem;
  height: 1rem;
  accent-color: #4f46e5;
}

.metronome-status-msg {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.32;
  color: #4b5563;
}

.metronome-status-msg--warn {
  color: #92400e;
  font-weight: 600;
}

/* Compact single-row layout for all metronome controls */
.metronome-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
}

.metronome-controls-section {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
  padding: 0.38rem 0.45rem;
}

.metronome-controls-section--final-feedback {
  background: #fcfcff;
}

.metronome-section-title {
  margin: 0 0 0.32rem;
  font-size: 0.78rem;
  line-height: 1.2;
  font-weight: 700;
  color: #1f2937;
}

.metronome-settings-grid {
  display: grid;
  gap: 0.3rem;
  grid-template-columns: auto auto auto auto auto auto;
  align-items: end;
  justify-content: flex-start;
}

.metronome-setting-field {
  display: grid;
  gap: 0.14rem;
  min-width: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: #374151;
}

.metronome-setting-field input {
  width: auto;
  min-height: 30px;
  font-size: 0.8rem;
  border-radius: 6px;
  border: 1px solid #9ca3af;
  padding: 0.1rem 0.3rem;
  background: #ffffff;
  color: #111827;
  box-sizing: border-box;
}

.metronome-setting-field select {
  width: auto;
  min-height: 30px;
  font-size: 0.8rem;
  border-radius: 6px;
  border: 1px solid #9ca3af;
  padding: 0.1rem 0.3rem;
  background: #ffffff;
  color: #111827;
  box-sizing: border-box;
}

.metronome-setting-field input:disabled,
.metronome-setting-field select:disabled {
  background: #f3f4f6;
  color: #4b5563;
  border-color: #d1d5db;
  opacity: 1;
  cursor: not-allowed;
}

.metronome-controls-section--exercise {
  background: #f8fbff;
}

.metronome-exercise-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: flex-end;
}

.metronome-setting-field--exercise-picker {
  width: min(11rem, 100%);
}

.metronome-setting-field--start .metronome-toggle-button {
  width: auto;
}

.metronome-setting-field--bpm input,
.metronome-setting-field--accuracy input,
.metronome-setting-field--tolerance input {
  width: 84px;
}

.metronome-setting-field--signature select {
  width: 104px;
}

.metronome-setting-field--sound select {
  width: 176px;
}

.metronome-exercise-grid .metronome-setting-field input {
  width: 102px;
}

.metronome-exercise-grid .metronome-setting-field--exercise-picker select {
  width: 150px;
}

.metronome-setting-field--wide {
  grid-column: span 2;
}

.metronome-exercise-timer-status {
  margin: 0.3rem 0 0;
  font-size: 0.75rem;
  line-height: 1.3;
  color: #334155;
  font-weight: 600;
}

.metronome-exercise-ladder-status {
  color: #1e3a8a;
}

.metronome-exercise-lock-msg {
  margin: 0.28rem 0 0;
  font-size: 0.74rem;
  line-height: 1.25;
  font-weight: 600;
  color: #6b7280;
}

.metronome-setting-field small {
  font-size: 0.68rem;
  color: #6b7280;
  line-height: 1.2;
}

.metronome-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.3rem;
}

/* Inline label + narrow number input pairs */
.metronome-inline-field {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
}

.metronome-inline-field input {
  width: 3.5rem;
  min-height: 32px;
  font-size: 0.82rem;
  border-radius: 6px;
  border: 1px solid #9ca3af;
  padding: 0.12rem 0.3rem;
  background: #ffffff;
  color: #111827;
  caret-color: #111827;
  box-sizing: border-box;
}

.metronome-inline-field input::placeholder {
  color: #6b7280;
}

.metronome-controls-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.metronome-toggle-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0.15rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.2;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.metronome-toggle-button--start {
  background: #1d4ed8;
}

.metronome-toggle-button--stop {
  background: #b91c1c;
}

.metronome-toggle-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.exercise-mode-free {
  background: #eff6ff;
  border-color: #dbeafe;
}

.exercise-mode-timed {
  background: #f0fdf4;
  border-color: #dcfce7;
}

.exercise-mode-beat-ladder {
  background: #fffbeb;
  border-color: #fef3c7;
}

.exercise-mode-time-ladder {
  background: #f5f3ff;
  border-color: #ede9fe;
}

.exercise-mode-streak-goal {
  background: #fff7ed;
  border-color: #ffedd5;
}

.metronome-beat-indicator {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 600;
  color: #4338ca;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.metronome-beat-indicator--exercise {
  align-self: end;
  padding-bottom: 0.2rem;
}

/* Session average accuracy — compact inline pill */
.metronome-avg-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.42rem;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Average accuracy pill colour modifiers — same pass/near/fail palette as timing feedback */
.metronome-avg-pill--neutral {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e3a8a;
}

.metronome-avg-pill--pass {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}

.metronome-avg-pill--near {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}

.metronome-avg-pill--fail {
  background: #fef2f2;
  border-color: #f87171;
  color: #b91c1c;
}

/* Stage 12 — auto BPM progression info pills */
.metronome-stage12-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0.22rem 0.32rem;
  border-radius: 8px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #3730a3;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
}

.metronome-stage12-pill--neutral {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #334155;
}

.metronome-stage12-pill.metronome-avg-pill--pass {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}

.metronome-stage12-pill.metronome-avg-pill--near {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}

.metronome-stage12-pill.metronome-avg-pill--fail {
  background: #fef2f2;
  border-color: #f87171;
  color: #b91c1c;
}

/* Per-scale timing feedback — slim coloured message below the row */
.metronome-timing-feedback {
  margin: 0;
  padding: 0.22rem 0.4rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
}

.metronome-final-feedback-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.metronome-final-feedback-row .metronome-section-title {
  margin: 0;
  flex: 0 0 auto;
}

.metronome-final-feedback-row .metronome-timing-feedback,
.metronome-final-feedback-row .metronome-status-msg {
  flex: 0 1 auto;
  max-width: min(100%, 52rem);
}

@media (max-width: 680px) {
  .metronome-settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metronome-settings-grid .metronome-setting-field input,
  .metronome-settings-grid .metronome-setting-field select,
  .metronome-exercise-grid .metronome-setting-field input,
  .metronome-exercise-grid .metronome-setting-field select {
    width: 100%;
  }

  .metronome-exercise-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metronome-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Stage 13 — small iPad/medium landscape touch polish for metronome controls */
@media (min-width: 768px) and (max-width: 1180px) and (orientation: landscape) {
  .metronome-controls {
    gap: 0.55rem;
    padding: 0.5rem 0.55rem 0.55rem;
  }

  .metronome-controls-section {
    padding: 0.45rem 0.5rem;
  }

  .metronome-settings-grid,
  .metronome-exercise-grid {
    gap: 0.38rem;
    min-width: 0;
  }

  .metronome-setting-field {
    gap: 0.18rem;
    font-size: 0.76rem;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }

  .metronome-setting-field input,
  .metronome-setting-field select {
    min-height: 36px;
    font-size: 0.84rem;
    padding: 0.14rem 0.35rem;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .metronome-toggle-button {
    min-height: 38px;
    font-size: 0.86rem;
    padding: 0.2rem 0.8rem;
  }

  .scale-trainer-controls .chord-trainer-field,
  .scale-trainer-controls .scale-trainer-select,
  .scale-trainer-panel .chord-trainer-controls-primary,
  .scale-trainer-panel .chord-trainer-controls-secondary {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }

  .scale-trainer-controls .scale-trainer-select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Keep adjacent piano keys visually separated on iPad Safari/MidiWeb. */
  .piano-white-key {
    position: relative;
  }

  .piano-white-key::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: var(--piano-white-h);
    background: rgba(15, 23, 42, 0.2);
    pointer-events: none;
    z-index: 3;
  }

  .piano-white-key:last-child::after {
    display: none;
  }

  .piano-white-key-surface {
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
  }

  .piano-black-key-surface {
    box-shadow:
      inset 0 0 0 1px rgba(255, 255, 255, 0.16),
      0 0 0 1px rgba(15, 23, 42, 0.22);
  }
}

/* Green: score met or exceeded threshold */
.metronome-timing-feedback--pass {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

/* Amber: within 75 % of threshold */
.metronome-timing-feedback--near {
  border-color: #fcd34d;
  background: #fffbeb;
  color: #92400e;
}

/* Red: below 75 % of threshold */
.metronome-timing-feedback--fail {
  border-color: #f87171;
  background: #fef2f2;
  color: #b91c1c;
}

.scale-trainer-panel .chord-trainer-controls {
  gap: 0.14rem;
  margin: 0.08rem 0 0.12rem;
}

.scale-trainer-controls .chord-trainer-controls-primary,
.scale-trainer-controls .chord-trainer-controls-secondary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.22rem 0.32rem;
  min-width: 0;
}

.scale-trainer-panel .chord-trainer-field {
  gap: 0.1rem;
}

.scale-trainer-panel .chord-trainer-field > label:first-child,
.scale-trainer-panel .chord-trainer-field > label[for] {
  font-size: 0.76rem;
}

.scale-trainer-panel fieldset.chord-trainer-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: flex-start;
  gap: 0.08rem 0.28rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.12rem 0.26rem 0.16rem;
  margin: 0;
  min-width: 0;
}

.scale-trainer-panel fieldset.chord-trainer-field legend {
  font-weight: 600;
  color: #374151;
  font-size: 0.72rem;
  line-height: 1.15;
  padding: 0 0.1rem;
  flex: 1 0 100%;
  width: 100%;
}

.scale-trainer-panel fieldset.chord-trainer-field label {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 0.82rem;
  color: #1f2937;
  margin: 0;
  min-height: 34px;
  padding: 0.04rem 0.12rem;
  flex: 1 1 auto;
  min-width: min(4.5rem, 100%);
  cursor: pointer;
  box-sizing: border-box;
}

.scale-trainer-panel fieldset.chord-trainer-field input[type='radio'] {
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}

.scale-trainer-select,
.scale-trainer-panel select.scale-trainer-select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 40px;
  font-size: 0.9rem;
  line-height: 1.2;
  color: #111827;
  background: #ffffff;
  border: 1px solid #9ca3af;
  border-radius: 8px;
  padding: 0.22rem 0.42rem;
}

.scale-trainer-hand-radios {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
}

.scale-trainer-hand-radios label {
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
}

.scale-trainer-actions-wrap {
  margin: 0.22rem 0 0.15rem;
}

.scale-trainer-actions-row {
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.35rem;
  align-items: stretch;
}

.scale-trainer-actions-row button {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  min-height: 44px;
  padding: 0.28rem 0.4rem;
  font-size: 0.88rem;
}

/* Show / Hide Scale: light purple (Previous / Next stay outline blue via .chord-trainer-next-button) */
.chord-trainer-answer-controls.scale-trainer-actions-row .scale-trainer-show-toggle-button {
  background: #f5f3ff;
  color: #5b21b6;
  border: 2px solid #c4b5fd;
  font-weight: 600;
}

.chord-trainer-answer-controls.scale-trainer-actions-row .scale-trainer-show-toggle-button:focus-visible {
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
}

/* Restart button — amber/orange, visually distinct from blue navigation buttons */
.chord-trainer-answer-controls.scale-trainer-actions-row .scale-trainer-restart-button {
  background: #d97706;
  color: #ffffff;
  border: 2px solid #b45309;
  font-weight: 600;
}

.chord-trainer-answer-controls.scale-trainer-actions-row .scale-trainer-restart-button:focus-visible {
  outline: 2px solid #d97706;
  outline-offset: 2px;
}

.scale-trainer-question {
  margin: 0.22rem 0 0.15rem;
}

.scale-trainer-feedback {
  margin: 0.25rem 0 0;
  font-size: 0.88rem;
  line-height: 1.32;
}

@media (min-width: 600px) {
  .scale-trainer-controls .chord-trainer-controls-primary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .scale-trainer-controls .chord-trainer-controls-secondary {
    grid-template-columns: minmax(0, 1.35fr) repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .scale-trainer-hand-radios {
    flex-wrap: nowrap;
  }

  .scale-trainer-hand-radios label {
    flex: 0 1 auto;
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .scale-trainer-actions-row {
    flex-direction: column;
    flex-wrap: wrap;
  }

  .scale-trainer-actions-row button {
    width: 100%;
  }
}

/* Screen reader only (diagrams) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Stage 9+ — compact theory diagrams */
.diagram-block-title {
  margin: 0 0 0.18rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: #4b5563;
  line-height: 1.2;
}

.chord-trainer-diagram-answer-row {
  display: grid;
  gap: 0.45rem;
  margin: 0.12rem 0 0.2rem;
  min-width: 0;
  align-items: start;
  grid-template-columns: minmax(0, 1fr);
}

.chord-trainer-diagram-col {
  min-width: 0;
}

.chord-trainer-diagram-col--piano {
  min-width: min(100%, 280px);
}

.chord-trainer-piano-both {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.chord-trainer-piano-both-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: flex-start;
}

.chord-trainer-piano-both-item {
  flex: 1 1 150px;
  min-width: 0;
}

.chord-trainer-answer-beside-diagram {
  margin: 0;
}

.chord-trainer-answer-slot {
  min-width: 0;
}

.chord-trainer-answer-slot--hidden {
  display: none;
}

@media (min-width: 700px) {
  .chord-trainer-diagram-answer-row {
    grid-template-columns: minmax(0, 1.45fr) minmax(13rem, 0.9fr);
    align-items: start;
  }

  .chord-trainer-answer-slot--hidden {
    display: block;
    visibility: hidden;
    min-height: 1px;
  }
}

.scale-trainer-diagrams {
  display: grid;
  gap: 0.4rem;
  margin: 0.12rem 0 0.18rem;
  min-width: 0;
  align-items: start;
  grid-template-columns: minmax(0, 1fr);
}

.scale-trainer-diagram-piano-col {
  min-width: 0;
}

.scale-progress-card {
  margin-top: 0.3rem;
  border: 1px solid #dbe1ea;
  border-radius: 10px;
  background: #f9fafb;
  padding: 0.48rem 0.56rem;
}

.scale-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.scale-progress-title {
  margin: 0;
  font-size: 0.84rem;
  letter-spacing: 0.01em;
  color: #1f2937;
  font-weight: 700;
}

.scale-progress-toggle-row {
  display: inline-flex;
  gap: 0.16rem;
  background: #eef2f7;
  border-radius: 999px;
  padding: 0.12rem;
}

.scale-progress-toggle {
  border: 1px solid transparent;
  background: transparent;
  color: #374151;
  border-radius: 999px;
  padding: 0.1rem 0.52rem;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.25;
}

.scale-progress-toggle-active {
  background: #1d4ed8;
  border-color: #1e40af;
  color: #fff;
}

.scale-progress-chart {
  margin-top: 0.2rem;
}

.scale-progress-section .chord-progress-bars.chord-progress-columns {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 0.2rem;
}

.scale-progress-section .chord-progress-column-label {
  font-size: 0.7rem;
}

.scale-progress-section .chord-progress-column-meta {
  font-size: 0.62rem;
}

@media (max-width: 760px) {
  .progress-panel-top-controls {
    justify-content: flex-start;
    min-width: 0;
  }

  .progress-panel-stats {
    min-width: 0;
    width: 100%;
  }

  .scale-progress-section .chord-progress-bars.chord-progress-columns {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.scale-trainer-diagram-piano-col--hand {
  min-width: 0;
}

.scale-trainer-diagrams--both {
  grid-template-columns: minmax(0, 1fr);
}

.scale-trainer-diagrams--both .piano-keyboard-scroll {
  overflow-x: hidden;
}

.scale-trainer-diagrams--both .piano-keyboard {
  width: 100%;
  min-width: 0;
  display: block;
}

.scale-trainer-diagrams--both .piano-note-diagram--large .piano-keyboard-inner {
  --piano-white-w: clamp(0.88rem, 1.6vw, 1.28rem);
  --piano-white-h: clamp(2.55rem, 4.1vw, 3.05rem);
  --piano-black-w: clamp(0.52rem, 0.95vw, 0.74rem);
  margin-inline: auto;
}

.scale-trainer-diagrams--both-two-octaves {
  gap: 0.3rem;
}

.scale-trainer-diagrams--both-two-octaves .piano-note-diagram {
  padding: 0.24rem 0.28rem;
}

.scale-trainer-diagrams--both-two-octaves .piano-note-diagram--compact .piano-keyboard-inner {
  --piano-white-w: 0.94rem;
  --piano-white-h: 2.48rem;
  --piano-black-w: 0.54rem;
}

.scale-trainer-diagrams--both-two-octaves .piano-key-label-text,
.scale-trainer-diagrams--both-two-octaves .piano-black-key-label {
  font-size: 0.54rem;
}

@media (min-width: 700px) {
  .scale-trainer-diagrams--both {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scale-trainer-diagrams--both-two-octaves .piano-keyboard-scroll {
    overflow-x: hidden;
  }
}

.scale-trainer-diagram-path-col {
  min-width: 0;
}

@media (min-width: 640px) {
  .scale-trainer-diagram-path-col .scale-path-diagram {
    overflow-x: auto;
  }

  .scale-trainer-diagram-path-col .scale-path-steps {
    flex-wrap: nowrap;
  }
}

.scale-path-diagram {
  padding: 0.28rem 0.38rem;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fafafa;
  min-width: 0;
}

.scale-path-diagram--empty {
  background: #f9fafb;
}

.scale-path-empty-msg {
  margin: 0;
  font-size: 0.78rem;
  color: #6b7280;
}

.scale-path-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.12rem 0.08rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.scale-path-step {
  display: inline-flex;
  align-items: center;
  gap: 0.06rem;
  font-size: 0.78rem;
  line-height: 1.2;
}

.scale-path-step-label {
  display: inline-flex;
  min-width: 1.65rem;
  justify-content: center;
  padding: 0.14rem 0.28rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.scale-path-step--done .scale-path-step-label {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #065f46;
}

.scale-path-step--current .scale-path-step-label {
  background: #eef2ff;
  border-color: #818cf8;
  color: #312e81;
  box-shadow: 0 0 0 1px #c7d2fe inset;
}

.scale-path-step--future .scale-path-step-label {
  background: #f3f4f6;
  border-color: #e5e7eb;
  color: #6b7280;
}

.scale-path-arrow {
  color: #9ca3af;
  font-size: 0.72rem;
  padding: 0 0.04rem;
  user-select: none;
}

.scale-path-steps--revealed .scale-path-step-label {
  font-size: 0.8rem;
  padding: 0.16rem 0.32rem;
}

/* --- Piano: whites in a row, blacks overlaid on upper part of whites --- */
.piano-note-diagram {
  padding: 0.32rem 0.45rem;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fafafa;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.piano-note-diagram-empty {
  margin: 0;
  font-size: 0.78rem;
  color: #6b7280;
}

.piano-keyboard-scroll {
  display: flex;
  justify-content: center;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.piano-keyboard {
  display: inline-block;
  flex: 0 0 auto;
  min-width: min-content;
}

.piano-keyboard-inner {
  --piano-white-w: 1.38rem;
  --piano-white-h: 3.05rem;
  --piano-black-w: 0.78rem;
  --piano-black-body-pct: 0.62;
  --piano-white-count: 7;
  position: relative;
  width: calc(var(--piano-white-count) * var(--piano-white-w));
  max-width: 100%;
}

.piano-note-diagram--large .piano-keyboard-inner {
  --piano-white-w: 1.62rem;
  --piano-white-h: 3.4rem;
  --piano-black-w: 0.92rem;
}

.piano-note-diagram--compact .piano-keyboard-inner {
  --piano-white-w: 1.12rem;
  --piano-white-h: 2.72rem;
  --piano-black-w: 0.64rem;
}

.piano-black-label-layer {
  position: relative;
  width: 100%;
  height: 1rem;
  margin-bottom: 0.06rem;
  overflow: visible;
  pointer-events: none;
}

.piano-keys-block {
  position: relative;
  width: 100%;
  overflow: visible;
}

.piano-white-row {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  position: relative;
  z-index: 1;
}

.piano-black-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: var(--piano-white-h);
  z-index: 2;
  pointer-events: none;
}

.piano-black-key-slot {
  position: absolute;
  left: calc(
    (var(--piano-after-white-index, 0) + 1) * var(--piano-white-w) - var(--piano-black-w) / 2
  );
  top: 0;
  width: var(--piano-black-w);
  height: var(--piano-white-h);
  overflow: visible;
}

.piano-black-key-label-wrap {
  position: absolute;
  left: calc(
    (var(--piano-after-white-index, 0) + 1) * var(--piano-white-w) - var(--piano-black-w) / 2 +
      var(--piano-black-w) / 2
  );
  top: 0;
  transform: translateX(-50%);
  max-width: min(5.5rem, calc(var(--piano-white-w) * 2.7));
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.piano-black-key-label-wrap:empty {
  display: none;
}

.piano-black-key-surface {
  position: absolute;
  top: 0;
  left: 0;
  height: calc(var(--piano-white-h) * var(--piano-black-body-pct));
  width: 100%;
  border-radius: 3px 3px 5px 5px;
  border: 1px solid #111827;
  background: linear-gradient(180deg, #374151 0%, #0f172a 100%);
  box-sizing: border-box;
  flex-shrink: 0;
}

.piano-white-key {
  width: var(--piano-white-w);
  flex: 0 0 var(--piano-white-w);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.piano-white-key-surface {
  height: var(--piano-white-h);
  border-radius: 3px 3px 5px 5px;
  border: 1px solid #9ca3af;
  border-right-width: 0.5px;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  box-sizing: border-box;
}

.piano-white-key:first-child .piano-white-key-surface {
  border-left-width: 1px;
}

.piano-white-key:last-child .piano-white-key-surface {
  border-right-width: 1px;
}

.piano-key-surface--expected {
  border-color: #166534 !important;
  box-shadow: inset 0 0 0 2px #22c55e;
  background: linear-gradient(180deg, #86efac 0%, #4ade80 100%) !important;
}

.piano-black-key-surface.piano-key-surface--expected {
  background: linear-gradient(180deg, #22c55e 0%, #166534 100%) !important;
  border-color: #bbf7d0 !important;
  box-shadow:
    inset 0 0 0 1px #dcfce7,
    0 0 0 1px #15803d;
}

.piano-key-surface--played {
  box-shadow: inset 0 0 0 1px #93c5fd, 0 0 0 1px #3b82f6;
}

.piano-white-key-surface.piano-key-surface--played {
  background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%) !important;
}

.piano-black-key-surface.piano-key-surface--played {
  background: linear-gradient(180deg, #1d4ed8 0%, #172554 100%) !important;
  border-color: #1e40af !important;
}

@keyframes piano-key-next-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.piano-key-surface--current {
  outline: 3px solid #ea580c;
  outline-offset: 0;
  position: relative;
  z-index: 2;
  animation: piano-key-next-pulse 1.2s ease-in-out infinite;
}

.piano-white-key-surface.piano-key-surface--current {
  background: linear-gradient(180deg, #fed7aa 0%, #fb923c 100%) !important;
  border-color: #ea580c !important;
}

.piano-black-key-surface.piano-key-surface--current {
  background: linear-gradient(180deg, #f97316 0%, #9a3412 100%) !important;
  border-color: #fdba74 !important;
}

.piano-black-key-slot--current {
  z-index: 3;
}

.piano-key-surface--expected.piano-key-surface--played.piano-white-key-surface {
  background: linear-gradient(180deg, #4ade80 0%, #93c5fd 100%) !important;
  border-color: #14532d !important;
}

.piano-white-label-row {
  display: flex;
  flex-direction: row;
  margin-top: 0.2rem;
}

.piano-white-label-cell {
  width: var(--piano-white-w);
  flex: 0 0 var(--piano-white-w);
  min-height: 1.15rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  text-align: center;
}

.piano-key-label-line {
  display: block;
  max-width: 100%;
}

.piano-key-label-text {
  display: block;
  font-size: clamp(0.58rem, 1.1vw, 0.72rem);
  line-height: 1.12;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  max-width: min(4.5rem, calc(var(--piano-white-w) * 2.2));
}

.piano-note-diagram--large .piano-key-label-text {
  font-size: clamp(0.62rem, 1.15vw, 0.78rem);
  max-width: min(5rem, calc(var(--piano-white-w) * 2.4));
}

.piano-black-key-label {
  display: block;
  padding: 0.02rem 0.26rem;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  font-size: clamp(0.56rem, 1.02vw, 0.72rem);
  line-height: 1.08;
  font-weight: 700;
  white-space: nowrap;
}

/* Next-note label emphasis: bold blue text (white key) */
.piano-key-label-text--next {
  font-weight: 700;
  color: #1d4ed8;
}

/* Next-note label emphasis: bold blue pill (black key) */
.piano-black-key-label--next {
  font-weight: 700;
  color: #1d4ed8;
  border-color: #93c5fd;
  background: #eff6ff;
}

/* =====================================================================
   Stage 18 — Practice UI redesign
   Replaces all Stage 16/16b/17 trainer styling.
   Goal: flat compact practice card, large hero, real 2-col stage on iPad.
   ===================================================================== */

:root {
  --surface: #ffffff;
  --surface-soft: #f4f7ff;
  --surface-mute: #fafbff;
  --border-soft: #dee5f5;
  --border-strong: #c8d3ee;
  --text-main: #131838;
  --text-muted: #5b6779;
  --blue: #3158e8;
  --blue-deep: #2244c5;
  --blue-soft: #e8eeff;
  --purple: #6d5dfc;
  --peach: #ffe9d8;
  --peach-deep: #ffc7a3;
  --mint: #d8f7e6;
  --sky: #d6e9ff;
  --warm-text: #8a3b16;
  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 8px;
}

/* ---------- Outer trainer card: flatten the old nested boxes ---------- */
.practice-card.trainer-shell,
.practice-card.scale-trainer-panel,
.practice-card.chord-trainer-panel {
  background: var(--surface) !important;
  border: 1px solid var(--border-soft) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: 0 2px 8px rgba(20, 30, 70, 0.05) !important;
  padding: 0.55rem 0.6rem 0.6rem !important;
  display: grid !important;
  gap: 0.45rem !important;
}

/* Defeat the inner nested .card / .trainer-section-card / .trainer-shell look */
.practice-card .trainer-section-card,
.practice-card .trainer-header-card {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.practice-card .trainer-section-title,
.practice-card .metronome-section-title {
  display: none !important;
}

/* ---------- Compact header ---------- */
.practice-card .practice-header,
.practice-card .trainer-header-card {
  display: flex !important;
  align-items: center !important;
  gap: 0.45rem !important;
  padding: 0.05rem 0.15rem !important;
  margin: 0 !important;
}

.practice-card h2.trainer-panel-title-row {
  margin: 0 !important;
  font-size: 1rem !important;
  line-height: 1.15 !important;
  color: var(--text-main) !important;
}

.practice-card .practice-header-title {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.4rem !important;
  font-weight: 700 !important;
  color: var(--text-main) !important;
}

.practice-card .practice-header-title input[type='radio'] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--blue);
}

.trainer-section-header {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  margin-bottom: 8px !important;
  flex-wrap: wrap;
}

.trainer-section-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #ffffff;
  padding: 8px 16px;
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
  color: #102044;
}

.trainer-section-toggle--active {
  background: #3154e8;
  border-color: #2442c5;
  color: #ffffff;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.22), 0 1px 0 rgba(255, 255, 255, 0.35);
  transform: translateY(1px);
}

.trainer-section-toggle--inactive:hover {
  background: #eef3ff;
  border-color: #8ea2ff;
}

.trainer-section-title {
  line-height: 1;
}

.trainer-midi-pill {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  background: #eef2ff;
  color: #234;
}

.trainer-midi-pill--ready {
  background: #e8f7ee;
  color: #126b37;
}

.trainer-midi-pill--warning {
  background: #eef2ff;
  color: #3154e8;
}

.trainer-route-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #f6c66d;
  background: #fff7e6;
  color: #8a4b00;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

@media (max-width: 700px) {
  .trainer-section-header {
    margin-bottom: 6px !important;
  }
}

@media (max-width: 640px) {
  .trainer-route-pill {
    white-space: normal;
  }
}

/* ---------- Compact notices ---------- */
.practice-card .compact-notice {
  margin: 0 !important;
  padding: 0.32rem 0.5rem !important;
  border-radius: var(--radius-sm) !important;
  font-size: 0.78rem !important;
  line-height: 1.3 !important;
  background: var(--blue-soft) !important;
  border: 1px solid #d6deff !important;
  color: #1d2c80 !important;
}

.practice-card .compact-notice.scale-trainer-banner--paused,
.practice-card .compact-notice.chord-trainer-banner--paused {
  background: #fff8e6 !important;
  border-color: #fde2a4 !important;
  color: #7a4a00 !important;
}

/* ---------- Control dock: flat horizontal grid (NOT a white box) ---------- */
.practice-card .control-dock {
  background: var(--surface-soft) !important;
  border: 1px solid var(--border-soft) !important;
  border-radius: var(--radius) !important;
  padding: 0.45rem 0.5rem 0.5rem !important;
  box-shadow: none !important;
}

.practice-card .control-dock .chord-trainer-controls,
.practice-card .control-dock .scale-trainer-controls {
  display: grid !important;
  gap: 0.4rem !important;
  margin: 0 !important;
}

.practice-card .control-dock .chord-trainer-controls-primary,
.practice-card .control-dock .chord-trainer-controls-secondary {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 0.35rem 0.5rem !important;
}

.practice-card .control-field,
.practice-card .control-dock .chord-trainer-field {
  display: grid !important;
  gap: 0.18rem !important;
  min-width: 0 !important;
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
}

.practice-card .control-field > label,
.practice-card .control-dock .chord-trainer-field > label[for],
.practice-card .control-dock fieldset.chord-trainer-field legend {
  font-size: 0.7rem !important;
  font-weight: 600 !important;
  color: var(--text-muted) !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 !important;
  width: auto !important;
  flex: none !important;
}

.practice-card .control-field select,
.practice-card .control-field input,
.practice-card .scale-trainer-select,
.practice-card .control-dock select,
.practice-card .control-dock input[type='number'],
.practice-card .control-dock input[type='text'] {
  min-height: 38px !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border-strong) !important;
  background: #fff !important;
  color: var(--text-main) !important;
  font-size: 0.88rem !important;
  padding: 0.25rem 0.5rem !important;
  width: 100% !important;
  box-shadow: none !important;
}

/* ---------- Option chips: replace ugly raw radio fieldsets ---------- */
.practice-card .option-chip-group {
  display: grid !important;
  gap: 0.18rem !important;
  border: 0 !important;
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
  min-width: 0 !important;
}

.practice-card .option-chip-group legend {
  display: block !important;
  margin-bottom: 0.18rem !important;
}

.practice-card .option-chip-group > label {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.32rem !important;
  min-height: 34px !important;
  padding: 0.15rem 0.55rem !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: 999px !important;
  background: #fff !important;
  color: var(--text-main) !important;
  font-size: 0.82rem !important;
  font-weight: 500 !important;
  cursor: pointer;
  flex: 0 1 auto !important;
  min-width: 0 !important;
  white-space: nowrap;
}

.practice-card .option-chip-group > label:has(input:checked) {
  background: var(--blue-soft) !important;
  border-color: var(--blue) !important;
  color: var(--blue-deep) !important;
  font-weight: 600 !important;
}

.practice-card .option-chip-group > label > input[type='radio'],
.practice-card .option-chip-group > label > input[type='checkbox'] {
  width: 0.95rem !important;
  height: 0.95rem !important;
  accent-color: var(--blue) !important;
}

.practice-card .option-chip-group {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 0.25rem !important;
  align-items: center !important;
  align-content: flex-start !important;
}

@media (min-width: 700px) {
  .practice-card .control-dock .chord-trainer-controls-secondary,
  .practice-card .control-dock .scale-trainer-controls-secondary {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    align-items: start !important;
  }

  .practice-card .option-chip-group {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 0.22rem !important;
  }

  .practice-card .option-chip-group > legend {
    flex: 0 0 100% !important;
  }

  .practice-card .option-chip-group > label {
    flex: 1 1 0 !important;
    justify-content: center !important;
    min-width: 0 !important;
    padding-left: 0.32rem !important;
    padding-right: 0.32rem !important;
  }
}

/* ---------- Practice stage: real 2-column on iPad landscape ---------- */
.practice-card .practice-stage {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 0.5rem !important;
  margin: 0 !important;
  align-items: stretch !important;
}

.practice-card .practice-stage-main {
  display: grid !important;
  gap: 0.35rem !important;
  min-width: 0 !important;
}

.practice-card .practice-stage-aside {
  display: grid !important;
  gap: 0.4rem !important;
  align-content: start !important;
  min-width: 0 !important;
}

@media (min-width: 820px) {
  .practice-card .practice-stage {
    grid-template-columns: minmax(0, 1fr) minmax(10.5rem, 13rem) !important;
  }
}

/* ---------- Hero panel: huge chord/scale display with warm/cool wash --- */
.practice-card .hero-panel {
  display: grid !important;
  align-items: center !important;
  justify-items: center !important;
  text-align: center !important;
  border-radius: var(--radius-lg) !important;
  border: 1px solid var(--border-soft) !important;
  padding: clamp(0.55rem, 1.6vw, 1rem) 0.7rem !important;
  margin: 0 !important;
  box-shadow: none !important;
}

.practice-card .hero-panel--chord {
  background: linear-gradient(135deg, #f6efe4 0%, #e9dcff 100%) !important;
  border-color: #d3c2f5 !important;
}

.practice-card .hero-panel--scale {
  background: linear-gradient(135deg, var(--sky) 0%, var(--mint) 100%) !important;
  border-color: #b9d2ff !important;
}

.practice-card .hero-panel.correct {
  background: linear-gradient(135deg, #d2f7df 0%, #b6f0ce 100%) !important;
  border-color: #74d99b !important;
}

.practice-card .hero-panel.chord-trainer-question--wrong {
  background: linear-gradient(135deg, #ffe0e0 0%, #ffc8c8 100%) !important;
  border-color: #ee9a9a !important;
}

/* Defeat the legacy challenge-card boxed/padded look when used as hero */
.practice-card .hero-panel.challenge-card {
  border-width: 1px !important;
  padding: clamp(0.28rem, 0.9vw, 0.55rem) 0.45rem !important;
}

.practice-card .hero-main {
  margin: 0 !important;
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: baseline !important;
  justify-content: center !important;
  gap: 0.4rem 0.8rem !important;
}

.practice-card .hero-panel .chord-name-large {
  font-size: clamp(3.5rem, 9vw, 6.5rem) !important;
  line-height: 0.92 !important;
  font-weight: 800 !important;
  letter-spacing: -0.025em !important;
  color: var(--text-main) !important;
}

.practice-card .hero-panel .chord-roman.chord-name-large {
  font-size: clamp(2rem, 5vw, 3.4rem) !important;
  color: #5d3a91 !important;
}

.practice-card .hero-detail {
  margin: 0.25rem 0 0 !important;
  font-size: clamp(0.82rem, 1.6vw, 1rem) !important;
  font-weight: 500 !important;
  color: var(--text-muted) !important;
  line-height: 1.25 !important;
}

.practice-card .hero-feedback {
  margin: 0.35rem 0 0 !important;
  font-size: 0.88rem !important;
  font-weight: 700 !important;
  color: #1c2e84 !important;
}

.practice-card .hero-panel.correct .hero-feedback {
  color: #15643b !important;
}

.practice-card .hero-panel.chord-trainer-question--wrong .hero-feedback {
  color: #971b1b !important;
}

.practice-card .hero-panel.chord-trainer-question--wrong .chord-name-large,
.practice-card .hero-panel.chord-trainer-question--wrong .hero-detail {
  color: #971b1b !important;
}

/* Hide the now-redundant "Chord challenge"/"Your scale quest" kickers if any remain */
.practice-card .challenge-kicker {
  display: none !important;
}

/* ---------- Keyboard panel: integrated, no big white empty box --------- */
.practice-card .keyboard-panel {
  margin: 0 !important;
  padding: 0.25rem 0.3rem 0.35rem !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: var(--radius) !important;
  display: grid !important;
  gap: 0.25rem !important;
}

.practice-card .keyboard-panel .piano-note-diagram {
  background: #fbfcff !important;
  border: 1px solid var(--border-soft) !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 1px 2px rgba(20, 30, 70, 0.04) !important;
  padding: 0.32rem 0.45rem !important;
}

.practice-card .chord-trainer-piano-both,
.practice-card .chord-trainer-piano-both-row {
  margin: 0 !important;
}

.practice-card .chord-trainer-piano-both-row {
  gap: 0.35rem !important;
}

/* ---------- Trainer buttons: one consistent family ---------- */
.practice-card .trainer-button,
.practice-card .practice-stage-aside button,
.practice-card .chord-trainer-answer-controls button {
  appearance: none !important;
  width: 100% !important;
  min-height: 42px !important;
  padding: 0.4rem 0.75rem !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
  font-size: 0.9rem !important;
  font-weight: 600 !important;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.06s ease;
}

.practice-card .trainer-button:active,
.practice-card .practice-stage-aside button:active {
  transform: translateY(1px);
}

.practice-card .trainer-button:hover {
  filter: brightness(0.97);
}

.practice-card .trainer-button--primary {
  background: var(--blue) !important;
  border-color: var(--blue-deep) !important;
  color: #fff !important;
}

.practice-card .trainer-button--secondary {
  background: var(--blue-soft) !important;
  border-color: #cdd9ff !important;
  color: var(--blue-deep) !important;
}

.practice-card .trainer-button--restart {
  background: #fff1e2 !important;
  border-color: var(--peach-deep) !important;
  color: var(--warm-text) !important;
}

.practice-card .trainer-button--speech {
  background: #edf7ee !important;
  border-color: #a8d5ac !important;
  color: #2a6b30 !important;
}

/* ---------- Reading settings toggle ---------- */
.reading-settings-card {
  padding: 0.55rem 0.85rem;
}

.reading-settings-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-main);
  user-select: none;
}

.reading-settings-checkbox {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Parent Practice Monitor dashboard ─────────────────────────────────── */
.pdash {
  padding: 0.85rem 1rem;
}

.pdash-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.pdash-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.pdash-online {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
}

.pdash-online--online {
  background: #e6f4ea;
  color: #2a6b30;
}

.pdash-online--offline {
  background: #fdf3cd;
  color: #7a5800;
}

/* Single scrollable row — never wraps regardless of profile count */
.pdash-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(200px, 260px);
  gap: 0.65rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.pdash-card {
  background: var(--surface-mute, #f8f8fb);
  border: 1px solid var(--border-soft, #e0e0ec);
  border-radius: var(--radius-sm, 8px);
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
  text-align: left;
}

.pdash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  min-width: 0;
}

.pdash-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: normal;
  word-break: break-word;
  min-width: 0;
  text-align: left;
}

/* Sync status badges */
.pdash-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}

.pdash-badge--synced   { background: #e6f4ea; color: #2a6b30; }
.pdash-badge--syncing  { background: #e8f0fe; color: #1a56b0; }
.pdash-badge--pending  { background: #e8f0fe; color: #1a56b0; }
.pdash-badge--waiting  { background: #fdf3cd; color: #7a5800; }
.pdash-badge--failed   { background: #fde8e8; color: #9b1c1c; }
.pdash-badge--idle     { background: var(--surface-mute, #f0f0f6); color: var(--text-muted, #888); }

/* Stats list */
.pdash-stats {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
}

.pdash-stat {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}

.pdash-stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #2244c5;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: left;
  margin: 0;
}

.pdash-stat-value {
  font-size: 0.82rem;
  color: var(--text-main);
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
  text-align: left;
  margin: 0;
}

.pdash-stat-value--muted {
  color: var(--text-muted, #888);
}

.pdash-stat--warning .pdash-stat-label,
.pdash-stat--warning .pdash-stat-value {
  color: #9b1c1c;
}

/* ── Weekly email toggle ────────────────────────────────────────────────── */

.pdash-email-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding: 14px 16px;
  background: var(--surface-mute, #f5f5fa);
  border-radius: 10px;
  border: 1px solid var(--border, #e0e0ec);
}

.pdash-email-toggle-label {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  user-select: none;
}

.pdash-email-toggle-title {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--text, #111);
}

.pdash-email-toggle-desc {
  display: block;
  font-size: 12px;
  color: var(--text-muted, #777);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Toggle pill button */
.pdash-toggle-btn {
  flex-shrink: 0;
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  border: none;
  background: var(--surface-stroke, #ccc);
  cursor: pointer;
  transition: background 0.2s;
  padding: 0;
}

.pdash-toggle-btn--on {
  background: #4f46e5;
}

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

.pdash-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform 0.2s;
  display: block;
}

.pdash-toggle-btn--on .pdash-toggle-thumb {
  transform: translateX(20px);
}

/* Status feedback */
.pdash-email-status {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.pdash-email-status--sending { background: #e8f0fe; color: #1a56b0; }
.pdash-email-status--sent    { background: #e6f4ea; color: #2a6b30; }
.pdash-email-status--error   { background: #fde8e8; color: #9b1c1c; }

.practice-card .action-stack {
  display: grid !important;
  gap: 0.4rem !important;
}

.practice-card .trainer-answer-card {
  margin-top: 0.3rem !important;
  padding: 0.45rem 0.55rem !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border-soft) !important;
  background: var(--surface-mute) !important;
  font-size: 0.82rem !important;
  color: var(--text-main) !important;
}

.practice-card .trainer-answer-card h3 {
  margin: 0 0 0.25rem !important;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
}

.practice-card .trainer-answer-card p {
  margin: 0.12rem 0 !important;
  line-height: 1.3 !important;
}

/* Hide the legacy answer slot used inside the previous keyboard row */
.practice-card .chord-trainer-diagram-answer-row .chord-trainer-answer-slot {
  display: none !important;
}

/* ---------- Rhythm strip: compact horizontal metronome bar ---------- */
.practice-card .rhythm-strip {
  background: var(--surface-soft) !important;
  border: 1px solid var(--border-soft) !important;
  border-radius: var(--radius) !important;
  padding: 0.4rem 0.5rem !important;
  box-shadow: none !important;
  display: grid !important;
  gap: 0.32rem !important;
}

.practice-card .rhythm-strip > * {
  margin: 0 !important;
}

.practice-card .rhythm-strip .metronome-controls-section {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
}

/* Scale Trainer polish: cleaner wrappers and consistent select focus */
.practice-card--scale .rhythm-strip {
  background: #f7faff !important;
  border: 1px solid #dbe5ff !important;
  border-radius: 14px !important;
  overflow: hidden !important;
  padding: 8px 0 8px 8px !important;
  gap: 6px !important;
  box-sizing: border-box !important;
}

.practice-card--scale .rhythm-strip-row--main {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin-bottom: 4px !important;
  min-height: 0 !important;
  align-items: center !important;
}

.practice-card--scale .rhythm-strip .metronome-controls-section--settings,
.practice-card--scale .rhythm-strip .metronome-controls-section--exercise {
  background: transparent !important;
  border: 0 !important;
  border-radius: 12px !important;
  padding: 0 !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

.practice-card--scale .rhythm-strip .metronome-controls-section--exercise {
  background: transparent !important;
  padding: 0 !important;
  margin-top: 6px !important;
}

.practice-card .rhythm-strip-row {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 0.35rem 0.45rem !important;
}

.practice-card .rhythm-strip-row--fields {
  display: block !important;
  width: 100% !important;
}

.practice-card .rhythm-strip-row--main {
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 0.32rem 0.42rem;
}

.practice-card .rhythm-strip-start {
  width: auto !important;
  min-width: 6rem !important;
  flex: 0 0 auto !important;
  padding: 0.45rem 0.95rem !important;
  font-weight: 700 !important;
  font-size: 0.92rem !important;
}

.practice-card .rhythm-strip-beat {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-deep);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
  min-width: 3rem;
  justify-content: center;
}

.practice-card .rhythm-strip-beat-label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.7;
}

.practice-card .rhythm-strip-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.28rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-mute);
  border: 1px solid var(--border-soft);
  font-size: 0.74rem;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.practice-card .rhythm-strip-pill strong {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.practice-card .rhythm-strip-pill.metronome-avg-pill--pass,
.practice-card .rhythm-strip-pill.metronome-avg-pill--neutral.metronome-avg-pill--pass {
  background: #dff7e6 !important;
  border-color: #93dca8 !important;
  color: #14633b !important;
}

.practice-card .rhythm-strip-pill.metronome-avg-pill--near {
  background: #fff5d6 !important;
  border-color: #f3cf76 !important;
  color: #7a4900 !important;
}

.practice-card .rhythm-strip-pill.metronome-avg-pill--fail {
  background: #ffe5e5 !important;
  border-color: #f1a0a0 !important;
  color: #911818 !important;
}

.practice-card .rhythm-strip-row--fields .metronome-settings-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
  column-gap: 12px !important;
  row-gap: 6px !important;
  width: 100% !important;
  min-width: 0 !important;
  align-items: end !important;
  margin: 0 !important;
  padding: 0 10px 0 0 !important;
  box-sizing: border-box !important;
}

.practice-card .rhythm-strip .metronome-setting-field {
  display: flex !important;
  flex-direction: column !important;
  gap: 3px !important;
  font-size: 0.7rem !important;
  color: var(--text-muted) !important;
  font-weight: 600 !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}

.practice-card .rhythm-strip .metronome-setting-field span {
  color: var(--text-muted) !important;
  font-size: 0.78rem !important;
  line-height: 1.1 !important;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600 !important;
  margin-bottom: 0 !important;
  padding: 0 !important;
}

.practice-card .rhythm-strip .metronome-setting-field input,
.practice-card .rhythm-strip .metronome-setting-field select {
  box-sizing: border-box !important;
  width: 100% !important;
  min-height: 40px !important;
  height: 40px !important;
  max-width: 100% !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border-strong) !important;
  background: #fff !important;
  color: var(--text-main) !important;
  font-size: 0.9rem !important;
  line-height: 1.2 !important;
  padding: 0 36px 0 12px !important;
  font-weight: 500 !important;
  text-transform: none;
  letter-spacing: 0;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.practice-card--scale .rhythm-strip .metronome-setting-field select,
.practice-card--scale .scale-trainer-controls select,
.practice-card--scale .scale-trainer-select {
  border: 1px solid #c7d2fe !important;
  border-radius: 10px !important;
  background-color: #ffffff !important;
  min-height: 42px !important;
  box-shadow: none !important;
  outline: none !important;
  -webkit-appearance: none;
  appearance: none;
}

.practice-card--scale .rhythm-strip .metronome-setting-field select:focus,
.practice-card--scale .rhythm-strip .metronome-setting-field select:focus-visible,
.practice-card--scale .scale-trainer-controls select:focus,
.practice-card--scale .scale-trainer-controls select:focus-visible,
.practice-card--scale .scale-trainer-select:focus,
.practice-card--scale .scale-trainer-select:focus-visible {
  border-color: #3b5bdb !important;
  box-shadow: 0 0 0 2px rgba(59, 91, 219, 0.15) !important;
  outline: none !important;
}

.practice-card--scale .rhythm-strip .metronome-setting-field--sound select {
  padding-right: 36px !important;
}

.practice-card--scale .rhythm-strip .metronome-setting-field--sound {
  padding-right: 10px !important;
  box-sizing: border-box !important;
}

.practice-card .rhythm-strip .metronome-exercise-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important;
  column-gap: 12px !important;
  row-gap: 6px !important;
  align-items: end !important;
  background: rgba(255, 255, 255, 0.72) !important;
  border: 0 !important;
  border-radius: var(--radius-sm) !important;
  padding: 0 !important;
  margin-top: 6px !important;
  width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

.practice-card--scale .rhythm-strip .metronome-exercise-grid {
  background: transparent !important;
  border: 0 !important;
  margin: 0 !important;
  width: 100% !important;
  box-sizing: border-box !important;
  border-radius: 10px !important;
}

/* Keep only one metronome container border in Scale Trainer */
.practice-card--scale .rhythm-strip .rhythm-strip-row--main {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
}

.practice-card .rhythm-strip .metronome-exercise-grid > *,
.practice-card .rhythm-strip .metronome-settings-grid > * {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.practice-card .rhythm-strip .metronome-setting-field .number-stepper {
  margin: 0 !important;
  align-self: start !important;
  width: max-content !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.practice-card .rhythm-strip .metronome-setting-field .number-stepper-controls,
.practice-card .rhythm-strip .metronome-setting-field .number-stepper__controls {
  justify-self: start !important;
  display: inline-grid !important;
  grid-template-columns: 40px 72px 40px !important;
  gap: 8px !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.practice-card .rhythm-strip .metronome-setting-field .number-stepper-button,
.practice-card .rhythm-strip .metronome-setting-field .number-stepper__button {
  width: 40px !important;
  min-width: 40px !important;
  height: 40px !important;
}

.practice-card .rhythm-strip .metronome-setting-field .number-stepper-value,
.practice-card .rhythm-strip .metronome-setting-field .number-stepper__value {
  width: 72px !important;
  min-width: 72px !important;
  max-width: 72px !important;
  height: 40px !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
}

.practice-card--scale .rhythm-strip:has(.metronome-controls-section--exercise.exercise-mode-free) {
  background: rgba(237, 245, 255, 0.62) !important;
  border-color: #cfe0ff !important;
}

.practice-card--scale .rhythm-strip:has(.metronome-controls-section--exercise.exercise-mode-timed) {
  background: rgba(236, 255, 244, 0.62) !important;
  border-color: #c4efd6 !important;
}

.practice-card--scale .rhythm-strip:has(.metronome-controls-section--exercise.exercise-mode-beat-ladder) {
  background: rgba(244, 239, 255, 0.62) !important;
  border-color: #ddd0ff !important;
}

.practice-card--scale .rhythm-strip:has(.metronome-controls-section--exercise.exercise-mode-time-ladder) {
  background: rgba(255, 241, 232, 0.62) !important;
  border-color: #ffd2b7 !important;
}

.practice-card--scale .rhythm-strip:has(.metronome-controls-section--exercise.exercise-mode-streak-goal) {
  background: rgba(255, 248, 216, 0.62) !important;
  border-color: #f4e39b !important;
}

.practice-card .rhythm-strip .metronome-controls-section--exercise.exercise-mode-free .metronome-exercise-grid {
  background: rgba(237, 245, 255, 0.74) !important;
}

.practice-card .rhythm-strip .metronome-controls-section--exercise.exercise-mode-timed .metronome-exercise-grid {
  background: rgba(236, 255, 244, 0.74) !important;
}

.practice-card .rhythm-strip .metronome-controls-section--exercise.exercise-mode-beat-ladder .metronome-exercise-grid {
  background: rgba(244, 239, 255, 0.74) !important;
}

.practice-card .rhythm-strip .metronome-controls-section--exercise.exercise-mode-time-ladder .metronome-exercise-grid {
  background: rgba(255, 241, 232, 0.74) !important;
}

.practice-card .rhythm-strip .metronome-controls-section--exercise.exercise-mode-streak-goal .metronome-exercise-grid {
  background: rgba(255, 248, 216, 0.74) !important;
}

@media (max-width: 900px) {
  .practice-card .rhythm-strip-row--fields .metronome-settings-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important;
  }

  .practice-card .rhythm-strip .metronome-exercise-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important;
  }
}

@media (max-width: 620px) {
  .practice-card .rhythm-strip-row--fields .metronome-settings-grid,
  .practice-card .rhythm-strip .metronome-exercise-grid {
    grid-template-columns: 1fr !important;
  }
}

.practice-card .rhythm-strip .metronome-exercise-grid .metronome-beat-indicator {
  display: none !important;
}

.practice-card .rhythm-strip .metronome-exercise-timer-status,
.practice-card .rhythm-strip .metronome-exercise-ladder-status {
  margin: 0.18rem 0 0 !important;
  font-size: 0.74rem !important;
  color: var(--blue-deep) !important;
  font-weight: 600 !important;
}

.practice-card .rhythm-strip .rhythm-strip-msg {
  margin: 0 !important;
  padding: 0.22rem 0.5rem !important;
  border-radius: var(--radius-sm) !important;
  background: #fff7e0;
  border: 1px solid #f3d585;
  color: #7a4900;
  font-size: 0.78rem;
}

.practice-card .rhythm-strip .rhythm-strip-feedback {
  margin: 0 !important;
  padding: 0.28rem 0.5rem !important;
  border-radius: var(--radius-sm) !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
}

/* ---------- Progress panel ---------- */
.practice-card .progress-panel,
.practice-card .progress-reward-panel {
  margin: 0.2rem 0 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
}

.practice-card .progress-panel .trainer-pill {
  display: none !important;
}

.practice-card .progress-panel .chord-progress-section,
.practice-card .progress-panel .scale-progress-card {
  background: var(--surface-mute) !important;
  border: 1px solid var(--border-soft) !important;
  border-radius: var(--radius) !important;
  padding: 0.5rem 0.6rem !important;
  box-shadow: none !important;
  margin: 0 !important;
}

.practice-card .progress-panel .chord-progress-header,
.practice-card .progress-panel .scale-progress-header {
  align-items: center !important;
  gap: 0.35rem 0.6rem !important;
}

.practice-card .progress-panel .progress-panel-title,
.practice-card .progress-panel .scale-progress-title {
  font-size: 0.86rem !important;
  font-weight: 700 !important;
  color: var(--text-main) !important;
  margin: 0 !important;
}

.practice-card .progress-panel .progress-panel-stat-pill {
  border-radius: 999px !important;
  background: #fff !important;
  border: 1px solid var(--border-soft) !important;
  padding: 0.18rem 0.5rem !important;
  min-height: 28px !important;
  box-shadow: none !important;
}

.practice-card .progress-panel .progress-panel-stat-label {
  font-size: 0.7rem !important;
  color: var(--text-muted) !important;
  font-weight: 600 !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.practice-card .progress-panel .progress-panel-stat-value {
  font-size: 0.82rem !important;
  color: var(--text-main) !important;
  font-weight: 700 !important;
}

.practice-card .progress-panel .chord-progress-toggle,
.practice-card .progress-panel .scale-progress-toggle {
  min-height: 28px !important;
  border-radius: 999px !important;
  font-size: 0.72rem !important;
  padding: 0.1rem 0.6rem !important;
  border: 1px solid var(--border-strong) !important;
  background: #fff !important;
  color: var(--text-main) !important;
  font-weight: 600 !important;
  box-shadow: none !important;
}

.practice-card .progress-panel .chord-progress-toggle-active,
.practice-card .progress-panel .scale-progress-toggle-active {
  background: var(--blue) !important;
  border-color: var(--blue-deep) !important;
  color: #fff !important;
}

.practice-card .chord-progress-column-fill,
.practice-card .chord-progress-bar-fill {
  background: linear-gradient(to top, var(--blue) 0%, var(--purple) 60%, #f0a3d6 100%) !important;
}

/* ---------- Defeat the legacy `.card`/`.trainer-shell` outer styles ---- */
.practice-card.card,
.practice-card.trainer-shell {
  background: var(--surface) !important;
  border-radius: var(--radius-lg) !important;
}

/* Keep Chord Trainer option sets as one horizontal option row. */
.practice-card--chord .control-dock .chord-trainer-controls-secondary .option-chip-group {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 0.22rem !important;
}

.practice-card--chord .control-dock .chord-trainer-controls-secondary .option-chip-group > legend {
  grid-column: 1 / -1 !important;
  margin: 0 !important;
}

.practice-card--chord .control-dock .chord-trainer-controls-secondary .option-chip-group > label {
  min-width: 0 !important;
  width: 100% !important;
  justify-content: center !important;
  padding-left: 0.28rem !important;
  padding-right: 0.28rem !important;
}

/* Keep Scale Trainer hand focus options readable on iPad/mo/* ── Circle of Fifths collapsible toggle ───────────────────────────────────── */

.cof-collapsible {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0 0;
}

.cof-toggle-btn {
  appearance: none;
  background: var(--blue-soft, #eef2ff);
  border: 1px solid var(--blue, #6c8eff);
  border-radius: 6px;
  color: var(--blue-deep, #3a5bd9);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 5px 14px;
  transition: filter 0.12s ease, transform 0.06s ease;
  white-space: nowrap;
}

.cof-toggle-btn:hover {
  filter: brightness(0.95);
}

.cof-toggle-btn:active {
  transform: translateY(1px);
}

/* ── Circle of Fifths ─────────────────────────────────────────────────────── */

.cof-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 0 8px;
}

.cof-svg {
  width: 340px;
  height: 340px;
  display: block;
  overflow: visible;
  /* Light, single shadow — much less heavy than before */
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.18));
}

/* All interactive segments */
.cof-seg {
  cursor: pointer;
}

.cof-seg path {
  transition: fill 0.18s ease;
}

/* Typography for SVG text elements */
.cof-label-major {
  font-family: Georgia, 'Times New Roman', serif;
  pointer-events: none;
  user-select: none;
}

.cof-label-sig {
  font-family: system-ui, sans-serif;
  pointer-events: none;
  user-select: none;
}

.cof-label-minor {
  font-family: system-ui, sans-serif;
  pointer-events: none;
  user-select: none;
}

.cof-center-key {
  font-family: Georgia, 'Times New Roman', serif;
  pointer-events: none;
  user-select: none;
}

.cof-center-relative {
  font-family: system-ui, sans-serif;
  pointer-events: none;
  user-select: none;
}
/* ═══════════════════════════════════════════════════════════════════════════
   NOTATION TRAINER STYLES
   ═══════════════════════════════════════════════════════════════════════════ */

.notation-trainer {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

.notation-trainer-header {
  display: grid;
  gap: 0.5rem;
}

.notation-trainer-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: #1f2937;
}

/* Stage tab bar */
.notation-stage-tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.notation-tab {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.7rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: #475569;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
  min-height: 44px;
}

.notation-tab:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #1f2937;
}

.notation-tab--active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.notation-tab-number {
  font-size: 0.72rem;
  font-weight: 700;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: rgba(0,0,0,0.12);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.notation-tab--active .notation-tab-number {
  background: rgba(255,255,255,0.25);
}

/* Shared settings row */
.notation-shared-settings {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.notation-setting-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: #374151;
  white-space: nowrap;
}

.notation-setting-select {
  font-size: 0.82rem;
  padding: 0.25rem 0.5rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  color: #1f2937;
  cursor: pointer;
  max-width: 220px;
}

/* MIDI activation row */
.notation-midi-row {
  margin-top: 0.25rem;
}

.notation-activate-btn {
  padding: 0.4rem 1rem;
  border: 1.5px solid #2563eb;
  border-radius: 6px;
  background: #fff;
  color: #2563eb;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.notation-activate-btn:hover {
  background: #eff6ff;
}

.notation-midi-active {
  font-size: 0.8rem;
  font-weight: 600;
  color: #166534;
  margin: 0;
}

/* Sub-panel (shared by all trainer stages) */
.notation-panel {
  display: grid;
  gap: 0.6rem;
  min-width: 0;
}

.notation-panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  justify-content: space-between;
}

.notation-panel-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: #1f2937;
}

.notation-score-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.notation-score-text {
  font-size: 0.8rem;
  color: #374151;
}

/* Instruction + hear button row */
.notation-instruction-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.notation-instruction-row .notation-instruction {
  margin: 0;
  flex: 1;
}

.notation-hear-btn {
  padding: 0.3rem 0.75rem;
  border: 1.5px solid #7c3aed;
  border-radius: 5px;
  background: #faf5ff;
  color: #6d28d9;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 36px;
  flex-shrink: 0;
}

.notation-hear-btn:hover {
  background: #ede9fe;
}

/* Staff area */
.notation-staff-area {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  padding: 0.5rem;
  min-height: 160px;
}

.staff-display svg {
  display: block;
}

/* Instructions */
.notation-instruction {
  font-size: 0.9rem;
  color: #374151;
  margin: 0;
}

/* Answer buttons */
.notation-answer-buttons {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.notation-answer-btn {
  min-width: 2.8rem;
  min-height: 44px;
  padding: 0.4rem 0.65rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  font-size: 1rem;
  font-weight: 700;
  color: #1f2937;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.notation-answer-btn:hover:not(.disabled) {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.notation-answer-btn.disabled,
.notation-answer-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Feedback */
.notation-feedback {
  padding: 0.5rem 0.75rem;
  border-radius: 7px;
  font-size: 0.88rem;
  font-weight: 500;
  min-width: 0;
}

.notation-feedback--correct {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.notation-feedback--wrong {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* Buttons */
.notation-next-btn,
.notation-start-btn,
.notation-stop-btn {
  padding: 0.45rem 1.1rem;
  border-radius: 7px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  border: none;
}

.notation-next-btn {
  background: #2563eb;
  color: #fff;
}

.notation-next-btn:hover {
  background: #1d4ed8;
}

.notation-start-btn {
  background: #16a34a;
  color: #fff;
}

.notation-start-btn:hover {
  background: #15803d;
}

.notation-stop-btn {
  background: #dc2626;
  color: #fff;
}

.notation-stop-btn:hover {
  background: #b91c1c;
}

.notation-reset-btn,
.notation-show-btn {
  padding: 0.3rem 0.7rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 5px;
  background: #f8fafc;
  font-size: 0.78rem;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  min-height: 36px;
}

.notation-reset-btn:hover,
.notation-show-btn:hover {
  background: #e2e8f0;
}

/* Speak / read-aloud button — matches hear-btn palette but distinct colour */
.notation-speak-btn {
  padding: 0.3rem 0.75rem;
  border: 1.5px solid #0369a1;
  border-radius: 5px;
  background: #f0f9ff;
  color: #0369a1;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 36px;
  flex-shrink: 0;
}

.notation-speak-btn:hover {
  background: #e0f2fe;
}

/* Feedback row — allows speak button to sit inline with feedback text */
.notation-feedback-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* Keyboard hint */
.notation-keyboard-hint {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 400;
}

/* Hints */
.notation-hint {
  font-size: 0.8rem;
  margin: 0;
  color: #64748b;
}

.notation-hint--muted {
  color: #94a3b8;
}

.notation-hint--ok {
  color: #166534;
}

/* Note Card Trainer */
.note-card-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  min-height: 100px;
  justify-content: center;
}

.note-card-name {
  font-size: clamp(2.5rem, 10vw, 4.5rem);
  font-weight: 800;
  color: #1d4ed8;
  letter-spacing: -0.02em;
  line-height: 1;
}

.notation-staff-reveal {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  padding: 0.5rem;
}

/* Progress row */
.notation-progress-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.notation-progress-text {
  font-size: 0.82rem;
  color: #374151;
}

.notation-accuracy {
  font-size: 0.82rem;
  font-weight: 600;
}

.notation-progress-bar-outer {
  flex: 1;
  min-width: 80px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.notation-progress-bar-fill {
  height: 100%;
  background: #2563eb;
  border-radius: 999px;
  transition: width 0.2s;
}

.notation-expected-hint {
  font-size: 0.8rem;
}

.notation-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* Music Piece Trainer */
.notation-file-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.notation-file-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: #374151;
}

.notation-file-input {
  font-size: 0.82rem;
  color: #374151;
  max-width: 340px;
}

.notation-file-hint {
  font-size: 0.76rem;
}

.notation-loading {
  font-size: 0.84rem;
  color: #64748b;
  font-style: italic;
  margin: 0;
}

.notation-piece-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1f2937;
}

.notation-piece-composer {
  font-size: 0.84rem;
  color: #475569;
}

.notation-osmd-area {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;  /* smooth scroll on iPad */
  min-height: 200px;
}

.osmd-container {
  min-height: 200px;
}

.osmd-error {
  padding: 1rem;
}

.notation-section-controls {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border-radius: 7px;
  border: 1px solid #e2e8f0;
}

.notation-section-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
}

.notation-section-field {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: #374151;
  white-space: nowrap;
}

.notation-number-input {
  width: 4rem;
  padding: 0.2rem 0.4rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 5px;
  font-size: 0.82rem;
  text-align: center;
}

.notation-section-hint {
  font-size: 0.76rem;
}

/* Import warnings */
.notation-warnings {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 7px;
  padding: 0.5rem 0.75rem;
  display: grid;
  gap: 0.35rem;
}

.notation-warnings-list {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.15rem;
}

.notation-warning {
  font-size: 0.8rem;
}

.notation-warning--info  { color: #1e40af; }
.notation-warning--warn  { color: #92400e; }
.notation-warning--error { color: #991b1b; }

.notation-answer-reveal {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-size: 0.88rem;
  color: #1f2937;
  padding: 0.4rem 0.75rem;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 6px;
}

/* iPad responsive */
@media (max-width: 600px) {
  .notation-stage-tabs {
    gap: 0.2rem;
  }

  .notation-tab {
    padding: 0.3rem 0.5rem;
    font-size: 0.78rem;
    min-height: 44px;
  }

  .notation-tab-label {
    display: none;
  }

  .notation-tab-number {
    width: 1.6rem;
    height: 1.6rem;
    font-size: 0.8rem;
  }

  .note-card-name {
    font-size: clamp(2rem, 12vw, 3.5rem);
  }

  .notation-staff-area,
  .notation-osmd-area {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .notation-answer-buttons {
    gap: 0.3rem;
  }

  .notation-answer-btn {
    min-width: 2.4rem;
    font-size: 0.9rem;
  }
}
/* ============================================================
   Profile Customiser — full-page dark overlay (mirrors AdminDashboard style)
   ============================================================ */

.profile-customizer {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  background: #0f1117;
  color: #e2e8f0;
  overflow: hidden;
  font-family: inherit;
}

/* ---- Access denied ---- */
.profile-customizer--denied {
  align-items: center;
  justify-content: center;
}

.profile-customizer__denied-box {
  background: #161b27;
  border: 1px solid #2a3142;
  border-radius: 12px;
  padding: 2rem 2.5rem;
  text-align: center;
  max-width: 360px;
}

.profile-customizer__denied-box p {
  color: #94a3b8;
  margin: 0 0 1.25rem;
}

/* ---- Header ---- */
.profile-customizer__header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: #161b27;
  border-bottom: 1px solid #2a3142;
  flex-shrink: 0;
  min-height: 56px;
}

.profile-customizer__title {
  flex: 1;
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -0.2px;
}

.profile-customizer__header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.profile-customizer__back-btn {
  background: transparent;
  border: 1px solid #3b4252;
  color: #94a3b8;
  border-radius: 6px;
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.profile-customizer__back-btn:hover {
  background: #1e2336;
  color: #e2e8f0;
  border-color: #4a5568;
}

.profile-customizer__save-btn {
  background: #6366f1;
  border: none;
  color: #fff;
  border-radius: 7px;
  padding: 0.4rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

.profile-customizer__save-btn:hover {
  background: #4f46e5;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

.profile-customizer__save-btn:active {
  background: #4338ca;
}

.profile-customizer__saved-badge {
  font-size: 0.82rem;
  font-weight: 600;
  color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 20px;
  padding: 0.2rem 0.7rem;
  animation: pc-fade-in 0.2s ease;
}

@keyframes pc-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Body ---- */
.profile-customizer__body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.5rem 3rem;
}

.profile-customizer__hint {
  font-size: 0.875rem;
  color: #64748b;
  margin: 0 0 1.25rem;
}

/* ---- Table wrapper ---- */
.profile-customizer__table-wrapper {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid #1e2336;
}

/* ---- Table ---- */
.profile-customizer__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  table-layout: auto;
  min-width: 420px;
}

/* ---- Header row ---- */
.profile-customizer__th {
  background: #161b27;
  padding: 0;
  border-bottom: 2px solid #2a3142;
  font-weight: 600;
  text-align: center;
  vertical-align: top;
  white-space: nowrap;
}

.profile-customizer__th--component {
  text-align: left;
  padding: 0.85rem 1.1rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  width: 200px;
  min-width: 160px;
}

.profile-customizer__th--profile {
  min-width: 120px;
  padding: 0.6rem 0.75rem 0.5rem;
  border-left: 1px solid #1e2336;
}

/* ---- Profile column header ---- */
.profile-customizer__profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
}

.profile-customizer__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}

.profile-customizer__profile-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #e2e8f0;
}

.profile-customizer__col-actions {
  display: flex;
  gap: 0.3rem;
  justify-content: center;
  padding-bottom: 0.25rem;
}

.profile-customizer__col-action-btn {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  border-radius: 10px;
  padding: 0.12rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  line-height: 1.6;
}

.profile-customizer__col-action-btn:hover {
  background: rgba(99, 102, 241, 0.25);
  color: #c7d2fe;
}

.profile-customizer__col-action-btn--none {
  background: rgba(100, 116, 139, 0.1);
  border-color: rgba(100, 116, 139, 0.25);
  color: #64748b;
}

.profile-customizer__col-action-btn--none:hover {
  background: rgba(100, 116, 139, 0.2);
  color: #94a3b8;
}

/* ---- Data rows ---- */
.profile-customizer__row {
  background: #13161f;
  transition: background 0.1s;
}

.profile-customizer__row:hover {
  background: #181d2c;
}

.profile-customizer__row--alt {
  background: #0f1117;
}

.profile-customizer__row--alt:hover {
  background: #131723;
}

.profile-customizer__td {
  padding: 0;
  border-top: 1px solid #1a1e2e;
}

.profile-customizer__td--label {
  padding: 0.7rem 1.1rem;
  text-align: left;
  color: #cbd5e1;
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
}

.profile-customizer__td--toggle {
  text-align: center;
  vertical-align: middle;
  border-left: 1px solid #1a1e2e;
  padding: 0.5rem 0.75rem;
}

/* ---- Toggle switch (pill-style) ---- */
.profile-customizer__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #1e2336;
  border: 1px solid #2e3650;
  border-radius: 999px;
  padding: 0.2rem 0.5rem 0.2rem 0.3rem;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
  white-space: nowrap;
  min-width: 64px;
  justify-content: flex-start;
}

.profile-customizer__toggle:hover {
  border-color: #3b4a6b;
}

.profile-customizer__toggle:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

.profile-customizer__toggle--on {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.5);
}

.profile-customizer__toggle--on:hover {
  background: rgba(99, 102, 241, 0.26);
  border-color: rgba(99, 102, 241, 0.7);
}

.profile-customizer__toggle-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #3b4252;
  flex-shrink: 0;
  transition: background 0.18s, transform 0.18s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}

.profile-customizer__toggle--on .profile-customizer__toggle-thumb {
  background: #6366f1;
  transform: none;
}

.profile-customizer__toggle-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #4a5568;
  text-transform: uppercase;
  transition: color 0.18s;
  min-width: 22px;
  text-align: left;
}

.profile-customizer__toggle--on .profile-customizer__toggle-label {
  color: #a5b4fc;
}
/* ============================================================
   Admin Dashboard — full-page dark overlay
   ============================================================ */

.admin-dashboard {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  background: #0f1117;
  color: #e2e8f0;
  overflow: hidden;
  font-family: inherit;
}

/* ---- Header ---- */
.admin-dashboard__header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: #161b27;
  border-bottom: 1px solid #2a3142;
  flex-shrink: 0;
  min-height: 56px;
}

.admin-dashboard__header-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.admin-dashboard__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: 0.01em;
}

.admin-dashboard__header-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  background: #1e3a5f;
  color: #93c5fd;
  border: 1px solid #2563eb44;
  white-space: nowrap;
}

.admin-dashboard__header-spacer {
  width: 80px; /* mirror back button width for centering */
  flex-shrink: 0;
}

.admin-dashboard__back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  border: 1px solid #2a3142;
  background: #1e2433;
  color: #94a3b8;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.admin-dashboard__back-btn:hover {
  background: #252d40;
  color: #e2e8f0;
  border-color: #3b4a63;
}

.admin-dashboard__back-btn:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* ---- Scrollable body ---- */
.admin-dashboard__body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem clamp(0.75rem, 3vw, 1.75rem) 2.5rem;
  display: grid;
  gap: 1.75rem;
}

/* ---- Section ---- */
.admin-dashboard__section {
  display: grid;
  gap: 0.75rem;
}

.admin-dashboard__section-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #64748b;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #1e2433;
}

/* ---- Cards ---- */
.admin-dashboard__card {
  background: #161b27;
  border: 1px solid #2a3142;
  border-radius: 10px;
  overflow: hidden;
}

.admin-dashboard__card--flush {
  /* inner components own their own padding */
}

.admin-dashboard__card--flush > * {
  /* let child panels breathe a little */
  padding: 0.75rem 1rem;
}

.admin-dashboard__card--collapsible {
  /* no extra padding — toggle does it */
}

/* ---- Collapse toggle ---- */
.admin-dashboard__collapse-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-size: 0.92rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.admin-dashboard__collapse-toggle:hover {
  background: #1e2433;
  color: #f1f5f9;
}

.admin-dashboard__collapse-toggle:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
}

.admin-dashboard__chevron {
  font-size: 0.75rem;
  color: #475569;
  flex-shrink: 0;
}

/* ---- Definition list ---- */
.admin-dashboard__dl {
  margin: 0;
  padding: 0 1rem 0.85rem;
  display: grid;
  gap: 0.3rem;
}

.admin-dashboard__dl-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid #1e2433;
  font-size: 0.85rem;
}

.admin-dashboard__dl-row:last-child {
  border-bottom: none;
}

.admin-dashboard__dl-row dt {
  color: #94a3b8;
  flex-shrink: 0;
}

.admin-dashboard__dl-row dd {
  margin: 0;
  color: #e2e8f0;
  text-align: right;
}

/* ---- Music data grid ---- */
.admin-dashboard__music-grid {
  padding: 0 1rem 0.85rem;
  display: grid;
  gap: 0;
}

.admin-dashboard__music-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid #1e2433;
  font-size: 0.85rem;
  color: #94a3b8;
}

.admin-dashboard__music-row:last-child {
  border-bottom: none;
}

.admin-dashboard__music-row--full {
  flex-direction: column;
  gap: 0.2rem;
  align-items: flex-start;
}

.admin-dashboard__value {
  color: #e2e8f0;
  font-weight: 500;
  text-align: right;
}

.admin-dashboard__mono {
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;
  font-size: 0.82rem;
  color: #a5b4fc;
}

/* ---- Lab body ---- */
.admin-dashboard__lab-body {
  padding: 0 1rem 1rem;
}

/* ---- Access denied ---- */
.admin-dashboard--denied {
  display: grid;
  place-items: center;
}

.admin-dashboard__denied-box {
  background: #161b27;
  border: 1px solid #2a3142;
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  display: grid;
  gap: 1rem;
  color: #94a3b8;
}

/* ---- Child components: override colours for dark bg ---- */
.admin-dashboard .sync-status-panel,
.admin-dashboard .sync-prep-panel,
.admin-dashboard .progress-backup-panel {
  color: #e2e8f0;
}

/* ---- Ensure inner cards/sections don't double-border ---- */
.admin-dashboard__card--flush .card {
  border: none;
  background: transparent;
  padding: 0;
  box-shadow: none;
}

/* ---- Scrollbar ---- */
.admin-dashboard__body::-webkit-scrollbar {
  width: 6px;
}
.admin-dashboard__body::-webkit-scrollbar-track {
  background: #0f1117;
}
.admin-dashboard__body::-webkit-scrollbar-thumb {
  background: #2a3142;
  border-radius: 3px;
}
.admin-dashboard__body::-webkit-scrollbar-thumb:hover {
  background: #3b4a63;
}

/* ---- Responsive ---- */
@media (min-width: 720px) {
  .admin-dashboard__body {
    max-width: 960px;
    margin-inline: auto;
    width: 100%;
  }
}

/* ---- Admin access button (in welcome panel) ---- */
.admin-access-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  border: 1px solid rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.admin-access-btn:hover {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(99, 102, 241, 0.55);
  color: #a5b4fc;
}

.admin-access-btn:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}
