:root {
  color-scheme: light;
  --ink: #20201e;
  --orange: #fa8a2a;
  --muted: #4b5652;
  --paper: #ffe9c6;
  --seafoam: #4c8f8a;
  --rim: #4c8f8a;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background-color: #e8dcc4;
  background-image:
    radial-gradient(circle, #4c8f8a28 1px, transparent 1px),
    linear-gradient(135deg, #fff4df55, transparent 60%);
  background-size:
    18px 18px,
    100% 100%;
  color: var(--ink);
  font:
    16px/1.45 system-ui,
    sans-serif;
}
main {
  max-width: 760px;
  margin: 6px auto;
  padding: 0 12px;
}
[hidden] {
  display: none !important;
}
.instrument {
  background: var(--paper);
  border: 2px solid var(--rim);
  border-radius: 18px;
  padding: 10px 14px;
  overflow: clip;
}
.topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--seafoam);
  padding: 8px 12px;
  border-bottom: 3px double var(--rim);
  margin: -10px -14px 2px;
  border-radius: 15px 15px 0 0;
  min-width: 0;
}
.topline strong {
  font:
    italic 700 25px/1.15 Georgia,
    serif;
  letter-spacing: -0.6px;
}
.topline strong span {
  color: var(--muted);
  font:
    700 10px system-ui,
    sans-serif;
  letter-spacing: 1.5px;
  margin-left: 10px;
}
#status {
  color: #873326;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
}
.lcd {
  background: #ffdfa9;
  border: 2px solid var(--rim);
  border-radius: 9px;
  padding: 4px 10px;
  font-family: monospace;
}
.readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}
.readout > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
#tempoDisplay {
  font-size: 42px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -4px;
}
.readout small {
  font-size: 14px;
}
.beatread {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0 12px;
  align-items: center;
}
.beatread strong {
  font-size: 24px;
}
#spoken {
  grid-column: 1/3;
  text-align: right;
  font-size: 14px;
  min-height: 20px;
}
.beatlights {
  display: flex;
  gap: 5px;
  min-height: 7px;
  margin-top: 3px;
}
.beatlights span {
  flex: 1;
  height: 7px;
  background: #4c8f8a20;
  border: 1px solid var(--rim);
  border-radius: 2px;
}
.beatlights span.group {
  border-left: 3px solid var(--ink);
}
.beatlights span.active {
  background: #f62817;
}
button,
input,
select {
  font: inherit;
}
button,
#tempo,
select {
  background: #fff4df;
  color: var(--ink);
  border: 1px solid #71958e;
  border-radius: 8px;
}
button {
  cursor: pointer;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 650;
  touch-action: manipulation;
}
button:hover {
  background: #ffdfa9;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}
label,
.mixerHeading {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}
label {
  display: block;
}
input[type="range"] {
  accent-color: var(--orange);
  cursor: pointer;
  width: 100%;
}
#tempo,
select {
  padding: 4px 6px;
  width: 100%;
  min-width: 0;
}
.controlrow {
  display: flex;
  gap: 10px;
  align-items: center;
}
.tempoControl {
  flex: 1;
  min-width: 0;
}
.numbercontrol {
  display: flex;
  gap: 10px;
  margin: 4px 0;
}
.numbercontrol input {
  flex: 1;
  text-align: center;
  font-size: 23px;
  padding: 3px 8px;
}
.numbercontrol button {
  font-size: 24px;
  width: 48px;
  min-height: 44px;
  padding: 4px;
}
.tap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  height: 76px;
  width: 76px;
  flex-shrink: 0;
  font-size: 20px;
  border: 2px solid var(--rim);
  padding: 0;
  gap: 5px;
  line-height: 1;
  text-align: center;
}
.tap span {
  font-size: 12px;
  letter-spacing: 0.06em;
  line-height: 1;
}
.settings {
  display: grid;
  grid-template-columns: 1fr 1fr 1.3fr 1.8fr;
  gap: 10px;
}
.settings label {
  min-width: 0;
}
.settings select {
  height: 40px;
  margin-top: 2px;
  font-size: 16px;
  letter-spacing: 0;
  touch-action: manipulation;
}
.mixerHeading {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--rim);
  padding-top: 8px;
  margin-top: 4px;
}
.mixerHeading small {
  color: var(--muted);
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 400;
}
.mixer {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding-left: 28px;
}
.channel {
  text-align: center;
  background: #4c8f8a2b;
  border: 1px solid #71958e;
  border-radius: 8px;
  padding: 4px 0;
  min-width: 0;
}
.channel label {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-size: 13px;
  letter-spacing: 0;
  line-height: 1.1;
}
.channel label b {
  font-size: 16px;
  font-weight: 500;
}
.channel output {
  font: 600 13px monospace;
}
.sliderScale {
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 3px auto;
  position: relative;
}
.channel input {
  writing-mode: vertical-lr;
  direction: rtl;
  height: 80px;
  width: 44px;
  margin: 0;
  display: block;
  touch-action: none;
}
.scaleTicks {
  width: 9px;
  height: 80px;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    var(--rim) 0px,
    var(--rim) 1px,
    transparent 1px,
    transparent 7.9px
  );
  border-bottom: 1px solid var(--rim);
}
.mixerScale {
  position: absolute;
  left: 0;
  top: 44px;
  height: 80px;
  width: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font: 12px/1 monospace;
  text-align: right;
  pointer-events: none;
}
.mixerScale span {
  transform: translateY(-50%);
}
.mixerScale span:last-child {
  transform: translateY(50%);
}
.transport {
  display: flex;
  gap: 12px;
  align-items: center;
}
#start {
  background: #f62817;
  border-color: #bd2819;
  color: #20201e;
  border-radius: 22px;
  min-height: 44px;
  min-width: 116px;
  padding: 8px 12px;
  font-size: 16px;
  letter-spacing: 0.6px;
}
#start:hover {
  background: #e94b24;
}
.master {
  flex: 1;
  min-width: 0;
}
.master label {
  display: flex;
  justify-content: space-between;
  letter-spacing: 0;
}
.master output {
  letter-spacing: 0;
}
.master input,
.tempoControl > input {
  height: 26px;
  margin: 0;
  touch-action: pan-y;
}
#notice {
  font-size: 13px;
  margin: 0;
}
#notice:empty {
  display: none;
}
footer {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 4px;
}
details {
  max-width: 320px;
}
summary {
  cursor: pointer;
  min-height: 32px;
  touch-action: manipulation;
}
details a {
  color: #873326;
}
.installHelp p {
  font-size: 14px;
}
.installHelp button {
  min-height: 44px;
}
@media (min-width: 660px) {
  .instrument {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 18px;
    grid-template-areas: "title title" "display tempo" "transport tempo" "settings settings" "mixerTitle mixerTitle" "mixer mixer" "notice notice";
  }
  .topline {
    grid-area: title;
  }
  .lcd {
    grid-area: display;
  }
  #metroControls {
    display: contents;
  }
  .controlrow {
    grid-area: tempo;
  }
  .settings {
    grid-area: settings;
  }
  .transport {
    grid-area: transport;
  }
  .mixerHeading {
    grid-area: mixerTitle;
  }
  .mixer {
    grid-area: mixer;
  }
  #notice {
    grid-area: notice;
  }
}
/* Phone portrait: three generous faders per row, using spare viewport height. */
@media (max-width: 659px) {
  main {
    margin: 4px auto;
    padding: 0 6px;
    --fader-height: clamp(80px, calc((100svh - 620px) / 2), 260px);
  }
  .instrument {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto auto minmax(230px, 1fr) auto;
    grid-template-areas: "title" "display" "transport" "tempo" "settings" "mixerTitle" "mixer" "notice";
    gap: 6px;
    padding: 8px;
    min-height: calc(
      100svh - 58px - env(safe-area-inset-top) - env(safe-area-inset-bottom)
    );
    border-radius: 12px;
  }
  .topline {
    grid-area: title;
    margin: -8px -8px 0;
    padding: 8px 10px;
    border-radius: 9px 9px 0 0;
  }
  .topline strong {
    font-size: 24px;
  }
  #status {
    font-size: 11px;
    letter-spacing: 1px;
  }
  .lcd {
    grid-area: display;
    padding: 4px 10px;
  }
  .readout {
    min-height: 40px;
  }
  .readout small {
    font-size: 13px;
  }
  #tempoDisplay {
    font-size: 36px;
    letter-spacing: -2px;
  }
  .beatread {
    gap: 0 8px;
  }
  .beatread strong {
    font-size: 24px;
  }
  #spoken {
    min-height: 18px;
    font-size: 14px;
  }
  #metroControls {
    display: contents;
  }
  .transport {
    grid-area: transport;
    gap: 12px;
    padding: 0;
    margin: 0;
  }
  #start {
    min-height: 48px;
    min-width: 120px;
    font-size: 17px;
  }
  .master label {
    font-size: 12px;
    line-height: 1.2;
  }
  .master input {
    height: 38px;
  }
  .controlrow {
    grid-area: tempo;
    margin: 0;
    gap: 10px;
    align-items: center;
  }
  .tempoControl label {
    line-height: 1.2;
  }
  .tempoControl > input {
    display: none;
  }
  .numbercontrol {
    margin: 3px 0 0;
    gap: 8px;
    height: 48px;
  }
  .numbercontrol button {
    width: 48px;
    min-width: 48px;
    padding: 0;
  }
  .numbercontrol input {
    font-size: 22px;
    padding: 2px 6px;
  }
  .tap {
    height: 60px;
    width: 60px;
    font-size: 18px;
    gap: 4px;
  }
  .tap span {
    font-size: 11px;
  }
  .settings {
    grid-area: settings;
    margin: 0;
    gap: 6px;
    grid-template-columns: 1fr 1fr 1.3fr 1.5fr;
  }
  .settings label {
    font-size: 11px;
    line-height: 1.2;
    letter-spacing: 0;
  }
  .settings select {
    height: 48px;
    margin-top: 3px;
    padding: 4px;
    font-size: 16px;
  }
  .mixerHeading {
    grid-area: mixerTitle;
    margin: 0;
    padding-top: 6px;
    font-size: 14px;
  }
  .mixerHeading small {
    display: none;
  }
  .mixer {
    grid-area: mixer;
    padding: 0;
    margin: 0;
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    min-height: 230px;
  }
  .channel {
    display: flex;
    flex-direction: column;
    padding: 5px 6px;
    border-radius: 8px;
  }
  .channel label {
    height: 22px;
    min-height: 22px;
    font-size: 14px;
    white-space: nowrap;
  }
  .channel label b {
    display: none;
  }
  .channel output {
    font-size: 14px;
    line-height: 1.2;
  }
  .sliderScale {
    height: var(--fader-height);
    min-height: var(--fader-height);
    flex: none;
    margin: 3px 0;
    gap: 0;
    width: 100%;
  }
  .channel input {
    height: var(--fader-height);
    width: 48px;
    max-width: 100%;
    min-height: 80px;
    z-index: 1;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
  }
  .channel input::-webkit-slider-runnable-track {
    width: 8px;
    height: 100%;
    background: var(--rim);
    border-radius: 6px;
  }
  .channel input::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 30px;
    height: 30px;
    margin-left: -11px;
    background: var(--orange);
    border: 2px solid var(--ink);
    border-radius: 50%;
  }
  .channel input::-moz-range-track {
    width: 8px;
    height: 100%;
    background: var(--rim);
    border-radius: 6px;
  }
  .channel input::-moz-range-thumb {
    width: 26px;
    height: 26px;
    background: var(--orange);
    border: 2px solid var(--ink);
    border-radius: 50%;
  }
  .scaleTicks {
    position: absolute;
    width: 8px;
    height: calc(100% - 30px);
    top: 15px;
    background: repeating-linear-gradient(
      to bottom,
      var(--rim) 0 1px,
      transparent 1px 10%
    );
  }
  .scaleTicks:first-child {
    left: 5px;
  }
  .scaleTicks:last-child {
    right: 5px;
  }
  .scaleTicks:first-child::before,
  .scaleTicks:first-child::after {
    position: absolute;
    left: -2px;
    font: 11px/1 monospace;
    color: var(--ink);
  }
  .scaleTicks:first-child::before {
    content: "100";
    top: -12px;
  }
  .scaleTicks:first-child::after {
    content: "0";
    bottom: -12px;
  }
  .mixerScale {
    display: none;
  }
  #notice {
    grid-area: notice;
    font-size: 13px;
    margin: 0;
  }
  footer {
    margin: 4px 0 0;
    font-size: 12px;
    justify-content: flex-end;
    gap: 4px 14px;
  }
  footer > span {
    display: none;
  }
  footer summary {
    min-height: 38px;
    display: flex;
    align-items: center;
  }
}

