#beat-recipe-page .br-name-tempo-stack {
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 0.75rem !important;
  max-width: 32rem !important;
  min-width: 15rem !important;
  flex-basis: 15rem !important;
}

/* Beat Recipe is taller than a phone screen. Let vertical swipes that begin
   anywhere in the sheet move the app, while keeping the swing slider horizontal. */
#beat-recipe-page {
  touch-action: pan-y pinch-zoom !important;
}

#beat-recipe-page button,
#beat-recipe-page input:not([type="range"]),
#beat-recipe-page select,
#beat-recipe-page label,
#beat-recipe-page [role="button"] {
  touch-action: manipulation !important;
}

#beat-recipe-page input[type="range"] {
  touch-action: pan-x !important;
}

#beat-recipe-page .br-name-tempo-stack > div {
  width: 100% !important;
  max-width: none !important;
}

#beat-recipe-page .br-name-tempo-stack input[type="text"] {
  width: 100% !important;
  max-width: none !important;
  overflow: visible !important;
  text-overflow: clip !important;
}

@media (min-width: 1024px) {
  #beat-recipe-page .br-summary-row {
    gap: 0.75rem !important;
  }

  #beat-recipe-page .br-summary-row > :first-child {
    width: 17.5rem !important;
    max-width: 17.5rem !important;
  }

  #beat-recipe-page .br-name-tempo-stack {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: none !important;
    margin-inline: 0 !important;
  }

  #beat-recipe-page .br-active-sheet-banks {
    width: 20rem !important;
    max-width: 20rem !important;
    min-width: 0 !important;
  }
}

.br-timing-lab {
  border: 4px solid #0a0a0a;
  background: #fff;
  color: #0a0a0a;
  box-shadow: 5px 5px 0 #0a0a0a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  margin-bottom: 1.5rem;
}

.br-timing-toolbar {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(220px, 1.25fr) minmax(250px, 1.5fr);
  gap: 0.75rem;
  align-items: end;
  padding: 0.9rem;
  background: #111114;
  color: #fff;
  border-bottom: 4px solid #0a0a0a;
}

.br-control {
  min-width: 0;
}

.br-control label,
.br-timing-title {
  display: block;
  color: #f59e0b;
  font-size: 0.72rem;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.br-grid-select {
  width: 100%;
  min-height: 2.4rem;
  border: 1px solid #52525b;
  border-radius: 0.45rem;
  background: #050508;
  color: #fff;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 800;
}

.br-swing-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: center;
}

.br-swing-slider {
  width: 100%;
  accent-color: #f59e0b;
  touch-action: pan-x;
}

.br-swing-value {
  min-width: 4.2rem;
  color: #f59e0b;
  font-size: 0.86rem;
  font-weight: 900;
  text-align: right;
}

.br-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.br-legend span {
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0.25rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 900;
  white-space: nowrap;
}

