body { 
    font-family: sans-serif; 
    background: #f7faff;
    color: #222;
    margin: 0;
    padding: 20px; }

.container {
    max-width: 1100px;
    margin: 40px auto;
    background: #fff;
    border-radius: 1em;
    box-shadow: 0 4px 24px #bcd3;
    padding: 2em 2em 1.5em 2em;
}

h2 {
    font-family: Arial;
    text-align: center;
    font-size: 2em;
    font-weight: bold;
    color: #4f8cff;
    margin-bottom: 1.2em;
}

.controls-area {
    display: flex;
    justify-content: center;
    gap: 1em;
    align-items: center;
    margin-bottom: 1em;
    background: #f0f4fa;
    border-radius: 0.7em;
    padding: 1em 1.5em;
    box-shadow: 0 2px 8px #bcd2;
}

label[for="bpmRange"] {
    font-weight: 500;
    color: #4f8cff;
    font-size: 1.1em;
}

#bpmRange {
    accent-color: #4f8cff;
    width: 160px;
    margin: 0 0.5em;
}

.btn-play, .btn-code, .btn-clear, .btn-add, .btn-reset {
    border: none;
    border-radius: 0.75em;
    background: linear-gradient(90deg, #4f8cff 0%, #6ed0fa 100%);
    color: #fff;
    font-size: 1.1em;
    box-shadow: 0 2px 8px rgba(79,140,255,0.12);
    transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    height: 3rem;
    min-width: 3rem;
    padding: 0 1.5em;
    margin-left: 0.5em;
}

.btn-play:hover, .btn-code:hover, .btn-clear:hover, .btn-add:hover, .btn-reset:hover {
    background: linear-gradient(90deg, #6ed0fa 0%, #4f8cff 100%);
    box-shadow: 0 4px 16px rgba(79,140,255,0.18);
    transform: scale(1.04);
}

.preset-area {
    display: flex;
    align-items: center;
    gap: 0.1em;
}

.select-reset {
    appearance: none;
    -webkit-appearance: none;
    background: linear-gradient(90deg, #4f8cff 0%, #6ed0fa 100%);
    border: 2.5px solid #4f8cff;
    border-radius: 0.75em;
    height: 3rem;
    width: 2.5rem;
    min-width: 2.5rem;
    box-shadow: 0 2px 8px rgba(79,140,255,0.12);
    cursor: pointer;
    margin-left: 0.5em;
    position: relative;
    color: transparent; /* 主区文本透明 */
    background-image: url("data:image/svg+xml;utf8,<svg width='20' height='20' viewBox='0 0 20 20' fill='white' xmlns='http://www.w3.org/2000/svg'><path d='M5.516 7.548a.75.75 0 0 1 1.06 0L10 10.972l3.424-3.424a.75.75 0 1 1 1.06 1.06l-3.954 3.954a.75.75 0 0 1-1.06 0l-3.954-3.954a.75.75 0 0 1 0-1.06z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2em;
}

/* 下拉菜单选项正常显示 */
.select-reset option {
    color: #222;
    background: #fff;
    text-indent: 0;
}


.grid-area {
    display: flex;
    justify-content: center;
    margin-bottom: 1em;
    background: #f0f4fa;
    border-radius: 0.7em;
    box-shadow: 0 2px 8px #bcd2;
    padding: 1.2em 0;
}

#output-area {
    margin-top: 1.5em;
    background: #f0f4fa;
    border-radius: 0.5em;
    box-shadow: 0 2px 8px #bcd3;
    padding: 1em;
    border: 1px solid #bcd;
    display: none; /* 默认隐藏，生成代码后显示 */
}

#output-code, #output {
    font-family: 'Fira Mono', 'Consolas', monospace;
    font-size: 1em;
    color: #333;
    background: none;
    border: none;
    padding: 0;
    white-space: pre-wrap;
}

#output {
    font-family: 'Consolas', monospace;
    font-size: 1em;
    color: #333;
    white-space: pre-wrap;
}

.cell { 
    fill: #e3e9f7;
    stroke: #bcd;
    stroke-width: 1;
    cursor: pointer;
    transition: fill 0.2s, stroke 0.2s, filter 0.2s;
}

.cell.active{
    fill: #4f8cff;
    stroke: #1a4fa0;
    filter: drop-shadow(0 0 4px #4f8cff88);
}

.cell.current {
    fill: #fffbe6;
    stroke: #ffd700;
    stroke-width: 2;
}

.icon-play, .icon-pause {
    display: inline-block;
    width: 24px;
    height: 24px;
    background-size: 24px 24px;
    background-repeat: no-repeat;
}
.icon-play {
    background-image: url(../icons/play.svg);
}
.icon-pause {
    background-image: url(../icons/pause.svg);
}

.instrument-picker {
    position: absolute;
    z-index: 9999;
    background: #fff;
    border: 1px solid #bcd;
    border-radius: 0.5em;
    box-shadow: 0 4px 24px #bcd3;
    padding: 1em;
    max-height: 340px;
    overflow-y: auto;
    min-width: 420px;
}
.instrument-picker-category {
    font-weight: bold;
    margin: 0.7em 0 0.3em 0;
    color: #4f8cff;
}
.instrument-picker-sample-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    margin-bottom: 0.5em;
}
.instrument-picker-sample-btn {
    margin: 0.2em;
    padding: 0.4em 0.8em;
    border-radius: 0.3em;
    border: 1px solid #bcd;
    background: #fff;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.instrument-picker-sample-btn.selected,
.instrument-picker-sample-btn:hover {
    background: #4f8cff22;
    color: #1a3a6e;
}
.done-btn {
    margin-top: 0.2em;
    padding: 0.5em 2em;
    border-radius: 0.4em;
    background: #4f8cff;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 0.5;
    font-weight: bold;
    transition: background 0.15s;
}
.done-btn:hover {
    background: #6ed0fa;
}

.instrument-btn {
  /* background:  #e3e9f7; */
  background: transparent;
  border: none;
  border-radius: 0.5em;
  padding: 6px 24px 6px 10px;
  font-size: 15px;
  min-width: 70px;
  text-align: left;
  position: relative;
  margin-right: 4px;
}
.instrument-btn::after {
  content: '';
  border: 5px solid transparent;
  border-top: 5px solid #aaa; /* 图标颜色 */
  position: absolute;
  right: 4px;     /* 靠右边，但不要太紧 */
  top: 80%;       /* 斜下角偏移 */
  transform: translateY(-50%) ; 
  opacity: 0.4;   /* 更低调 */
  pointer-events: none;
}
.instrument-btn:hover {
  background: #e3e9f7;
  border-color: #888;
}

.track-delete-button {
  margin-left: 4px;
  background:  #e3e9f7;
  border: none;
  border-radius: 0.5em;
  color: #aaa;
  font-size: 18px;
  width: 40px;
  opacity: 0.3;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.track-delete-button:hover {
  opacity: 1;
  background: #ffeaea;
  color: #e00;
}

.instrument-btn, .track-delete-button {
  height: 40px;
  line-height: 40px;
  vertical-align: middle;
}

.grid-line {
    stroke: navy;
    stroke-width: 1;
}



.btn-play, .btn-code, .btn-clear, .btn-add, .btn-reset, .select-reset {
    position: relative;
}

/* 美化所有带 title 的按钮的悬浮提示 */
[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    top: -2.2em;
    transform: translateX(-50%);
    background: linear-gradient(90deg, #4f8cff 0%, #6ed0fa 100%);
    color: #fff;
    padding: 0.45em 1.2em;
    border-radius: 0.6em;
    font-size: 0.98em;
    font-family: inherit;
    white-space: nowrap;
    box-shadow: 0 2px 12px #4f8cff33;
    z-index: 9999;
    opacity: 0.50;
    pointer-events: none;
}
[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -0.8em;
    transform: translateX(-50%);
    border: 7px solid transparent;
    border-top: 7px solid #4f8cff;
    z-index: 9999;
    opacity: 0.60;
    pointer-events: none;
}

.grid-step-label {
    font-size: 13px;
    fill: #888;
    text-anchor: middle;
    pointer-events: none;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.grid-area {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

#stepLabels {
    margin-bottom: 10px;
}