/* Chord trainer — Apple-like shell + diagram + build fretboard */

.trainer-hidden {
  display: none !important;
}

.trainer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.trainer-controls label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-right: 6px;
}

.trainer-seg {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 2px;
  background: var(--surface-2);
  border-radius: 8px;
  gap: 2px;
}
.trainer-seg--difficulty button {
  flex: 0 1 auto;
}
.trainer-seg button {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.trainer-seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Per-game score strip inside each mode panel */
.panel-game-hud {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0 0 16px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  line-height: 1.4;
}

#game-toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  transform: translateX(-50%) translateY(12px);
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 0.9375rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}
#game-toast.game-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#game-toast.game-toast--ok {
  background: #e8f5e9;
  color: #1b5e20;
}
#game-toast.game-toast--bad {
  background: #ffebee;
  color: #b71c1c;
}

/* Name mode */
.name-quiz-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Chord choices + Skip on one row (Name Game) */
.name-mc-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  width: 100%;
  align-self: stretch;
}

.name-mc-row #name-mc-wrap {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
}

.name-mc-row .trainer-actions--name-skip {
  flex: 0 0 auto;
  width: auto;
  margin-top: 0;
  justify-content: center;
}

#name-diagram-wrap {
  min-height: calc(200px * var(--trainer-mini-scale, 1.7) + 16px);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px 10px;
  box-sizing: border-box;
  overflow: visible;
}

.name-game-instructions {
  margin: 8px 0 0;
  padding: 0 8px;
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text-secondary);
  text-align: center;
}

.name-game-instructions strong {
  color: var(--text);
  font-weight: 600;
}

/* Reserves layout space so a scaled diagram doesn’t overlap the MC grid */
.trainer-mini-outer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: calc(152px * var(--trainer-mini-scale, 1.7));
  min-height: calc(200px * var(--trainer-mini-scale, 1.7));
  margin: 4px auto;
}

/* Mini diagram (DOM from trainer.js)
   String centers in JS: 15, 40, 65, 90px; each string is 2px with margin-left -1 → outer span 14–91.
   Nut + fret wires match that span only (no bleed past G/A). Scaled via --trainer-mini-scale. */
.trainer-mini-wrap {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin-top: 0;
  transform: scale(var(--trainer-mini-scale, 1.7));
  transform-origin: center center;
  /* Sharper edges when scaled (reduces soft/blurry look in some browsers) */
  backface-visibility: hidden;
}
/* Card: padding keeps fret numbers, open O, and G C E A labels inside the border */
.trainer-mini-fretboard {
  position: relative;
  display: inline-block;
  vertical-align: top;
  box-sizing: border-box;
  padding: 24px 12px 30px 10px;
  background: linear-gradient(180deg, #fafafa 0%, #ececec 100%);
  border: 1px solid rgba(60, 60, 67, 0.35);
  border-radius: 8px;
  overflow: visible;
}
/* 106×130 grid — all diagram geometry stays relative to this box */
.trainer-mini-fretboard-inner {
  position: relative;
  width: 106px;
  height: 130px;
  overflow: visible;
}
.trainer-mini-nut {
  position: absolute;
  width: 77px;
  height: 4px;
  background: #0d0d0d;
  top: 10px;
  left: 14px;
  border-radius: 1px;
}
.trainer-mini-string {
  position: absolute;
  width: 2px;
  height: 116px;
  margin-left: -1px;
  background: #3a3a3c;
  top: 14px;
  z-index: 2;
}
.trainer-mini-fret-line {
  position: absolute;
  width: 77px;
  height: 2px;
  background: #636366;
  left: 14px;
  z-index: 1;
}
.trainer-mini-fret-num {
  position: absolute;
  left: 0;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-secondary);
  width: 12px;
  text-align: right;
}
.trainer-mini-fret-num--position {
  color: #ff2d2d;
  font-weight: 800;
  font-size: 10px;
}
.trainer-mini-label {
  position: absolute;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-secondary);
  transform: translateX(-50%);
  bottom: -18px;
}
.trainer-mini-open {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid #0d0d0d;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  /* Open O above the nut; less negative = closer to the nut */
  top: -1px;
  background: var(--surface);
  box-sizing: border-box;
}
.trainer-mini-dot {
  position: absolute;
  width: 22px;
  height: 22px;
  background: #1d1d1f;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
}