.br-count { color: #f59e0b; }
.br-e { color: #06b6d4; }
.br-and { color: #10b981; }
.br-uh { color: #d946ef; }
.br-micro { color: #71717a; }

.br-measure-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: 1rem;
  background: #f6f6f8;
}

.br-measure-card {
  min-width: 0;
  border: 3px solid #0a0a0a;
  background: #fff;
}

.br-measure-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.6rem;
  background: #0a0a0a;
  color: #fff;
}

.br-measure-head strong {
  font-size: 0.75rem;
  line-height: 1.25;
  letter-spacing: 0.04em;
}

.br-play-button {
  min-height: 2.2rem;
  flex: 0 0 auto;
  border: 2px solid #f59e0b;
  border-radius: 0.4rem;
  background: #f59e0b;
  color: #09090b;
  padding: 0.35rem 0.65rem;
  font: inherit;
  font-size: 0.7rem;
  font-weight: 900;
  cursor: pointer;
}

.br-play-button[data-playing="true"] {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}

.br-count-strip-wrap {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0.9rem 0.65rem 0.65rem;
}

.br-count-strip {
  display: grid;
  align-items: stretch;
  min-width: 520px;
  height: 8.5rem;
  border-top: 3px solid #111;
}

.br-count-strip[data-density="high"] {
  min-width: 760px;
}

.br-count-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 3px;
  border-left: 1px solid #d4d4d8;
  padding-bottom: 0.45rem;
}

.br-count-cell[data-role="count"] { border-left: 3px solid #111; }
.br-count-cell[data-role="e"] { border-left-color: #06b6d4; }
.br-count-cell[data-role="and"] { border-left-color: #10b981; }
.br-count-cell[data-role="uh"] { border-left-color: #d946ef; }

.br-count-cell::before {
  content: "";
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: currentColor;
  margin-bottom: 0.4rem;
  transition: transform 60ms linear, box-shadow 60ms linear;
}

.br-count-cell[data-role="count"]::before {
  width: 0.9rem;
  height: 0.9rem;
}

.br-count-cell[data-active="true"]::before {
  transform: scale(1.65);
  box-shadow: 0 0 0 5px color-mix(in srgb, currentColor 25%, transparent), 0 0 14px currentColor;
}

.br-count-label {
  min-height: 1rem;
  font-size: 0.68rem;
  line-height: 1;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.br-free-grid {
  min-height: 8.5rem;
  display: grid;
  place-items: center;
  border: 2px dashed #a1a1aa;
  color: #52525b;
  background: repeating-linear-gradient(-45deg, #fafafa, #fafafa 10px, #f4f4f5 10px, #f4f4f5 20px);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
  padding: 1rem;
}

.br-timing-note {
  padding: 0 1rem 0.9rem;
  color: #52525b;
  font-size: 0.68rem;
  line-height: 1.45;
  font-weight: 700;
}

.br-bank-explainer {
  margin-top: 0.3rem;
  padding: 0.65rem 0.75rem;
  border-left: 3px solid #f59e0b;
  background: #fff8e7;
  color: #262626;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.br-bank-explainer strong {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
}

.br-bank-explainer p {
  margin: 0;
  font-size: 0.6rem;
  line-height: 1.55;
}

.br-recipe-step-guide {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid #b99561;
  border-radius: 12px;
  background: linear-gradient(120deg, #172227, #2c383b);
  box-shadow: inset 0 1px 0 #ffffff35, 0 5px 14px #0002;
}

.br-recipe-step-guide span {
  color: #f2eadc;
  font: 700 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.02em;
}

@media screen and (max-width: 760px) {
  .br-recipe-step-guide { grid-template-columns: minmax(0, 1fr); }
}

/* Beat Recipe: readable, hardware-inspired cards for the live SAMPKAI pads. */
@media screen {
  #beat-recipe-page [class*="md:grid-cols-5"]:has(> [class*="md:col-span-4"][class*="grid-cols-4"] button[title*=" Step "]) {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 0.85rem !important;
    min-width: 0;
    padding: 14px;
    border: 1px solid #c6c9c4;
    border-radius: 15px;
    background: linear-gradient(145deg, #eef0ed, #e4e8e5);
  }

  #beat-recipe-page [class*="md:grid-cols-5"]:has(> [class*="md:col-span-4"][class*="grid-cols-4"] button[title*=" Step "]) > [class*="md:col-span-"] {
    grid-column: 1 / -1 !important;
    min-width: 0;
    width: 100%;
  }

  #beat-recipe-page [class*="md:grid-cols-5"]:has(> [class*="md:col-span-4"][class*="grid-cols-4"] button[title*=" Step "]) > [class*="md:col-span-1"] {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    padding: 0 3px 9px;
    border-bottom: 2px solid #a49b87;
  }

  #beat-recipe-page [class*="md:grid-cols-5"]:has(> [class*="md:col-span-4"][class*="grid-cols-4"] button[title*=" Step "]) > [class*="md:col-span-1"] span:first-child {
    font-size: 15px !important;
    color: #202e32 !important;
    letter-spacing: 0.09em;
  }

  #beat-recipe-page [class*="md:grid-cols-5"]:has(> [class*="md:col-span-4"][class*="grid-cols-4"] button[title*=" Step "]) > [class*="md:col-span-1"] span:last-child {
    font-size: 10px !important;
    color: #5b6768 !important;
  }

  #beat-recipe-page [class*="md:col-span-4"][class*="grid-cols-4"]:has(button[title*=" Step "]) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 1.1rem !important;
  }

  #beat-recipe-page [class*="min-h-[190px]"]:has(button[title*=" Step "]) {
    min-height: 0 !important;
    padding: 14px !important;
    gap: 10px !important;
    justify-content: flex-start !important;
    background: linear-gradient(150deg, #283139 0%, #151c22 58%, #10161b 100%) !important;
    border-color: #6d7777 !important;
    color: #f0ede5 !important;
    border-radius: 14px !important;
    box-shadow: inset 0 1px 0 #8a908a, 0 8px 18px #070b0f50 !important;
    transform: none !important;
  }

  #beat-recipe-page [class*="min-h-[190px]"]:has(button[title*=" Step "]) > div:first-child {
    padding-bottom: 9px;
    border-bottom: 1px solid #687474;
  }

  #beat-recipe-page [class*="min-h-[190px]"]:has(button[title*=" Step "]) > div:first-child span {
    color: #e7d4a9 !important;
    font-size: 12px !important;
    letter-spacing: 0.12em;
  }

  #beat-recipe-page [class*="min-h-[190px]"]:has(button[title*=" Step "]) > div:last-child {
    border-top-color: #526165 !important;
  }

  #beat-recipe-page .br-recipe-lane {
    --lane-accent: #a7a5f0;
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
    padding: 9px;
    border: 1px solid #4b5a5f;
    border-left: 4px solid var(--lane-accent);
    border-radius: 9px;
    background: linear-gradient(100deg, #172127, #202b30);
    box-shadow: inset 0 1px 2px #0008;
  }

  #beat-recipe-page .br-recipe-lane[data-recipe-lane="kick"] { --lane-accent: #e6ad58; }
  #beat-recipe-page .br-recipe-lane[data-recipe-lane="snare"] { --lane-accent: #d699ca; }
  #beat-recipe-page .br-recipe-lane[data-recipe-lane="clap"] { --lane-accent: #d98782; }
  #beat-recipe-page .br-recipe-lane[data-recipe-lane="hihat"] { --lane-accent: #87c8c9; }

  #beat-recipe-page .br-lane-control {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  #beat-recipe-page .br-lane-name {
    flex: 0 0 64px;
    color: var(--lane-accent);
    font: 800 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.08em;
  }

  #beat-recipe-page .br-lane-select {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    max-width: none !important;
    height: 34px !important;
    padding: 0 8px !important;
    border: 1px solid #718185 !important;
    border-radius: 6px !important;
    background: #29373c !important;
    color: #f5f0e7 !important;
    font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace !important;
    cursor: pointer;
  }

  #beat-recipe-page .br-lane-select:focus-visible {
    outline: 2px solid var(--lane-accent) !important;
    outline-offset: 2px;
  }

  #beat-recipe-page .br-pad-symbol-select {
    flex: 0 0 116px;
    width: 116px;
    min-width: 0;
    max-width: 116px !important;
    height: 34px !important;
    padding: 0 6px !important;
    border: 1px solid #a78f6a !important;
    border-radius: 6px !important;
    background: #3b322c !important;
    color: #f2dfb9 !important;
    font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace !important;
    cursor: pointer;
  }

  #beat-recipe-page .br-pad-symbol-select:focus-visible {
    outline: 2px solid #efbe72 !important;
    outline-offset: 2px;
  }

  #beat-recipe-page .br-pad-symbol-select[data-active="true"] {
    border-color: #f2c577 !important;
    background: #8b622d !important;
    color: #fff7dc !important;
    box-shadow: 0 0 8px #edb95480;
  }

  #beat-recipe-page .br-pad-symbol-select:disabled {
    opacity: 0.45;
    cursor: not-allowed;
  }

  #beat-recipe-page .br-progress-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  #beat-recipe-page .br-progress-controls button {
    flex: 1 1 155px;
    min-height: 38px;
    border: 1px solid #b9a075;
    border-radius: 7px;
    background: linear-gradient(#cfb985, #8f7555);
    color: #16181a;
    font: 800 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.04em;
    cursor: pointer;
  }

  #beat-recipe-page .br-progress-controls button:last-child {
    border-color: #8aada9;
    background: linear-gradient(#93bab4, #63827f);
  }

  #beat-recipe-page .br-keylab-mirror {
    padding: 15px 18px;
    border: 2px solid #9a8060;
    border-radius: 12px;
    background: linear-gradient(120deg, #25282b, #1b2528);
    color: #eee6d8;
    box-shadow: inset 0 1px #ffffff1c, 0 8px 20px #0004;
    text-align: left;
  }

  #beat-recipe-page .br-keylab-mirror > strong {
    color: #d9bb86;
    font: 900 13px/1.25 ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.08em;
  }

  #beat-recipe-page .br-keylab-mirror > p {
    margin: 7px 0 0;
    color: #c8d1cd;
    font: 600 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  }

  #beat-recipe-page .br-keylab-lanes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
    gap: 8px;
    margin-top: 12px;
  }

  #beat-recipe-page .br-keylab-lane {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid #61716d;
    border-left: 4px solid #d3ae72;
    border-radius: 6px;
    background: #121c20;
    font: 600 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  }

  #beat-recipe-page .br-keylab-lane b { color: #f2dba9; overflow-wrap: anywhere; }
  #beat-recipe-page .br-keylab-lane span { color: #bcd1ca; overflow-wrap: anywhere; }

  #beat-recipe-page .br-lane-steps {
    grid-template-columns: repeat(8, minmax(0, 1fr)) !important;
    gap: 5px !important;
    counter-reset: recipe-step;
  }

  #beat-recipe-page .br-lane-steps > button {
    height: 31px !important;
    min-height: 31px !important;
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1px solid #677579 !important;
    border-radius: 5px !important;
    background: #344147 !important;
    box-shadow: inset 0 1px 1px #ffffff24, 0 2px 2px #0005;
  }

  #beat-recipe-page .br-lane-steps > button:nth-child(4n + 1) {
    border-color: #c5a575 !important;
  }

  #beat-recipe-page .br-lane-steps > button[aria-pressed="true"] {
    background: var(--lane-accent) !important;
    border-color: #f9eed8 !important;
    box-shadow: 0 0 10px color-mix(in srgb, var(--lane-accent) 60%, transparent), inset 0 1px 0 #fff8;
  }

  #beat-recipe-page .br-lane-steps > button[class*="bg-red-500"] {
    background: #f04c4c !important;
    border-color: #ffc1b2 !important;
  }

  #beat-recipe-page .br-lane-steps > button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
  }

  #beat-recipe-page .br-lane-steps > button::after {
    counter-increment: recipe-step;
    content: counter(recipe-step);
    pointer-events: none;
    color: #edf0eb;
    font: 800 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  }

  #beat-recipe-page .br-lane-steps > button[aria-pressed="true"]::after {
    color: #172024;
  }

  #beat-recipe-page .br-lane-steps > button[class*="bg-red-500"]::after {
    color: #fff;
  }

  #beat-recipe-page [class*="min-h-[190px]"]:has(button[title*=" Step "]) > div:first-child select {
    height: 32px !important;
    max-width: 112px !important;
    font-size: 11px !important;
  }
}

@media screen and (max-width: 700px) {
  #beat-recipe-page [class*="md:col-span-4"][class*="grid-cols-4"]:has(button[title*=" Step "]) {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #beat-recipe-page .br-lane-steps > button {
    height: 38px !important;
    min-height: 38px !important;
  }
}

@media screen and (max-width: 480px) {
  #beat-recipe-page .br-lane-control {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
  }

  #beat-recipe-page .br-pad-symbol-select {
    grid-column: 2;
    width: 100%;
    max-width: none !important;
  }
}

@media (max-width: 760px) {
  #beat-recipe-page .br-name-tempo-stack {
    min-width: 0 !important;
    flex-basis: auto !important;
  }

  .br-timing-toolbar,
  .br-measure-grid {
    grid-template-columns: 1fr;
  }

  .br-measure-head {
    align-items: flex-start;
  }

  .br-play-button {
    min-width: 8rem;
  }
}

@media print {
  .br-timing-toolbar,
  .br-play-button {
    display: none !important;
  }

  .br-count-strip-wrap {
    overflow: visible;
  }
}
