.settings-card .controls,
.practice-card .practice-grid {
  min-height: 0;
  height: 100%;
}

.settings-card .field,
.settings-card .switch,
.practice-card .field {
  align-content: center;
}

.field select,
.field input[type="number"] {
  width: 100%;
  border: 2px solid color-mix(in srgb, var(--accent) 34%, var(--border));
  border-radius: 14px;
  padding: 7px 34px 7px 10px;
  background: var(--control);
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 1rem;
  font-weight: 900;
}

.native-select-hidden {
  display: none;
}

.custom-select {
  position: relative;
  width: 100%;
}

.custom-select-button,
.custom-select-menu button {
  width: 100%;
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 1rem;
  font-weight: 900;
  text-align: left;
}

.custom-select-button {
  min-height: 38px;
  border: 2px solid color-mix(in srgb, var(--accent) 34%, var(--border));
  border-radius: 14px;
  padding: 7px 34px 7px 10px;
  background:
    linear-gradient(45deg, transparent 50%, var(--accent-2) 50%) calc(100% - 18px) 50% / 6px 6px no-repeat,
    linear-gradient(135deg, var(--accent-2) 50%, transparent 50%) calc(100% - 12px) 50% / 6px 6px no-repeat,
    var(--control);
}

.custom-select-button:hover,
.custom-select-button:focus {
  border-color: var(--accent);
  background-color: color-mix(in srgb, var(--control) 82%, var(--accent) 18%);
  outline: none;
}

.custom-select-menu {
  position: absolute;
  z-index: 8;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: grid;
  gap: 4px;
  max-height: 220px;
  overflow: auto;
  padding: 6px;
  border: 2px solid color-mix(in srgb, var(--accent) 42%, var(--border));
  border-radius: 16px;
  background: var(--panel);
}

.custom-select-menu[hidden] {
  display: none;
}

.custom-select-menu button {
  min-height: 34px;
  border-radius: 12px;
  padding: 7px 9px;
  background: transparent;
}

.custom-select-menu button:hover,
.custom-select-menu button.active {
  background: var(--accent-soft);
}

