.key-stepper .key-reading-button {
  display: inline-flex;
  min-width: 40px;
  min-height: 36px;
  width: auto;
  height: auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 3px 7px;
  background: #293422;
  border-radius: 4px;
  color: #d7efb9;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.1;
}

.key-stepper .key-reading-button:not(:disabled):hover,
.stage-top #stageKey:not(:disabled):hover {
  background: #3a492c;
}

.key-stepper > button:focus-visible {
  outline-offset: -2px;
}

.stage-top #stageKey {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 36px;
  height: auto;
  padding: 3px 7px;
  line-height: 1.1;
  white-space: nowrap;
  flex: 0 0 auto;
}

.key-reading-value {
  line-height: 1.1;
}

.capo-indicator {
  color: #b9cfa5;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0;
  white-space: nowrap;
}

.reading-capo-summary {
  max-width: 100%;
  margin: -8px 0 18px;
  padding-inline: 2px;
  color: #b4c8a2;
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.stage-mode .reading-capo-summary,
.is-editing .reading-capo-summary {
  display: none;
}

.chord-info-dialog .chord-info-capo {
  margin: 8px 0 0;
  color: #b4c9a3;
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.key-editing-controls {
  flex-wrap: wrap;
  gap: 8px 12px;
}

.key-editing-controls .base-key {
  margin: 0;
  white-space: nowrap;
}

.key-editing-controls .base-key input {
  min-width: 56px;
  min-height: 34px;
  font-size: 16px;
}

.key-detect-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid #4d613b;
  color: #d7efb9;
  font-size: 12px;
  white-space: nowrap;
}

.key-detect-button svg {
  width: 15px;
  height: 15px;
}

.key-detect-button:not(:disabled):hover {
  background: #293422;
}

.key-tool-dialog {
  max-width: 520px;
}

.key-tool-dialog .dialog-heading h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.key-tool-dialog .dialog-heading + p,
.key-tool-dialog form > p:first-child {
  margin: 8px 0 16px;
}

.key-mode-options {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.key-mode-options {
  display: grid;
  gap: 8px;
}

.key-mode-options legend {
  margin-bottom: 8px;
  color: #dce8cf;
  font-weight: 600;
}

.key-option,
.key-detector-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #161d12;
  border: 1px solid #36462e;
  border-radius: 8px;
}

.key-option,
label.key-detector-choice {
  cursor: pointer;
}

.key-mode-options:has(> label.key-detector-choice) > .key-detector-choice {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
}

.key-mode-options:has(> label.key-detector-choice) > .key-detector-choice > span {
  grid-column: 2;
}

.key-option:has(input:checked),
.key-detector-choice:has(input:checked) {
  border-color: #779255;
  background: #242f1c;
}

.key-tool-dialog input[type="radio"] {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #d7f786;
}

.key-option strong {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 14px;
}

.key-option-pitch {
  color: #d7f786;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.key-option small,
.key-detector-field small {
  display: block;
  margin-top: 4px;
  color: #aabb9b;
  font-size: 12px;
  line-height: 1.5;
}

.key-mode-transposition {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 12px;
  color: #dce8cf;
  font-size: 13px;
  font-weight: 600;
}

.key-mode-transposition .stepper {
  gap: 6px;
}

.key-mode-transposition .stepper button {
  width: 38px;
  height: 38px;
  border: 1px solid #46583a;
  background: #1e2a17;
}

.key-mode-transposition .stepper output {
  min-width: 74px;
  font-size: 12px;
}

.capo-field {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin-top: 19px;
  color: #dce8cf;
  font-size: 14px;
  font-weight: 600;
}

.capo-field .app-select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  font-size: 16px;
}

#capoHelp,
#capoPreviewMessage {
  margin: 9px 0 0;
  color: #b0c2a1;
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.capo-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0 0;
  padding: 12px;
  border: 1px solid #37482e;
  border-radius: 8px;
  background: #151d12;
}

.capo-preview > div {
  min-width: 0;
}

