.tfl-satb-app,
.tfl-satb-app * {
  box-sizing: border-box;
}

.tfl-satb-app {
  --tfl-satb-bg: #f6f7fb;
  --tfl-satb-card: #ffffff;
  --tfl-satb-text: #142033;
  --tfl-satb-muted: #667085;
  --tfl-satb-line: #e5e7ef;
  --tfl-satb-accent: #2547d0;
  --tfl-satb-accent-soft: #eef2ff;
  --tfl-satb-good: #0f7a4f;
  --tfl-satb-bad: #b42318;
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
  color: var(--tfl-satb-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.tfl-satb-header {
  margin: 6px 0 16px;
  text-align: left;
}

.tfl-satb-header h2 {
  margin: 0 0 6px;
  font-size: clamp(26px, 5vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.tfl-satb-header p {
  margin: 0;
  color: var(--tfl-satb-muted);
  font-size: 15px;
}

.tfl-satb-loading,
.tfl-satb-error,
.tfl-satb-card {
  border-radius: 22px;
  padding: 18px;
  background: var(--tfl-satb-card);
  box-shadow: 0 12px 34px rgba(17, 24, 39, 0.08);
  border: 1px solid rgba(229, 231, 239, 0.8);
  margin: 0 0 14px;
}

.tfl-satb-error {
  color: var(--tfl-satb-bad);
}

.tfl-satb-card h3 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.tfl-satb-card p {
  margin: 0;
  color: var(--tfl-satb-muted);
  line-height: 1.45;
}

.tfl-satb-level-grid {
  display: grid;
  gap: 10px;
}

.tfl-satb-level-button,
.tfl-satb-chip,
.tfl-satb-voice-toggle,
.tfl-satb-option,
.tfl-satb-secondary,
.tfl-satb-nav,
.tfl-satb-main-play {
  appearance: none;
  border: 1px solid var(--tfl-satb-line);
  background: #fff;
  color: var(--tfl-satb-text);
  border-radius: 16px;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
  text-align: center;
}

.tfl-satb-level-button:hover,
.tfl-satb-chip:hover,
.tfl-satb-voice-toggle:hover,
.tfl-satb-option:hover,
.tfl-satb-secondary:hover,
.tfl-satb-nav:hover,
.tfl-satb-main-play:hover {
  transform: translateY(-1px);
  border-color: rgba(37, 71, 208, 0.45);
}

.tfl-satb-is-active,
.tfl-satb-option.tfl-satb-is-active,
.tfl-satb-chip.tfl-satb-is-active,
.tfl-satb-voice-toggle.tfl-satb-is-active,
.tfl-satb-level-button.tfl-satb-is-active {
  color: var(--tfl-satb-accent);
  background: var(--tfl-satb-accent-soft);
  border-color: rgba(37, 71, 208, 0.35);
}

.tfl-satb-main-play {
  width: 100%;
  min-height: 58px;
  border-radius: 999px;
  background: var(--tfl-satb-accent);
  color: #fff;
  border-color: var(--tfl-satb-accent);
  font-size: 18px;
  box-shadow: 0 12px 28px rgba(37, 71, 208, 0.22);
}

.tfl-satb-main-play:hover {
  border-color: var(--tfl-satb-accent);
}

.tfl-satb-step-meta,
.tfl-satb-mode-pill,
.tfl-satb-section-label,
.tfl-satb-toggle-label {
  color: var(--tfl-satb-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.tfl-satb-presets,
.tfl-satb-toggle-group {
  margin-top: 16px;
}

.tfl-satb-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tfl-satb-chip {
  min-height: 38px;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
}

.tfl-satb-voice-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.tfl-satb-voice-toggle {
  min-height: 62px;
  padding: 8px 6px;
}

.tfl-satb-voice-toggle span {
  display: block;
  font-size: 20px;
  line-height: 1;
}

.tfl-satb-voice-toggle small {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  color: inherit;
  opacity: 0.78;
}

.tfl-satb-notation-card {
  padding: 10px;
  overflow: hidden;
}

.tfl-satb-notation-target {
  width: 100%;
  overflow-x: auto;
}


.tfl-satb-notation-hint {
  margin: 0 4px 8px;
  color: var(--tfl-satb-muted);
  font-size: 13px;
  line-height: 1.35;
}

.tfl-satb-svg-row {
  cursor: pointer;
}

.tfl-satb-row-hit {
  fill: transparent;
  stroke: transparent;
}

.tfl-satb-svg-row:hover .tfl-satb-row-hit,
.tfl-satb-svg-row:focus .tfl-satb-row-hit {
  fill: rgba(37, 71, 208, 0.04);
  stroke: rgba(37, 71, 208, 0.12);
}

.tfl-satb-row-visible .tfl-satb-svg-label {
  fill: var(--tfl-satb-accent);
}

.tfl-satb-notation-svg {
  display: block;
  width: 100%;
  min-width: 320px;
  height: auto;
}

.tfl-satb-svg-bg {
  fill: #fbfcff;
}

.tfl-satb-staff-line {
  stroke: #d7dce8;
  stroke-width: 1;
}

.tfl-satb-bar-line {
  stroke: #c7cedd;
  stroke-width: 1;
}

.tfl-satb-svg-label {
  fill: var(--tfl-satb-text);
  font-weight: 800;
  font-size: 20px;
}

.tfl-satb-hidden-overlay {
  fill: rgba(246, 247, 251, 0.86);
  stroke: #e5e7ef;
}

.tfl-satb-hidden-text {
  fill: var(--tfl-satb-muted);
  font-size: 13px;
  font-weight: 650;
}

.tfl-satb-note-duration {
  stroke: var(--tfl-satb-accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  opacity: 0.28;
}


.tfl-satb-clef {
  fill: #334155;
  font-family: "Times New Roman", "DejaVu Serif", serif;
  font-size: 34px;
  opacity: 0.88;
}

.tfl-satb-clef-bass {
  font-size: 31px;
}

.tfl-satb-ledger-line {
  stroke: #c7cedd;
  stroke-width: 1.15;
  stroke-linecap: round;
}

.tfl-satb-stem {
  stroke: var(--tfl-satb-accent);
  stroke-width: 1.7;
  stroke-linecap: round;
  opacity: 0.9;
}

.tfl-satb-note-open {
  fill: #fff;
  stroke: var(--tfl-satb-accent);
  stroke-width: 2;
}

.tfl-satb-note-hole {
  fill: #fbfcff;
  pointer-events: none;
}

.tfl-satb-accidental {
  fill: var(--tfl-satb-muted);
  font-family: "Times New Roman", "DejaVu Serif", serif;
  font-size: 18px;
  font-weight: 700;
}

.tfl-satb-note-head {
  fill: var(--tfl-satb-accent);
  stroke: #fff;
  stroke-width: 1.5;
}

.tfl-satb-note-ornament {
  stroke-dasharray: 3 4;
  opacity: 0.78;
}

.tfl-satb-note-head.tfl-satb-note-ornament {
  fill: #6b7cff;
}

.tfl-satb-ornament-dot {
  fill: #f59e0b;
}

.tfl-satb-note-name {
  fill: var(--tfl-satb-muted);
  font-size: 11px;
  font-weight: 650;
}

.tfl-satb-options {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.tfl-satb-option {
  text-align: left;
  padding-left: 16px;
}

.tfl-satb-task-actions,
.tfl-satb-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 14px;
}

.tfl-satb-secondary {
  background: #f8fafc;
}

.tfl-satb-result {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 800;
}

.tfl-satb-result-correct {
  color: var(--tfl-satb-good);
  background: #ecfdf3;
}

.tfl-satb-result-wrong {
  color: var(--tfl-satb-bad);
  background: #fff1f1;
}

.tfl-satb-analysis {
  margin-top: 14px;
  border-top: 1px solid var(--tfl-satb-line);
  padding-top: 14px;
}

.tfl-satb-analysis h4 {
  margin: 0 0 8px;
  font-size: 16px;
}

.tfl-satb-analysis p + p {
  margin-top: 8px;
}

.tfl-satb-bottom-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  padding: 10px;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(229, 231, 239, 0.9);
  border-radius: 22px;
  box-shadow: 0 -8px 26px rgba(17, 24, 39, 0.08);
  backdrop-filter: blur(10px);
}

.tfl-satb-nav:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.tfl-satb-debug {
  margin-top: 14px;
  font-size: 12px;
  color: var(--tfl-satb-muted);
}

.tfl-satb-debug pre {
  overflow-x: auto;
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 12px;
}

@media (min-width: 720px) {
  .tfl-satb-app {
    padding: 24px;
  }

  .tfl-satb-level-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tfl-satb-controls-card {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) 1.2fr;
    gap: 18px;
    align-items: start;
  }

  .tfl-satb-controls-card .tfl-satb-presets {
    margin-top: 0;
  }

  .tfl-satb-controls-card .tfl-satb-toggle-group {
    grid-column: span 2;
  }

  .tfl-satb-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .tfl-satb-app {
    padding: 10px;
  }

  .tfl-satb-card {
    border-radius: 18px;
    padding: 14px;
  }

  .tfl-satb-voice-grid {
    gap: 6px;
  }

  .tfl-satb-voice-toggle {
    min-height: 56px;
  }

  .tfl-satb-bottom-bar {
    grid-template-columns: 1fr 1.2fr 1fr;
    gap: 6px;
    padding: 8px;
  }

  .tfl-satb-nav {
    font-size: 13px;
    padding: 8px 6px;
  }
}

.tfl-satb-task-hint {
  margin: 8px 0 12px;
  color: var(--tfl-satb-muted);
  font-size: 14px;
  line-height: 1.45;
}

.tfl-satb-play-task {
  width: 100%;
  justify-content: center;
  margin: 6px 0 4px;
}


/* v1.5 guided wizard */
.tfl-satb-compact-header {
  margin-bottom: 10px;
}

.tfl-satb-compact-header h2 {
  font-size: clamp(22px, 6vw, 34px);
}

.tfl-satb-wizard-card {
  padding: 18px;
}

.tfl-satb-wizard-dots {
  display: flex;
  gap: 7px;
  margin-bottom: 14px;
}

.tfl-satb-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--tfl-satb-line);
}

.tfl-satb-dot-current {
  width: 26px;
  background: var(--tfl-satb-accent);
}

.tfl-satb-dot-done {
  background: rgba(37, 71, 208, 0.35);
}

.tfl-satb-wizard-play {
  margin-top: 18px;
}

.tfl-satb-wizard-feedback {
  margin-top: 14px;
  padding: 13px 14px;
  border-radius: 16px;
  color: var(--tfl-satb-good);
  background: #ecfdf3;
  font-weight: 750;
  line-height: 1.35;
}

.tfl-satb-wizard-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 9px;
  margin-top: 14px;
}

.tfl-satb-primary-next {
  background: var(--tfl-satb-accent);
  border-color: var(--tfl-satb-accent);
  color: #fff;
}

.tfl-satb-primary-next:disabled {
  background: #eef2ff;
  border-color: #e5e7ef;
  color: var(--tfl-satb-muted);
}

.tfl-satb-link-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--tfl-satb-accent);
  font: inherit;
  font-weight: 700;
  padding: 10px 4px 0;
  cursor: pointer;
  text-align: center;
  width: 100%;
}

