/* Compact controls must stay readable when focused. Keep native pinch zoom
   enabled; do not compensate for small text with viewport scale restrictions. */
/* Theme rules must not re-display deliberately hidden listening controls. */
html body #hoeren.hoeren-audio-disabled [hidden] {
  display: none !important;
}
html body #hoeren.hoeren-audio-disabled audio {
  grid-column: 1 / -1 !important;
  width: 100% !important;
  min-width: 0 !important;
  min-height: 54px;
}

@media (max-width: 1180px), (hover: none) and (pointer: coarse) {
  html {
    zoom: 1 !important;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  html body :is(input, select, textarea),
  html body :is(#primarySidebar, #schreiben, #profileModal) :is(input, select, textarea),
  html[data-theme] body .main #deutsch_library :is(input, select, textarea),
  html[data-theme] body #schreiben > .writing-toolbar > #writingSelect,
  html body #shadowPlaybackSpeed {
    font-size: max(16px, 1rem) !important;
  }

  html body :is(button, a, input, select, textarea, [contenteditable="true"]) {
    touch-action: manipulation;
  }
}

/* Large touch tablets must not inherit the desktop's 80% page scale. */
@media (max-width: 1180px), (pointer: coarse) {
  html body.mobile-shell-ready.learner-keyboard-open :is(#mobileBottomNav, #supportAssistantTrigger) {
    display: none !important;
  }
  html body.mobile-shell-ready.learner-keyboard-open .main {
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)) !important;
  }
  html:has(body.mobile-shell-ready.learner-keyboard-open) {
    scroll-padding-bottom: 18px;
  }
}

@media (pointer: coarse) {
  html[data-theme] body #dashboard { zoom: 1 !important; }
  html[data-theme] body .main .page.active:is(#dashboard, #lesen, #hoeren, #schreiben, #sprechen, #telc_score, #pflege, #copy_text, #deutsch_library, #mock, #stats, #shadowing, #arena) :is(button, select, input:not([type=radio]):not([type=checkbox]):not([type=hidden]):not([type=range])),
  html[data-theme] body .topbar :is(button, select),
  html[data-theme] body #lesen.active #lesenPracticeView > .learning-toolbar > button,
  html[data-theme] body :is(#closeModal, #closeExplain, #closeProfile) {
    min-height: 44px !important;
    min-width: 44px !important;
  }
  html[data-theme] body #hoeren .listen-question-card label {
    min-height: 44px !important;
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }
}

@media (min-width: 1181px) and (max-width: 1400px) and (pointer: coarse) {
  html[data-theme] body #dashboard .dashboard-skill-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* A phone turned sideways has very little vertical room. Keep navigation
   reachable at the page end rather than over the learner's answers/editor. */
@media (min-width: 600px) and (max-width: 950px) and (max-height: 500px) and (orientation: landscape) {
  html[data-theme] body.mobile-shell-ready .mobile-bottom-nav {
    position: static !important;
    margin: 12px 8px calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    width: calc(100% - 16px) !important;
  }
  html[data-theme] body.mobile-shell-ready .main {
    padding-bottom: 18px !important;
  }
  html:not(.arena-standalone-core):has(body.mobile-shell-ready) {
    scroll-padding-bottom: 18px;
  }
  html[data-theme] body #schreiben .writing-toolbar__basic {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}