@media (min-width: 440px) {
  .capo-preview:has(#keyModeGuide:not([hidden])) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

#keyModeGuideHint {
  margin: 8px 0 0;
}

.capo-preview dt {
  margin: 0 0 5px;
  color: #aebfa0;
  font-size: 12px;
  line-height: 1.45;
}

.capo-preview dd {
  min-width: 0;
  margin: 0;
  color: #e0efcd;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

#keyDetectorFileBlock {
  display: grid;
  gap: 12px;
}

#keyDetectorFileBlock > label,
#keyDetectorFileBlock > small {
  margin: 0;
}

#keyDetectorFileBlock input[type="file"] {
  min-height: 48px;
}

.key-detector-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
}

.key-detector-field input {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  background: #11170e;
  border: 1px solid #46583a;
  border-radius: 7px;
  color: #dee8d4;
  font-size: 16px;
}

.key-detector-field input::file-selector-button {
  margin-right: 8px;
  padding: 5px 8px;
  border: 0;
  border-radius: 4px;
  background: #2b3922;
  color: #dee8d4;
}

.key-detector-analysis-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
  margin-top: 12px;
}

.key-detector-analysis-actions button {
  min-height: 40px;
  padding: 8px 13px;
}

.key-detector-analysis-actions button[type="button"] {
  border: 1px solid #48583c;
}

.key-detector-status {
  margin: 10px 0 0;
}

.key-detector-status:empty {
  margin: 0;
}

.key-detector-status.is-error {
  color: #ffc6b4;
}

.key-detector-result {
  margin-top: 14px;
}

.key-tempo-result {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid #36462e;
  border-radius: 8px;
  background: #161d12;
}

.key-tempo-result h3 {
  margin: 0 0 4px;
  color: #afc4a4;
  font-size: 12px;
  font-weight: 600;
}

.key-tempo-result strong {
  color: #d7f786;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.key-tempo-result p {
  margin: 4px 0 0;
}