/* Barre (same idea as index.html createChordDiagramForVoicing — drawn under dots) */
.trainer-mini-barre {
  position: absolute;
  height: 20px;
  box-sizing: border-box;
  padding-top: 2px;
  line-height: 1;
  background: #1d1d1f;
  border-radius: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

/* Name-the-chord MC: one row of four options */
#name-mc-wrap {
  width: 100%;
  max-width: 100%;
  align-self: stretch;
}

.mc-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  max-width: 100%;
}
.mc-grid button {
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 10px 6px;
  border: 1px solid rgba(36, 140, 62, 0.28);
  border-radius: var(--radius-sm);
  background: rgba(52, 199, 89, 0.1);
  color: var(--text);
  cursor: pointer;
  min-height: 42px;
  min-width: 0;
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s, border-color 0.12s;
}
.mc-grid button:hover {
  background: rgba(52, 199, 89, 0.18);
  border-color: rgba(36, 140, 62, 0.45);
}
.mc-grid button:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Name-the-chord: keep wrong picks visibly marked until the round advances */
#name-mc-grid button.mc-wrong-chosen {
  background: rgba(255, 59, 48, 0.14);
  border-color: #ff3b30;
  color: #b00020;
}
#name-mc-grid button.mc-wrong-chosen:hover {
  background: rgba(255, 59, 48, 0.22);
  border-color: #ff3b30;
}
#name-mc-grid button.mc-wrong-chosen:disabled {
  opacity: 1;
  cursor: default;
}

/* Skip: show which choice was correct before the next puzzle */
#name-mc-grid button.mc-reveal-correct {
  background: rgba(46, 125, 50, 0.2);
  border-color: #2e7d32;
  color: #1b5e20;
}
#name-mc-grid button.mc-reveal-correct:hover {
  background: rgba(46, 125, 50, 0.28);
  border-color: #2e7d32;
}
#name-mc-grid button.mc-reveal-correct:disabled {
  opacity: 1;
  cursor: default;
}

.name-pool-empty {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-align: center;
  padding: 16px;
}

.trainer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 8px;
}

/* Skip — subtle red in both games */
#name-skip-btn.trainer-skip-btn,
#build-skip-btn.trainer-skip-btn {
  background: rgba(255, 59, 48, 0.12);
  border-color: rgba(255, 59, 48, 0.42);
  color: #b00020;
}
#name-skip-btn.trainer-skip-btn:hover,
#build-skip-btn.trainer-skip-btn:hover {
  background: rgba(255, 59, 48, 0.2);
  border-color: rgba(255, 59, 48, 0.55);
  color: #8b0000;
}

.trainer-actions button.secondary {
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  line-height: 1.25;
}
#build-clear-btn {
  background: rgba(52, 199, 89, 0.14);
  border-color: rgba(36, 140, 62, 0.4);
  color: #1b5e20;
}
#build-clear-btn:hover {
  background: rgba(52, 199, 89, 0.24);
  border-color: rgba(36, 140, 62, 0.52);
  color: #145214;
}

#build-hint-btn {
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  background: rgba(255, 193, 7, 0.2);
  border-color: rgba(200, 150, 0, 0.45);
  color: #7a5f00;
}
#build-hint-btn:hover {
  background: rgba(255, 193, 7, 0.32);
  border-color: rgba(180, 130, 0, 0.55);
  color: #5c4800;
}

