.tempo-card {
  grid-area: tempo;
  padding: clamp(14px, 1.6vw, 40px);
  display: grid;
  grid-template-rows: auto minmax(auto, 0.54fr) auto minmax(200px, 1.82fr) auto auto;
  gap: clamp(6px, 1.15vh, 15px);
  overflow: hidden;
}

.settings-card {
  grid-area: settings;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.practice-card {
  grid-area: practice;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 9px;
}

.rhythm-card-wrap {
  grid-area: rhythm;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.settings-card,
.practice-card,
.rhythm-card-wrap {
  padding: 12px;
}

.brand-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-row > div:first-child {
  flex: 1;
  min-width: 0;
}

.brand-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-2);
  font-size: clamp(0.8rem, 0.95vw, 1.4rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 0.88;
  letter-spacing: -0.06em;
  text-transform: uppercase;
}

h1 {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(3.3rem, 5.2vw, 8rem);
  color: var(--text);
}

h2 {
  font-size: clamp(1.55rem, 2vw, 3.5rem);
}

.section-heading.compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.signature-field {
  min-width: 210px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 22px;
  background: var(--accent-2);
  color: #121212;
}

.signature-field span,
.signature-field small,
.tempo-readout label,
.tempo-readout span,
.field span,
.status-grid span,
.rhythm-note {
  color: var(--muted);
}

.signature-field span,
.signature-field small {
  color: rgba(18, 18, 18, 0.68);
  font-family: Inter, "Microsoft YaHei", "Segoe UI", sans-serif;
  font-weight: 850;
  white-space: nowrap;
}

.signature-field strong {
  font-size: 2.9rem;
  line-height: 0.86;
  letter-spacing: -0.08em;
}

.signature-field small {
  font-size: 0.82rem;
  white-space: nowrap;
}

.tempo-panel {
  display: grid;
  grid-template-columns: clamp(44px, 7vw, 140px) 1fr clamp(44px, 7vw, 140px);
  gap: clamp(8px, 1vw, 20px);
  align-items: center;
  min-height: clamp(100px, 18vh, 260px);
}

.icon-button {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: clamp(14px, 1.8vw, 36px);
  border: 2px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: clamp(1.6rem, 3.5vw, 5rem);
  font-weight: 900;
  line-height: 1;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.icon-button:hover,
.theme-toggle:hover,
.theme-reset:hover,
.tap-button:hover,
.timer-reset:hover,
.practice-modes button:hover,
.tempo-presets button:hover,
.practice-reset:hover,
.rhythm-beat-bar:hover,
.rhythm-cell:hover,
.rhythm-split-button:hover {
  background: var(--panel-3);
  border-color: color-mix(in srgb, var(--accent) 46%, var(--border));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);
}

.tempo-readout {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: clamp(96px, 14vh, 150px);
}

.tempo-readout label,
.tempo-readout span {
  font-family: Inter, "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: clamp(0.9rem, 1vw, 1.5rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tempo-readout span {
  margin-top: 2px;
  margin-bottom: clamp(4px, 0.6vh, 10px);
  color: var(--accent-2);
}

#bpmInput {
  width: 100%;
  max-height: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: clamp(4rem, 10vw, 16rem);
  font-weight: 900;
  line-height: 0.82;
  text-align: center;
  letter-spacing: -0.06em;
  outline: none;
  caret-color: transparent;
  cursor: default;
}

#bpmInput::-webkit-outer-spin-button,
#bpmInput::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.slider,
.range-field input {
  width: 100%;
  min-height: 32px;
  accent-color: var(--accent);
  cursor: pointer;
  touch-action: pan-y;
}

.slider {
  height: 32px;
  margin-top: clamp(8px, 1vh, 16px);
  margin-bottom: 2px;
}

.slider,
.range-field input[type="range"] {
  appearance: none;
  background: transparent;
}

.slider::-webkit-slider-runnable-track,
.range-field input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border: 1px solid color-mix(in srgb, var(--text) 26%, transparent);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent)) 0 0 / var(--range-fill, 50%) 100% no-repeat, var(--control);
}

.slider::-webkit-slider-thumb,
.range-field input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 14%, transparent);
}

