/* v0955: desktop/tablet = a single centered row without scrolling;
   phone = one horizontally scrollable row. A measured CSS zoom is applied
   to direct flex items so hit-testing remains aligned with the painted UI. */
.tca-app.is-workspace #tca-toolbar,
.tca-app.is-workspace #tca-toolbar.is-compact,
.tca-app.is-workspace #tca-toolbar.is-wrapped,
html.tca-lesson-strip-mode .tca-app.is-workspace #tca-toolbar {
  display:flex!important;
  flex-direction:row!important;
  flex-wrap:nowrap!important;
  align-items:center!important;
  justify-content:center!important;
  gap:clamp(2px,.32vw,5px)!important;
  box-sizing:border-box!important;
  width:100%!important;
  max-width:100%!important;
  min-width:0!important;
  min-height:52px!important;
  height:auto!important;
  max-height:none!important;
  padding:6px clamp(24px,4vw,76px)!important;
  white-space:nowrap!important;
  overflow-x:hidden!important;
  overflow-y:visible!important;
  scroll-snap-type:none!important;
}
.tca-app.is-workspace #tca-toolbar > .tca-spacer {display:none!important}
.tca-app.is-workspace #tca-toolbar > :not(.tca-color-palette):not(.tca-stamp-options):not(.tca-spacer) {
  flex:0 0 auto!important;
  min-width:0;
  zoom:var(--tca-toolbar-fit-zoom,1);
}
html:not(.tca-lesson-strip-mode) .tca-app.is-workspace #tca-toolbar .tca-mobile-zoom-group {
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  flex:0 0 auto!important;
  gap:3px!important;
}
html.tca-lesson-strip-mode .tca-app.is-workspace #tca-toolbar .tca-mobile-zoom-group {display:none!important}
/* A narrower toolbar becomes icon-oriented before resorting to scaling.
   Tool names are retained as aria-label/title in index.php. */
.tca-app.is-workspace #tca-toolbar.tca-fit-icons .tca-tool-mode-btn {
  width:34px!important;
  min-width:34px!important;
  max-width:34px!important;
  height:38px!important;
  min-height:38px!important;
  padding:5px!important;
  gap:0!important;
}
.tca-app.is-workspace #tca-toolbar.tca-fit-icons .tca-tool-mode-btn > :not(.tca-tool-icon) {display:none!important}
.tca-app.is-workspace #tca-toolbar.tca-fit-icons .tca-tool-mode-btn .tca-tool-icon {
  width:22px!important;
  height:22px!important;
  flex:0 0 22px!important;
}
.tca-app.is-workspace #tca-toolbar.tca-fit-icons button:not(.tca-tool-mode-btn) {
  min-height:36px!important;
  padding:5px 6px!important;
  font-size:10px!important;
}
.tca-app.is-workspace #tca-toolbar.tca-fit-icons .tca-icon-only-btn {
  width:34px!important;
  min-width:34px!important;
  max-width:34px!important;
  padding:0!important;
}
.tca-app.is-workspace #tca-toolbar.tca-fit-icons .tca-size-control input[type=range]{width:58px!important}
.tca-app.is-workspace #tca-toolbar.tca-fit-icons .tca-toolbar-page-label {display:none!important}
.tca-app.is-workspace #tca-toolbar.tca-fit-icons .tca-toolbar-page-jump {padding:4px 5px!important;gap:3px!important}
.tca-app.is-workspace #tca-toolbar.tca-fit-icons .tca-toolbar-page-jump input {width:32px!important;min-width:32px!important}
.tca-app.is-workspace #tca-toolbar.tca-fit-icons .tca-mobile-zoom-group {gap:2px!important}
.tca-app.is-workspace #tca-toolbar.tca-fit-icons .tca-color-button {width:30px!important;min-width:30px!important;height:30px!important;min-height:30px!important}
/* Phone, including landscape phones: preserve the familiar full-size buttons. */
@media (max-width:540px), (orientation:landscape) and (max-height:500px) and (pointer:coarse){
  .tca-app.is-workspace #tca-toolbar,
  .tca-app.is-workspace #tca-toolbar.is-compact,
  .tca-app.is-workspace #tca-toolbar.is-wrapped,
  html.tca-lesson-strip-mode .tca-app.is-workspace #tca-toolbar {
    justify-content:flex-start!important;
    flex-wrap:nowrap!important;
    padding:6px 9px!important;
    gap:4px!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    scroll-snap-type:x proximity!important;
    -webkit-overflow-scrolling:touch!important;
    scrollbar-width:thin;
  }
  .tca-app.is-workspace #tca-toolbar > :not(.tca-color-palette):not(.tca-stamp-options):not(.tca-spacer) {
    zoom:1!important;
  }
}

/* v0955 desktop: a genuinely single-row toolbar; the previous desktop
   flex-wrap:wrap/space-between combination pushed controls onto a second row
   under real remote/book layouts, covering the separately positioned homework
   button. Tablet and phone rules above are byte-for-byte unchanged. */
@media (min-width:1180px) and (hover:hover) and (pointer:fine) {
  .tca-app.is-workspace #tca-toolbar,
  .tca-app.is-workspace #tca-toolbar.is-compact,
  .tca-app.is-workspace #tca-toolbar.is-wrapped,
  html.tca-lesson-strip-mode .tca-app.is-workspace #tca-toolbar {
    flex-direction:row!important;
    flex-wrap:nowrap!important;
    justify-content:center!important;
    align-items:center!important;
    gap:clamp(2px,.25vw,5px)!important;
    padding:7px clamp(16px,1.5vw,28px)!important;
    height:auto!important;
    min-height:60px!important;
    max-height:none!important;
    overflow-x:hidden!important;
    overflow-y:visible!important;
    white-space:nowrap!important;
    scroll-snap-type:none!important;
  }
  .tca-app.is-workspace #tca-toolbar > :not(.tca-color-palette):not(.tca-stamp-options):not(.tca-spacer) {
    zoom:var(--tca-toolbar-fit-zoom,1)!important;
    flex:0 0 auto!important;
  }
  html:not(.tca-lesson-strip-mode) .tca-app.is-workspace #tca-toolbar .tca-mobile-zoom-group {
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    flex:0 0 auto!important;
    gap:3px!important;
  }
  html.tca-lesson-strip-mode .tca-app.is-workspace #tca-toolbar .tca-mobile-zoom-group {display:none!important;}
  .tca-app.is-workspace #tca-toolbar > .tca-spacer {display:none!important;}
}