/* Mode banners (The Dot Plot, The Name Game) */
.dot-plot-banner,
.name-game-banner {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 0 0 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Name Game panel — subtle blue-tinted card (matches app accent) */
#panel-name.panel {
  background: linear-gradient(165deg, #f7faff 0%, #f0f6ff 48%, #e8f2fc 100%);
  border-color: rgba(0, 113, 227, 0.16);
  box-shadow: 0 1px 4px rgba(0, 113, 227, 0.08);
}

/* Diagram Driller panel — subtle yellow-tinted card */
#panel-driller.panel {
  background: linear-gradient(165deg, #fffdf5 0%, #fff9e8 45%, #fff3d6 100%);
  border-color: rgba(200, 160, 0, 0.22);
  box-shadow: 0 1px 4px rgba(200, 150, 0, 0.1);
}

/* The Dot Plot panel — subtle pink-tinted card */
#panel-build.panel {
  background: linear-gradient(165deg, #fff8fb 0%, #fff0f5 45%, #ffe8f2 100%);
  border-color: rgba(200, 90, 130, 0.2);
  box-shadow: 0 1px 4px rgba(200, 80, 120, 0.09);
}

/* Mode tabs — selected tab uses the same tint as its panel */
#trainer-main .mode-switch #mode-name[aria-pressed="true"] {
  background: linear-gradient(165deg, #f7faff 0%, #f0f6ff 48%, #e8f2fc 100%);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 113, 227, 0.12), 0 0 0 1px rgba(0, 113, 227, 0.14);
}

#trainer-main .mode-switch #mode-driller[aria-pressed="true"] {
  background: linear-gradient(165deg, #fffdf5 0%, #fff9e8 45%, #fff3d6 100%);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(200, 150, 0, 0.12), 0 0 0 1px rgba(200, 160, 0, 0.2);
}

#trainer-main .mode-switch #mode-build[aria-pressed="true"] {
  background: linear-gradient(165deg, #fff8fb 0%, #fff0f5 45%, #ffe8f2 100%);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(200, 80, 120, 0.1), 0 0 0 1px rgba(200, 90, 130, 0.18);
}

/* Build mode (The Dot Plot) */
.build-prompt {
  text-align: center;
  margin-bottom: 12px;
}

.dot-plot-instructions {
  margin: 0 auto 10px;
  padding: 0 8px;
  max-width: 36rem;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text-secondary);
  text-align: center;
}

.dot-plot-instructions strong {
  color: var(--text);
  font-weight: 600;
}

.build-prompt .build-target {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-top: 0;
  /* Keep chord title clear of open-string row (indicators use negative top on the diagram). */
  margin-bottom: 4px;
}

.build-fretboard-shell {
  position: relative;
  width: min(452px, 100%);
  max-width: 100%;
  margin: 0 auto 4px;
  /* Right: fret numbers sit outside the neck + large finger dots on A string bleed past the string */
  padding-right: 56px;
  /* Left: G open-indicator + large finger dots on the 4th string from the nut side */
  padding-left: 36px;
  /* Top: open indicators sit ~56px above the nut; this absorbs them */
  padding-top: 64px;
  /* Bottom: large finger dots use translate(-50%,-50%); keep last-fret dots inside the shell */
  padding-bottom: 28px;
  box-sizing: border-box;
}

.build-chord-diagram {
  position: relative;
  /* vw slack must include wrap + panel + shell horizontal padding (see mobile comment) */
  --fb-w: min(400px, calc(100vw - 172px));
  width: var(--fb-w);
  height: calc(var(--fb-w) * 3.5);
  margin: 0 auto;
}

.build-chord-diagram .nut {
  width: 100%;
  height: 6px;
  background: #d1d1d6;
  border-radius: 2px;
  margin-bottom: 0;
}

