/* Interactive Circle of Fifths & Key Finder (/tools/circle-of-fifths-key-finder/), 2026-11-30.
   Uses tokens from ft-shell-20261106.css and components from ft-tool-20261106.css.
   Reserves SVG wheel, key-finder matches, chord palettes, and stat heights from first paint so CLS stays 0.000. */

.ft-tool .ft-fields {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), minmax(0, 1fr)));
}

.ft-tool .ft-field,
.ft-tool fieldset,
.ft-tool .ft-panel,
.ft-tool .ft-stack,
.ft-tool .ft-inputgroup {
  min-width: 0;
  max-width: 100%;
}

.ft-tool .ft-select {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ft-tool input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
.ft-tool select,
.ft-tool textarea,
.ft-tool .ft-input,
.ft-tool .ft-select {
  font-size: max(16px, 1rem);
  min-height: 44px;
}

.ft-tool input[type="range"] {
  min-height: 44px;
}

.ft-tool .ft-btn {
  min-width: 44px;
  min-height: 44px;
  height: auto;
  padding-block: 0.45rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

.cof-tip {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-left: 3px solid var(--ft-accent);
  border-radius: 0 var(--ft-radius) var(--ft-radius) 0;
  background: var(--ft-surface-2);
  color: var(--ft-ink-2);
  font-size: var(--ft-text-xs);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.cof-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ft-space-3);
  min-width: 0;
  margin: 0;
  padding: var(--ft-space-4) 0 0;
  border: 0;
  border-top: 1px solid var(--ft-line);
}

.cof-group:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.cof-group__legend {
  float: left;
  width: 100%;
  margin: 0 0 var(--ft-space-1);
  padding: 0;
  color: var(--ft-ink);
  font-size: var(--ft-text-md);
  font-weight: 650;
}

.cof-group__legend + * {
  clear: both;
}

.cof-examples {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--ft-space-2);
}

@media (max-width: 22.5rem) {
  .cof-examples {
    grid-template-columns: minmax(0, 1fr);
  }
}

.cof-example-btn {
  justify-content: flex-start;
  text-align: left;
  font-family: var(--ft-font-mono);
  font-size: var(--ft-text-xs);
}

.cof-detect-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ft-space-2);
  min-height: 11.5rem;
  padding: 0.65rem;
  border: 1px solid var(--ft-line);
  border-radius: var(--ft-radius);
  background: var(--ft-surface-2);
}

.cof-match {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.45rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--ft-line);
  border-radius: var(--ft-radius);
  background: var(--ft-surface);
}

.cof-match--top {
  border-color: var(--ft-accent);
}

.cof-match__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  min-width: 0;
}

.cof-match__title {
  margin: 0;
  color: var(--ft-ink);
  font-size: var(--ft-text-sm);
  font-weight: 650;
}

.cof-match__meta {
  color: var(--ft-ink-2);
  font-family: var(--ft-font-mono);
  font-size: var(--ft-text-xs);
}

.cof-match__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cof-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.16rem 0.45rem;
  border: 1px solid var(--ft-line);
  border-radius: 999px;
  background: var(--ft-surface-2);
  color: var(--ft-ink);
  font-family: var(--ft-font-mono);
  font-size: 0.75rem;
  line-height: 1.3;
}

.cof-pill--borrowed,
.cof-pill--harmonic-minor,
.cof-pill--secondary-dominant {
  border-color: var(--ft-accent);
  background: var(--ft-accent-soft);
}

.cof-match__note {
  margin: 0;
  color: var(--ft-ink-2);
  font-size: var(--ft-text-xs);
  line-height: 1.35;
}

.cof-sliderrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8.25rem;
  align-items: center;
  gap: var(--ft-space-2) var(--ft-space-3);
  min-width: 0;
}

@media (max-width: 26rem) {
  .cof-sliderrow {
    grid-template-columns: minmax(0, 1fr);
  }
}

.cof-checkrow {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 44px;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--ft-line);
  border-radius: var(--ft-radius);
  background: var(--ft-surface-2);
  color: var(--ft-ink);
  font-size: var(--ft-text-sm);
  line-height: 1.35;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.cof-checkrow input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--ft-accent);
  cursor: pointer;
}

.cof-transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--ft-space-2);
  min-width: 0;
}

.cof-transport__btns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ft-space-2);
  min-width: 0;
}

.cof-summarypill {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--ft-line);
  border-radius: var(--ft-radius);
  background: var(--ft-surface-2);
  color: var(--ft-ink);
  font-family: var(--ft-font-mono);
  font-size: var(--ft-text-xs);
  line-height: 1.35;
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* Interactive Dual-Ring SVG Wheel */
.cof-wheel-figure {
  margin: 0;
  min-width: 0;
}

.cof-wheel-frame {
  position: relative;
  width: 100%;
  max-width: 26rem;
  aspect-ratio: 1 / 1;
  margin-inline: auto;
  border: 1px solid var(--ft-line-strong);
  border-radius: var(--ft-radius);
  background: var(--ft-surface-2);
  overflow: hidden;
  box-sizing: border-box;
  user-select: none;
}

.cof-wheel-frame svg {
  display: block;
  width: 100%;
  height: 100%;
}

.cof-wheel__bg {
  fill: var(--ft-surface-2);
  stroke: var(--ft-line);
  stroke-width: 1.25;
}

.cof-neighbor-arc {
  fill: var(--ft-accent-soft);
  stroke: var(--ft-accent);
  stroke-width: 2;
  stroke-dasharray: 5 3;
  pointer-events: none;
}

.cof-wedge {
  cursor: pointer;
}

