/* Restore the 172 native layout without changing text or business scripts.
   Important dimensions cancel inline values written by the retained fit helper. */
html:has(body.page-fit-home) { height: auto; min-height: 100%; overflow: auto; }
html:has(body.page-fit-workspace) { height: 100%; overflow: hidden; }
body.page-fit {
  position: relative;
  width: 100% !important;
  left: auto !important;
  top: auto !important;
  transform: none !important;
  zoom: 1;
  margin: 0;
}
body.page-fit-home {
  height: auto !important;
  min-height: 100vh;
  overflow: visible;
  display: flex;
  flex-direction: column;
}
body.page-fit-workspace {
  height: 100vh !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.page-fit-workspace #topbar {
  height: 52px;
  min-height: 0;
  padding: 8px 16px;
  flex-wrap: nowrap;
  gap: normal;
}
body.page-fit-workspace .topbar-left { align-items: baseline; flex-wrap: nowrap; }
body.page-fit-workspace .topbar-center { min-width: 0; flex: 1; text-align: center; }
body.page-fit-workspace .topbar-right { flex: 0 1 auto; flex-wrap: nowrap; }
body.page-fit-workspace #main { overflow: hidden; }
body.page-fit-workspace #viewer-container { min-width: 0; flex: 1; flex-shrink: 1; }
body.page-fit-workspace #statusbar { max-height: none; overflow: visible; }
body.page-fit-workspace .subtitle { white-space: nowrap; }
body.page-fit dialog { transform: none; }
@media (max-width: 1200px) {
  body.page-fit-workspace #topbar { height: auto; min-height: 52px; flex-wrap: wrap; gap: 8px 16px; }
  body.page-fit-workspace .topbar-left { align-items: center; flex: 0 1 auto; }
  body.page-fit-workspace .topbar-center { min-width: 160px; text-align: right; }
  body.page-fit-workspace .topbar-right { flex: 1 1 100%; min-width: 0; overflow-x: auto; padding-bottom: 4px; }
  body.page-fit-workspace .topbar-right > * { flex-shrink: 0; }
  body.page-fit-workspace #statusbar { max-height: 20vh; overflow-y: auto; flex-shrink: 0; }
}
@media (max-width: 600px) {
  body.page-fit-workspace #topbar { padding: 8px; }
  body.page-fit-workspace .topbar-left { flex-wrap: wrap; width: 100%; }
  body.page-fit-workspace .subtitle { white-space: normal; }
  body.page-fit-workspace .topbar-center { flex: 1 1 100%; text-align: left; }
  body.page-fit-workspace #main { overflow-x: auto; }
  body.page-fit-workspace #viewer-container { min-width: 320px; flex: 1 0 320px; }
  body.page-fit-workspace #sidebar-left,
  body.page-fit-workspace #sidebar-right { flex-shrink: 0; }
}

/* Compact image tools on narrow workspaces. */
@media (max-width: 1500px) {
  body.page-fit-workspace #quickToolbar {
    gap: 2px;
    padding: 6px 8px;
  }
  body.page-fit-workspace #quickToolbar .quick-btn {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
  }
  body.page-fit-workspace #quickToolbar .quick-btn svg {
    width: 22px;
    height: 22px;
  }
  /* Override the legacy 56px/48px important exception only at narrow widths. */
  body.page-fit-workspace #quickToolbar .quick-btn.angle-btn-large {
    width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
  }
  body.page-fit-workspace #quickToolbar .quick-btn.angle-btn-large svg {
    width: 22px !important;
    height: 22px !important;
  }
  body.page-fit-workspace #quickToolbar .quick-divider {
    flex: 0 0 1px;
    margin: 0 4px;
  }
}

/* Reserve two status-text lines without clipping qualification warnings. */
@media (max-width: 1500px) {
  body.page-fit-workspace #statusbar .status-left {
    min-height: 33px;
  }
}
