.toolbar > div:first-of-type { min-width:0; flex:1; }
.toolbar-actions { flex:none; }
.workspace { height:var(--visible-height,100dvh); }
.modal { top:var(--visible-top,0px); bottom:auto; height:var(--visible-height,100dvh); overflow-y:auto; overscroll-behavior:contain; }
.modal-card { min-width:0; max-height:calc(var(--visible-height,100dvh) - 36px); overflow-y:auto; overscroll-behavior:contain; overflow-wrap:anywhere; }
.modal-footer { flex-wrap:wrap; }
.modal .parent-options { position:static; max-height:min(225px,30dvh); }
.profile-popover { max-height:calc(var(--visible-height,100dvh) - 84px); overflow-y:auto; overscroll-behavior:contain; }
.context-menu { max-width:calc(100vw - 16px); max-height:calc(var(--visible-height,100dvh) - 16px); overflow-y:auto; overscroll-behavior:contain; }
.preview-document,.history-preview,.shared-note,.shared-path,.shared-content,.docs-content { min-width:0; overflow-wrap:anywhere; }
.preview-pane :not(pre) > code,.history-preview :not(pre) > code,.shared-content :not(pre) > code { max-width:100%; white-space:normal; overflow-wrap:anywhere; }
.preview-pane table,.history-preview table,.shared-content table,.docs-content table { display:block; max-width:100%; overflow-x:auto; border-collapse:collapse; }
.history-preview img { max-width:100%; height:auto; }
.properties-list { grid-template-columns:minmax(0,1fr); gap:4px; }
.properties-list dd { text-align:left; margin-bottom:10px; overflow-wrap:anywhere; }
.history-entry { flex-wrap:wrap; }
.history-entry-actions { justify-content:flex-start; }
.toast { bottom:max(16px,env(safe-area-inset-bottom)); z-index:80; }

@media (max-width:780px), (max-width:1024px) and (pointer:coarse) {
    .workspace { padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
    .sidebar { bottom:auto; height:var(--visible-height,100dvh); padding-block:env(safe-area-inset-top) env(safe-area-inset-bottom); padding-left:env(safe-area-inset-left); }
    .toolbar { display:grid; grid-template-columns:auto minmax(0,1fr) auto; gap:8px 10px; padding:10px 12px; }
    #mobile-notes-toggle { grid-column:1; grid-row:1; min-height:44px; }
    .toolbar > div:first-of-type { grid-column:2; grid-row:1; }
    .toolbar-actions { display:contents; }
    .toolbar-actions > .profile-menu { grid-column:3; grid-row:1; justify-self:end; }
    .profile-menu summary { min-width:44px; min-height:44px; justify-content:center; }
    .toolbar-actions > .danger { display:none; }
    #edit-note { grid-column:2 / -1; grid-row:2; justify-self:end; }
    #read-note { grid-column:2; grid-row:2; justify-self:end; }
    #save-note { grid-column:3; grid-row:2; }
    #save-state { grid-column:1; grid-row:2; max-width:95px; font-size:12px; overflow-wrap:anywhere; }
    .toolbar-actions .button { min-height:44px; padding:9px 11px; }
    .profile-item,.context-menu button,.parent-option { min-height:44px; }
    .tree-note,.tree-folder summary { min-height:44px; }
    .tree-context-trigger { width:44px; height:44px; }
    .side-actions button { width:40px; height:40px; }
    .editor-pane { padding:12px; }
    .editor-pane textarea { min-height:180px; font-size:16px; }
    .format-toolbar { flex-wrap:nowrap; overflow-x:auto; padding-bottom:10px; }
    .format-toolbar button { flex:none; min-width:40px; min-height:40px; }
    .editor-layout.is-reading .preview-pane { padding:12px; }
    .editor-layout.is-reading .preview-document { padding:18px 14px; }
    input:not([type="radio"]):not([type="checkbox"]),textarea,select { font-size:16px; }
    .modal { padding:12px; }
    .modal-card { max-height:calc(var(--visible-height,100dvh) - 24px); padding:18px; }
    .modal-footer .button,.modal-footer > a { min-height:44px; }
    .history-entry-actions button,.history-entry-actions a { min-height:40px; }
    .shared-content pre,.preview-pane pre { max-width:100%; }
    .shared-theme-menu button,.shared-theme summary,.shared-copy { min-height:44px; }
}

@media (max-width:600px) {
    .trash-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); width:100%; }
    .trash-actions > * { min-width:0; }
    .trash-actions .button { display:flex; align-items:center; justify-content:center; min-height:44px; width:100%; text-align:center; white-space:normal; }
    .trash-actions > [data-trash-preview-url] ~ .danger { grid-column:1 / -1; }
}