.build-chord-diagram .fretboard-vertical {
  position: relative;
  width: 100%;
  height: calc(var(--fb-w) * 3.25);
  background: linear-gradient(180deg, #f5f5f7 0%, #e8e8ed 100%);
  border: 1px solid var(--border);
  border-top: none;
  box-sizing: border-box;
  cursor: pointer;
  border-radius: 0 0 8px 8px;
}

.build-chord-diagram .string-vertical {
  position: absolute;
  width: 2px;
  height: 100%;
  background: #aeaeb2;
  z-index: 2;
}
.build-chord-diagram .string-vertical:nth-child(1) { left: 0; }
.build-chord-diagram .string-vertical:nth-child(2) { left: 33.33%; }
.build-chord-diagram .string-vertical:nth-child(3) { left: 66.66%; }
.build-chord-diagram .string-vertical:nth-child(4) { left: calc(100% - 2px); }

.build-chord-diagram .fret-horizontal {
  position: absolute;
  width: 100%;
  height: 2px;
  background: #c7c7cc;
  z-index: 1;
}
.build-chord-diagram .fret-horizontal:nth-child(5) { top: 8.33%; }
.build-chord-diagram .fret-horizontal:nth-child(6) { top: 16.66%; }
.build-chord-diagram .fret-horizontal:nth-child(7) { top: 25%; }
.build-chord-diagram .fret-horizontal:nth-child(8) { top: 33.33%; }
.build-chord-diagram .fret-horizontal:nth-child(9) { top: 41.66%; }
.build-chord-diagram .fret-horizontal:nth-child(10) { top: 50%; }
.build-chord-diagram .fret-horizontal:nth-child(11) { top: 58.33%; }
.build-chord-diagram .fret-horizontal:nth-child(12) { top: 66.66%; }
.build-chord-diagram .fret-horizontal:nth-child(13) { top: 75%; }
.build-chord-diagram .fret-horizontal:nth-child(14) { top: 83.33%; }
.build-chord-diagram .fret-horizontal:nth-child(15) { top: 91.66%; }
.build-chord-diagram .fret-horizontal:nth-child(16) { top: calc(100% - 2px); }

.build-chord-diagram .open-indicators {
  position: absolute;
  top: -56px;
  left: 0;
  right: 0;
  width: 100%;
  height: 44px;
  padding-bottom: 8px;
  box-sizing: content-box;
  z-index: 10;
}
.build-chord-diagram .open-indicator {
  position: absolute;
  width: 44px;
  height: 44px;
  border: 2px solid #8e8e93;
  border-radius: 50%;
  background: var(--surface);
  display: none;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  line-height: 40px;
  box-sizing: border-box;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.build-chord-diagram .open-indicator[data-string="g4"] { left: 0; }
.build-chord-diagram .open-indicator[data-string="c4"] { left: 33.33%; }
.build-chord-diagram .open-indicator[data-string="e4"] { left: 66.66%; }
.build-chord-diagram .open-indicator[data-string="a4"] { left: 100%; }
.build-chord-diagram .open-indicator.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.build-chord-diagram .finger-dot {
  position: absolute;
  width: 44px;
  height: 44px;
  background: var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: none;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  text-align: center;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.35);
  z-index: 20;
}
.build-chord-diagram .finger-dot.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Skip → flash all chord tones on the visible neck */
.build-chord-diagram .build-chord-hint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 14;
}
.build-chord-diagram .finger-dot-hint {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  border: 3px solid #e68600;
  background: rgba(255, 193, 7, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #1d1d1f;
  animation: build-hint-pulse 0.85s ease-in-out infinite;
}
.build-chord-diagram .open-indicator.open-indicator--hint {
  display: flex !important;
  align-items: center;
  justify-content: center;
  border-color: #e68600;
  box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.75);
  animation: build-hint-open 0.85s ease-in-out infinite;
}
.build-fretboard-shell.build--hint-active .fretboard-vertical,
.build-fretboard-shell.build--hint-active .open-indicators {
  pointer-events: none;
}
@keyframes build-hint-pulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.92;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.06);
    opacity: 1;
  }
}
@keyframes build-hint-open {
  0%,
  100% {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }
  50% {
    transform: translateX(-50%) scale(1.08);
    opacity: 0.92;
  }
}

.build-chord-diagram .fret-numbers-vertical {
  position: absolute;
  right: -40px;
  top: 0;
  width: 1.75rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 4px 0;
  box-sizing: border-box;
  text-align: right;
}

.build-chord-diagram .fret-markers {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 5;
}
.build-chord-diagram .fret-marker {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #c7c7cc;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.build-chord-diagram .position-indicator {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 2px;
  min-height: 1.2em;
}

#panel-build .trainer-actions--build {
  margin-top: 0;
  margin-bottom: 10px;
}

#panel-build .build-feedback {
  margin-top: 0;
  margin-bottom: 10px;
  min-height: 0;
}

.build-feedback {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 12px;
  min-height: 2.5em;
}
.build-feedback strong {
  color: var(--text);
}
.build-feedback p {
  margin: 0 0 10px;
}
.build-feedback p:last-child {
  margin-bottom: 0;
}
.build-feedback .build-feedback-hint {
  margin-top: 12px;
  margin-bottom: 6px;
  font-size: 0.8125rem;
}
.build-feedback .build-feedback-list {
  margin: 0 auto 0;
  padding-left: 1.2rem;
  max-width: 22rem;
  text-align: left;
  line-height: 1.45;
}
.build-feedback .build-feedback-list li {
  margin-bottom: 6px;
}
.build-feedback .build-feedback-list li:last-child {
  margin-bottom: 0;
}

.build-reveal-mini {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.build-reveal-mini p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0;
}