.tfl-satb-task-inner h3 {
  margin-top: 0;
}

.tfl-satb-notation-compact {
  padding: 8px;
}

.tfl-satb-notation-compact .tfl-satb-notation-hint {
  font-size: 12px;
  margin-bottom: 6px;
}

@media (max-width: 520px) {
  .tfl-satb-app {
    padding: 8px;
  }

  .tfl-satb-loading,
  .tfl-satb-error,
  .tfl-satb-card {
    border-radius: 18px;
    padding: 14px;
    margin-bottom: 10px;
  }

  .tfl-satb-wizard-card h3 {
    font-size: 20px;
  }

  .tfl-satb-wizard-card p {
    font-size: 15px;
  }

  .tfl-satb-level-card {
    padding: 12px;
  }

  .tfl-satb-level-card h3 {
    font-size: 16px;
  }

  .tfl-satb-level-grid {
    gap: 7px;
  }

  .tfl-satb-level-button {
    min-height: 38px;
    font-size: 13px;
    padding: 8px;
  }

  .tfl-satb-main-play {
    min-height: 54px;
    font-size: 17px;
  }

  .tfl-satb-options {
    gap: 8px;
  }

  .tfl-satb-option {
    min-height: 42px;
    padding: 9px 12px;
  }

  .tfl-satb-actions-row {
    margin-top: 8px;
  }
}