.slider::-moz-range-track,
.range-field input[type="range"]::-moz-range-track {
  height: 8px;
  border: 1px solid color-mix(in srgb, var(--text) 26%, transparent);
  border-radius: 999px;
  background: var(--control);
}

.slider::-moz-range-progress,
.range-field input[type="range"]::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.slider::-moz-range-thumb,
.range-field input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 14%, transparent);
}

.visualizer {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 10px;
  min-height: 0;
}

.beat-stage {
  position: relative;
  min-height: clamp(130px, 26vh, 380px);
  display: grid;
  place-items: center;
  border-radius: clamp(16px, 1.8vw, 48px);
  background: var(--panel-2);
  overflow: hidden;
}

.beat-stage::before {
  content: "BEAT";
  position: absolute;
  left: clamp(10px, 1.4vw, 36px);
  top: clamp(8px, 1.2vh, 18px);
  color: rgba(247, 243, 232, 0.08);
  font-size: clamp(2rem, 5vw, 9rem);
  font-weight: 900;
  line-height: 0.8;
  letter-spacing: -0.09em;
}

.beat-flash {
  position: absolute;
  inset: 18px;
  border: 3px solid var(--border);
  border-radius: 14px;
  background: var(--beat-idle);
  opacity: 0.72;
}

.beat-flash.pulse {
  animation: beat-flash 150ms steps(1, end);
}

.beat-flash.pulse.accent {
  animation-name: beat-flash-accent;
}

.beat-flash.pulse.secondary {
  animation-name: beat-flash-secondary;
}

.beat-flash.pulse.subdivision {
  animation-name: beat-flash-subdivision;
}

.beat-flash.pulse.rest {
  animation-name: beat-flash-rest;
}

@keyframes beat-flash {
  0%, 68% {
    background: var(--rhythm-light);
    border-color: var(--rhythm-light);
    opacity: 1;
  }
  69%, 100% {
    background: var(--beat-idle);
    border-color: var(--border);
    opacity: 0.72;
  }
}

@keyframes beat-flash-accent {
  0%, 68% {
    background: var(--rhythm-accent);
    border-color: var(--rhythm-accent);
    opacity: 1;
  }
  69%, 100% {
    background: var(--beat-idle);
    border-color: var(--border);
    opacity: 0.72;
  }
}

@keyframes beat-flash-secondary {
  0%, 68% {
    background: var(--rhythm-secondary);
    border-color: var(--rhythm-secondary);
    opacity: 0.96;
  }
  69%, 100% {
    background: var(--beat-idle);
    border-color: var(--border);
    opacity: 0.72;
  }
}

@keyframes beat-flash-subdivision {
  0%, 68% {
    background: color-mix(in srgb, var(--rhythm-light) 24%, transparent);
    border-color: color-mix(in srgb, var(--rhythm-light) 62%, var(--border));
    opacity: 0.92;
  }
  69%, 100% {
    background: var(--beat-idle);
    border-color: var(--border);
    opacity: 0.72;
  }
}

@keyframes beat-flash-rest {
  0%, 68% {
    background: var(--panel-3);
    border-color: var(--muted);
    opacity: 0.82;
  }
  69%, 100% {
    background: var(--beat-idle);
    border-color: var(--border);
    opacity: 0.72;
  }
}

.beat-count {
  position: relative;
  z-index: 1;
  font-size: clamp(3.5rem, 10vw, 18rem);
  font-weight: 900;
  line-height: 0.82;
  letter-spacing: -0.08em;
  color: var(--text);
}

.bar-timeline {
  min-height: clamp(18px, 2.5vh, 30px);
  display: grid;
  align-items: center;
}

.beat-dots {
  display: grid;
  grid-template-columns: repeat(var(--beat-count, 4), 1fr);
  gap: clamp(4px, 0.8vw, 10px);
  align-items: center;
  width: 100%;
}

.beat-dot {
  min-width: 0;
  display: grid;
  grid-auto-flow: column;
  grid-template-columns: repeat(var(--cell-units, 1), minmax(0, 1fr));
  gap: 4px;
  align-items: center;
}

.beat-dot-cell {
  grid-column: span var(--cell-span, 1);
  min-height: 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(247, 243, 232, 0.12);
  transition: background 0.08s ease, border-color 0.08s ease, box-shadow 0.08s ease, filter 0.08s ease;
}

