/* Desktop retains its original control positions and full PDF pages. */
.controls-toggle, #mobile-transport, #mobile-preferences { display: none; }
/* Override generic button hover in both themes, including sticky touch hover. */
#controls-toggle:hover { background: none; }
@media (hover: hover) and (pointer: fine) {
  #controls-toggle:hover .drawer-label { background: var(--light); }
}
#account-controls { font-size: 11px; margin-top: 16px; line-height: 1.8; }
#account-controls:empty { display: none; }
#account-controls button { text-decoration: underline; min-height: 44px; }
#session-dialog { max-width: min(440px, calc(100vw - 30px)); line-height: 1.6; }
#session-dialog a { display: inline-block; padding-block: 12px; }
.score-page { aspect-ratio: var(--page-aspect); }
.score-surface { position: relative; width: 100%; aspect-ratio: var(--page-aspect); }

/* Keep the compact breakpoint in sync with mobile.js and zoom.js. */
@media (max-width: 760px), (max-width: 1024px) and (max-height: 600px) and (orientation: landscape) {
  body { overflow: hidden; }
  .sidebar-footer, .score-bottom { display: none; }
  main { display: block; height: 100dvh; min-height: 0; min-width: 0; }
  .score-pane {
    position: relative;
    height: calc(100dvh - var(--mobile-player-height, 160px));
    border: 0;
    padding-top: env(safe-area-inset-top);
  }
  .sidebar {
    position: fixed;
    inset: auto 0 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - env(safe-area-inset-top) - 16px);
    width: 100%;
    padding: 0 max(12px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    overflow: hidden;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -4px 24px #182e3020;
  }
  .sidebar.expanded { max-height: min(85dvh, calc(100dvh - env(safe-area-inset-top) - 8px)); }
  .controls-toggle {
    position: relative;
    display: flex;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 0 0;
    font-size: 11px;
    color: var(--green);
    border-radius: 12px;
  }
  /* Keep the full-width 44px tap target; only the inset label gets a highlight. */
  .drawer-label { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 4px 10px; border-radius: 6px; line-height: 16px; }
  .drawer-grip { position: absolute; top: 7px; width: 32px; height: 3px; border-radius: 3px; background: var(--line); }
  .drawer-chevron { display: block; flex: 0 0 12px; width: 12px; height: 12px; }
  .expanded .drawer-chevron { transform: rotate(180deg); }
  #player-details { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 4px 20px; scrollbar-width: thin; }
  .sidebar:not(.expanded) #player-details { display: none; }
  #mobile-transport { display: block; flex-shrink: 0; }
  #mobile-transport[inert] { opacity: .4; }
  #mobile-transport .transport-section { padding: 0; }
  .expanded #mobile-transport { border-top: 1px solid var(--line); padding-top: 8px; }
  .location { min-height: 22px; }
  #progress { display: none; }
  .transport { justify-content: space-evenly; gap: 8px; margin: 0; }
  .transport .icon-button { min-width: 44px; height: 48px; }
  .play-button { width: 48px; height: 48px; }
  .collection-label, .eyebrow { display: none; }
  .work-heading { padding: 12px 0; }
  .work-heading h1 { font-size: 22px; margin: 0 0 6px; }
  .work-heading h1 br { display: none; }
  .controls { display: block; }
  .controls section { padding: 16px 0; }
  .jump-row { padding: 8px 0 16px; }
  .jump-row form { min-height: 44px; }
  .jump-row button { min-width: 36px; min-height: 44px; }
  .jump-row input { width: 52px; }
  .sidebar :is(select, input[type=number], input[type=text]) { font-size: 16px; }
  .sidebar :is(.text-button, .bookmark-edit, .secondary-button, summary) { min-height: 44px; }
  .sidebar .modes button { min-height: 44px; font-size: 11px; }
  .sidebar .hint { font-size: 11px; }
  .metronome-options label { min-height: 36px; }
  #mobile-preferences { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; border-top: 1px solid var(--line); padding-top: 12px; }
  #mobile-preferences .score-toolbar {
    display: block;
    height: auto;
    min-height: 0;
    background: none;
    border: 0;
    padding: 0;
  }
  #mobile-preferences .score-toolbar > div:first-child { display: none; }
  #mobile-preferences .score-actions { justify-content: space-between; gap: 0; flex-wrap: wrap; }
  #mobile-preferences .icon-button { min-width: 40px; height: 44px; }
  #mobile-preferences :is(#zoom-out, #zoom-in) { display: none; }
  #mobile-preferences #zoom-value { width: auto; white-space: nowrap; }
  #mobile-preferences .follow { font-size: 11px; }
  #mobile-preferences .page-navigation { justify-content: center; }
  #mobile-preferences .theme-controls { justify-content: space-between; margin: 0; border: 0; padding: 0; }
  #mobile-preferences #theme { width: auto; flex: 1; }
  .score-context { display: none; }
  .score-context:has(.visual-metronome:not([hidden])) {
    display: flex;
    justify-content: center;
    height: auto;
    min-height: 36px;
    padding: 4px 8px;
  }
  .score-context > span { display: none; }
  #score-scroll { padding: 0; scroll-padding-top: 4px; }
  #pages { gap: 8px; width: 100%; min-width: 0; }
  .score-page {
    /* Fit the entire cropped score width, never a persisted desktop zoom. */
    width: 100%;
    max-width: 100%;
    aspect-ratio: var(--mobile-aspect);
    min-width: 0;
    border: 0;
    border-radius: 0;
    overflow: hidden;
  }
  .score-surface {
    position: absolute;
    width: var(--mobile-surface-width);
    left: var(--mobile-surface-left);
    top: var(--mobile-surface-top);
  }
  /* Reading needs only vertical scrolling; the cursor remains draggable. */
  .score-page, .score-overlay { touch-action: pan-y pinch-zoom; }
  #toast { top: 12px; bottom: auto; z-index: 6; }
}
/* Landscape phones use a narrow right-hand rail, not a bottom dock.
   Expanding settings overlays the score without changing its fitted width. */