.tfl-satb-teacher-feedback {
  margin-top: 14px;
  padding: 14px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid var(--tfl-satb-line);
}

.tfl-satb-teacher-feedback h4 {
  margin: 0 0 7px;
  font-size: 14px;
  color: var(--tfl-satb-text);
}

.tfl-satb-teacher-feedback p {
  margin: 0;
  color: var(--tfl-satb-muted);
  line-height: 1.45;
}

.tfl-satb-teacher-feedback p + p {
  margin-top: 8px;
}

.tfl-satb-teacher-hint {
  font-weight: 650;
}

.tfl-satb-listen-hint {
  width: 100%;
  margin-top: 10px;
}

/* v2.1 curriculum selection */
.tfl-satb-theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.tfl-satb-theme-button {
  appearance: none;
  border: 1px solid var(--tfl-satb-line);
  background: #fff;
  border-radius: 18px;
  padding: 14px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 142px;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.tfl-satb-theme-button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(37, 71, 208, .35);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .08);
}

.tfl-satb-theme-button.tfl-satb-is-disabled {
  opacity: .58;
  cursor: not-allowed;
  background: #f8fafc;
}

.tfl-satb-theme-title {
  font-weight: 850;
  color: var(--tfl-satb-text);
  font-size: 16px;
  line-height: 1.2;
}