.beat-dot-cell.light {
  border-color: color-mix(in srgb, var(--rhythm-light) 44%, var(--border));
}

.beat-dot-cell.secondary {
  border-color: color-mix(in srgb, var(--rhythm-secondary) 52%, var(--border));
}

.beat-dot-cell.accent {
  border-color: color-mix(in srgb, var(--rhythm-accent) 56%, var(--border));
}

.beat-dot-cell.rest {
  border-style: dashed;
  opacity: 0.56;
}

.beat-dot-cell.active {
  border-color: var(--text);
  background: var(--rhythm-light);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--rhythm-light) 24%, transparent), 0 8px 18px color-mix(in srgb, var(--rhythm-light) 24%, transparent);
  filter: brightness(1.18);
}

.beat-dot-cell.secondary.active {
  background: var(--rhythm-secondary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--rhythm-secondary) 24%, transparent), 0 8px 18px color-mix(in srgb, var(--rhythm-secondary) 26%, transparent);
}

.beat-dot-cell.accent.active {
  background: var(--rhythm-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--rhythm-accent) 24%, transparent), 0 8px 18px color-mix(in srgb, var(--rhythm-accent) 28%, transparent);
}

.beat-dot-cell.rest.active {
  background: var(--panel-3);
  box-shadow: 0 0 0 2px rgba(247, 243, 232, 0.14), 0 8px 18px rgba(247, 243, 232, 0.1);
}

.status-grid,
.primary-actions,
.controls,
.practice-grid,
.tempo-presets,
.rhythm-grid {
  display: grid;
  gap: 10px;
}

.status-grid {
  grid-template-columns: repeat(3, 1fr);
}

.status-grid div,
.field,
.switch {
  min-height: clamp(48px, 6vh, 86px);
  display: grid;
  gap: clamp(2px, 0.4vh, 5px);
  align-content: center;
  padding: clamp(6px, 0.8vw, 18px);
  border: 2px solid transparent;
  border-radius: clamp(14px, 1.4vw, 30px);
  background: var(--panel-2);
}

.status-grid strong {
  font-size: clamp(1.3rem, 2.4vw, 4.5rem);
  line-height: 0.84;
  letter-spacing: -0.08em;
}

.status-grid span,
.field span,
.switch span,
.rhythm-note {
  font-family: Inter, "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 0.88rem;
  font-weight: 820;
  line-height: 1.18;
  white-space: nowrap;
}

.field:not(.inactive) span,
.switch span,
.practice-modes button,
.tempo-presets button,
.rhythm-title {
  color: var(--text);
}

.field:not(.inactive) span strong {
  color: var(--accent-2);
  font-size: 0.82rem;
}

.primary-actions {
  grid-template-columns: 0.9fr 0.72fr 1.2fr;
  gap: clamp(6px, 0.8vw, 18px);
}

.tap-button,
.timer-reset,
.start-button,
.practice-modes button,
.tempo-presets button,
.practice-reset,
.rhythm-reset,
.rhythm-beat-bar,
.rhythm-cell,
.rhythm-split-button {
  border-radius: 18px;
  color: var(--text);
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.theme-reset {
  min-height: 44px;
  border-radius: 16px;
  background: var(--accent);
  color: #120f0d;
  font-weight: 900;
}

.tap-button,
.timer-reset,
.practice-modes button,
.tempo-presets button,
.practice-reset,
.rhythm-reset {
  background: var(--panel-2);
}

.tap-button,
.timer-reset,
.start-button {
  min-height: clamp(46px, 6vh, 86px);
}

.start-button {
  background: var(--accent);
  color: #120f0d;
  font-size: clamp(1rem, 1.4vw, 2.2rem);
  font-weight: 900;
  letter-spacing: -0.04em;
}

.start-button.playing {
  background: var(--ok);
}

.primary-actions button,
.tempo-presets button,
.practice-modes button {
  font-weight: 900;
  white-space: nowrap;
}

.practice-modes button,
.tempo-presets button,
.practice-reset,
.rhythm-reset,
.tap-button,
.timer-reset {
  font-size: 1rem;
}

.controls {
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: minmax(64px, 1fr);
}

.practice-grid {
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: minmax(52px, 1fr);
}

