/* C014/A: explicit insets can be overridden by the local layout test, not UA claims. */
:root{--safe-top:env(safe-area-inset-top,0px);--safe-right:env(safe-area-inset-right,0px);--safe-bottom:env(safe-area-inset-bottom,0px);--safe-left:env(safe-area-inset-left,0px);--safari-vh:100dvh;--safari-vv-top:0px;--safari-keyboard-bottom:0px;-webkit-text-size-adjust:auto;text-size-adjust:auto}
html,body{overscroll-behavior-y:contain}
.topbar{padding-top:var(--safe-top);min-height:calc(63px + var(--safe-top));height:auto}
.workspace{padding-bottom:var(--safe-bottom)}
.sidebar{padding-top:calc(26px + var(--safe-top));padding-bottom:calc(18px + var(--safe-bottom))}
.modal-backdrop{top:var(--safari-vv-top);bottom:auto;height:var(--safari-vh);padding:calc(12px + var(--safe-top)) calc(12px + var(--safe-right)) calc(12px + var(--safe-bottom)) calc(12px + var(--safe-left))}
.modal{max-height:100%;min-height:0}.modal-header,.modal-footer{flex-shrink:0}.modal-body{min-height:0;overscroll-behavior:contain}
[data-audio-session-banner]{bottom:calc(18px + var(--safe-bottom) + var(--safari-keyboard-bottom))!important;right:calc(12px + var(--safe-right))!important;max-width:calc(100vw - 24px - var(--safe-left) - var(--safe-right))!important}
[data-safari-recovery]{margin:1rem;padding:1rem;border:1px solid var(--line);border-radius:.6rem;background:var(--paper);overflow-wrap:anywhere}
[data-safari-recovery] pre{white-space:pre-wrap;overflow-wrap:anywhere;max-height:35vh;overflow:auto}
#document-editor{-webkit-user-select:text;user-select:text;-webkit-touch-callout:default;scroll-margin-block:1rem}
@media (max-width:850px){
 body{font-size:.875rem}
 .topbar{padding-left:calc(17px + var(--safe-left));padding-right:calc(17px + var(--safe-right))}
 .page{padding-left:calc(16px + var(--safe-left));padding-right:calc(16px + var(--safe-right));padding-bottom:calc(24px + var(--safe-bottom))}
 button,.btn{white-space:normal;overflow-wrap:anywhere;min-height:2.75rem;max-width:100%;font-size:1rem;flex-shrink:1}
 button.small,.btn.small,.small-text{font-size:.875rem}.caption{font-size:.8rem}.field>span,.field>label{font-size:.875rem}
 input,select,textarea,.control{font-size:max(1rem,16px)!important}
 h1{font-size:1.8rem}h2{font-size:1.3rem}h3{font-size:1rem}
 .document-editor{font-size:1rem!important;padding:1rem!important;min-height:18rem!important}
 .document-title{font-size:1.15rem}.document-toolbar{gap:.4rem}
 .encounter-head,.page-header,.toolbar,.between,.panel-heading,.top-actions{flex-wrap:wrap;min-width:0}
 .bench-mobile-tabs{flex-wrap:wrap}.bench-mobile-tabs button{font-size:.9rem;min-width:0}
 .grid.two,.grid.three,.grid.four{grid-template-columns:minmax(0,1fr)}
 .record-block .actions{align-items:stretch}.record-block button{flex:1 1 8rem}
 .chat-compose{padding-bottom:calc(13px + var(--safe-bottom));min-width:0}
 .chat-compose textarea{font-size:1rem}.chat-compose .actions .caption{font-size:.75rem}
 .modal-header,.modal-body,.modal-footer{padding:1rem}.modal-footer{flex-wrap:wrap}
 .safari-keyboard .chat-compose:focus-within{position:fixed;z-index:45;left:var(--safe-left);right:var(--safe-right);bottom:var(--safari-keyboard-bottom);background:var(--paper);max-height:calc(var(--safari-vh) - 1rem);overflow:auto;border:1px solid var(--line)}
 .safari-keyboard .chat-compose:focus-within textarea{min-height:3.5rem;height:20dvh;max-height:calc(var(--safari-vh) * .32);resize:none}
 .safari-keyboard .chat-compose:focus-within .actions>:not([data-action="send-message"]){display:none}
 .safari-keyboard .chat-compose:focus-within .actions{justify-content:flex-end}
 .safari-keyboard #document-editor{min-height:5rem!important;height:calc(var(--safari-vh) * .45);max-height:calc(var(--safari-vh) * .6)}
}
@supports(font:-apple-system-body){:root{font:-apple-system-body}}
@media (max-width:850px){
 .safari-keyboard .document-panel:focus-within{position:fixed;z-index:44;left:var(--safe-left);right:var(--safe-right);top:calc(var(--safari-vv-top) + var(--safe-top));height:calc(var(--safari-vh) - var(--safe-top) - var(--safe-bottom));min-height:0;max-height:var(--safari-vh);display:flex;flex-direction:column;overflow:auto}
 .safari-keyboard .document-panel:focus-within>.panel-heading,.safari-keyboard .document-panel:focus-within>.tabs,.safari-keyboard .document-panel:focus-within>.document-title,.safari-keyboard .document-panel:focus-within>.doc-audit-note,.safari-keyboard .document-panel:focus-within>.document-toolbar:not(.document-edit-toolbar){display:none}
 .safari-keyboard .document-edit-toolbar{flex-shrink:0;padding:.3rem;gap:.25rem}
 .safari-keyboard .document-edit-toolbar>[data-action]:not([data-action="format-document"]){display:none}
 .safari-keyboard .document-panel:focus-within #document-editor{flex:1 1 auto;min-height:3rem!important;height:auto;max-height:none;padding:.5rem!important}
 .safari-keyboard .doc-footer{display:flex;flex-wrap:wrap;flex-shrink:0;padding:.4rem;font-size:.75rem;gap:.4rem}
 .safari-keyboard .doc-footer #word-count{display:none}
}
@media (max-width:850px){
 .bench-mobile-tabs button{flex:1 1 7rem}
 .encounter-head h1{font-size:1.3rem}
 .panel-heading,.encounter-meta{font-size:.875rem}
 .record-block .caption{font-size:.8rem!important}
 .doc-footer{font-size:.75rem;flex-wrap:wrap;gap:.5rem}
}
