/* Shared usability contract: readable content, bounded popovers and clear focus. */
:root{--ui-focus:#2d739d;--ui-border:#d8e3ed;--ui-secondary:#536c82;--ui-surface:#f7fafc}
:where(button,a,input,select,textarea,summary,[tabindex]):focus-visible{outline:3px solid var(--ui-focus);outline-offset:3px}
:where(button,summary,a){touch-action:manipulation}
.merge-date-part{display:inline-block;white-space:nowrap;overflow-wrap:normal;word-break:normal;max-width:100%}
.empty-actions{display:flex;justify-content:center;margin:18px 0 0}
.empty-actions .button{min-height:44px;padding:10px 18px}
.sheet-tool-menu[open]>summary{border-color:var(--ui-focus);background:#edf5fb}
.sheet-tag-picker>div{max-height:240px;overflow-y:auto;overscroll-behavior:contain}
.sheet-tool-popover{max-height:min(380px,60dvh);overflow-y:auto;overscroll-behavior:contain}
.admin-simple-nav button[aria-current=page]{font-weight:650}
.friendly-fields .column-detail{scroll-margin-top:150px}
@media(min-width:1001px){.friendly-fields .column-detail{position:sticky;top:90px}.today-focus .focus-list{grid-template-columns:repeat(auto-fill,minmax(min(100%,360px),1fr))}}
@media(max-width:760px){
 body[data-view=admin] .admin-shell .admin-tabs.admin-simple-nav{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:6px;overflow:visible!important;padding:6px;white-space:normal}
 body[data-view=admin] .admin-shell .admin-tabs.admin-simple-nav>button{min-width:0!important;width:100%;min-height:44px;white-space:normal;line-height:1.4;padding:8px;font-size:13px}
 .friendly-fields .fields-save-bar{display:grid;grid-template-columns:minmax(0,1fr);gap:8px;position:static}
 .friendly-fields .fields-main-tabs{margin:0;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%}
 .friendly-fields .fields-main-tabs>.button{min-width:0;min-height:44px;font-size:13px;white-space:nowrap;padding:8px 6px}
 .friendly-fields .fields-save-bar>div:last-child{display:flex;flex-direction:row-reverse;align-items:center;justify-content:space-between;gap:8px;text-align:left}
 .friendly-fields .fields-save-bar [data-fields-state]{font-size:12px}
 .friendly-fields .column-row-actions .button{min-width:36px!important;min-height:40px!important}
 .friendly-fields .column-row-actions [data-column-edit]{min-width:48px!important}
 .friendly-fields .column-detail{scroll-margin-top:76px}
 .admin-sheet .admin-sheet-toolbar{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 .admin-sheet .admin-sheet-toolbar .sheet-search-label,.admin-sheet .admin-sheet-toolbar [data-sheet-save]{grid-column:1/-1;width:100%;margin:0}
 .admin-sheet-toolbar button,.admin-sheet-toolbar .sheet-tool-menu>summary{width:100%;min-width:0;justify-content:center;text-align:center}
 .admin-sheet .sheet-search-label input{font-size:16px;height:44px}
 .admin-sheet [data-sheet-field]:focus{font-size:16px}
 .sheet-meta-bar{align-items:flex-start;font-size:12px;line-height:1.5;gap:8px}
 .sheet-meta-bar [data-sheet-status]{text-align:right}
 .sheet-help-menu .sheet-tool-popover{right:0;left:auto;width:min(270px,calc(100vw - 64px))}
 .csv-review-dialog{width:calc(100vw - 24px);max-height:calc(100dvh - 32px);padding:14px;box-sizing:border-box}
 .csv-review-rows .csv-item-decisions button,.csv-review-rows .csv-ignore-button{width:36px;height:36px;min-height:36px}
 .csv-review-rows .csv-review-item-title{padding-right:44px;font-size:13px}
 .csv-review-rows .csv-item-content{padding-right:44px}
 .csv-review-actions>button{min-height:44px}
 .bottom-nav{padding-bottom:max(8px,env(safe-area-inset-bottom))}
}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto!important;animation-duration:.01ms!important;transition-duration:.01ms!important}}

/* Mobile editing keeps the primary action and preview within easy reach. */
.mobile-editor-views{display:none}
@media(max-width:760px){
 body[data-view=admin] .admin-shell .admin-tabs.admin-simple-nav{gap:4px;padding:4px;margin-bottom:10px}
 body[data-view=admin] .admin-shell .admin-tabs.admin-simple-nav>button{min-height:40px;padding:6px}
 .friendly-fields,.admin-sheet{padding-bottom:76px}
 .friendly-fields .fields-save-bar{padding:8px 0;gap:0}
 .friendly-fields .fields-save-bar>div:last-child{position:fixed;left:12px;right:12px;bottom:calc(62px + env(safe-area-inset-bottom));z-index:44;padding:8px 10px;background:#fff;border:1px solid var(--ui-border);border-radius:10px;box-shadow:0 -3px 14px #244f7210}
 .friendly-fields .fields-save-bar [data-fields-save]{min-height:40px;padding:8px 16px}
 .friendly-fields .column-detail{scroll-margin-top:12px}
 .admin-sheet .admin-sheet-toolbar{gap:6px}
 .admin-sheet .admin-sheet-toolbar [data-sheet-save]{position:fixed;left:12px;bottom:calc(62px + env(safe-area-inset-bottom));width:calc(100% - 24px);min-height:44px;z-index:44;box-shadow:0 -3px 14px #244f7210}
 .admin-sheet .admin-sheet-toolbar [data-sheet-save]:disabled{opacity:1;background:#e3eaf0;color:#63798d;border:1px solid var(--ui-border)}
 .admin-sheet-toolbar button,.admin-sheet-toolbar .sheet-tool-menu>summary{min-height:40px;padding:7px 8px}
 .merge-editor .unified-card-editor{padding:8px;border-radius:10px}
 .merge-editor .mobile-editor-views{display:flex;gap:4px;padding:4px;margin-bottom:8px;background:#eaf1f7;border-radius:8px;position:sticky;top:8px;z-index:20}
 .mobile-editor-views button{flex:1;min-height:40px;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--ui-secondary);font-size:13px}
 .mobile-editor-views button[aria-pressed=true]{background:#fff;border-color:var(--ui-border);color:#244f72;font-weight:650}
 .merge-editor[data-mobile-view=template] .preview-panel,.merge-editor[data-mobile-view=preview] .template-panel,.merge-editor[data-mobile-view=preview] .toolbar{display:none!important}
 .merge-editor .unified-card-editor>.toolbar{padding:5px;gap:4px;margin-bottom:8px}
 .merge-editor .standard-tools-section{padding:4px;gap:4px;width:auto;max-width:100%;border-radius:7px}
 .merge-editor .standard-section-title{display:none}
 .merge-editor .standard-tools-section .tool-group-controls{gap:4px;flex-wrap:wrap}
 .merge-editor .standard-tools-section .editor-tool-group,.merge-editor .standard-tools-section .tool-group-controls{display:contents}
 .merge-editor .standard-tools-section{flex-wrap:wrap}
 .merge-editor .toolbar button,.merge-editor .toolbar select,.merge-editor .toolbar summary{min-height:36px}
 .merge-editor .toolbar #font-family{width:108px;font-size:16px}
 .merge-editor .toolbar #format{width:100px;font-size:16px}
 .merge-editor .toolbar #size{width:56px;font-size:16px}
 .merge-editor .toolbar #width{font-size:16px}
 .merge-editor .unified-card-editor .template-panel,.merge-editor .unified-card-editor .preview-panel{padding:8px;min-height:0}
 .merge-editor .unified-card-editor #template{padding:6px;gap:6px;margin-top:4px}
 .merge-editor .edit-cell{min-height:48px}
 .merge-editor .unified-card-editor .preview-panel>#preview{margin:8px auto 0}
 .merge-editor .unified-card-editor .card-editor-workspace{gap:0}
 .merge-editor .preview-panel>.section-title select{font-size:16px!important;max-width:44%;padding:4px!important}
}

@media(min-width:1100px){
 body[data-view=saved] .saved-toolbar{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:center}
 body[data-view=saved] .saved-period-tabs{grid-column:1;grid-row:1;justify-self:start;min-width:280px}
 body[data-view=saved] .saved-tools{grid-column:2;grid-row:1;display:flex;gap:6px;align-items:center;flex-wrap:nowrap}
 body[data-view=saved] .saved-date-control{grid-column:1/-1;grid-row:2;max-width:620px;width:100%;box-sizing:border-box}
 body[data-view=saved] .saved-period-tabs button,body[data-view=saved] .saved-tools button{white-space:nowrap;min-width:60px;flex-shrink:0}
}