/* ═══════════════════════════════════════════════════════
   Baritone / tuning toggle bar
   ═══════════════════════════════════════════════════════ */

.tuning-toggle-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tuning-toggle-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.tuning-seg {
  display: inline-flex;
  padding: 2px;
  background: var(--surface-2);
  border-radius: 8px;
  gap: 2px;
}

.tuning-seg button {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.tuning-seg button[aria-pressed="true"] {
  background: #1d1d1f;
  color: #f5f5f7;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.tuning-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0.75;
}

.tuning-seg button[aria-pressed="true"] .tuning-badge {
  opacity: 1;
}

/* Subtle banner when baritone is active */
body.is-baritone .tuning-toggle-bar {
  background: rgba(255, 193, 7, 0.08);
  border-radius: 8px;
  padding: 6px 10px;
  margin-left: -10px;
  margin-right: -10px;
}

/* ═══════════════════════════════════════════════════════
   Global mobile/touch improvements
   ═══════════════════════════════════════════════════════ */

/* Prevent double-tap zoom on all interactive elements */
button,
.open-indicator,
.build-chord-diagram .fretboard-vertical {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Minimum tap target for all buttons */
button {
  min-height: 36px;
}

/* Safe-area padding for iOS home indicator / notch */
body {
  padding-bottom: max(0px, env(safe-area-inset-bottom));
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* ═══════════════════════════════════════════════════════
   Responsive: iPhone 375–430px
   ═══════════════════════════════════════════════════════ */

@media (max-width: 480px) {
  /* Reduce outer padding */
  .wrap {
    padding-left: 12px;
    padding-right: 12px;
    padding-top: 16px;
  }

  /* MC grid: 4-column is too tight for chord names — switch to 2-column */
  .mc-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .mc-grid button {
    padding: 10px 8px;
    font-size: 0.875rem;
    min-height: 44px;
  }

  /* Tuning toggle: stack label + seg if narrow */
  .tuning-toggle-bar {
    gap: 8px;
  }

  .tuning-seg button {
    padding: 7px 10px;
    font-size: 0.75rem;
  }

  /* Mode switch buttons — ensure comfortable tap targets */
  .mode-switch button {
    padding: 12px 10px;
    font-size: 0.8125rem;
    min-height: 44px;
  }

  /* Build action buttons — let them wrap at 2 per row */
  .trainer-actions--build {
    gap: 6px;
  }

  .trainer-actions--build button {
    min-height: 44px;
    flex: 1 1 calc(50% - 6px);
  }

  /* Build fretboard: size from viewport minus horizontal chrome so the neck + fret column fit.
       wrap L+R: 12+12 = 24px
       panel L+R: 12+12 = 24px
       shell padding-left: 36px  shell padding-right: 56px  → 92px
       Total: 24 + 24 + 92 = 140px */
  .build-chord-diagram {
    --fb-w: min(400px, calc(100vw - 140px));
  }

  /* Scale down mini chord diagrams slightly on small screens */
  :root {
    --trainer-mini-scale: 1.4;
  }

  /* Name diagram wrapper: reduce min-height to match smaller scale */
  #name-diagram-wrap {
    min-height: calc(200px * 1.4 + 16px);
  }

  /* Panel padding reduction */
  .panel {
    padding: 16px 12px;
  }

  /* Controls: tighten up */
  .trainer-controls {
    padding: 10px 12px;
    gap: 10px 14px;
  }

  /* Build prompt chord name — slightly smaller on tiny screens */
  .build-prompt .build-target {
    font-size: 1.5rem;
  }
}

@media (max-width: 375px) {
  :root {
    --trainer-mini-scale: 1.25;
  }

  #name-diagram-wrap {
    min-height: calc(200px * 1.25 + 16px);
  }

  .mc-grid button {
    font-size: 0.8125rem;
    padding: 9px 6px;
  }
}

/* Three-way mode tabs — slightly tighter copy */
#trainer-main .mode-switch button {
  font-size: 0.8125rem;
  padding: 10px 8px;
}

/* ---------- Diagram Driller (from TNG; scoped to panel) ---------- */
#panel-driller .diagram-driller-banner {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 0 0 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

#panel-driller .driller-chord-display {
  text-align: center;
  margin-bottom: 20px;
}

#panel-driller .driller-chord-display:has(.driller-chord-name.revealed) {
  margin-bottom: 2px;
}

