html body.preview-redesign .editor-screen .template-tools-card[open] { display:grid !important; grid-template-columns:1fr !important; gap:10px !important; padding:12px !important; }
html body.preview-redesign .template-tools-current { grid-column:1 / -1 !important; grid-area:auto !important; padding:0 0 10px !important; }
html body.preview-redesign .template-tools-current #templateToolsTitle { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
html body.preview-redesign .template-tools-card .template-row-primary,
html body.preview-redesign .template-tools-card .template-row-secondary { display:grid !important; grid-template-columns:repeat(2,minmax(0,1fr)) !important; gap:8px !important; width:100% !important; padding:0 !important; margin:0 !important; position:static !important; background:transparent !important; border:0 !important; box-shadow:none !important; }
html body.preview-redesign .template-tools-card .template-row-secondary[hidden] { display:none !important; }
html body.preview-redesign .template-tools-card .template-more-actions { display:block !important; grid-area:auto !important; min-width:0 !important; width:100% !important; padding:0 !important; border:0 !important; }
html body.preview-redesign .template-tools-card .template-action-button { display:flex !important; align-items:center !important; justify-content:center !important; width:100% !important; min-width:0 !important; min-height:44px !important; height:auto !important; padding:8px 6px !important; margin:0 !important; border-radius:999px !important; text-align:center !important; font-size:13px !important; line-height:1.2 !important; grid-column:auto !important; }
html body.preview-redesign .template-tools-card .template-action-label { grid-column:auto !important; text-align:center !important; }
html body.preview-redesign .template-tools-card .template-action-icon { display:none !important; }
html body.preview-redesign .template-tools-card .template-action-button[hidden] { display:none !important; }
html body.preview-redesign .editor-screen .template-tools-card .template-row-primary .template-more-toggle:last-child { grid-column:auto !important; }
html body.preview-redesign .template-tools-content { display:contents; }
@media (min-width:900px) {
 html body.preview-redesign .editor-screen .template-tools-card[open] { grid-template-areas:none !important; grid-template-columns:minmax(0,3fr) minmax(0,2fr) !important; align-items:center !important; }
 html body.preview-redesign .editor-screen .template-tools-card[open] > .template-tools-collapse-summary,
 html body.preview-redesign .editor-screen .template-tools-card[open] > .template-tools-current { grid-column:1 / -1 !important; grid-area:auto !important; }
 html body.preview-redesign .editor-screen .template-tools-card[open] > .template-tools-current { display:flex !important; align-items:center !important; justify-content:space-between !important; }
 html body.preview-redesign .editor-screen .template-tools-card[open] .template-tools-current > div,
 html body.preview-redesign .editor-screen .template-tools-card[open] .template-tools-insert { grid-area:auto !important; }
 html body.preview-redesign .editor-screen .template-tools-card[open] > .template-row-primary { grid-column:1 !important; grid-template-columns:repeat(3,minmax(0,1fr)) !important; grid-area:auto !important; }
 html body.preview-redesign .editor-screen .template-tools-card[open] > .template-more-actions { grid-column:2 !important; grid-area:auto !important; }
 html body.preview-redesign .editor-screen .template-tools-card[open] .template-more-toggle { display:none !important; }
}

/* No desktop, preserve espaço suficiente para os rótulos das ações. */
@media (min-width:900px) {
 html body.preview-redesign .editor-screen .template-tools-card[open] .template-tools-content .template-action-button:not(.template-more-toggle):not([hidden]) {
   min-width:120px !important;
   padding-inline:10px !important;
   white-space:nowrap !important;
 }
}

/* Tela cheia e lateral recolhida têm largura livre para a grade completa. */
@media (min-width:900px) {
 html body.preview-redesign.editor-focus-mode .editor-screen .template-tools-card[open] > .template-tools-content,
 html body.preview-redesign .editor-screen.recent-sidebar-collapsed .template-tools-card[open] > .template-tools-content {
   grid-template-columns:repeat(5,minmax(140px,1fr)) !important;
   gap:8px !important;
 }
}

/* No editor PACS, os campos visíveis compartilham toda a faixa disponível. */
@media (min-width:1100px) {
 html body.preview-redesign.quick-editor-mode .editor-screen .details-panel > .field-grid {
   grid-template-columns:minmax(160px,1.15fr) minmax(220px,1.65fr) minmax(360px,3.2fr) !important;
   grid-template-areas:
     "folder category exam"
     "more more more" !important;
   gap:10px !important;
   width:100% !important;
   max-width:100% !important;
 }
 html body.preview-redesign.quick-editor-mode .editor-screen .details-panel > .field-grid:has(#examSideField:not([hidden])) {
   grid-template-columns:minmax(145px,1fr) minmax(190px,1.35fr) minmax(360px,3.1fr) minmax(110px,.85fr) !important;
   grid-template-areas:"folder category exam side" "more more more more" !important;
 }
 html body.preview-redesign.quick-editor-mode .editor-screen .details-panel #examSideField:not([hidden]) {
   grid-area:side !important;
   min-width:0 !important;
 }
 html body.preview-redesign.quick-editor-mode .editor-screen .details-panel > .field-grid:has(#examSubcategoryField[hidden]) {
   grid-template-columns:minmax(170px,1fr) minmax(360px,2fr) !important;
   grid-template-areas:"folder exam" "more more" !important;
 }
 html body.preview-redesign.quick-editor-mode .editor-screen .details-panel > .field-grid:has(#examSubcategoryField[hidden]):has(#examSideField:not([hidden])) {
   grid-template-columns:minmax(150px,1fr) minmax(360px,2.35fr) minmax(110px,.8fr) !important;
   grid-template-areas:"folder exam side" "more more more" !important;
 }
}