.key-tool-dialog.is-practice-detector {
  --practice-dialog-inset: clamp(14px, 4vw, 22px);
  width: min(610px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  padding: 0 var(--practice-dialog-inset) var(--practice-dialog-inset);
  scroll-padding-top: calc(var(--practice-dialog-inset) + 48px);
}

.cloud-app .is-practice-detector > .dialog-heading {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0 calc(-1 * var(--practice-dialog-inset));
  padding: var(--practice-dialog-inset) var(--practice-dialog-inset) 8px;
  border-bottom: 1px solid #35442c;
  background: #1a2116;
}

.is-practice-detector .dialog-heading h2 {
  font-size: clamp(19px, 4.5vw, 24px);
}

.is-practice-detector .key-detector-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.is-practice-detector .key-detector-summary:not(:has(> :not([hidden]))) {
  display: none;
}

.is-practice-detector .key-detector-summary > * {
  min-width: 0;
  margin-top: 0;
}

@media (min-width: 521px) {
  .is-practice-detector .key-detector-summary:has(> :not([hidden]) + :not([hidden])) {
    grid-template-columns: minmax(0, 2fr) minmax(114px, 1fr);
  }
}

.is-practice-detector .key-detector-result legend {
  margin-bottom: 6px;
  font-size: 13px;
}

.is-practice-detector .key-detector-result .key-mode-options {
  gap: 5px;
}

.is-practice-detector .key-detector-choice {
  padding: 7px 9px;
}

.is-practice-detector .key-detector-choice:first-child {
  border-color: #5c7548;
  background: #25331e;
}

.is-practice-detector .key-detector-info {
  display: grid;
  grid-template-columns: minmax(0, 7.8em) minmax(0, 1fr);
  align-items: baseline;
  width: 100%;
  gap: 6px;
  color: #dce8cf;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.is-practice-detector .key-detector-caption { color: #b5c6a8; }
.is-practice-detector .key-detector-info strong { font-weight: 650; }
.is-practice-detector .key-detector-choice:first-child strong { color: var(--accent); }

.is-practice-detector .key-tempo-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  gap: 4px;
}

.is-practice-detector .key-tempo-result :is(h3, p) { margin: 0; }
.is-practice-detector .key-tempo-result strong { font-size: 21px; }

@media (max-width: 520px) {
  .is-practice-detector .key-tempo-result {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .is-practice-detector .key-tempo-result p { grid-column: 1 / -1; }
}

.key-practice {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #455637;
  border-radius: 8px;
  background: #161d12;
}

.key-practice h3 {
  margin: 0;
  color: #e0efcd;
  font-size: 15px;
  font-weight: 650;
}

.key-practice-controls,
.key-practice-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.key-practice-pitch {
  display: grid;
  gap: 3px;
  color: #b8c9ab;
  font-size: 12px;
}

.key-practice-pitch strong {
  color: var(--accent);
  font-size: 19px;
}

.key-practice-steps {
  display: grid;
  grid-template-columns: 42px minmax(80px, auto) 42px;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.key-practice-steps button,
.key-practice-footer button {
  min-height: 42px;
  border: 1px solid #4d613b;
  background: #22301b;
  color: #e0efcd;
}

.key-practice-steps button {
  font-size: 20px;
}

.key-practice :is(output, small, .key-practice-footer button) {
  font-size: 12px;
}

.key-practice-footer small {
  color: #b8c9ab;
}

.is-practice-detector .key-practice {
  gap: 9px;
  margin-top: 12px;
}

.is-practice-detector :is(.key-practice-controls, .key-practice-footer) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.is-practice-detector .key-practice-steps {
  grid-template-columns: 38px minmax(60px, auto) 38px;
}

.is-practice-detector .key-practice-footer button {
  max-width: 136px;
  padding: 4px 8px;
}

.key-detector-actions {
  flex-wrap: wrap;
  margin-top: 18px;
}

.key-detector-actions:not(:has(> button:not([hidden]))) {
  display: none;
}

.audio-download-hint a {
  color: #d7efb9;
  text-underline-offset: 3px;
}

.audio-download-hint a:focus-visible {
  outline-offset: 2px;
}

.audio-link-help {
  width: fit-content;
  min-height: 40px;
  padding: 5px 0;
  color: #d7efb9;
  font-size: 13px;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.audio-link-dialog {
  width: min(600px, calc(100% - 28px));
  max-width: 600px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
}

.audio-link-dialog .dialog-heading h2 {
  margin: 0;
  font-size: 23px;
}

.audio-link-dialog p,
.audio-link-dialog li {
  color: #bdc9b4;
  font-size: 14px;
  line-height: 1.65;
}

.audio-link-dialog ol {
  padding-left: 23px;
}

.audio-link-dialog li + li {
  margin-top: 9px;
}

.audio-link-dialog a {
  color: #d7efb9;
  font-size: 13px;
  text-underline-offset: 3px;
}

.audio-link-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.audio-link-dialog .audio-link-open {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #586d44;
  border-radius: 8px;
  background: #263421;
  font-weight: 650;
  text-decoration: none;
}

.audio-link-dialog .audio-link-open:hover { background: #34462a; }

.audio-link-example {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  padding: 12px 14px;
  border: 1px solid #3b4c31;
  border-radius: 8px;
  background: #151d11;
  color: #b6c7a7;
  font-size: 13px;
}

.audio-link-example code {
  margin-left: 6px;
  color: #e1f6bd;
}

.audio-link-dialog p.audio-link-reminder {
  margin-top: 22px;
  font-size: 12px;
}

@media (max-width: 420px) {
  .key-tool-dialog {
    width: calc(100% - 24px);
    padding: 16px;
  }

  .capo-preview {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
}

@media print {
  .reading-capo-summary:not([hidden]) {
    display: block !important;
    margin: 0 0 12px;
    color: #333;
  }
}
.capo-sync-status { margin: 10px 0 0; color: #b9cda9; font-size: 12px; line-height: 1.6; }
.capo-copy-local { margin-top: 10px; padding: 9px 12px; border: 1px solid #526945; font-size: 12px; text-align: left; }
.capo-copy-local[hidden] { display: none; }
