/* Diamond Caelum AI — ÇDP v1.8.1-rc1 · iPad ergonomics.
   Only interaction/overflow presentation; no changes to source archive or editor data. */

/* One-line buttons: avoid wrapping rows in headings, action groups and tab strips. */
.page.active .heading-actions,
.page.active .card-buttons,
.page.active .panel-head-actions,
.page.active .panel-tool-row,
.page.active .vai-toolbar-strip,
.page.active .vai-submode-bar,
.page.active .studio-reply-actions,
.page.active .studio-sug-actions,
.page.active .gem-mode-bar,
.page.active .dc-record-toolbar {
  flex-wrap: nowrap !important;
  min-width: 0;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.page.active .heading-actions,
.page.active .card-buttons,
.page.active .panel-head-actions,
.page.active .vai-toolbar-strip,
.page.active .vai-submode-bar,
.page.active .studio-reply-actions,
.page.active .studio-sug-actions,
.page.active .gem-mode-bar,
.page.active .dc-record-toolbar {
  overflow-x: auto !important;
  overflow-y: hidden !important;
  scrollbar-width: thin;
  touch-action: pan-x;
}
.page.active .heading-actions > button,
.page.active .card-buttons > button,
.page.active .panel-head-actions > button,
.page.active .vai-toolbar-strip > button,
.page.active .vai-submode-bar > button,
.page.active .dc-record-toolbar > button,
.page.active .gem-mode-bar > button {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
}
/* No horizontal bar should make its parent column wider than the visible panel. */
.page.active .card-title,
.page.active .panel-head { min-width: 0; max-width: 100%; }
.page.active .card-title > h2,
.page.active .panel-head > h3 { min-width: 0; }

/* Vertical scroll for text-based panels only: never hijack a drawing/zoom canvas. */
#res-panel-center, #res-panel-right,
#vai1-right, #vai2-right, #vai3-right, #vai4-right,
#vai5-right, #vai6-right, #vai7-right, #vai8-right, #vai9-right,
#ns-left, #ns-right, #rep-left, #rep-right,
#dc-vault-left, #dc-vault-right,
#cmp-left, #cmp-right, #astro-left, #astro-right,
#sky-bottom-panel, .studio-context-box, .studio-chat-log,
.lab-list-panel, .lab-detail-panel,
#fs-star-list, #fs-subview-content,
#notes-saved-list, #reports-saved-list, #research-saved-files-card {
  min-height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scroll-padding-bottom: 18px;
}
/* Text panels can scroll, while nested horizontal button bars remain touchable. */
#res-panel-center, #res-panel-right,
#ns-left, #ns-right, #rep-left, #rep-right,
#dc-vault-left, #dc-vault-right,
#sky-bottom-panel, .studio-chat-log,
.lab-list-panel, .lab-detail-panel { touch-action: pan-y; }
#sky-bottom-panel { overflow-x: hidden !important; }
#sky-bottom-panel .table-scroll { overflow-x: auto !important; touch-action: pan-x pan-y; }

/* Context menu: measured placement is in app.js, scroll remains on the menu. */
#dc-context-popover.dc-context-popover {
  box-sizing: border-box;
  width: min(280px, calc(100dvw - 20px)) !important;
  max-width: calc(100dvw - 20px) !important;
  max-height: min(68dvh, 520px, calc(100dvh - 20px)) !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior: contain !important;
  touch-action: pan-y !important;
  pointer-events: auto !important;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px)) !important;
  scroll-padding-bottom: 18px;
}
#dc-context-popover .dc-ctx-head {
  position: sticky; top: -8px; z-index: 1;
  background: rgba(244, 243, 254, .97);
}
#dc-context-popover .dc-ctx-item,
#dc-context-popover .dc-ctx-submenu { flex: 0 0 auto; }
#dc-context-popover .dc-ctx-item { min-height: 38px !important; }
#dc-context-popover .dc-ctx-item:focus-visible { outline: 2px solid #3668be; outline-offset: -2px; }
/* Keep the ••• trigger visible even while its context menu is open. */
[data-open-ctx].dc-dots-btn,
[data-open-ctx]:is(button) { visibility: visible !important; opacity: 1 !important; flex-shrink: 0 !important; }

/* Every edge/corner of a floating window is an accessible resize target. */
.float-window { max-width: calc(100dvw - 12px); }
.float-window [data-fw-resize] {
  position: absolute !important;
  touch-action: none !important;
  z-index: 8 !important;
  display: block !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  margin: 0 !important;
  padding: 0 !important;
}
.float-window [data-fw-resize="t"] { top:0; left:22px; right:22px; height:12px; cursor:n-resize; }
.float-window [data-fw-resize="b"] { bottom:0; left:22px; right:22px; height:15px; cursor:s-resize; }
.float-window [data-fw-resize="l"] { left:0; top:20px; bottom:20px; width:13px; cursor:w-resize; }
.float-window [data-fw-resize="r"] { right:0; top:20px; bottom:20px; width:13px; cursor:e-resize; }
.float-window [data-fw-resize="tl"] { top:0; left:0; width:24px; height:24px; cursor:nwse-resize; }
.float-window [data-fw-resize="tr"] { top:0; right:0; width:24px; height:24px; cursor:nesw-resize; }
.float-window [data-fw-resize="bl"] { bottom:0; left:0; width:24px; height:24px; cursor:nesw-resize; }
.float-window [data-fw-resize="br"] { bottom:0; right:0; width:24px; height:24px; cursor:nwse-resize; font-size:0 !important; }
.float-window [data-fw-resize]:focus-visible { outline:2px solid #a0ecf4 !important; outline-offset:-2px; background:rgba(96,215,232,.13) !important; }
.float-window.is-folded [data-fw-resize],
.float-window.is-maximized-float [data-fw-resize] { display:none !important; }
.float-window .float-body { overflow-x:hidden; overflow-y:auto !important; touch-action:pan-y !important; min-height:0; }

@media (max-width:740px) {
  .page.active .heading-actions { align-self:stretch; }
  #dc-context-popover.dc-context-popover { max-height:min(68dvh, 520px, calc(100dvh - 24px)) !important; }
}
