/* Shared focus treatment for editable controls. Keep geometry and theme intact. */
:root body :is(
 input:not(:is([type=checkbox],[type=radio],[type=range],[type=color],[type=file],[type=button],[type=submit],[type=reset],[type=hidden],[type=image])),
 textarea,select,[contenteditable]:not([contenteditable="false"])
):is(:focus,:focus-visible){
 outline:2px solid var(--focus-ring-color,var(--theme-accent,var(--mint,#8be5ba)))!important;
 outline-offset:-2px!important;box-shadow:none!important;
}
/* Composite inputs own one frame; their editable children stay borderless. */
:root body :is(.search-box,.ca-editor,.split-document):has(:is(input,textarea,[contenteditable]:not([contenteditable="false"])):focus){
 outline:2px solid var(--focus-ring-color,var(--theme-accent,var(--mint,#8be5ba)))!important;
 outline-offset:-2px!important;box-shadow:none!important;
}
:root body :is(.search-box,.ca-editor,.split-document) :is(input,textarea,[contenteditable]:not([contenteditable="false"])):is(:focus,:focus-visible){
 outline:none!important;outline-offset:0!important;box-shadow:none!important;
}

/* Keep touch scrolling in the active dialog; closing the last layer releases the page. */
@media (max-width:980px), (pointer:coarse) {
 :root:has(dialog:modal,.ref-thumbnail-popover:popover-open,.portrait-notes[open]),
 :root:has(dialog:modal,.ref-thumbnail-popover:popover-open,.portrait-notes[open]) body {
  overflow:hidden;
  overscroll-behavior:none;
 }
 :is(dialog:modal,.ref-thumbnail-popover:popover-open,.portrait-notes[open]) {
  overscroll-behavior:contain;
 }
}
