/* ---------- Head ---------- */
.mt-head { border-bottom: var(--rule); padding-bottom: var(--sp-4); }
.mt-sub { font-family: var(--font-mono); font-size: var(--fs-lg); margin-top: var(--sp-1); color: var(--ink-2); }

/* Shared with the other tool pages; duplicated so this page needs only one stylesheet. */
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg__btn { background: transparent; border: 0; padding: 0.35rem 0.7rem; font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2); cursor: pointer; line-height: 1.3; }
.seg__btn + .seg__btn { border-left: 1px solid var(--line); }
.seg__btn:hover { background: var(--paper-2); color: var(--ink); }
.seg__btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg__btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Tempo + settings ---------- */
.mt-main {
  display: grid; grid-template-columns: minmax(0, 24rem) minmax(0, 1fr); gap: var(--sp-6);
  padding: var(--sp-5) 0; align-items: start;
}

.mt-bpm { display: flex; align-items: center; gap: var(--sp-3); }
.mt-bpm__field { display: block; }
/* `input.` outranks the generic input[type="number"] rule in base.css. */
input.mt-bpm__num {
  font-family: var(--font-mono); font-weight: 500; font-variant-numeric: tabular-nums;
  font-size: clamp(3.5rem, 2.6rem + 4vw, 5.5rem); line-height: 1; letter-spacing: -0.04em;
  width: 3.2ch; padding: 0; border: 0; background: transparent; text-align: center;
  border-bottom: 2px solid transparent; border-radius: 0; -moz-appearance: textfield; appearance: textfield;
}
.mt-bpm__num::-webkit-inner-spin-button, .mt-bpm__num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input.mt-bpm__num:hover:not(:disabled), input.mt-bpm__num:focus { border-bottom-color: var(--line); outline: none; }
input.mt-bpm__num:focus-visible { border-bottom-color: var(--accent); }
input.mt-bpm__num:disabled { color: var(--ink); }
.mt-nudge {
  width: 2.5rem; height: 2.5rem; flex: none; border: 1px solid var(--line); border-radius: 50%;
  background: transparent; font-size: var(--fs-lg); line-height: 1; cursor: pointer; color: var(--ink-2);
}
.mt-nudge:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); }
.mt-nudge:disabled { opacity: 0.35; cursor: not-allowed; }
.mt-bpm__meta { color: var(--ink-2); font-size: var(--fs-sm); margin-top: var(--sp-1); }
.mt-bpm__meta .mono { color: var(--ink-3); font-size: var(--fs-xs); letter-spacing: 0.08em; }

.mt-slider { width: 100%; margin: var(--sp-4) 0; accent-color: var(--accent); }
.mt-slider:disabled { opacity: 0.45; }
.mt-actions { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.mt-play { min-width: 7.5rem; justify-content: center; padding: 0.6rem 1.1rem; font-size: var(--fs-md); }
.mt-play kbd { background: transparent; color: inherit; opacity: 0.7; border-color: currentColor; }
.is-playing .mt-play { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.mt-clock { margin-left: auto; color: var(--ink-3); font-size: var(--fs-sm); }
.is-playing .mt-clock { color: var(--ink); }

.mt-settings { display: grid; gap: var(--sp-4); align-content: start; padding-top: var(--sp-2); }
.mt-timesig { display: flex; align-items: center; gap: var(--sp-2); }
.mt-timesig select { font-family: var(--font-mono); font-size: var(--fs-md); }
.mt-timesig__slash { font-family: var(--font-mono); font-size: var(--fs-lg); color: var(--ink-3); }
.mt-volume { width: 100%; max-width: 16rem; accent-color: var(--ink); }

/* ---------- Beat strip ---------- */
.mt-beats {
  display: grid; grid-template-columns: repeat(var(--beats, 4), minmax(0, 1fr));
  border-top: 2px solid var(--ink); border-left: var(--rule);
}
.mt-beat {
  position: relative; display: grid; align-content: space-between; justify-items: start; gap: var(--sp-3);
  min-height: 6.5rem; padding: var(--sp-3); text-align: left;
  background: transparent; border: 0; border-right: var(--rule); border-bottom: var(--rule); cursor: pointer;
  transition: background-color 60ms linear, color 60ms linear;
}
.mt-beat:hover { background: var(--paper-2); }
.mt-beat__num { font-family: var(--font-mono); font-weight: 500; font-size: var(--fs-xl); line-height: 1; }
.mt-beat__dots { display: flex; gap: 6px; }
.mt-beat__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }

.mt-beat--accent .mt-beat__num { color: var(--accent); }
.mt-beat--accent::before { content: ""; position: absolute; left: var(--sp-3); right: var(--sp-3); top: 0; height: 3px; background: var(--accent); }
.mt-beat--mute { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--paper-2) 6px 7px); }
.mt-beat--mute .mt-beat__num { color: var(--ink-3); text-decoration: line-through; }