@media (max-width: 360px) {
  .channel label {
    font-size: 11px;
  }
  .settings label {
    letter-spacing: 0;
  }
  .topline strong {
    font-size: 20px;
  }
}
@media (pointer: coarse) {
  footer > span {
    display: none;
  }
}
@media (display-mode: standalone) {
  body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
      env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
}

.brand {
  min-width: 0;
}
.brandline {
  display: flex;
  flex-wrap: wrap;
  gap: 0 14px;
  font-size: 12px;
  line-height: 1.4;
}
.brandline > span:first-child {
  font-weight: 700;
}
.byline {
  font-weight: 400;
}
.topline {
  gap: 10px;
}
.topline strong {
  display: block;
}
.topline #status {
  flex-shrink: 0;
}
@media (max-width: 659px) {
  .brandline {
    font-size: 12px;
    gap: 0 10px;
  }
}

@media (max-width: 659px) and (max-height: 700px) {
  main {
    --fader-height: 72px;
  }
  .channel input {
    min-height: 72px;
  }
  .instrument {
    gap: 4px;
  }
  .topline {
    padding: 6px 10px;
  }
  .topline strong {
    font-size: 21px;
  }
  .readout {
    min-height: 32px;
  }
  #tempoDisplay {
    font-size: 30px;
  }
  .lcd {
    padding: 3px 8px;
  }
  #start {
    min-height: 44px;
  }
  .master input {
    height: 32px;
  }
  .numbercontrol {
    height: 44px;
  }
  .numbercontrol button {
    width: 44px;
    min-width: 44px;
  }
  .tap {
    height: 54px;
    width: 54px;
  }
  .settings select {
    height: 44px;
  }
  .channel {
    padding: 2px 6px;
  }
  .channel label {
    height: 20px;
    min-height: 20px;
  }
  footer summary {
    min-height: 30px;
  }
}

.barsHint {
  grid-column: 1/-1;
  margin: 0;
  color: #454942;
  font-size: 13px;
  line-height: 1.35;
  letter-spacing: 0;
  font-weight: 400;
}
@media (min-width: 660px) {
  main {
    margin-top: 18px;
  }
}

/* Expanded footer help is reading content, not a narrow control column. */
footer details { min-width: 0; }
footer details p { overflow-wrap: anywhere; }
@media(max-width:659px){
  footer { align-items:flex-start; }
  footer details { max-width:100%; }
  footer summary { display:list-item; min-height:44px; padding:10px 0; font-size:14px; line-height:1.4; }
  footer details[open] { flex:1 0 100%; width:100%; max-width:none; padding:0 12px 8px; background:var(--paper); border:1px solid var(--rim); border-radius:8px; }
  footer details[open] p { margin:8px 0 12px; font-size:16px; line-height:1.5; color:var(--ink); }
}
