/* The Studio: the instrument on the choir's vellum and gold. Displays on top,
   the keyboard you play it with, the words, the take as a strip; the voice
   at the side, where the choir keeps its library. */
body[data-room="studio"] header .transport, body[data-room="studio"] header .knob,
body[data-room="studio"] #bAdd, body[data-room="studio"] #bUndo, body[data-room="studio"] #bExamples,
body[data-room="studio"] #bCompose, body[data-room="studio"] #bLight, body[data-room="studio"] #bClear { display: none; }

#studio { grid-row: 2 / span 2; display: grid; place-items: stretch; padding: 0; min-height: 0;
  grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: auto minmax(0, 1fr);
  background: radial-gradient(ellipse at 40% 0%, #1b1e27 0%, var(--nave) 60%); }
#studio .label { white-space: nowrap; }
#studio .sep { width: 1px; align-self: stretch; background: var(--line); }
#studio kbd { font: 11px var(--mono); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; color: var(--vellum); }

/* the bar: record, play, send */
#stBar { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding-block: 7px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--line); background: var(--stone); }
#stBar button { font-size: 12.5px; padding: 4px 9px; }
#stRec .dot { color: var(--rubric); }
#stClock { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 15px; min-width: 6ch; color: var(--gold); }
#stName { width: 130px; font-size: 13px; }
#stInfo { font-family: var(--label); font-size: 12px; letter-spacing: 0.05em; color: var(--dim); }
#stBar select { font-size: 12.5px; max-width: 165px; }
#stBar .check { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--dim); }
#stBar button:disabled { opacity: 0.45; cursor: default; }

/* the main column scrolls when the window is short */
#stMain { min-height: 0; overflow-y: auto; overflow-x: hidden; display: grid; gap: 8px; align-content: start;
  padding: 10px max(16px, env(safe-area-inset-left, 0px)) 14px; scrollbar-width: thin; grid-auto-rows: max-content; }
#stViews { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.3fr) minmax(0, 0.9fr); grid-template-rows: 1fr 1fr; gap: 8px; height: clamp(170px, 24vh, 300px); }
.stv { position: relative; min-width: 0; min-height: 0; background: var(--stone); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stv canvas { display: block; width: 100%; height: 100%; }
.stv-head, .stv-spec { grid-row: 1 / span 2; }
.stv-spec canvas { image-rendering: auto; }
.stv .stcap { position: absolute; left: 9px; top: 6px; font-family: var(--label); font-size: 11.5px; letter-spacing: 0.08em; color: var(--dim); pointer-events: none; }
.stv .readout { position: absolute; right: 9px; top: 6px; font: 500 12px var(--mono); color: var(--gold); font-variant-numeric: tabular-nums; pointer-events: none; }
#stStart { position: absolute; left: 9px; bottom: 8px; font-size: 12px; padding: 3px 9px; background: rgba(32, 36, 45, 0.85); }
.stv-glot .stcap { display: none; }

/* the keyboard: consonants in stone, vowels in rubric, the pitch keys like ivory */
#stKeys { display: grid; gap: 4px; }
#stKeys .rowlabel { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-family: var(--label); font-size: 11.5px; letter-spacing: 0.06em; color: var(--dim); margin-top: 2px; }
#stMidi { color: var(--dim); }
.krow { display: flex; flex-wrap: wrap; gap: 4px; }
.skey { position: relative; min-width: 38px; height: 38px; padding: 0 5px; display: grid; place-items: center; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 6px; background: var(--stone-2); color: var(--vellum); cursor: pointer; user-select: none; touch-action: none; }
.skey .g { font-family: "Gentium Plus", "Charis SIL", var(--display); font-size: 19px; line-height: 1; }
.skey small { position: absolute; right: 4px; bottom: 2px; font: 500 9.5px var(--mono); color: var(--dim); }
.skey.vowel { background: color-mix(in srgb, var(--rubric) 22%, var(--stone-2)); border-color: color-mix(in srgb, var(--rubric) 40%, var(--line)); }
.skey.pitch { background: #d9cfba; border-color: #b9ad94; color: #1a1408; min-width: 46px; }
.skey.pitch .g { font-family: var(--display); font-size: 16px; font-weight: 700; }
.skey.pitch small { color: #6d6450; }
.skey.pitch.fin { box-shadow: inset 0 -3px 0 var(--rubric); }
.skey[data-down="1"] { background: var(--gold); border-color: var(--gold); color: #1a1408; }
.skey[data-down="1"] small { color: #3b2d10; }

/* words */
#stWords { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; }
#stText { flex: 1 1 260px; min-width: 0; font-size: 15px; padding: 6px 10px; }
#stLyricRow { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 4px; min-height: 0; }
#stLyricRow .syl { font-family: "Gentium Plus", var(--display); font-size: 15px; letter-spacing: 0; padding: 1px 8px; color: var(--dim); }
#stLyricRow .syl.next { background: var(--gold); color: #1a1408; border-color: var(--gold); }
#stLyricRow .syl.clear { font-family: var(--label); font-size: 12px; }

/* the take */
#stTake { display: grid; grid-template-rows: auto 200px; background: var(--stone); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
#stTake .tbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 5px 10px; border-bottom: 1px solid var(--line); }
#stTake .tbar button { font-size: 12px; padding: 2px 8px; }
#stTake .tbar label { display: flex; align-items: center; gap: 6px; }
#stTake .tbar input[type=range] { width: 80px; }
#stTake output { font-family: var(--mono); font-size: 11px; color: var(--dim); }
#stSel { font-size: 12.5px; color: var(--dim); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 200px; }
#stStrip { display: block; width: 100%; height: 100%; outline: none; touch-action: none; }
#stStrip:focus-visible { box-shadow: inset 0 0 0 2px var(--gold); }
#studio #stStatus { margin: 0; font-size: 13.5px; color: var(--dim); min-height: 1.4em; }

/* the voice */
#stVoice { border-left: 1px solid var(--line); background: var(--stone); overflow-y: auto; min-height: 0; padding: 10px 14px 16px; display: grid; gap: 6px; align-content: start; scrollbar-width: thin; }
#studio #stVoice h2 { margin: 0 0 2px; font-size: 18px; }
#stVoice h3 { margin: 8px 0 0; font-size: 14px; font-weight: 500; color: var(--vellum); border-top: 1px solid var(--line); padding-top: 8px; }
#stVoice .row { display: grid; grid-template-columns: 56px minmax(0, 1fr) 54px; align-items: center; gap: 6px; }
#stVoice .row select { grid-column: 2 / span 2; width: 100%; min-width: 0; box-sizing: border-box; font-size: 13px; }
#stVoice .row output { font-family: var(--mono); font-size: 11px; color: var(--dim); text-align: right; }
#stVoice input[type=range] { width: 100%; }
#stVoice .sub { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
#stVoice .sub select { flex: 1; min-width: 0; font-size: 13px; }
#stVoice button { font-size: 12px; padding: 3px 9px; }
#studio #stVoice p.help { margin: 6px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--dim); }
#stVoice p.help b { color: var(--vellum); font-weight: 500; }

@media (max-width: 980px) {
  /* one column: the whole room scrolls, the voice below the take */
  #studio { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; overflow-y: auto; align-content: start; }
  #stMain { overflow: visible; }
  #stVoice { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  #stViews { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto; height: auto; }
  .stv-head, .stv-spec { grid-row: auto; height: 170px; }
  .stv-vowel, .stv-glot { height: 120px; }
  #stBar select { max-width: 140px; }
}

body.st-live #stStart { display: none; }