.field select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent-2) 50%),
    linear-gradient(135deg, var(--accent-2) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.field select:hover,
.field select:focus {
  border-color: var(--accent);
  background-color: color-mix(in srgb, var(--control) 82%, var(--accent) 18%);
  outline: none;
}

.field.inactive,
.switch.inactive {
  opacity: 0.34;
  background: var(--control);
}

.field.inactive select,
.field.inactive input,
.switch.inactive input,
.switch.inactive i {
  cursor: not-allowed;
}

.switch {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.switch input,
.practice-enable input,
.toggle-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-field {
  position: relative;
}

.practice-enable i,
.toggle-field i {
  width: 48px;
  height: 26px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--control);
  transition: background 0.16s ease, border-color 0.16s ease;
}

.practice-enable i::before,
.toggle-field i::before {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  margin: 2px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.16s ease, background 0.16s ease;
}

.practice-enable input:checked + i,
.toggle-field input:checked + i {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.toggle-field input:disabled + i {
  border-color: var(--border);
  background: var(--control);
  opacity: 0.62;
}

.practice-enable input:checked + i::before,
.toggle-field input:checked + i::before {
  transform: translateX(22px);
  background: var(--accent);
}

.tempo-presets {
  grid-template-columns: repeat(5, 1fr);
  margin-top: clamp(6px, 0.8vh, 10px);
}

.tempo-presets button,
.practice-modes button {
  min-height: clamp(36px, 5vh, 68px);
}

.practice-heading {
  margin-bottom: 0;
}

.practice-enable {
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

.practice-enable span {
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 0.94rem;
  font-weight: 900;
}

.practice-options {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 9px;
  transition: opacity 0.18s ease;
}

.practice-card.disabled .practice-options {
  opacity: 0.5;
}

.practice-card.disabled .practice-options button,
.practice-card.disabled .practice-options select,
.practice-card.disabled .practice-options input {
  pointer-events: none;
}

.practice-modes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin-bottom: 0;
}

.practice-modes button.active {
  border: 2px solid var(--accent);
  background: var(--accent-soft);
}

.section-heading.rhythm-heading {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  justify-content: normal;
  gap: 3px 6px;
  margin-bottom: 4px;
}

.rhythm-heading > div:first-child {
  grid-row: 1;
  grid-column: 1;
  min-width: 0;
}

.rhythm-heading .rhythm-enable {
  grid-row: 1;
  grid-column: 2;
  justify-self: end;
}

.rhythm-heading .rhythm-tools {
  grid-row: 2;
  grid-column: 1 / 3;
  justify-self: start;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 0;
}

.rhythm-enable {
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

.rhythm-enable span {
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 0.94rem;
  font-weight: 900;
}

.rhythm-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.rhythm-legend span {
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
  flex-shrink: 0;
}

.rhythm-legend .light {
  background: color-mix(in srgb, var(--rhythm-light) 24%, transparent);
}

.rhythm-legend .secondary {
  background: color-mix(in srgb, var(--rhythm-secondary) 28%, transparent);
}

.rhythm-legend .accent {
  background: color-mix(in srgb, var(--rhythm-accent) 28%, transparent);
}

.rhythm-legend .rest {
  color: var(--muted);
  background: var(--control);
}

.rhythm-help-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  font-family: Inter, "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  cursor: help;
  position: relative;
  user-select: none;
  transition: color 0.15s, border-color 0.15s;
}

.rhythm-help-icon:hover,
.rhythm-help-icon:focus-visible {
  color: var(--text);
  border-color: var(--text);
  outline: none;
}

.rhythm-help-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 240px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 0.7rem;
  font-weight: 520;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.rhythm-help-icon:hover::after,
.rhythm-help-icon:focus-visible::after {
  opacity: 1;
}

.rhythm-card-wrap.disabled .rhythm-help-icon {
  pointer-events: none;
}

.rhythm-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
}

.rhythm-card-wrap.disabled .rhythm-tools,
.rhythm-card-wrap.disabled .rhythm-grid,
.rhythm-card-wrap.disabled .rhythm-reset {
  opacity: 0.42;
  filter: saturate(0.72);
}

.rhythm-card-wrap.disabled .rhythm-beat-bar,
.rhythm-card-wrap.disabled .rhythm-cell,
.rhythm-card-wrap.disabled .rhythm-split-button,
.rhythm-card-wrap.disabled .rhythm-reset {
  pointer-events: none;
}

.rhythm-card-wrap.disabled .rhythm-cell:hover,
.rhythm-card-wrap.disabled .rhythm-split-button:hover,
.rhythm-card-wrap.disabled .rhythm-reset:hover {
  background: inherit;
  border-color: var(--border);
  box-shadow: none;
  filter: none;
}

.rhythm-card-wrap.disabled .rhythm-cell.playing,
.rhythm-card-wrap.disabled .rhythm-cell.merge-before,
.rhythm-card-wrap.disabled .rhythm-cell.merge-after,
.rhythm-card-wrap.disabled .rhythm-cell.merge-pressing {
  animation: none;
  outline: 0;
  border-color: var(--border);
  box-shadow: none;
  filter: none;
}

.rhythm-reset {
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 0.74rem;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.rhythm-reset:hover {
  background: var(--panel);
  border-color: var(--text);
}

.rhythm-reset:active {
  background: var(--control);
}

.rhythm-grid {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow-x: auto;
  overflow-y: visible;
}

.rhythm-beat-bar {
  flex: 1 1 0;
  min-width: 38px;
  min-height: 0;
  display: grid;
  grid-template-rows: clamp(28px, 1.5vw, 36px) 1fr clamp(28px, 1.5vw, 36px);
  gap: 5px;
}

.rhythm-split-button {
  width: 100%;
  min-width: 0;
  height: clamp(28px, 1.5vw, 36px);
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--control);
  color: var(--text);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}

.rhythm-split-button:disabled {
  opacity: 0.34;
  cursor: not-allowed;
}

.rhythm-cells {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(var(--cell-units, 1), minmax(0, 1fr));
  gap: 5px;
}

.rhythm-cell {
  grid-row: span var(--cell-span, 1);
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: clamp(12px, 0.6vw, 18px);
  background: var(--panel-2);
}

.rhythm-cell.light {
  border-color: color-mix(in srgb, var(--rhythm-light) 58%, var(--border));
  background: color-mix(in srgb, var(--rhythm-light) 18%, var(--panel-2));
}

.rhythm-cell.secondary {
  border-color: color-mix(in srgb, var(--rhythm-secondary) 64%, var(--border));
  background: color-mix(in srgb, var(--rhythm-secondary) 22%, var(--panel-2));
}

.rhythm-cell.accent {
  border-color: color-mix(in srgb, var(--rhythm-accent) 70%, var(--border));
  background: color-mix(in srgb, var(--rhythm-accent) 26%, var(--panel-2));
}

.rhythm-cell.rest {
  color: var(--muted);
  border-style: dashed;
  background: var(--control);
  opacity: 0.78;
}

.rhythm-cell.playing {
  animation: rhythm-cell-flash 160ms steps(1, end);
  box-shadow: inset 0 0 0 3px var(--text);
  border-color: var(--text);
}

.rhythm-cell.merge-before,
.rhythm-cell.merge-after {
  border-color: var(--text);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-2) 22%, transparent);
  filter: brightness(1.12);
}

.rhythm-cell.merge-before {
  border-bottom-color: var(--accent-2);
}

.rhythm-cell.merge-after {
  border-top-color: var(--accent-2);
}

.rhythm-cell.merge-pressing {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent), inset 0 0 0 999px rgba(247, 243, 232, 0.08);
  filter: brightness(1.2);
}

.rhythm-cell-index,
.rhythm-cell-label {
  display: none;
}

