/* Shared screen density. Loaded after page styles by the common layout.
 * Keep the browser's zoom and root rem size intact. The quiz player and the
 * manuscript document/export have their own typography and are not rescaled.
 */
@media screen {
  /* Legacy cards used centered cross-axis alignment. With long category names
   * that allowed the flex child to exceed its card and clip the start of text. */
  body.site-compact-shell .polished-category-grid .category-mini-card { min-width: 0; align-items: stretch; }
  body.site-compact-shell .polished-category-grid :is(.category-mini-main, .category-mini-actions) { width: 100%; min-width: 0; }
  body.site-compact-shell .polished-category-grid .category-mini-card h3 { overflow-wrap: anywhere; }
}
@media screen and (min-width: 981px) {
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) { font-size: 14px; }

  body.site-compact-shell:not(.test-page):not(.json-test-page) .site-main {
    width: min(100%, 1280px);
    max-width: 1280px;
    padding: 26px clamp(24px, 3vw, 44px) 44px;
  }
  body.site-compact-shell:not(.test-page):not(.json-test-page):is(.notifications-page, .account-profile-page) .site-main { width: min(100%, 1040px); max-width: 1040px; }
  body.site-compact-shell .site-footer {
    width: min(100%, 1280px);
    padding: 21px clamp(24px, 3vw, 44px) 36px;
    gap: 14px;
    font-size: 13px;
  }
  body.site-compact-shell .footer-logo { width: 36px; height: 36px; border-radius: 11px; }
  body.site-compact-shell .footer-brand strong { font-size: 16px; }

  /* Common pages, forms and administrative tools. */
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main h1 {
    font-size: clamp(34px, 4.8vw, 62px);
    margin-bottom: 14px;
  }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main :is(.panel > h2, .section-head h2, .page-title-row h2) {
    font-size: clamp(23px, 2.5vw, 34px);
    margin-bottom: 10px;
  }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main .panel {
    padding: 21px;
    border-radius: 19px;
  }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main .btn {
    min-height: 38px;
    padding: 9px 14px;
    border-radius: 12px;
    gap: 7px;
    font-size: 14px;
  }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main .btn-big { min-height: 46px; padding: 12px 19px; }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main .btn-small { min-height: 30px; padding: 6px 9px; font-size: 12px; }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main :is(input:not([type]), input[type="text"], input[type="number"], input[type="search"], input[type="email"], input[type="password"], input[type="url"], input[type="date"], select, textarea) {
    padding: 10px 12px;
    border-radius: 13px;
    font-size: 14px;
    min-width: 0;
  }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main :is(.form-stack, .form-grid) { gap: 12px; }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main label { gap: 6px; }
  body.site-compact-shell .site-main .eyebrow { min-height: 25px; padding: 5px 9px; font-size: 11px; margin-bottom: 12px; }
  body.site-compact-shell:not(.test-page):not(.json-test-page) .site-main .tabs { gap: 6px; margin-bottom: 14px; }
  body.site-compact-shell:not(.test-page):not(.json-test-page) .site-main .tabs :is(a, button) { min-height: 34px; padding: 8px 12px; border-radius: 12px; font-size: 13px; }
  body.site-compact-shell .site-main :is(.section-head, .page-title-row) { gap: 14px; margin-bottom: 18px; }
  /* List and settings pages need a page title, not the landing-page hero size. */
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main .page-title-row h1 {
    font-size: clamp(28px, 3.2vw, 42px);
    line-height: 1.15;
    overflow-wrap: anywhere;
  }
  body.site-compact-shell .site-main .page-title-row > * { min-width: 0; }

  /* Home retains its hero image, with a calmer title and smaller feature cards. */
  body.site-compact-shell .home-hero { min-height: clamp(390px, 50vh, 530px); padding: clamp(26px, 4.8vw, 59px); gap: 24px; border-radius: 30px; }
  body.site-compact-shell .home-hero p { font-size: clamp(16px, 1.6vw, 18px); }
  body.site-compact-shell .home-hero-stats { grid-template-columns: repeat(2, minmax(104px, 1fr)); gap: 10px; }
  body.site-compact-shell .home-hero-stats span { min-width: 120px; padding: 14px; border-radius: 16px; }
  body.site-compact-shell .home-hero-stats b { font-size: 27px; }
  body.site-compact-shell .home-example { gap: 18px; margin: 27px 0 22px; }
  body.site-compact-shell .home-example-copy { padding: clamp(20px, 3.2vw, 32px); }
  body.site-compact-shell .home-example-copy h2 { font-size: clamp(23px, 2.5vw, 34px); }
  body.site-compact-shell .home-example-copy p { font-size: 14px; }
  body.site-compact-shell :is(.features-grid, .stats-grid) { gap: 13px; margin-top: 22px; }
  body.site-compact-shell :is(.features-grid, .stats-grid) article { padding: 18px; border-radius: 19px; }
  body.site-compact-shell .features-grid h3 { font-size: 17px; }
  body.site-compact-shell .stats-grid b { font-size: 27px; }

  /* Document generators: shrink actual components, not their hit coordinates. */
  body.site-compact-shell :is(.ai-create-hero, .ai-create-grid, .ai-list-title, .ai-job-list, .ai-detail-grid, .ai-mode-switch-card, .ai-feature-switch) { max-width: 1000px; }
  body.site-compact-shell .ai-create-hero { grid-template-columns: minmax(0, 1fr) 264px; gap: 18px; margin-bottom: 18px; }
  body.site-compact-shell :is(.ai-create-hero > div:first-child, .ai-create-hero-card) { padding: 22px; border-radius: 22px; }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main .ai-create-hero h1 { font-size: clamp(28px, 3.2vw, 45px); margin: 6px 0 10px; }
  body.site-compact-shell .ai-create-hero p { font-size: 14px; line-height: 1.55; }
  body.site-compact-shell .ai-create-hero-card strong { font-size: 16px; }
  body.site-compact-shell .ai-create-grid { grid-template-columns: minmax(280px, .8fr) minmax(0, 1.4fr); gap: 18px; }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main .ai-create-panel h2 { font-size: 23px; }
  body.site-compact-shell .panel-kicker { width: 36px; height: 36px; margin-bottom: 10px; }
  body.site-compact-shell .dropzone { min-height: 208px; padding: 22px; border-radius: 19px; }
  body.site-compact-shell .dropzone-icon { width: 58px; height: 58px; border-radius: 18px; }
  body.site-compact-shell .dropzone strong { font-size: 16px; }
  body.site-compact-shell .ai-note { margin-top: 13px; padding: 11px 13px; border-radius: 14px; }
  body.site-compact-shell :is(.ai-mode-switch-card, .ai-feature-switch) { gap: 10px; margin-bottom: 18px; }
  body.site-compact-shell :is(.ai-mode-switch-card, .ai-feature-switch) a { padding: 13px 14px; border-radius: 18px; gap: 4px; }
  body.site-compact-shell :is(.ai-mode-switch-card, .ai-feature-switch) a strong { font-size: 14px; }
  body.site-compact-shell :is(.ai-mode-switch-card, .ai-feature-switch) a span { font-size: 13px; }
  body.site-compact-shell .ai-flow-preview { gap: 8px; margin: 18px 0; }
  body.site-compact-shell :is(.ai-flow-preview, .ai-rule-grid) > div { padding: 10px; border-radius: 14px; }
  body.site-compact-shell .ai-job-card { padding: 16px; gap: 14px; border-radius: 19px; }
  body.site-compact-shell .ai-job-card h2 { font-size: 20px; }
  body.site-compact-shell :is(.ai-wait-card, .ai-result-hero) { max-width: 760px; margin: 32px auto 24px; padding: clamp(24px, 4vw, 45px); border-radius: 27px; }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main :is(.ai-wait-card, .ai-result-hero) h1 { font-size: clamp(28px, 3.2vw, 45px); }
  body.site-compact-shell :is(.ai-wait-gorilla, .ai-result-icon) { width: 90px; height: 90px; }
  body.site-compact-shell :is(.ai-wait-gorilla, .ai-result-icon) img { width: 66px; height: 66px; }
  body.site-compact-shell :is(.vip-hero, .vip-list-head) { grid-template-columns: minmax(0, 1fr) 288px; gap: 19px; margin-bottom: 21px; }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main :is(.vip-hero, .vip-list-head) h1 { font-size: clamp(28px, 4vw, 51px); }
  body.site-compact-shell :is(.vip-hero, .vip-list-head) p { font-size: 15px; }
  body.site-compact-shell .vip-hero-card { padding: 18px; border-radius: 22px; }
  body.site-compact-shell .vip-hero-card strong { font-size: 18px; }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main .ai-podcast-hero h1 { font-size: clamp(32px, 4vw, 55px); }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main :is(.ai-podcast-result-copy, .vip-result-panel, .qg-collab-room-hero) h1 { font-size: clamp(27px, 3.2vw, 43px); }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main :is(.nlt-hero, .nlt-page-head, .notifications-hero) h1 { font-size: clamp(30px, 4vw, 51px); }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main .nlt-banner-copy h1 { font-size: clamp(25px, 3.2vw, 40px); }
  body.site-compact-shell .notifications-hero { padding: clamp(20px, 3.2vw, 30px); gap: 19px; }
  body.site-compact-shell .notifications-hero p { font-size: 14px; }

  /* Catalogs keep their existing hierarchy and card content. The few important
   * declarations below replace legacy important heading sizes only. */
  body.site-compact-shell :is(.polished-catalog-title, .tests-control-panel, .category-toolbar-panel, .polished-category-section, .tests-favorites-panel) { max-width: 1080px; }
  body.site-compact-shell .polished-catalog-title h1 { font-size: clamp(31px, 3.3vw, 46px) !important; }
  body.site-compact-shell.tests-compact-page .clean-tests-head h1 { font-size: clamp(28px, 2.9vw, 40px) !important; }
  body.site-compact-shell :is(.polished-catalog-title, .clean-tests-head) p { font-size: 14px; }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main :is(.category-toolbar-panel, .tests-control-panel) { padding: 11px 12px; border-radius: 16px; }
  body.site-compact-shell.tests-compact-page :is(.quiz-list, .compact-quiz-list) { max-width: 940px; gap: 10px; }
  body.site-compact-shell .site-main .quiz-card { padding: 16px 18px; border-radius: 16px; }
  body.site-compact-shell .site-main .quiz-card-content { gap: 12px; margin-top: 10px; }
  body.site-compact-shell .site-main .quiz-card h3 { font-size: clamp(18px, 1.6vw, 23px); }
  body.site-compact-shell.tests-compact-page .quiz-card h3 { font-size: clamp(18px, 1.3vw, 21px) !important; }
  body.site-compact-shell .quiz-grid .quiz-card { min-height: 240px; }
  body.site-compact-shell .site-main .card-actions { gap: 7px; }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main .card-actions .btn { min-height: 32px; padding: 7px 10px; font-size: 12px; }
  body.site-compact-shell .polished-category-grid { grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 10px; }
  body.site-compact-shell .polished-category-grid .category-mini-card { height: auto; min-height: 108px; padding: 9px 10px; gap: 0; border-radius: 13px; }
  body.site-compact-shell .polished-category-grid .category-mini-card h3 { font-size: 14px; line-height: 1.15; }
  body.site-compact-shell .polished-category-grid .category-mini-path { margin-top: 3px; }
  body.site-compact-shell .polished-category-grid .category-mini-card p { font-size: 12px; margin-top: 4px; -webkit-line-clamp: 1; }
  body.site-compact-shell .polished-category-grid .category-mini-actions { margin-top: 6px; flex-wrap: wrap; }
  body.site-compact-shell.category-browser-page .cb-layout { grid-template-columns: minmax(210px, 240px) minmax(0, 1fr); gap: 19px; }
  body.site-compact-shell.category-browser-page .site-main .panel { padding: 16px; border-radius: 15px; }
  body.site-compact-shell.category-browser-page .site-main .cb-navigation { padding: 12px 8px 10px; }
  body.site-compact-shell.category-browser-page .cb-tree-link { min-height: 36px; padding: 6px 8px; font-size: 13px; }
  body.site-compact-shell.category-browser-page .site-main .cb-heading h1 { font-size: clamp(25px, 2.4vw, 34px); }
  body.site-compact-shell.category-browser-page .cb-description { font-size: 14px; }
  body.site-compact-shell.category-browser-page .cb-tests-heading h2 { font-size: 19px; }

  /* Cabinet, category management and the common admin forms. */
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main :is(.cabinet-hero h1, .compact-page-title, .category-create-title h1) { font-size: clamp(28px, 3.2vw, 42px); }
  body.site-compact-shell.cabinet-compact-page .compact-page-title { font-size: clamp(34px, 4vw, 57px) !important; }
  body.site-compact-shell.category-create-clean-page .category-create-title h1 { font-size: clamp(28px, 3.2vw, 43px) !important; }
  body.site-compact-shell .cabinet-hero { padding: clamp(20px, 3.2vw, 34px); gap: 14px; border-radius: 24px; margin-bottom: 15px; }
  body.site-compact-shell .cabinet-grid { gap: 13px; margin: 14px 0 18px; }
  body.site-compact-shell .cabinet-widget { min-height: 106px; padding: 16px; gap: 11px; border-radius: 19px; }
  body.site-compact-shell.cabinet-compact-page .cabinet-widget { min-height: 74px; padding: 12px 13px; border-radius: 15px; }
  body.site-compact-shell .widget-icon { width: 38px; height: 38px; border-radius: 13px; font-size: 13px; }
  body.site-compact-shell .widget-body strong { font-size: 16px; }
  body.site-compact-shell .account-info-card { min-height: 96px; padding: 14px; border-radius: 14px; }
  body.site-compact-shell .account-info-card strong { font-size: 16px; }
  body.site-compact-shell .cabinet-list article { padding: 13px; gap: 11px; border-radius: 14px; }
  body.site-compact-shell .cabinet-list h3 { font-size: 17px; }
  body.site-compact-shell .category-admin-layout { gap: 18px; }
  body.site-compact-shell.category-admin-compact-page .site-main .cabinet-hero { padding: 12px 13px; border-radius: 15px; }
  body.site-compact-shell.category-admin-compact-page .cabinet-hero h1 { font-size: clamp(24px, 2.3vw, 32px) !important; }
  body.site-compact-shell.category-admin-compact-page .site-main .panel { padding: 12px 13px; border-radius: 15px; }
  body.site-compact-shell.category-admin-compact-page .panel h2 { font-size: clamp(19px, 1.6vw, 23px) !important; }
  body.site-compact-shell.category-admin-compact-page .category-admin-layout { grid-template-columns: 300px minmax(0, 1fr); gap: 12px; }
  body.site-compact-shell.category-admin-compact-page .site-main .form-stack { gap: 9px; }
  body.site-compact-shell .vip-model-settings { max-width: 1000px; gap: 13px; }
  body.site-compact-shell .vip-model-settings .vip-branch > summary { padding: 16px 18px; gap: 13px; }
  body.site-compact-shell .vip-model-settings .vip-branch-heading strong { font-size: 16px; }
  body.site-compact-shell .vip-model-settings .vip-branch-body { padding: 18px; }
  body.site-compact-shell .ai-kpi-row article { padding: 14px; border-radius: 18px; }
  body.site-compact-shell .ai-kpi-row b { font-size: clamp(21px, 2.4vw, 28px); }

  /* The pre-player introduction is outside qgp and should match the shell. */
  body.site-compact-shell .test-index-lead { padding: 10px 14px; margin-bottom: 11px; border-radius: 14px; }
  body.site-compact-shell .test-index-lead p { font-size: 12px; line-height: 1.45; }

  /* Manuscripts: adjust only the application heading/upload chrome. These
   * selectors never reach .ms-document, .ms-preview-pane or exported content. */
  body.site-compact-shell .ms-heading { gap: 22px; margin-bottom: 24px; }
  body.site-compact-shell .ms-heading h1 { font-size: clamp(27px, 2.5vw, 37px); }
  body.site-compact-shell .ms-document-heading h1 { font-size: clamp(25px, 2.2vw, 32px); }
  body.site-compact-shell .ms-heading p { font-size: 14px; }
  body.site-compact-shell :is(.ms-upload-card, .ms-how) { padding: 23px; }
  body.site-compact-shell .ms-home-grid { gap: 18px; }
  body.site-compact-shell .ms-dropzone { min-height: 184px; padding: 20px 14px; }
  body.site-compact-shell .ms-how h2 { font-size: 24px; margin-bottom: 22px; }
}

/* A compact desktop must not make touch controls or editable fields tiny.
 * Existing phone quiz controls and manuscript editor keep their own styles. */
@media screen and (max-width: 980px), screen and (pointer: coarse) {
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main :is(.btn, .tabs a, .tabs button, .quick-counts button, .cb-tree-link) {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
  }
  body.site-compact-shell:not(.test-page):not(.json-test-page):not(.ms-page) .site-main :is(input:not([type]), input[type="text"], input[type="number"], input[type="search"], input[type="email"], input[type="password"], input[type="url"], input[type="date"], select, textarea) {
    font-size: 16px;
  }
  body.site-compact-shell .polished-category-grid .category-mini-card {
    height: auto;
    min-height: 124px;
    overflow: visible;
  }
  body.site-compact-shell .polished-category-grid .category-mini-actions { flex-wrap: wrap; }
}