#panel-driller .diagram-driller-instructions {
  margin: 0 0 10px;
  padding: 0 8px;
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text-secondary);
  text-align: center;
}

#panel-driller .diagram-driller-instructions strong {
  color: var(--text);
  font-weight: 600;
}

#panel-driller .driller-preset-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin: 0.35rem auto 1rem;
  padding: 0.65rem 0.85rem;
  max-width: 36rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
  border-radius: 8px;
}

#panel-driller .driller-preset-row label {
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

#panel-driller .driller-preset-row select {
  flex: 1 1 220px;
  min-width: 12rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--text) 22%, transparent);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
}

#panel-driller .driller-chord-display:has(.driller-chord-name.revealed) ~ #driller-diagram-wrap {
  padding-top: 4px;
}

#panel-driller .driller-chord-name {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  min-height: 1.2em;
}

#panel-driller .driller-chord-name.hidden {
  color: transparent;
}

#panel-driller .driller-chord-name.revealed {
  color: var(--accent);
  font-size: 4rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

/* Same mini-diagram scale as Name Game (:root --trainer-mini-scale); TNG used 3.4 here — dropped for consistency */
#panel-driller #driller-diagram-wrap {
  min-height: calc(200px * var(--trainer-mini-scale, 1.7) + 16px);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px 10px;
  box-sizing: border-box;
  overflow: visible;
}

#panel-driller .driller-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

#panel-driller .driller-actions button {
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  padding: 12px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-width: 100px;
}

#panel-driller .driller-actions button:hover {
  background: var(--surface-2);
}

#panel-driller #driller-reveal-btn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

#panel-driller #driller-reveal-btn:hover {
  background: var(--accent-hover, #0077ed);
}

#panel-driller #driller-reveal-btn.revealed {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

#panel-driller .driller-teacher-mode {
  margin-top: 28px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}

#panel-driller .driller-teacher-mode > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#panel-driller .driller-teacher-mode > summary::-webkit-details-marker {
  display: none;
}

#panel-driller .driller-teacher-mode > summary::after {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--text-secondary);
  border-bottom: 2px solid var(--text-secondary);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
  margin-bottom: 0.2rem;
}

#panel-driller .driller-teacher-mode[open] > summary::after {
  transform: rotate(-135deg);
  margin-bottom: -0.15rem;
}

#panel-driller .driller-teacher-mode > summary:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.5);
}

#panel-driller .driller-teacher-body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--border);
}

#panel-driller .driller-teacher-body label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 12px 0 6px;
}

#panel-driller .driller-teacher-body label:first-of-type {
  margin-top: 0;
}

#panel-driller .driller-teacher-picker-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 12px;
  margin-top: 4px;
}

#panel-driller .driller-teacher-picker-field {
  flex: 1 1 140px;
  min-width: 0;
}

#panel-driller .driller-teacher-picker-field select {
  font-family: inherit;
  font-size: 0.9375rem;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

#panel-driller .driller-teacher-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

#panel-driller .driller-teacher-actions button {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: pointer;
}

#panel-driller .driller-teacher-actions button:hover {
  background: var(--accent-hover, #0077ed);
}

#panel-driller .driller-teacher-actions button.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

#panel-driller .driller-teacher-actions button.secondary:hover {
  background: var(--surface-2);
}

#panel-driller #driller-teacher-chord-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#panel-driller .driller-teacher-chord-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
}

#panel-driller .driller-teacher-chord-remove {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
}

#panel-driller .driller-teacher-chord-remove:hover {
  background: #ffebee;
  color: #c62828;
  border-color: rgba(198, 40, 40, 0.25);
}

#panel-driller .driller-teacher-help {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0 0 10px;
}

#panel-driller .driller-list-empty {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

#panel-driller #driller-teacher-status {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  flex: 1 1 12rem;
  min-width: 0;
}

#panel-driller #driller-teacher-status.is-error {
  color: #c62828;
}

#panel-driller #driller-voicing-picker-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

#panel-driller .voicing-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#panel-driller .voicing-card-diagram {
  --trainer-mini-scale: 0.88;
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: 1px;
}

#panel-driller .voicing-card-caption {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  line-height: 1.3;
}

#panel-driller .voicing-card-add {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

#panel-driller .voicing-card-add:hover {
  background: var(--accent-hover, #0077ed);
}