@media (max-width: 1024px) and (max-height: 600px) and (orientation: landscape) {
  main { --mobile-rail-width: calc(89px + env(safe-area-inset-right)); }
  .score-pane {
    width: calc(100% - var(--mobile-rail-width));
    height: 100dvh;
    padding-left: env(safe-area-inset-left);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar, .sidebar.expanded {
    inset: 0 0 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 72px;
    grid-template-rows: 44px minmax(0, 1fr);
    width: var(--mobile-rail-width);
    height: 100dvh;
    max-height: none;
    padding: max(8px, env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) 8px;
    border: 0;
    border-left: 1px solid var(--line);
    border-radius: 0;
    box-shadow: -4px 0 24px #182e3020;
  }
  .sidebar.expanded { width: min(100%, calc(420px + env(safe-area-inset-right))); column-gap: 12px; }
  .controls-toggle { grid-column: 2; grid-row: 1; padding: 4px 0; font-size: 10px; }
  .drawer-label { padding-inline: 6px; }
  .drawer-grip, .drawer-chevron { display: none; }
  #player-details { grid-column: 1; grid-row: 1 / -1; padding: 8px 4px 20px; }
  #mobile-transport, .expanded #mobile-transport {
    grid-column: 2;
    grid-row: 2;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    border: 0;
    padding: 0;
  }
  #mobile-transport .transport-section {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
  }
  #score-only-note { grid-column: 2; grid-row: 2; align-self: center; text-align: center; font-size: 9px; }
  .location { flex-direction: column; justify-content: center; min-height: 32px; gap: 2px; font-size: 8px; letter-spacing: 0; }
  .location strong { font-size: 14px; margin-left: 3px; }
  #time-now { font-size: 9px; white-space: nowrap; }
  .transport { flex-direction: column; gap: 0; }
  .transport .icon-button { width: 48px; min-height: 44px; height: 44px; }
  .play-button { flex-shrink: 0; }
}
@media (max-width: 380px) {
  #mobile-preferences .follow { flex-basis: 100%; min-height: 44px; }
  #mobile-preferences .divider { display: none; }
}
