/* Practice-only shell. The library, account and other screens keep their own layout. */
#app.is-studio {
  --bg: #191d24;
  --bg-soft: #232933;
  --panel: #222831;
  --panel-2: #2b333e;
  --line: #46515f;
  --line-soft: #36404d;
  --text: #f0f2f5;
  --text-dim: #d2d8e0;
  --muted: #b3becb;
  --accent: #d99a35;
  --accent-text: #20242b;
  --accent-soft: #4b3b23;
  --studio-action: #d99a35;
  --studio-action-ink: #20242b;
  --studio-instrument: #303943;
  --staff-bg: #fff;
  --staff-current: #a46916;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 480px;
  background: var(--bg);
  color: var(--text);
  scrollbar-color: var(--muted) var(--bg-soft);
}
[data-theme='light'] #app.is-studio {
  --bg: #f3f5f7;
  --bg-soft: #edf0f4;
  --panel: #fff;
  --panel-2: #f6f8fa;
  --line: #d8dee5;
  --line-soft: #e5e9ee;
  --text: #20242b;
  --text-dim: #404955;
  --muted: #59616b;
  --accent: #835713;
  --accent-soft: #fbefdc;
}
.is-studio .topbar {
  flex: 0 0 auto;
  min-height: 58px;
  padding: 8px clamp(16px, 2.3vw, 36px);
  background: var(--bg);
  gap: 16px;
}
.is-studio .brand { font-size: 20px; letter-spacing: -.03em; }
.is-studio .brand__name { font-size: inherit; }
.topbar .brand {
  min-height: 44px;
  color: var(--text);
  text-decoration: none;
}
.topbar .brand:hover, .topbar__home:hover { color: var(--accent); }
.topbar__home {
  flex: 0 0 auto;
  min-width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  color: var(--text-dim);
  border-radius: 8px;
  text-decoration: none;
}
.topbar__home-label { font-size: 14px; font-weight: 550; white-space: nowrap; }
.topbar :is(.brand, .topbar__home):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.is-studio .chip { background: transparent; }
.is-studio .nav { display: none; }
.is-studio.is-library-open .nav {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 4px;
  padding: 12px 24px;
  border: 0;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  max-height: 30dvh;
  overflow-y: auto;
}
.is-studio .nav__item { border: 0; border-radius: 6px; min-height: 44px; }
.is-studio .screen {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 1680px;
  margin-inline: auto;
  padding: 18px clamp(16px, 2.3vw, 36px) 24px;
  overflow: hidden;
}
.studio { gap: 18px; min-width: 0; height: 100%; }
.studio__head, .studio__transport { flex: 0 0 auto; }
.studio__pickers {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 420px) minmax(0, 260px);
  gap: 12px;
}
.studio__pickers > .field { min-width: 0; }
.studio__pickers > .field:only-child { grid-column: 1 / -1; }
.studio__pickers .control {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  font-size: 14px;
  text-overflow: ellipsis;
}
/* The selected controls are the visible title; keep a heading for navigation
   by assistive technology without repeating the same context on screen. */
