/* V63 — mobile/tablet layout fixes; loaded LAST to avoid older themes overriding responsive rules.
   Styling stays scoped to layouts and widths; theme colors, media assets and CMS content remain editable. */
:root { --kf-mobile-edge: clamp(12px, 3.6vw, 20px); }
html,body { min-width:0; }
body, #root { max-width:100%; }
:where(.public-design,.reference-design,.learner-app,.portal-main,.d-home,.d-section,.widget,.panel,.modal,.card,.learning-block,.admin-page,.admin-content,.admin-dashboard,.form-grid,.detail-grid,.container) { min-width:0; }
:where(img,video,canvas,svg) { max-width:100%; }
:where(input, textarea, select) { max-width:100%; min-width:0; }
:where(.table-wrap,.responsive-table,.table-container) { max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
:where(.table-wrap,.responsive-table,.table-container) table { min-width:max-content; }
:where(.prose,.content-text,.modal,.field,.detail-grid,.panel,.course-body,.learning-block) { overflow-wrap:anywhere; }
:where(.modal,.panel,.card,.learning-block,.d-course) :is(iframe,embed,video) { max-width:100%; }
:where(.modal,.panel,.card,.learning-block,.d-course) iframe { display:block; }
@media (max-width:1024px) {
  .container { width:calc(100% - 40px); max-width:100%; }
  .public-design .d-wrap,.public-design .container { width:calc(100% - 40px); max-width:100%; }
  .public-design .d-section-heading { min-width:0; }
  .public-design .d-section-heading>div { min-width:0; }
  .public-design .d-section-heading :is(h1,h2,h3,p) { max-width:100%; overflow-wrap:break-word; }
  .public-design .d-entry-grid,.public-design .d-course-grid,.public-design .layout-grid,.public-design .w-grid {
     grid-template-columns:repeat(2,minmax(0,1fr));
  }
  .public-design .d-header-inner { max-width:100%; }
  .public-design .d-header nav.open { max-height:calc(100dvh - 92px);overflow-y:auto;overscroll-behavior:contain; }
  .portal-builder-workspace,.sidebar-designer,.design-workspace { min-width:0; }
  .portal-live-preview,.sidebar-live-preview,.design-live-preview { max-width:100%; }
}
@media (max-width:767px) {
  html { max-width:100%; overflow-x:clip; scroll-padding-top:70px; }
  body { overflow-x:clip; }
  #root,.app,.public-design,.reference-design,.d-home,.learner-app,.portal-shell,.site-shell { width:100%;max-width:100%;min-width:0; }
  .container,.public-design .d-wrap,.public-design .container,.reference-design .d-wrap { width:calc(100% - 2*var(--kf-mobile-edge)); max-width:100%; margin-inline:auto; }
  .section { padding-block:30px; }
  .section-tight { margin-top:15px; }
  .public-design .d-section { padding-block:26px; min-width:0; }
  .public-design .d-section>.d-wrap { min-width:0; }

  /* Headings and action links: this corrects clipped purple section title from screenshot. */
  .section-heading,.public-design .d-section-heading,.reference-design .d-section-heading,
  .design-market .d-section-heading,.design-reference-portal .d-stages .d-section-heading {
    display:flex;flex-direction:column;align-items:stretch;justify-content:flex-start;
    gap:12px;width:100%;max-width:100%;min-width:0;margin-bottom:18px;
    padding-inline:0;text-align:start;
  }
  .public-design .d-section.align-center .d-section-heading { align-items:stretch; }
  .section-heading>div,.public-design .d-section-heading>div,
  .reference-design .d-stages .d-section-heading>div { display:block;flex:0 1 auto;width:100%;max-width:100%;min-width:0; }
  .section-heading :is(h1,h2),.public-design .d-section-heading :is(h1,h2),
  .reference-design .d-section-heading h2,.design-reference-portal .d-stages .d-section-heading h2 {
     display:block;box-sizing:border-box;width:auto;min-width:0;max-width:100%;height:auto;
     font-size:clamp(21px,5.4vw,29px);line-height:1.55;
     white-space:normal;overflow:visible;overflow-wrap:break-word;word-break:normal;
  }
  .section-heading p,.public-design .d-section-heading p,.reference-design .d-section-heading p { max-width:100%;font-size:13px;line-height:1.85; }
  .section-heading>a,.public-design .d-section-heading>a,.public-design .d-section-heading .d-button,
  .reference-design .d-section-heading>a { align-self:flex-start;max-width:100%;min-height:40px;white-space:normal;text-align:center; }
  .public-design .d-section-heading .d-kicker { overflow-wrap:break-word; }
  .public-design .d-section-heading [style*=width],.public-design .d-section-heading [style*=height] { max-width:100%; }
  .reference-design .d-stages .d-section-heading p { grid-column:auto;grid-row:auto;text-align:start; }

  /* Cards and sections. Keep horizontal carousel only when its own scroll controls are present. */
  .public-design .d-entry-grid,.public-design .layout-grid,.public-design .cards-grid .d-course-grid,
  .public-design .d-course-grid,.public-design .w-grid,.public-design .w-split,
  .d-courses.cards-list .d-course-grid,.d-books.cards-list .d-course-grid,
  .d-exams.cards-list .d-course-grid,.course-grid,.feature-grid,.store-grid {
    display:grid;grid-template-columns:minmax(0,1fr);gap:15px;
  }
  .public-design :is(.d-course,.d-entry,.w-grid>article,.d-feature,.d-card,.course) { min-width:0;max-width:100%; }
  .public-design .cards-list .d-course { display:block; }
  .public-design .cards-strip .d-course-grid,.public-design .w-section[data-layout=strip] .w-grid {
    display:flex;gap:12px;overflow-x:auto;max-width:100%;scroll-snap-type:x proximity;
  }
  .public-design .cards-strip .d-course,.public-design .w-section[data-layout=strip] .w-grid>article {
    flex:0 0 min(82vw,330px);min-width:0;max-width:calc(100vw - 2*var(--kf-mobile-edge));
  }
  .public-design .d-course :is(img,video),.public-design .course-image img { max-width:100%;object-fit:cover; }
  .public-design .d-actions,.public-design .hero-buttons,.public-design .section-actions,
  .page-title,.actions,.actions.wrap,.modal-actions,.toolbar-actions { flex-wrap:wrap;gap:9px;max-width:100%; }
  .public-design :is(.d-button,.btn,.text-link),.btn { max-width:100%;white-space:normal;overflow-wrap:break-word; }
  .public-design .d-banner-box,.public-design .d-hero-copy,.public-design .ref-hero-surface,
  .public-design .ref-portal-shell { min-width:0;max-width:100%; }
  .public-design .d-banner-box { padding:20px 16px; }
  .public-design .d-hero h1,.public-design .d-hero h2 { font-size:clamp(27px,7vw,39px);line-height:1.45;overflow-wrap:break-word; }
  .public-design .d-bento-hero,.public-design .d-market-hero,.public-design .d-studio-hero,
  .public-design .d-editorial-hero,.public-design .d-journey-hero,.public-design .d-notebook-hero {
    display:grid;grid-template-columns:minmax(0,1fr);gap:18px;
  }
  .public-design .d-editorial-hero figure,.public-design .d-photo { min-width:0;max-width:100%; }
  .public-design .d-spotlight-hero { min-height:0;height:auto; }
  .public-design .d-spotlight-hero>.d-wrap { padding-block:150px 22px; }
  .ref-portal-shell>.ref-hero-surface { padding:20px 16px 45px;border-radius:18px; }
  .public-design .d-hero-copy,.public-design .d-hero-copy>div,.public-design .d-hero-copy p { max-width:100%; }
  .public-design .d-facts { flex-wrap:wrap;gap:12px;max-width:100%; }

  /* Public and dashboard navigation. Keep menus in the viewport; never cover the whole page with blank whitespace. */
  .site-header { min-height:68px;height:auto;gap:8px;padding-block:8px; }
  .site-header .brand { min-width:0;max-width:calc(100% - 50px); }
  .site-header .brand-copy,.d-brand { min-width:0; }
  .site-header .brand b { max-width:100%;overflow-wrap:break-word; }
  .site-header nav { inset-inline:var(--kf-mobile-edge);top:calc(100% - 2px);max-height:calc(100dvh - 82px);overflow:auto;overscroll-behavior:contain; }
  .d-header-inner { min-height:65px;gap:9px; }
  .d-header nav,.design-editorial .d-header nav,
  .reference-design .d-header nav {
    inset-inline:0;width:100%;max-width:100%;max-height:calc(100dvh - 76px);
    overflow-y:auto;overscroll-behavior:contain;box-shadow:0 12px 35px #15203326;
    padding:14px;border-radius:0 0 15px 15px;z-index:80;
  }
  .d-header nav.open,.site-header nav.open { display:flex;flex-direction:column;align-items:stretch;justify-content:flex-start;gap:10px;height:auto;min-height:0; }
  .d-header nav :is(a,button),.site-header nav :is(a,button) { max-width:100%;white-space:normal;overflow-wrap:break-word; }
  .d-header :is(.d-brand,.d-nav-actions),.site-header .nav-actions { min-width:0; }
  .sidebar { max-width:calc(100vw - 16px); }
  .learner-app .sidebar.learner-menu { width:min(var(--nav-width,330px),calc(100vw - 16px));max-width:calc(100vw - 16px); }
  .learner-app .portal-main,.portal-main { box-sizing:border-box;width:100%;max-width:100%;min-width:0;padding:18px var(--kf-mobile-edge) 42px; }
  .learner-app .learning-blocks,.learning-dashboard,.learning-welcome,.learning-resume,.portal-layout { max-width:100%;min-width:0; }
  .learner-app .learning-welcome,.learner-app .learning-resume,.learner-app .learning-custom { flex-wrap:wrap;gap:14px; }
  .learner-app .learning-welcome>img,.learner-app .learning-resume>img,.learner-app .learning-custom>img { width:100%;max-width:100%;height:auto;max-height:250px;object-fit:contain; }
  .learner-app .learning-shortcuts,.learner-app .learning-stats,.learner-app .learning-library,.portal-link-cards {
    grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;
  }
  .learner-app .learning-block.has-mobile-columns :is(.learning-shortcuts,.learning-stats,.learning-library,.portal-link-cards) {
    grid-template-columns:repeat(min(2,var(--block-mobile-columns,2)),minmax(0,1fr));
  }
  .learner-app .learning-block :is(h1,h2,h3,p),.learning-dashboard :is(h1,h2,h3,p) { max-width:100%;overflow-wrap:break-word; }
  .learner-app .learning-welcome>div,.learner-app .learning-resume>div { min-width:0;max-width:100%; }

  /* Popups: full content must scroll and the close control must remain accessible. */
  .modal-backdrop { z-index:10050;box-sizing:border-box;inset:0;width:100%;height:100dvh;max-height:100dvh;
    padding:8px;display:flex;align-items:center;justify-content:center;overflow:hidden; }
  .modal,.modal.wide { box-sizing:border-box;width:100%;max-width:100%;min-width:0;
    height:auto;max-height:calc(100dvh - 16px);max-height:calc(100svh - 16px);
    margin:0;padding:14px;border-radius:14px;overflow-x:hidden;overflow-y:auto;
    -webkit-overflow-scrolling:touch;overscroll-behavior:contain; }
  .modal .modal-head { position:sticky;top:-14px;z-index:4;display:flex;align-items:center;
    padding:10px 0 13px;margin:0 0 12px;background:var(--surface);gap:10px; }
  .modal .modal-head h2 { min-width:0;flex:1;font-size:clamp(17px,4.6vw,23px);line-height:1.6;overflow-wrap:break-word; }
  .modal .modal-head .icon-btn { flex:0 0 38px;width:38px;height:38px; }
  .modal :is(form,.form-grid,.detail-grid,.row-editor,.grid-2,.fields-grid,.editor-grid) { min-width:0;max-width:100%; }
  .modal .form-grid,.modal .detail-grid,.modal .row-editor { grid-template-columns:minmax(0,1fr); }
  .modal .span-two,.modal .field { grid-column:auto;min-width:0; }
  .modal .field :is(input,textarea,select),.modal :is(input,textarea,select) { width:100%;max-width:100%; }
  .modal .actions,.modal-actions { position:static;flex-wrap:wrap;min-height:0; }
  .modal :is(pre,code) { max-width:100%;overflow-wrap:anywhere;white-space:pre-wrap; }
  .modal .issued-code { max-width:100%;overflow-wrap:anywhere; }
  .modal .table-wrap { max-width:100%;overflow-x:auto; }
  .modal :is(.btn,.small-btn) { max-width:100%;white-space:normal; }

  /* Admin, forms, editors, CMS, exams and social spaces. */
  .page-title { display:flex;align-items:flex-start;flex-direction:column;gap:10px; }
  .page-title>div { width:100%;min-width:0;max-width:100%; }
  .page-title h1 { font-size:clamp(22px,6vw,30px);overflow-wrap:break-word; }
  .form-grid,.detail-grid,.settings-grid,.admin-grid,.profile-grid,.cms-contact-grid { grid-template-columns:minmax(0,1fr); }
  .form-grid>* , .detail-grid>*,.settings-grid>* { min-width:0; }
  .field,.panel { max-width:100%;min-width:0; }
  .field input,.field select,.field textarea { box-sizing:border-box;width:100%;max-width:100%; }
  .table-wrap { max-width:100%;overflow-x:auto; }
  .table-wrap table { width:max-content;min-width:100%;max-width:none; }
  .table-wrap table th,.table-wrap table td { white-space:normal;min-width:95px; }
  .table-wrap table td :is(.actions,.btn) { max-width:none; }
  .design-workspace,.portal-builder-workspace,.sidebar-designer,.article-admin,
  .widget-library-body,.widget-editor-workspace,.editor-layout,.exam-workspace,.social-feed-layout {
     min-width:0;max-width:100%;grid-template-columns:minmax(0,1fr); }
  .design-editor-panel,.design-live-preview,.portal-preview-stage,.portal-live-preview,.sidebar-live-preview,
  .widget-editor,.editor-main,.article-admin { min-width:0;max-width:100%; }
  .design-gallery,.sidebar-style-choices { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .portal-preview-document,.sidebar-preview-document { max-width:100%;min-width:0; }
  .portal-preview-toolbar,.design-editor-tabs,.cms-toolbar { max-width:100%;overflow-x:auto; }
  .exam-session-header,.exam-question-editor>.section-heading { flex-wrap:wrap;gap:12px; }
  .exam-session-header>* { min-width:0; }
  .social-community,.social-feed-layout,.social-rooms-layout,.social-chat,.chat-composer { min-width:0;max-width:100%; }
  .social-chat :is(input,textarea),.chat-compose :is(input,textarea) { min-width:0;max-width:100%; }
  .social-post,.social-feed-card,.comment,.chat-message { max-width:100%;overflow-wrap:anywhere; }
  .site-footer .container { min-width:0;max-width:100%; }
}
@media (max-width:430px) {
  .container,.public-design .d-wrap,.public-design .container,.reference-design .d-wrap { width:calc(100% - 24px); }
  .public-design .d-section-heading,.section-heading { gap:10px; }
  .section-heading :is(h1,h2),.public-design .d-section-heading :is(h1,h2) { font-size:clamp(20px,5.5vw,24px); }
  .public-design .d-section-heading>a { margin-top:3px; }
  .public-design .d-banner-box { padding:18px 12px; }
  .ref-portal-shell>.ref-hero-surface { padding:16px 12px 34px; }
  .learner-app .learning-shortcuts,.learner-app .learning-stats,.learner-app .learning-library,.portal-link-cards { gap:8px; }
  .learner-app .learning-block :is(h2,h3) { font-size:clamp(17px,5vw,22px); }
  .modal-backdrop { padding:5px; }
  .modal,.modal.wide { max-height:calc(100svh - 10px);padding:12px; }
  .modal .modal-head { top:-12px; }
}
@media (max-width:340px) {
  .learner-app .learning-shortcuts,.learner-app .learning-stats,.learner-app .learning-library,.portal-link-cards {
    grid-template-columns:minmax(0,1fr); }
  .learner-app .learning-block.has-mobile-columns :is(.learning-shortcuts,.learning-stats,.learning-library,.portal-link-cards) {
    grid-template-columns:minmax(0,1fr); }
  .design-gallery,.sidebar-style-choices { grid-template-columns:1fr; }
}
@media (prefers-reduced-motion:reduce) {
  html { scroll-behavior:auto; }
}