.cof-wedge path {
  fill: var(--ft-surface);
  stroke: var(--ft-line-strong);
  stroke-width: 1.25;
  transition: fill 120ms ease, stroke 120ms ease;
}

.cof-wedge.is-neighbor path {
  fill: var(--ft-accent-soft);
  stroke: var(--ft-accent);
  stroke-width: 1.65;
}

.cof-wedge.is-selected path {
  fill: var(--ft-accent);
  stroke: var(--ft-ink);
  stroke-width: 2.1;
}

.cof-wedge:hover path {
  stroke: var(--ft-ink);
  stroke-width: 2;
}

.cof-wedge text {
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.cof-wedge__note {
  fill: var(--ft-ink);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 16px;
  font-weight: 700;
}

.cof-wedge__sub {
  fill: var(--ft-ink-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9.5px;
  font-weight: 600;
}

.cof-wedge__minor {
  fill: var(--ft-ink);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 12.5px;
  font-weight: 650;
}

.cof-wedge__minsub {
  fill: var(--ft-ink-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-weight: 600;
}

.cof-wedge.is-selected text {
  fill: #ffffff;
}

html[data-theme="dark"] .cof-wedge.is-selected text {
  fill: #071912;
}

.cof-hub {
  fill: var(--ft-surface);
  stroke: var(--ft-line-strong);
  stroke-width: 1.5;
}

.cof-hub__key {
  fill: var(--ft-ink);
  text-anchor: middle;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 16.5px;
  font-weight: 750;
}

.cof-hub__sig {
  fill: var(--ft-ink-2);
  text-anchor: middle;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  font-weight: 600;
}

.cof-dim-badge {
  cursor: pointer;
}

.cof-dim-badge rect {
  fill: var(--ft-surface-2);
  stroke: var(--ft-accent);
  stroke-width: 1.5;
}

.cof-dim-badge:hover rect {
  fill: var(--ft-accent-soft);
}

.cof-dim-badge text {
  fill: var(--ft-ink);
  text-anchor: middle;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  pointer-events: none;
}

/* Keyboard-accessible wheel buttons alongside SVG */
.cof-kbd-rings {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ft-space-2);
  padding: 0.65rem;
  border: 1px solid var(--ft-line);
  border-radius: var(--ft-radius);
  background: var(--ft-surface-2);
}

.cof-kbd-rings__label {
  margin: 0;
  color: var(--ft-ink-2);
  font-size: var(--ft-text-xs);
  font-weight: 600;
}

.cof-ringbtns {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.35rem;
}

@media (max-width: 30rem) {
  .cof-ringbtns {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.cof-ringbtn {
  padding-inline: 0.25rem;
  font-family: var(--ft-font-mono);
  font-size: var(--ft-text-xs);
  font-weight: 650;
}

.cof-ringbtn[aria-pressed="true"] {
  border-color: var(--ft-accent);
  background: var(--ft-accent);
  color: #ffffff;
}

html[data-theme="dark"] .cof-ringbtn[aria-pressed="true"] {
  color: #071912;
}

.cof-ringbtn--neighbor:not([aria-pressed="true"]) {
  border-color: var(--ft-accent);
  background: var(--ft-accent-soft);
}

/* Audible chord palettes */
.cof-palette {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ft-space-2);
  padding: 0.75rem;
  border: 1px solid var(--ft-line);
  border-radius: var(--ft-radius);
  background: var(--ft-surface-2);
}

.cof-palette__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem;
}

.cof-palette__title {
  margin: 0;
  color: var(--ft-ink);
  font-size: var(--ft-text-sm);
  font-weight: 650;
}

.cof-palette__sub {
  margin: 0;
  color: var(--ft-ink-2);
  font-size: var(--ft-text-xs);
}

.cof-chordgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.25rem), minmax(0, 1fr)));
  gap: 0.45rem;
}

.cof-chordbtn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.12rem;
  min-height: 3.35rem;
  padding: 0.45rem 0.6rem;
  text-align: left;
}

.cof-chordbtn.is-playing {
  border-color: var(--ft-accent);
  background: var(--ft-accent-soft);
}

.cof-chordbtn__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem;
  width: 100%;
}

.cof-chordbtn__sym {
  color: var(--ft-ink);
  font-size: var(--ft-text-sm);
  font-weight: 700;
}

.cof-chordbtn__rom {
  color: var(--ft-accent);
  font-family: var(--ft-font-mono);
  font-size: 0.75rem;
  font-weight: 650;
}

.cof-chordbtn__notes {
  color: var(--ft-ink-2);
  font-family: var(--ft-font-mono);
  font-size: 0.72rem;
  line-height: 1.25;
}

.cof-readoutcard {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--ft-space-3);
  padding: var(--ft-space-4);
  border: 1px solid var(--ft-line);
  border-radius: var(--ft-radius);
  background: var(--ft-surface-2);
}

.cof-readoutcard__head {
  display: grid;
  gap: 0.25rem;
}

.cof-readoutcard__title {
  margin: 0;
  color: var(--ft-ink);
  font-size: var(--ft-text-md);
  font-weight: 650;
}

.cof-readoutcard__sub {
  margin: 0;
  color: var(--ft-ink-2);
  font-size: var(--ft-text-xs);
  line-height: 1.45;
}

.cof-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--ft-space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.cof-stats .ft-stat {
  min-height: 5.5rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 34rem) {
  .cof-stats {
    grid-template-columns: minmax(0, 1fr);
  }
}

.cof-after-example {
  margin-top: var(--ft-space-4);
}

@media (max-width: 24rem) {
  .ft-tool .ft-panel {
    padding: 0.75rem;
  }
  .cof-readoutcard,
  .cof-palette,
  .cof-kbd-rings {
    padding: 0.6rem;
  }
}