.studio__selection-summary {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
/* A dedicated scrolling region reserves real space for the controls. Nothing
   floats over the keys, including on short windows and with settings open. */
.studio__workspace {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scrollbar-gutter: stable;
}
.studio__workspace > * { flex: 0 0 auto; }
.studio__workspace:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.studio__head {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 22px;
  min-height: 62px;
}
.studio .trainer__headtext { min-width: 0; flex: 1; }
.studio .screen__title { font-size: clamp(22px, 2.2vw, 32px); margin: 0; letter-spacing: -.025em; }
.studio .screen__subtitle { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.studio .screen__subtitle:empty { display: none; }
.studio__library { flex: 0 0 auto; padding-inline: 0 20px; border-right: 1px solid var(--line); border-radius: 0; }
.studio__library::before {
  content: '';
  width: 20px;
  height: 20px;
  margin-right: 8px;
  display: inline-block;
  vertical-align: middle;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m10 5-7 7 7 7M3 12h18' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.studio__hand-group { display: flex; border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.studio__hand {
  min-height: 40px;
  padding: 7px 16px;
  background: transparent;
  border: 0;
  border-radius: 5px;
  font-size: 14px;
  white-space: nowrap;
  color: var(--text-dim);
  cursor: pointer;
}
.studio__hand[aria-pressed='true'] { background: var(--accent-soft); color: var(--text); font-weight: 650; }
.studio__hand:hover { background: var(--bg-soft); }
.studio__settings-toggle { font-size: 14px; flex-shrink: 0; }
.studio__settings-toggle[aria-expanded='true'] { background: var(--accent-soft); border-color: var(--accent); }
.studio__settings {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 35dvh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.studio__settings > * { flex-shrink: 0; }
.studio__settings-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.studio__settings-head h2 { font-size: 17px; }
.studio__settings .screen__desc { margin: 0; max-width: 80ch; font-size: 14px; }
.studio__settings .trainer__pickers { align-items: end; }
.studio__settings .field { min-width: 0; }
.studio__settings .control { max-width: 100%; }
.studio__options { display: flex; align-items: end; flex-wrap: wrap; gap: 16px 24px; }
.studio__secondary-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.studio__help { font-size: 14px; color: var(--muted); max-width: 80ch; }
.studio .trainer__counting { margin: 0; }
.studio .staff-host { padding: 18px 16px; border-color: var(--line); border-radius: 14px; }
.studio .pt-staff { scrollbar-width: auto; scrollbar-color: #7c8795 #eef1f5; }
.studio .pt-staff:focus-visible { outline-offset: 3px; }
.studio__target { display: none; }
.studio__score-hint { display: none; }
.studio__keyboard { min-width: 0; border-radius: 14px; background: var(--studio-instrument); color: #f4f6f8; overflow: hidden; }
.studio__keyboard-toggle {
  width: 100%;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  background: transparent;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  font-weight: 550;
  cursor: pointer;
}
.studio__keyboard-action { font-size: 14px; font-weight: 400; }
.studio__keyboard-toggle:hover { background: #3c4855; }
.studio__keyboard-toggle:focus-visible { outline-offset: -4px; }
.studio__keyboard .kb-host {
  --kb-lane: #303943;
  --oct-label: #e0e6ed;
  padding: 0 14px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  max-width: 1100px;
  margin-inline: auto;
}
.studio__keyboard .flegend { margin: 0; padding: 0 18px 10px; color: #dce3eb; font-size: 12px; }
.studio__keyboard .flegend__label { color: inherit; }
.studio .pt-keyboard { scrollbar-width: auto; scrollbar-color: #9ba6b5 #303943; }
.studio__transport {
  min-width: 0;
  padding: 14px 18px;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-radius: 14px;
}
.studio .btn { min-height: 44px; }
.studio .btn--accent { background: var(--studio-action); color: var(--studio-action-ink); border-color: transparent; }
.studio .btn--accent:hover { background: #e5ab4d; }
.studio__play { min-width: 140px; min-height: 54px !important; font-size: 16px; font-weight: 650; }
.studio__play::before {
  content: '';
  width: 18px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 10px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 3v18l16-9z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.studio__play.is-playing::before { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 3h5v18H5zM14 3h5v18h-5z'/%3E%3C/svg%3E"); }
.studio__play.is-listening::before { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 4h16v16H4z'/%3E%3C/svg%3E"); }
.studio__mode { min-width: 148px; }
.studio__mode .control { width: 100%; min-height: 44px; }
.studio .field--bpm { min-width: 186px; flex-shrink: 0; }
.studio .bpm { gap: 4px; }
.studio .bpm__number { width: 58px; padding: 4px 0; border: 0; background: transparent; font-size: 21px; font-weight: 650; appearance: textfield; }
.studio .bpm__number::-webkit-inner-spin-button { appearance: none; }
.studio .bpm__unit { font-size: 13px; color: var(--text-dim); padding-right: 6px; }
.studio__tempo-step { width: 42px; padding: 4px; font-size: 23px; }
.studio .field__label { font-size: 13px; color: var(--muted); }
.studio__metronome, .studio__loop { margin: 0; flex-shrink: 0; }
.studio__metronome .field__label, .studio__loop .field__label { font-size: 14px; color: var(--text-dim); }
.studio input[type='checkbox'] { width: 20px; height: 20px; accent-color: var(--studio-action); }
.studio input[type='range'] { accent-color: var(--studio-action); }
.studio .stats-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px 28px; }
.studio .stat { display: flex; align-items: baseline; flex-direction: row-reverse; gap: 7px; padding: 0; background: transparent; border: 0; }
.studio .stat__value { font-size: 14px; font-weight: 650; }
.studio .stat__label { font-size: 13px; color: var(--muted); }
.studio .trainer__note { text-align: center; }
.studio .trainer__note:empty { display: none; }
.studio :is(button, input, select):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.studio :is(button, input, select):disabled { cursor: not-allowed; opacity: .55; }
.studio .next-hint { margin: 0; }

@media (max-width: 1200px) {
  .studio__head { flex-wrap: wrap; gap: 12px; }
  .studio .trainer__headtext { flex-basis: 35%; }
  .studio__hand { padding-inline: 12px; }
  .studio__transport { gap: 12px; flex-wrap: wrap; }
  .studio__play { min-width: 124px; }
}
@media (max-width: 760px) {
  .is-studio .topbar { min-height: 48px; padding: 2px 12px; gap: 10px; flex-wrap: nowrap; }
  .is-studio .brand, .is-studio .topbar__spacer { display: none; }
  .topbar__home { flex: 0 0 44px; width: 44px; padding: 0; }
  .topbar__home-label { display: none; }
  .is-studio .chip { flex: 1; max-width: none; min-width: 0; }
  .is-studio .chip__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .is-studio .vol input[type='range'] { width: 58px; }
  .is-studio #btn-theme { width: 36px; min-width: 36px; height: 36px; padding: 4px; font-size: 0; }
  .is-studio #btn-theme::before { content: ''; display: block; width: 20px; height: 20px; margin: auto; border: 2px solid currentColor; border-radius: 50%; background: linear-gradient(90deg,currentColor 50%,transparent 50%); }
  .is-studio .screen { padding: 12px 10px max(8px, env(safe-area-inset-bottom)); }
  .studio { gap: 8px; }
  .studio__pickers { grid-column: 2; grid-row: 1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .studio__workspace { gap: 8px; scrollbar-gutter: auto; }
  .studio__head { display: grid; grid-template-columns: 36px minmax(0,1fr) 44px; align-items: start; gap: 10px; min-height: 56px; }
  .studio__library { width: 36px; min-height: 44px; padding: 0; border: 0; font-size: 0; }
  .studio__library::before { width: 22px; height: 22px; margin: 0; }
  .studio .screen__title { font-size: 23px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .studio .screen__subtitle { font-size: 13px; }
  .studio__hands { grid-column: 2; grid-row: 2; min-width: 0; }
  .studio__hand-group { padding: 2px; }
  .studio__hand { flex: 1; min-width: 44px; min-height: 44px; padding: 5px 6px; font-size: 14px; }
  .studio__settings-toggle { grid-column: 3; grid-row: 1; padding: 0; width: 44px; height: 44px; font-size: 0; }
  .studio__settings-toggle::before { content: ''; display: block; width: 22px; height: 22px; margin: auto; background: currentColor; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 6h18M3 12h18M3 18h18'/%3E%3Cpath d='M8 3v6M16 9v6M9 15v6'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat; }
  .studio .staff-host { padding: 8px 6px; border-radius: 12px; }
  .studio__score-hint { display: block; margin-top: 5px; font-size: 12px; color: var(--muted); text-align: right; }
  .studio__target { display: block; padding: 0 4px; font-size: 14px; color: var(--text-dim); }
  .studio__keyboard { border-radius: 12px; }
  .studio__keyboard-toggle { padding: 10px 12px; font-size: 14px; }
  .studio__keyboard .kb-host { padding: 0 6px 6px; }
  .studio__keyboard .flegend { padding: 2px 10px 10px; gap: 8px; flex-wrap: wrap; }
  .studio__transport { display: grid; grid-template-columns: minmax(0,1fr) 132px 44px; gap: 6px; padding: 10px; border-radius: 12px; align-items: end; }
  .studio__mode { grid-row: 1; grid-column: 1; min-width: 0; }
  .studio .field--bpm { grid-row: 1; grid-column: 2; min-width: 0; }
  .studio .bpm { gap: 0; justify-content: space-between; }
  .studio .bpm__number { width: 44px; font-size: 19px; min-height: 44px; }
  .studio .bpm__unit { display: none; }
  .studio .field__label { font-size: 14px; }
  .studio__tempo-step { width: 44px; min-width: 44px; min-height: 44px; }
  .studio__play { grid-column: 3; grid-row: 1; width: 44px; min-width: 44px; min-height: 44px !important; padding: 0; font-size: 0; }
  .studio__play::before { margin: 0; }
  .studio__metronome { grid-column: 1; grid-row: 3; }
  .studio__loop { grid-column: 2; grid-row: 3; }
  .studio__settings :is(.studio__metronome,.studio__loop) { grid-column: auto; grid-row: auto; }
  .studio__metronome .field__label, .studio__loop .field__label { font-size: 12px; }
  .studio .field--check { gap: 6px; align-items: center; }
  .studio .stats-row { gap: 8px 16px; justify-content: flex-start; }
  .studio__settings { padding: 14px; gap: 14px; }
  .studio__settings .trainer__pickers, .studio__options { display: grid; grid-template-columns: minmax(0,1fr); gap: 14px; }
  .studio__settings :is(.field,.control) { width: 100%; }
  .studio__settings .control { min-height: 44px; }
  .studio__settings .studio__hands { grid-column: 1; grid-row: auto; }
  .studio__mode .control { padding-inline: 6px; font-size: 14px; }
  .studio .bpm__range { width: 100%; }
  .studio .next-hint { flex-wrap: wrap; }
}
/* Navigation/configuration must remain reachable even in landscape, with
   enlarged text, or with a long imported title. Use document scroll, not clipping. */
#app.is-studio.is-library-open { height: auto; min-height: 100dvh; }
.is-studio.is-library-open .screen { overflow: visible; }
.is-studio.is-library-open .studio { height: auto; }
.is-studio.is-library-open .studio__workspace { overflow: visible; flex: 0 0 auto; }
@media (max-height: 650px) {
  #app.is-studio { height: auto; min-height: 100dvh; }
  .is-studio .screen { overflow: visible; }
  .studio { height: auto; }
  .studio__workspace { overflow: visible; flex: 0 0 auto; }
}
@media (min-width: 761px) and (max-height: 850px) {
  .studio { gap: 8px; }
  .studio__workspace { gap: 8px; }
  .is-studio .topbar { min-height: 48px; padding-block: 4px; }
  .is-studio .screen { padding-block: 8px; }
  .studio__head { min-height: 52px; }
  .studio .screen__title { font-size: 24px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .studio .staff-host { padding-block: 8px; }
  .studio__keyboard .kb-host { max-width: 880px; }
  .studio__transport { padding-block: 8px; }
}
@media (prefers-reduced-motion: no-preference) {
  .studio__settings { animation: studio-reveal 160ms cubic-bezier(.16,1,.3,1); }
  @keyframes studio-reveal { from { transform: translateY(-4px); } to { transform: translateY(0); } }
}