/* The beat that is sounding now. */
.mt-beat.is-on { background: var(--ink); color: var(--paper); }
.mt-beat.is-on .mt-beat__dot { background: color-mix(in srgb, var(--paper) 30%, transparent); }
.mt-beat.is-on.mt-beat--accent .mt-beat__num { color: var(--accent); }
.mt-beat.is-on.mt-beat--mute { background: var(--paper-2); color: var(--ink-3); }
.mt-beat__dot.is-on, .mt-beat.is-on .mt-beat__dot.is-on { background: var(--accent); }

.mt-beats__hint { font-size: var(--fs-xs); margin-top: var(--sp-2); display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: baseline; }
.mt-key { font-family: var(--font-mono); color: var(--ink-2); }
.mt-key--accent { color: var(--accent); }
.mt-key--mute { text-decoration: line-through; }

/* ---------- Speed trainer ---------- */
.mt-trainer { margin-top: var(--sp-6); padding-top: var(--sp-5); border-top: 2px solid var(--ink); }
.mt-trainer__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.mt-trainer__head h2 { font-size: var(--fs-lg); }
.mt-trainer__intro { color: var(--ink-2); max-width: 46rem; margin-top: var(--sp-3); }
.mt-trainer__intro b { color: var(--ink); font-weight: 600; }
[data-trainer="once"] .mt-trainer__intro, [data-trainer="cycle"] .mt-trainer__intro { display: none; }

.mt-trainer__form { display: flex; flex-wrap: wrap; gap: var(--sp-4); align-items: start; margin-top: var(--sp-4); }
.mt-inline { display: flex; gap: var(--sp-2); align-items: center; }
.mt-trainer__form input:disabled, .mt-trainer__form select:disabled { opacity: 0.55; }
.mt-trainer__plan { margin-top: var(--sp-3); color: var(--ink-2); max-width: 46rem; font-size: var(--fs-sm); }
.mt-trainer__plan b, .mt-trainer__done b { color: var(--ink); font-family: var(--font-mono); font-weight: 500; }
.mt-trainer__done { margin-top: var(--sp-3); padding: var(--sp-3); background: var(--good-bg); border-left: 3px solid var(--good); font-size: var(--fs-sm); }

.mt-trainer__status { margin-top: var(--sp-4); }
.mt-stats { display: flex; flex-wrap: wrap; gap: var(--sp-5); margin: 0 0 var(--sp-3); }
.mt-stats dt { font-family: var(--font-mono); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); }
.mt-stats dd { margin: 0; font-family: var(--font-mono); font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.mt-progress { height: 6px; background: var(--paper-2); margin-top: var(--sp-2); }
.mt-progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 200ms linear; }
.mt-progress--time > i { background: var(--ink-3); }

@media (max-width: 760px) {
  .mt-main { grid-template-columns: 1fr; gap: var(--sp-5); }
}
@media (max-width: 640px) {
  .mt-beats[data-many] { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .mt-beat { min-height: 5rem; }
  .mt-beat__num { font-size: var(--fs-lg); }
  .mt-actions kbd, .mt-beats__keys { display: none; }
}
