.zoe-motif-input {
  --zoe-key-rail: #393044;
  --zoe-motif-soft: var(--accent-soft, #eee6f8);
  min-width: 0;
  display: grid;
  gap: 15px;
  color: var(--ink, #2b2239);
}

.zoe-motif-input [hidden] {
  display: none !important;
}

.zoe-motif-tabs,
.zoe-motif-actions,
.zoe-motif-controls,
.zoe-motif-draft-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.zoe-motif-tabs {
  width: fit-content;
  max-width: 100%;
  flex-wrap: nowrap;
  padding: 4px;
  gap: 3px;
  border: 1px solid var(--line, #e8e0ef);
  border-radius: 13px;
  background: var(--surface, #fffdfd);
}

.zoe-motif-tabs button,
.zoe-motif-actions button,
.zoe-motif-controls button,
.zoe-motif-controls select,
.zoe-motif-controls input {
  min-height: 46px;
  min-width: 0;
  padding: 6px 12px;
  border: 1px solid var(--line, #e8e0ef);
  border-radius: 10px;
  font: inherit;
  font-size: .875rem;
  color: var(--ink, #2b2239);
  background: var(--surface, #fffdfd);
}

.zoe-motif-tabs button,
.zoe-motif-actions button,
.zoe-motif-controls button {
  font-weight: 680;
}

.zoe-motif-tabs button {
  border-color: transparent;
  padding-inline: 10px;
  white-space: nowrap;
}

.zoe-motif-tabs button[aria-pressed="true"],
.zoe-motif-controls button[aria-pressed="true"],
.zoe-motif-tabs button:hover {
  border-color: var(--line, #e8e0ef);
  color: var(--accent, #7253a3);
  background: var(--zoe-motif-soft);
}

.zoe-motif-controls {
  align-items: end;
  gap: 9px 12px;
}

.zoe-motif-controls label {
  display: grid;
  flex: 0 1 auto;
  min-width: 0;
  gap: 4px;
  color: var(--muted, #6b6077);
  font-size: .875rem;
  font-weight: 650;
}

.zoe-motif-controls input {
  width: 84px;
}

.zoe-motif-controls select {
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.zoe-motif-piano {
  background: var(--zoe-key-rail);
  border: 5px solid var(--zoe-key-rail);
  border-top-width: 7px;
  border-radius: 12px;
  touch-action: none;
}

.zoe-motif-keys {
  position: relative;
  height: clamp(125px, 22vw, 170px);
  touch-action: none;
  user-select: none;
}

.zoe-motif-key {
  position: absolute;
  top: 0;
  display: grid;
  align-content: end;
  justify-items: center;
  gap: 2px;
  padding: 0 1px 7px;
  margin: 0;
  line-height: 1.08;
  font-size: .8125rem;
  touch-action: none;
}

.zoe-motif-key > * {
  pointer-events: none;
}

.zoe-motif-key span {
  color: var(--accent, #7253a3);
  font-weight: 650;
}

.zoe-motif-key.is-white {
  z-index: 1;
  left: calc(100% / 7 * var(--position));
  width: calc(100% / 7);
  height: 100%;
  color: var(--ink, #2b2239);
  border: 1px solid var(--zoe-key-rail);
  border-radius: 0 0 7px 7px;
  box-shadow: inset 0 -4px 0 color-mix(in srgb, var(--line, #e8e0ef) 78%, #af9cbc);
  background: linear-gradient(color-mix(in srgb, var(--surface, #fffdfd) 89%, #cbbcd2), var(--surface, #fffdfd) 52%);
}

.zoe-motif-key.is-black {
  z-index: 2;
  left: calc(100% / 7 * var(--position));
  width: min(10.2%, 62px);
  height: 57%;
  transform: translateX(-50%);
  border: 1px solid #261d32;
  border-radius: 0 0 6px 6px;
  box-shadow: inset 0 -4px #2a2034, 1px 2px 3px #23173159;
  color: #fff6ff;
  background: linear-gradient(#50415f, #372a44);
  font-size: .74rem;
}

.zoe-motif-key.is-black span {
  color: #e2c9f9;
}

.zoe-motif-key.is-white.is-staged,
.zoe-motif-key.is-white.is-sounding {
  color: #352343;
  background: #dfc8f1;
  box-shadow: inset 0 -4px #b694d4;
}

.zoe-motif-key.is-white.is-sounding {
  background: #ceb0ef;
}

.zoe-motif-key.is-white:is(.is-staged, .is-sounding) span {
  color: #583478;
}

.zoe-motif-key.is-black:is(.is-staged, .is-sounding) {
  background: #7552a0;
  box-shadow: inset 0 -4px #58387f, 1px 2px 3px #23173159;
}

:root[data-theme="dark"] .zoe-motif-key.is-white:not(.is-staged, .is-sounding) {
  border-color: #3c3047;
  background: linear-gradient(#64576f, #514459);
  box-shadow: inset 0 -4px #44354f;
}

.zoe-motif-entry {
  display: grid;
  gap: 10px;
}

.zoe-motif-staged,
.zoe-motif-record-guide,
.zoe-motif-play-guide,
.zoe-motif-status {
  margin: 0;
  color: var(--muted, #6b6077);
  line-height: 1.45;
}

.zoe-motif-staged {
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--zoe-motif-soft);
}

.zoe-motif-status:empty {
  display: none;
}

.zoe-motif-status:not(:empty) {
  padding: 9px 12px;
  border-left: 3px solid var(--accent, #7253a3);
  border-radius: 7px;
  color: var(--ink, #2b2239);
  background: var(--zoe-motif-soft);
}

.zoe-motif-draft {
  display: grid;
  gap: 9px;
  padding-top: 11px;
  border-top: 1px solid var(--line, #e8e0ef);
}

.zoe-motif-draft-head {
  justify-content: space-between;
}

.zoe-motif-draft-head h3 {
  margin: 0;
  font-size: 1rem;
}

.zoe-motif-draft-head span {
  color: var(--muted, #6b6077);
  font-size: .875rem;
  font-weight: 650;
}

.zoe-motif-timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(145px, 100%), 1fr));
  gap: 7px;
}

.zoe-motif-timeline section {
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--line, #e8e0ef);
  border-radius: 9px;
  background: var(--surface, #fffdfd);
}

.zoe-motif-timeline h4 {
  margin: 0 0 5px;
  font-size: .875rem;
}

.zoe-motif-timeline p,
.zoe-motif-timeline ol {
  margin: 0;
  color: var(--muted, #6b6077);
  font-size: .875rem;
}

.zoe-motif-timeline ol {
  display: grid;
  gap: 4px;
  max-height: 170px;
  overflow: auto;
  padding: 0;
  list-style: none;
}

.zoe-motif-timeline li {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 6px;
  padding: 3px 5px;
  border-radius: 5px;
  background: var(--zoe-motif-soft);
}

.zoe-motif-timeline strong {
  color: var(--ink, #2b2239);
}

.zoe-motif-actions button:hover:not(:disabled),
.zoe-motif-controls button:hover:not(:disabled) {
  border-color: var(--accent, #7253a3);
}

.zoe-motif-actions .zoe-motif-primary {
  border-color: transparent;
  color: #fff;
  background: var(--accent, #7253a3);
}

:root[data-theme="dark"] .zoe-motif-actions .zoe-motif-primary {
  color: #291e37;
}

.zoe-motif-input button:disabled {
  opacity: .48;
  cursor: default;
}

.zoe-motif-commit {
  margin-left: auto;
}

@media (max-width: 390px) {
  .zoe-motif-tabs {
    width: 100%;
  }

  .zoe-motif-tabs button {
    flex: 1;
    padding-inline: 5px;
  }

  .zoe-motif-commit {
    margin-left: 0;
  }
}
