/* Declare typography first: important declarations in this layer outrank legacy page rules. */
@layer app-typography, app-surfaces, app-system;

/* Reference UI scale: 14px reading and controls, 13px supporting text.
   Article typography, score numbers, icons and keyboard hints retain their roles. */
@layer app-typography {
 body:is(.workspace-page,.writing-app,.auth-page) {
  /* One interface family: labels and metadata must not switch typefaces. */
  --brand-secondary-font:var(--brand-body-font)!important;
  --ui-font:var(--brand-body-font);--ui-label-font:var(--ui-font);
  --ui-body:14px;--ui-label:14px;--ui-meta:13px;
  --app-body-size:14px;--app-label-size:14px;--app-small-size:13px;
  --brand-body-size:14px;--brand-label-size:14px;--brand-meta-size:13px;
  --dialog-heading-size:16px;--app-dialog-title-size:16px;
  font-size:var(--ui-body)!important;line-height:1.5!important;
 }
 /* Include nested button labels and definition lists: element-specific legacy
    fonts otherwise produce different faces within a single panel or control. */
 body:is(.workspace-page,.writing-app,.auth-page)
 :where(.workspace-content,.writing-inspector,.editor-rail,.app-header,.grouped-sidebar,.grouped-mobile-navigation,dialog,.modal-card,.auth-form-panel,.website-setup-main,.document-menu,.app-dialog-card)
 :is(h1,h2,h3,h4,h5,h6,p,a,li,td,th,label,legend,input,select,textarea,button,summary,small,strong,em,span,dt,dd,figcaption):not(:where(#contentEditor,#contentEditor *,#documentTitleInput,pre,pre *,code,code *,kbd,kbd *,samp,samp *,svg *,[data-ui-icon],[aria-hidden=true],.icon,.icon *)) {
  font-family:var(--ui-font)!important;
 }
 body:is(.workspace-page,.writing-app,.auth-page)
 :where(.workspace-content,.writing-inspector,.editor-rail,.app-header,.grouped-sidebar,.grouped-mobile-navigation,dialog,.modal-card,.auth-form-panel,.website-setup-main,.document-menu,.app-dialog-card)
 :is(p,li,td,label,input,select,textarea,button,summary):not(:where(#contentEditor,#contentEditor *,#documentTitleInput,.score-semicircle-number,.score-semicircle-number *,[data-ui-icon],.editor-block-drag,.source-heading-level)) {
  font-size:var(--ui-body)!important;line-height:1.5!important;
 }
 body:is(.workspace-page,.writing-app,.auth-page)
 :is(.btn-primary,.btn-secondary,.quiet-button,.header-link,.action-link,.action-btn,.app-dialog-btn,.plan-checkout-button,.social-login-btn,.auth-submit,.filter-tab,.filter-chip,.content-view-tabs button,.research-view-tabs button) {
  font-size:var(--ui-body)!important;line-height:20px!important;
 }
 body:is(.workspace-page,.writing-app) :is(.grouped-sidebar,.grouped-mobile-navigation)
 :is(.nav-item,.navigation-group>summary,.nav-context>summary,.nav-popover>a,.sidebar-account>summary,.nav-new>summary,.management-nav-link,.management-nav-heading) {
  font-size:var(--ui-body)!important;line-height:20px!important;
 }
 body:is(.workspace-page,.writing-app) :is(.source-heading-text,.app-row-title,.project-name,.dashboard-document-copy>strong,.dashboard-project-list strong,.research-history-table a,.planner-table a,.audit-inventory a,.documents-table a,.documents-table td strong) {
  font-size:var(--ui-body)!important;line-height:1.5!important;
 }
 body:is(.workspace-page,.writing-app,.auth-page)
 :where(.workspace-content,.writing-inspector,dialog,.modal-card,.auth-form-panel,.website-setup-main,.app-dialog-card)
 :is(th,small,.muted-text,.help-text,.hint,.field-hint,.form-hint,.form-help,.field-help,.wp-hint,.wp-options,#wordpressFeedback,.app-row-meta,.document-subtitle,.document-row-meta,.settings-card-description,.setting-description,.score-explanation,.score-tasks-summary,.source-card-meta,.editor-panel-description,.editor-panel-intro) {
  font-size:var(--ui-meta)!important;line-height:1.5!important;
 }
 body:is(.workspace-page,.writing-app) header.app-header :is(.app-header-date,.app-header-date time,.app-header-date time span) {
  font-size:var(--ui-meta)!important;line-height:20px!important;
 }
 body:is(.workspace-page,.writing-app) :is(.badge,.document-status-badge,.status-badge,.status-pill,.nav-popover-label,.management-group-heading) {
  font-size:var(--ui-meta)!important;line-height:18px!important;
 }
 body:is(.workspace-page,.writing-app,.auth-page) :is(dialog,.modal-card,.app-dialog-card) :is(h1,h2,h3,.modal-title,.dialog-title) {
  font-size:16px!important;line-height:24px!important;
 }
 body.workspace-page :is(.app-page-title,.settings-section-heading .section-title,.admin-content-heading h2) {
  font-size:var(--ui-title)!important;line-height:1.3!important;
 }
 body.writing-app .editor-rail button>span {font-size:var(--ui-meta)!important;line-height:18px!important}
 body.writing-app #wordpressDialog :is(.wp-dialog-heading p,.wp-form label,.wp-connect-steps) {font-size:var(--ui-body)!important;line-height:1.5!important}
 body.writing-app .editor-block-menu :is(button,span) {font-size:14px!important}
 /* Supporting copy shares one scale, including dynamically populated status
    and allowance rows. Primary instructions and editable fields stay body size. */
 body.writing-app .writing-inspector :is(.selection-context,.selection-excerpt,.assistant-note,.panel-intro,.field-note,.editor-panel-description,#editorRemainingLimitsStatus,#editorRemainingLimitsRows dt,#editorRemainingLimitsRows dd,.editor-limits-heading a) {
  font-size:var(--ui-meta)!important;line-height:1.5!important;
 }
}

@layer app-typography {
 body.workspace-page .workspace-content table :is(tr[hidden],tr.hidden-row){display:none!important}
}