/* Refinamento exclusivo do painel de máscaras no celular. O arquivo deste
   layout é carregado depois de styles.css, portanto o ajuste precisa ficar
   aqui para não ser sobrescrito pelas regras responsivas. */
@media (max-width:899px) {
 html body.preview-redesign .editor-screen .template-tools-card[open] {
   gap:4px !important;
 }
 html body.preview-redesign .editor-screen .template-tools-card[open] > .template-tools-collapse-summary {
   padding-bottom:2px !important;
 }
 html body.preview-redesign .editor-screen .template-tools-card[open] .template-tools-current {
   padding-bottom:7px !important;
 }
 html body.preview-redesign .editor-screen .template-tools-card[open] .template-tools-insert {
   min-height:34px !important;
   padding:5px 12px !important;
   font-size:14px !important;
   line-height:1.2 !important;
 }
 html body.preview-redesign .editor-screen .template-tools-card[open] .template-row-primary {
   margin-top:10px !important;
 }
}
@media (min-width:900px) {
 html body.preview-redesign .editor-screen .template-tools-card[open] { display:block !important; }
 html body.preview-redesign .editor-screen .template-tools-card[open] > .template-tools-content { display:grid !important; grid-template-columns:minmax(0,3fr) minmax(0,2fr) !important; gap:8px !important; width:100% !important; }
 html body.preview-redesign .editor-screen .template-tools-card[open] > .template-tools-content:has(#deleteSelectedTemplateButton:not([hidden])) { grid-template-columns:repeat(2,minmax(0,1fr)) !important; }
 html body.preview-redesign .editor-screen .template-tools-content > .template-tools-current { display:flex !important; grid-area:auto !important; grid-column:1 / -1 !important; justify-content:space-between !important; align-items:center !important; }
 html body.preview-redesign .editor-screen .template-tools-content > .template-row-primary { display:grid !important; grid-area:auto !important; grid-column:1 !important; grid-template-columns:repeat(3,minmax(0,1fr)) !important; width:100% !important; }
 html body.preview-redesign .editor-screen .template-tools-content > .template-more-actions { display:block !important; grid-area:auto !important; grid-column:2 !important; width:100% !important; }
 html body.preview-redesign .editor-screen .template-tools-content .template-row-secondary:has(#deleteSelectedTemplateButton:not([hidden])) { grid-template-columns:repeat(3,minmax(0,1fr)) !important; }
 html body.preview-redesign .editor-screen .template-tools-content .template-row-secondary [data-template="blank"] { order:-1; }
 html body.preview-redesign .editor-screen .template-tools-content .template-more-toggle { display:none !important; }
 html body.preview-redesign .editor-screen .template-tools-content .template-action-button { display:flex !important; width:100% !important; justify-content:center !important; }
 /* As duas antigas linhas tornam-se um único grid, com células iguais. */
 html body.preview-redesign .editor-screen .template-tools-card[open] > .template-tools-content { grid-template-columns:repeat(5,minmax(0,1fr)) !important; gap:6px !important; }
 html body.preview-redesign .editor-screen .template-tools-card[open] > .template-tools-content:has(#deleteSelectedTemplateButton:not([hidden])) { grid-template-columns:repeat(6,minmax(0,1fr)) !important; }
 html body.preview-redesign .editor-screen .template-tools-card[open] .template-tools-content > .template-row-primary,
 html body.preview-redesign .editor-screen .template-tools-card[open] .template-tools-content > .template-more-actions,
 html body.preview-redesign .editor-screen .template-tools-card[open] .template-tools-content .template-row-secondary { display:contents !important; }
 html body.preview-redesign .editor-screen .template-tools-card[open] .template-tools-content .template-action-button:not(.template-more-toggle):not([hidden]) { display:flex !important; grid-area:auto !important; min-height:40px !important; height:40px !important; padding:5px 4px !important; font-size:13px !important; }
 html body.preview-redesign .editor-screen .template-tools-card[open] .template-tools-content .template-action-button[data-template="blank"] { order:1; }
 html body.preview-redesign .editor-screen .template-tools-card[open] .template-tools-content .template-action-button[data-template="reset"] { order:2; }
 html body.preview-redesign .editor-screen .template-tools-card[open] .template-tools-content .template-action-button[data-template="delete"] { order:3; }
}

/* Tela cheia e lateral recolhida têm largura livre para a grade completa. */
@media (min-width:900px) {
 html body.preview-redesign.editor-focus-mode .editor-screen .template-tools-card[open] > .template-tools-content,
 html body.preview-redesign .editor-screen.recent-sidebar-collapsed .template-tools-card[open] > .template-tools-content {
   grid-template-columns:repeat(5,minmax(140px,1fr)) !important;
   gap:8px !important;
 }
}