.tfl-satb-theme-description {
  color: var(--tfl-satb-muted);
  font-size: 13px;
  line-height: 1.35;
  flex: 1;
}

.tfl-satb-theme-status {
  align-self: flex-start;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 800;
  color: var(--tfl-satb-accent);
  background: #eef2ff;
}

.tfl-satb-is-disabled .tfl-satb-theme-status {
  color: var(--tfl-satb-muted);
  background: #e5e7eb;
}

.tfl-satb-selection-subtitle {
  color: var(--tfl-satb-muted);
  margin-top: -4px;
}

.tfl-satb-level-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
}

.tfl-satb-level-button strong {
  font-size: 15px;
}

.tfl-satb-level-button small {
  color: var(--tfl-satb-muted);
  line-height: 1.35;
  font-size: 12px;
}

.tfl-satb-level-button span {
  font-weight: 800;
  color: var(--tfl-satb-accent);
  font-size: 12px;
}

.tfl-satb-link-left {
  width: auto;
  text-align: left;
  padding: 0 0 8px;
}

.tfl-satb-link-compact {
  font-size: 13px;
  padding-top: 4px;
}

@media (max-width: 520px) {
  .tfl-satb-theme-grid {
    grid-template-columns: 1fr;
  }

  .tfl-satb-theme-button {
    min-height: 110px;
    padding: 12px;
  }
}