@keyframes rhythm-cell-flash {
  0%, 68% {
    filter: brightness(1.45);
    box-shadow: inset 0 0 0 999px rgba(247, 243, 232, 0.12);
  }
  69%, 100% {
    filter: none;
    box-shadow: none;
  }
}

/* ── 三列布局紧凑适配 ── */
.tempo-card {
  padding: clamp(14px, 1.2vw, 32px);
  gap: clamp(6px, 0.8vh, 10px);
  grid-template-rows: auto minmax(auto, 0.48fr) auto minmax(200px, 1.6fr) auto auto;
}
.tempo-panel { min-height: 100px; grid-template-columns: clamp(56px, 4vw, 100px) 1fr clamp(56px, 4vw, 100px); gap: clamp(6px, 0.6vw, 14px); }
.tempo-readout { min-height: clamp(80px, 12vh, 140px); }
.tempo-readout span { margin-top: 2px; margin-bottom: clamp(5px, 0.7vh, 10px); }
.slider { margin-top: clamp(8px, 1vh, 14px); margin-bottom: 2px; }
.icon-button { font-size: clamp(2.4rem, 2.5vw, 4rem); border-radius: clamp(16px, 1vw, 28px); }
#bpmInput { font-size: clamp(5.5rem, 9vw, 12rem); }
.beat-stage { min-height: clamp(180px, 16vh, 340px); border-radius: clamp(24px, 1.2vw, 40px); }
.beat-stage::before { font-size: clamp(2.6rem, 5vw, 8rem); }
.beat-count { font-size: clamp(6rem, 10vw, 14rem); }
h1 { font-size: clamp(2.2rem, 3.5vw, 6rem); white-space: nowrap; }
.eyebrow { font-size: clamp(0.8rem, 0.6vw, 1.2rem); }
.brand-row { gap: 8px; }
.brand-actions { gap: 4px; }
.signature-field { min-width: 130px; padding: 6px 8px; border-radius: 18px; }
.signature-field strong { font-size: clamp(1.6rem, 1.6vw, 2.4rem); }
.signature-field small { font-size: clamp(0.7rem, 0.5vw, 0.95rem); }
.status-grid { gap: 4px; }
.status-grid div { min-height: 44px; padding: 4px 7px; border-radius: 12px; gap: 2px; }
.status-grid span { font-size: clamp(0.8rem, 0.8vw, 1.1rem); white-space: nowrap; }
.status-grid strong { font-size: clamp(1.6rem, 2.2vw, 3.2rem); }
.primary-actions { gap: 4px; }
.tap-button, .timer-reset, .start-button { min-height: clamp(44px, 4vh, 64px); font-size: clamp(0.9rem, 1vw, 1.3rem); }
.start-button { font-size: clamp(1.1rem, 1.3vw, 1.8rem); }
.settings-card, .practice-card { padding: 8px 10px; }
.section-heading.compact { margin-bottom: 4px; gap: 6px; }
h2 { font-size: clamp(1.4rem, 2vw, 3rem); white-space: nowrap; }
.settings-card .field, .settings-card .switch, .practice-grid .field { min-height: clamp(42px, 3.5vh, 56px); padding: 4px 7px; border-radius: 13px; gap: 2px; }
.field span, .switch span { font-size: clamp(0.8rem, 0.7vw, 1rem); }
.field select { font-size: 0.76rem; padding: 3px 22px 3px 5px; }
.tempo-presets { gap: 4px; margin-top: 4px; }
.tempo-presets button { min-height: clamp(32px, 4vh, 56px); font-size: clamp(0.9rem, 1vw, 1.4rem); }
.practice-modes { gap: 4px; }
.practice-modes button { min-height: clamp(32px, 4vh, 56px); font-size: clamp(0.78rem, 0.8vw, 0.95rem); padding: 3px 5px; }
.practice-enable { padding: 3px 5px; gap: 4px; }
.practice-enable span { font-size: clamp(0.72rem, 0.6vw, 1rem); }
.rhythm-card-wrap { padding: 8px 10px; }
.rhythm-legend { gap: 3px; }
.rhythm-legend span { padding: 2px 6px; font-size: clamp(0.7rem, 0.55vw, 0.95rem); }
.rhythm-enable { padding: 4px 8px; gap: 5px; }
.rhythm-enable span { font-size: clamp(0.72rem, 0.6vw, 1rem); }
.rhythm-reset { min-height: 22px; padding: 0 7px; font-size: clamp(0.68rem, 0.55vw, 0.92rem); }
.rhythm-help-icon { width: 16px; height: 16px; font-size: 0.6rem; }
.rhythm-grid { gap: 6px; }
.rhythm-beat-bar { min-width: 38px; grid-template-rows: clamp(24px, 1.5vw, 32px) 1fr clamp(24px, 1.5vw, 32px); gap: 4px; }
.rhythm-split-button { height: clamp(24px, 1.5vw, 32px); font-size: 0.9rem; border-radius: 11px; }
.rhythm-cells { gap: 4px; }
.rhythm-cell { border-radius: clamp(10px, 0.6vw, 16px); }

