/* Fit the instrument and one complete capture into the current visible viewport. */
:root {
  --app-height: 100dvh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}
html { overflow: hidden; }
body {
  position: fixed; inset: 0; margin: 0; width: 100%; height: var(--app-height);
  min-height: 0; overflow: hidden;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}
#container { grid-column: 1; min-width: 0; }
#container video, #container .key img {
  width: 100% !important; height: 100%; max-width: none; max-height: none;
  object-fit: contain; object-position: center;
}
.keyboard-mobile { grid-column: 1; }
.welcome-privacy { flex-basis: 100%; padding: 0; margin: 0; }
.welcome-privacy #privacy-preferences {
  position: static; font: 12px/1.3 'Montserrat', sans-serif; color: #2c3b98;
  min-height: 36px; padding: 4px 0;
}
#privacy-panel { max-height: calc(var(--app-height) - var(--safe-top) - var(--safe-bottom) - 24px); bottom: calc(var(--safe-bottom) + 12px); left: calc(var(--safe-left) + 12px); width: min(440px, calc(100% - var(--safe-left) - var(--safe-right) - 24px)); }
.take-pages { display: flex; align-items: center; gap: 4px; }
.take-pages[hidden], .take-card[hidden] { display: none !important; }
#takePage { min-width: 42px; text-align: center; font-size: 11px; font-variant-numeric: tabular-nums; }
.touch-layout .welcome-controls #inputMode { display: none !important; }
.touch-layout .content-desktop { display: none; }
.touch-layout .content-mobile { display: block; }
.touch-layout .keyboard-mobile { display: flex; touch-action: none; }
.touch-layout .tilt { display: none; }
.notebook-compact #titlebar { width: min(28%, 150px); }
.notebook-compact .helpBtn { top: 8px; right: 8px; transform: none; width: 36px; height: 36px; border-width: 2px; line-height: 36px; font-size: 27px; }
.notebook-compact .keyboard-mobile { height: clamp(44px, calc(var(--app-height) * .10), 72px); }
.notebook-compact #melodyTray { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; min-width: 0; overflow: hidden; padding-bottom: 0; }
.notebook-compact.notebook-open #melodyTray { height: min(340px, calc(var(--app-height) * .56)); }
.notebook-compact .tray-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 1px 6px; padding: 4px 8px; min-height: 60px; }
.notebook-compact #melodyTray #trayToggle { gap: 4px; font-size: 12px; min-width: 0; }
.notebook-compact #trayToggle > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.notebook-compact #trayToggle .count, .notebook-compact #trayToggle .tray-chevron { flex: none; }
.notebook-compact .tray-chevron { width: 14px; font-size: 18px; }
.notebook-compact .count { padding: 2px 5px; font-size: 10px; }
.notebook-compact #captureStatus { grid-row: 2; grid-column: 1 / -1; margin: 0; font-size: 10px; line-height: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notebook-compact #liveMini { display: none; }
.notebook-compact #melodyTray button, .notebook-compact .import-label { min-height: 36px; padding: 5px 7px; font-size: 11px; }
.notebook-compact #melodyTray #finishTake { display: block !important; }
.notebook-compact #finishTake, .notebook-compact #returnToDuet { grid-row: 1; }
.notebook-compact #finishTake { grid-column: 2; }
.notebook-compact #returnToDuet { grid-column: 3; }
.notebook-compact #trayContents { display: grid; grid-template-rows: 36px minmax(0, 1fr) 18px; gap: 4px; padding: 4px 8px; min-height: 0; max-height: none; overflow: hidden; }
.notebook-compact #trayContents[hidden] { display: none; }
.notebook-compact .notebook-tools { padding: 0; gap: 4px; flex-wrap: nowrap; min-width: 0; }
.notebook-compact .notebook-tools > p { display: none; }
.notebook-compact .notebook-tools > div { gap: 4px; margin-left: auto; }
.notebook-compact #melodyTray .take-pages button { min-width: 36px; font-size: 22px; line-height: 1; padding: 2px; }
.notebook-compact .take-strip { display: block; padding: 0; min-height: 0; overflow: hidden; }
.notebook-compact .take-card { display: grid; grid-template-rows: 25px 14px minmax(16px, 1fr) 36px; gap: 3px; height: 100%; width: 100%; padding: 5px 7px; min-height: 0; }
.notebook-compact .take-heading, .notebook-compact .take-meta, .notebook-compact .take-actions { margin: 0; min-width: 0; }
.notebook-compact .take-title { font-size: 16px; padding: 1px 0; }
.notebook-compact .take-meta { font-size: 10px; line-height: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notebook-compact .take-roll { height: 100%; min-height: 0; width: 100%; }
.notebook-compact .take-actions { gap: 5px; }
.notebook-compact #melodyTray .take-delete { min-width: 36px; padding: 0; }
.notebook-compact .notebook-bottom { display: flex; flex-wrap: nowrap; gap: 6px; padding: 0; min-width: 0; font-size: 9px; line-height: 18px; }
.notebook-compact #storageStatus { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.notebook-compact .notebook-bottom a, .notebook-compact #undoNotice { flex: none; white-space: nowrap; }
.notebook-compact .empty-notebook { min-height: 0; height: 100%; padding: 8px; gap: 10px; }
.notebook-compact .empty-notebook strong { font-size: 12px; }
.notebook-compact .empty-notebook p { font-size: 10px; line-height: 1.35; margin-top: 5px; }
.notebook-compact .empty-symbol { font-size: 28px; }
.notebook-compact .popup { max-height: calc(var(--app-height) - var(--safe-top) - var(--safe-bottom) - 16px); top: 50%; }
.notebook-compact .welcome-controls { gap: 4px 10px; margin-top: 10px; }
.notebook-compact .welcome-privacy { flex-basis: auto; margin-right: auto; }
.notebook-compact .content-mobile .instructions { padding: 16px 22px; }
.notebook-compact .content-mobile .instructions img { max-width: 240px; }
/* On short landscape phones, notebook and instrument each get the full height. */
@media (min-width: 560px) and (max-height: 540px) {
  .notebook-compact.notebook-open body { grid-template-columns: minmax(0, 1fr) minmax(290px, 42%); grid-template-rows: minmax(0, 1fr) 44px; }
  .notebook-compact.notebook-open #container { grid-column: 1; grid-row: 1; }
  .notebook-compact.notebook-open .keyboard-mobile { grid-column: 1; grid-row: 2; height: 44px; }
  .notebook-compact.notebook-open #melodyTray { grid-column: 2; grid-row: 1 / -1; height: 100%; border-top: 0; border-left: 1px solid #ffffff55; }
  .notebook-compact .popup { width: min(600px, calc(100% - var(--safe-left) - var(--safe-right) - 24px)); }
  .notebook-compact .popup .title { padding: 14px 22px 0; }
  .notebook-compact .popup .title img { max-width: 160px; }
  .notebook-compact .popup .v2-subtitle { margin-top: 10px; }
  .notebook-compact .content-mobile .instructions { padding: 8px 22px; }
  .notebook-compact .content-mobile .instructions img { display: none; }
}
