/* Mobile workspace: keep navigation, 3D controls and catalogue usable together. */
.level-label-short,
.intro-requirements > summary {
  display:none;
}
.intro-requirements > div {
  display:grid;
  gap:10px;
}

@media (max-width:800px) {
  html,body {
    width:100%;
    height:100%;
    overflow:hidden;
  }
  .auto-methods {
    grid-template-columns:1fr;
  }

  header {
    display:grid;
    grid-template-columns:minmax(0,1fr) auto auto;
    grid-template-rows:42px 44px;
    align-items:center;
    min-height:94px;
    padding:6px 8px;
    gap:2px 6px;
  }
  .brand {
    grid-column:1;
    grid-row:1;
    min-width:0;
    font-size:14px;
    gap:7px;
  }
  .brand-mark {
    width:34px;
    height:34px;
  }
  .notice-shortcuts {
    grid-column:2;
    grid-row:1;
    justify-content:flex-end;
  }
  body:has(.designer-layout) .notice-shortcuts {
    grid-column:2 / 4;
  }
  .notice-shortcuts #auto-build {
    height:38px;
    min-height:38px;
    padding:0 9px;
    font-size:11px;
  }
  .notice-shortcuts #help {
    width:42px;
    height:38px;
    min-height:38px;
    padding:0;
    overflow:hidden;
    font-size:0;
  }
  .notice-shortcuts #help::before {
    content:'ⓘ';
    font-size:18px;
  }
  .help-trigger-hint {
    display:none!important;
  }
  nav {
    grid-column:1 / -1;
    grid-row:2;
    order:initial;
    display:grid;
    grid-template-columns:.8fr 1.35fr 1fr;
    width:100%;
    height:44px;
    padding:3px;
    gap:2px;
    overflow:hidden;
  }
  nav button {
    min-width:0;
    min-height:38px;
    padding:4px 6px;
    overflow:hidden;
    text-overflow:ellipsis;
    font-size:12px;
  }
  .header-actions {
    grid-column:3;
    grid-row:1;
    position:static;
    min-width:0;
    margin:0;
  }
  .header-actions .analysis-tabs {
    position:static;
    inset:auto;
    display:flex;
    width:auto;
    min-width:0;
    margin:0;
    padding:0;
    border:0;
    overflow:visible;
  }
  .header-actions .analysis-tabs > button {
    flex:none;
    width:auto;
    height:38px;
    min-height:38px;
    margin:0;
    padding:0 9px;
    border:1px solid #c9d6df;
    border-radius:7px;
    font-size:10px;
  }
  body:has(.designer-layout) header {
    grid-template-rows:42px 44px 44px;
    min-height:140px;
  }
  body:has(.designer-layout) .header-actions {
    grid-column:1 / -1;
    grid-row:3;
    width:100%;
    overflow:hidden;
  }
  body:has(.designer-layout) .header-actions .analysis-tabs {
    width:100%;
    height:44px;
    justify-content:flex-start;
    overflow-x:auto;
    overflow-y:hidden;
    scrollbar-width:thin;
    border-bottom:1px solid #c9d6df;
  }
  body:has(.designer-layout) .header-actions .analysis-tabs > button {
    flex:1 0 auto;
    min-width:max-content;
    height:44px;
    border-radius:7px 7px 0 0;
    padding:0 11px;
  }

  main {
    display:grid;
    grid-template-columns:1fr;
    grid-template-rows:minmax(270px,56%) minmax(220px,44%);
    height:calc(100dvh - var(--header-height,94px));
    min-height:0;
    overflow:hidden;
  }
  .workspace,
  .workspace.presenting-quiz {
    width:100%;
    height:auto;
    min-height:0;
  }
  .catalogue {
    height:auto;
    min-height:0;
    overflow:hidden;
    border-top:1px solid #b9cad6;
    box-shadow:0 -5px 18px #173b5314;
  }
  .catalogue-title,
  .catalogue-foot {
    display:none;
  }
  .search {
    flex:0 0 auto;
    margin:6px 8px 5px;
    padding:7px 10px;
  }
  #categories.stack-tabs {
    flex:0 0 auto;
    margin:0 8px;
    overflow-x:auto;
    overflow-y:hidden;
    scrollbar-width:thin;
  }
  #categories.stack-tabs > button {
    flex:1 0 auto;
    min-width:max-content;
    min-height:40px;
    padding:0 9px;
    font-size:10px;
  }
  #catalogue-items,
  .catalogue-items {
    flex:1 1 auto;
    max-height:none;
    min-height:0;
    margin:0 8px 6px;
    padding:5px;
    overflow:auto;
    grid-template-columns:1fr;
  }
  .part-card,
  .part-card:has(.card-add-all) {
    min-height:68px;
    padding:6px;
  }
  .catalogue .tutorial-bubble {
    flex:0 0 auto;
    margin:6px 8px;
    padding:8px 10px;
    font-size:12px;
    line-height:1.35;
  }
  .catalogue .tutorial-bubble small {
    margin:0 0 2px;
    font-size:9px;
  }
  .catalogue .tutorial-bubble strong {
    margin:0;
  }
  .catalogue .tutorial-bubble p {
    display:-webkit-box;
    margin:2px 0 0;
    overflow:hidden;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:2;
  }

  .view-tools,
  .designer-layout .view-tools,
  .quiz-layout .view-tools {
    top:auto;
    right:8px;
    bottom:8px;
    left:8px;
    display:flex;
    flex-direction:row;
    gap:4px;
    width:max-content;
    max-width:calc(100% - 16px);
    padding:4px;
    overflow-x:auto;
    border:1px solid #b9cad6;
    border-radius:9px;
    background:#ffffffdf;
    box-shadow:0 4px 16px #173b5324;
  }
  .view-tools span {
    width:3px;
    height:auto;
  }
  .view-tools button {
    flex:0 0 44px;
    width:44px;
    height:44px;
    min-height:44px;
  }
  #toast {
    right:8px;
    bottom:66px;
    width:min(290px,calc(100% - 16px));
    max-height:42%;
  }
  .activity-list small {
    max-width:86px;
    text-align:right;
  }
  .level-legend,
  .designer-layout .level-legend,
  .quiz-layout .level-legend {
    top:8px;
    right:8px;
    left:auto;
    display:flex;
    gap:3px;
    width:auto;
    padding:4px;
    border-radius:9px;
    box-shadow:0 4px 16px #173b531a;
  }
  .level-legend strong,
  .level-legend .level-label-long {
    display:none;
  }
  .level-legend .level-label-short {
    display:inline;
    padding:0;
    color:inherit;
  }
  .level-label-short::before {
    content:attr(data-label);
  }
  .level-legend button {
    display:grid;
    place-items:center;
    width:44px;
    height:44px;
    min-height:44px;
    padding:0;
    text-align:center;
    border-radius:6px;
  }

  .quiz-layout .level-legend {
    top:8px;
  }

  .catalogue > .project-badge.quiz {
    inset:auto;
    display:grid;
    grid-template-columns:auto minmax(0,1fr) auto;
    grid-template-rows:auto auto;
    width:auto;
    max-width:none;
    min-height:0;
    margin:6px 8px 2px;
    padding:6px 7px;
    gap:3px 6px;
  }
  .catalogue > .project-badge.quiz .assessment-label {
    grid-column:1;
    grid-row:1;
    justify-self:start;
    padding:4px 6px;
    font-size:9px;
  }
  .catalogue > .project-badge.quiz #height-badge {
    grid-column:2;
    grid-row:1;
    align-self:center;
    font-size:10px;
  }
  .catalogue > .project-badge.quiz #checks {
    grid-column:3;
    grid-row:1;
    min-height:44px;
    padding:5px 7px;
    font-size:11px;
    line-height:1.2;
  }
  .catalogue > .project-badge.quiz #exercise-constraints {
    grid-column:1 / -1;
    grid-row:2;
    margin:0;
    padding:0;
    border:0;
    font-size:10px;
    line-height:1.35;
  }
  .quiz-constraints > summary {
    display:flex;
    align-items:center;
    min-height:32px;
    cursor:pointer;
    font-weight:800;
  }
  .quiz-constraints:not([open]) > div {
    display:none;
  }
  .quiz-constraints[open] > div {
    display:block;
    padding:4px 0 2px;
  }

  .quiz-intro-catalogue .quiz-presentation {
    flex:1 1 auto;
    max-height:none;
    min-height:0;
    margin:6px 8px;
    padding:9px 10px;
    overflow:auto;
  }
  .quiz-presentation h2 {
    margin:2px 0 4px;
    font-size:19px;
  }
  .quiz-presentation > p {
    margin:3px 0;
    font-size:11px;
    line-height:1.4;
  }
  .quiz-presentation > .note {
    display:none;
  }
  .quiz-presentation .intro-requirements {
    display:block;
    margin:6px 0;
  }
  .intro-requirements > summary {
    display:flex;
    align-items:center;
    min-height:38px;
    padding:0 9px;
    cursor:pointer;
    border:1px solid #c8d6df;
    border-radius:8px;
    background:#eef4f7;
    font-size:12px;
    font-weight:800;
  }
  .intro-requirements:not([open]) > div {
    display:none;
  }
  .intro-requirements[open] > div {
    display:grid;
    gap:6px;
    padding-top:6px;
  }
  .intro-requirements aside {
    padding:7px 8px;
    font-size:11px;
    line-height:1.35;
  }
  .quiz-presentation .intro-actions {
    position:sticky;
    bottom:-9px;
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    gap:6px;
    padding:6px 0 0;
    background:#fff;
  }
  .quiz-presentation .intro-actions button {
    min-height:44px;
    padding:7px 10px;
  }
  .quiz-intro-catalogue #catalogue-items,
  .quiz-intro-catalogue .catalogue-items {
    flex:0 0 auto;
    max-height:72px;
  }

  .help-tabs {
    flex-wrap:nowrap;
    overflow-x:auto;
    overflow-y:hidden;
  }
  .help-tabs > button {
    flex:0 0 auto;
    min-height:42px;
  }

  dialog,
  dialog.analysis-panel,
  #panel.review-panel.analysis-panel,
  .load-panel.analysis-panel {
    position:fixed;
    inset:auto 8px 8px;
    width:auto;
    max-width:none;
    max-height:min(72dvh,650px);
    margin:0;
    padding:16px;
    overflow:auto;
    border-radius:14px;
  }
  .dialog-head {
    position:sticky;
    top:-16px;
    z-index:2;
    margin:0 0 12px;
    padding:0 0 10px;
    background:#fff;
  }
  .dialog-head h2,
  .analysis-panel .dialog-head h2 {
    margin-top:4px;
    font-size:21px;
  }
  #panel:has(.tutorial-intro) {
    max-height:62dvh;
  }
  #panel:has(.tutorial-intro) .tutorial-intro > p:first-child {
    margin:4px 0 8px;
    font-size:12px;
    line-height:1.4;
  }
  #panel:has(.tutorial-intro) .tutorial-cards {
    display:flex;
    gap:8px;
    margin:8px 0;
    padding:0 0 5px;
    overflow-x:auto;
    scroll-snap-type:x mandatory;
  }
  #panel:has(.tutorial-intro) .tutorial-cards li {
    flex:0 0 min(250px,78vw);
    min-height:92px;
    padding:9px;
    scroll-snap-align:start;
  }
  #panel:has(.tutorial-intro) .tutorial-cards li div > span {
    font-size:11px;
    line-height:1.35;
  }
  #panel:has(.tutorial-intro) .tutorial-intro > .note {
    display:none;
  }
  #panel:has(.tutorial-intro) .dialog-actions {
    bottom:-16px;
    padding:8px 0 0;
  }
}

@media (max-width:420px) {
  .brand span {
    font-size:13px;
  }
  .header-actions .analysis-tabs > button {
    padding:0 7px;
  }
}

@media (max-width:800px) and (orientation:landscape) {
  main {
    grid-template-columns:minmax(0,1.35fr) minmax(260px,.65fr);
    grid-template-rows:1fr;
  }
  .catalogue {
    border-top:0;
    border-left:1px solid #b9cad6;
    box-shadow:-5px 0 18px #173b5314;
  }
}
