/* The recursive tuning post: two scale pickers, a strip of roots with the
   local scale over the chosen one, the progression, and the matrix. The note
   colours and the matrix cells are the recursive JI post's, from custom.scss. */

.rt {
  --rt-active: color-mix(in srgb, var(--tool-accent) 18%, var(--tool-surface));
}
.rt h3 {
  margin: 1.4rem 0 0.5rem;
}

/* Pickers */
.rt-pickers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.75rem;
}
.rt-picker {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}
.rt-search {
  position: relative;
}
.rt-chosen {
  margin: 0;
  color: var(--tool-text-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}
.rt-chosen strong {
  color: var(--dark);
}
.rt-results {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  z-index: 10;
  max-height: min(22rem, 55vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--tool-border);
  border-radius: 8px;
  background: var(--tool-surface);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--dark) 20%, transparent);
}
.rt-group {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0.75rem;
  border-bottom: 1px solid var(--tool-border);
  background: var(--tool-surface-strong);
  color: var(--tool-text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.rt .rt-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.1rem 0.75rem;
  width: 100%;
  padding: 0.4rem 0.75rem;
  border: 0;
  border-bottom: 1px solid var(--tool-border);
  border-radius: 0;
  background: transparent;
  text-align: left;
  font-size: 0.86rem;
}
.rt .rt-item:hover,
.rt .rt-item.is-active {
  background: var(--rt-active);
}
.rt-item-aside {
  color: var(--tool-text-muted);
  font-size: 0.74rem;
  white-space: nowrap;
}
.rt-item-sub {
  grid-column: 1 / -1;
  overflow: hidden;
  color: var(--tool-text-muted);
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rt-note {
  padding: 0.5rem 0.75rem;
  color: var(--tool-text-muted);
  font-size: 0.8rem;
}
.rt-pairs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.6rem 0;
}
.rt .rt-pairs button {
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
}
.rt .rt-pairs button.is-active {
  border-color: var(--tool-accent);
  background: var(--rt-active);
}

/* Roots and notes */
.rt-roots,
.rt-notes {
  display: flex;
  gap: 0.3rem;
  padding-bottom: 0.4rem;
}
.rt-roots {
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.rt-notes {
  overflow-x: auto;
}
.rt .rt-root {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 3.2rem;
  padding: 0.3rem 0.45rem;
  font-size: 0.8rem;
  line-height: 1.25;
}
.rt .rt-root.is-active {
  border-color: var(--tool-accent);
  background: var(--rt-active);
}
.rt-root small,
.rt-key small {
  color: var(--tool-text-muted);
  font-size: 0.66rem;
}
.rt kbd {
  font-size: 0.62rem;
  opacity: 0.75;
}
.rt-key {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.1rem;
  width: 3.6rem;
  height: 7rem;
  padding: 0.35rem 0.2rem;
  border: 1px solid var(--tool-border);
  border-bottom: 4px solid var(--note-color, var(--tool-border));
  border-radius: 6px;
  background: var(--note-bg, var(--tool-surface));
  cursor: pointer;
  font-size: 0.76rem;
  text-align: center;
  touch-action: none;
  user-select: none;
}
.rt-key.is-period {
  border-top: 3px solid var(--tool-accent);
}
.rt-key.is-active {
  outline: 2px solid var(--tool-accent);
  outline-offset: -2px;
  filter: brightness(1.2);
}
.rt-key-name {
  color: var(--note-color, var(--dark));
  font-weight: 700;
  font-size: 0.7rem;
}
.rt-key-ratio {
  font-family: var(--codeFont);
  font-size: 0.72rem;
  word-break: break-all;
}

/* Progression */
.rt-progression {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.rt-chord {
  min-width: 3.6rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--tool-border);
  border-radius: 6px;
  font-size: 0.8rem;
}
.rt-chord strong {
  display: block;
}
.rt-chord small {
  display: block;
  color: var(--tool-text-muted);
  font-size: 0.66rem;
  white-space: nowrap;
}
.rt-chord.is-playing {
  border-color: var(--tool-accent);
  background: var(--rt-active);
}

/* Matrix */
.rt-matrix-wrap {
  max-height: 75vh;
  overflow: auto;
  border: 1px solid var(--tool-border);
  border-radius: 8px;
}
.rt .rt-matrix {
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.76rem;
}
.rt .rt-matrix th,
.rt .rt-matrix td {
  padding: 0.12rem;
  border: 0;
}
.rt .rt-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--tool-surface-strong);
  white-space: nowrap;
}
.rt .rt-matrix thead th small {
  display: block;
  color: var(--tool-text-muted);
  font-size: 0.64rem;
  font-weight: 400;
}
.rt .rt-matrix tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--tool-surface-strong);
}
.rt .rt-matrix thead th:first-child {
  left: 0;
  z-index: 3;
}
.rt .rt-row-head {
  width: 100%;
  padding: 0.2rem 0.4rem;
  font-size: 0.76rem;
  white-space: nowrap;
}
.rt .rt-matrix tr.is-root .rt-row-head {
  border-color: var(--tool-accent);
  background: var(--rt-active);
}
.rt .rt-matrix .recursive-note-cell {
  min-width: 5.4rem;
  cursor: pointer;
  touch-action: none;
  user-select: none;
}
.rt .rt-matrix .recursive-note-cell.is-active {
  outline: 2px solid var(--tool-accent);
  outline-offset: -2px;
}
.rt .rt-matrix .is-unmoved .tet-cents {
  opacity: 0.45;
}
