.mobile-only { display:none; }
@media (max-width: 950px) {
  #app { height:100dvh; height:100svh; grid-template-columns:minmax(0,1fr); grid-template-rows:56px minmax(0,1fr) calc(64px + env(safe-area-inset-bottom)); grid-template-areas:'top' 'stage' 'nav'; }
  .mobile-only { display:flex; }
  .topbar { gap:8px; padding:0 10px; min-width:0; position:relative; z-index:40; }
  .brand { flex:1; min-width:0; font-size:.9rem; }
  .brand span { overflow:hidden; text-overflow:ellipsis; }
  .topbar > .seg, .topbar > .search { display:none; }
  .topbar .tools { margin:0; }
  .tools > :not(#btnLanguage) { display:none; }
  .icon-btn, button { min-height:44px; }
  .icon-btn { min-width:44px; }
  #mobileSearchClose { display:none; }
  .menu-open .tools { position:absolute; top:56px; right:8px; padding:8px; width:min(310px,calc(100vw - 16px)); display:flex; flex-wrap:wrap; background:var(--panel-2); border:1px solid var(--line); border-radius:12px; box-shadow:0 12px 30px #0006; }
  .menu-open .tools > :not(#btnHelp) { display:flex; }
  .menu-open .tools .seg { width:100%; justify-content:space-around; }
  .search-open .brand, .search-open #mobileSearch, .search-open #mobileMenu, .search-open .tools { display:none; }
  .search-open .topbar > .search { display:block; flex:1; max-width:none; }
  .search-open #mobileSearchClose { display:flex; align-items:center; justify-content:center; }
  .search input { height:44px; font-size:16px; }
  .search-results { position:fixed; inset:56px 0 0; max-height:none; border-radius:0; padding:10px; }
  .search-results li { min-height:56px; flex-wrap:wrap; padding:10px; }
  .search-results li .n { flex-basis:100%; }
  .stage { min-width:0; min-height:0; position:relative; }
  #viewport { touch-action:none; }
  .stage-hint, .statusbar, .status, .pin, .hover-tip { display:none!important; }
  .mobile-nav { grid-area:nav; background:var(--panel); border-top:1px solid var(--line); padding:4px 6px calc(4px + env(safe-area-inset-bottom)); z-index:50; gap:4px; }
  .mobile-nav button { flex:1; background:none; border:0; border-radius:9px; color:var(--muted); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; font-size:1.2rem; }
  .mobile-nav button span { font-size:.75rem; }
  .mobile-nav button[aria-pressed=true] { background:var(--panel-2); color:var(--film); }
  .sidebar, .inspector { display:none; position:fixed; left:0; right:0; bottom:calc(64px + env(safe-area-inset-bottom)); height:46dvh; max-height:calc(100dvh - 124px - env(safe-area-inset-bottom)); z-index:30; border:1px solid var(--line); border-radius:18px 18px 0 0; box-shadow:0 -10px 32px #0004; background:var(--panel); }
  .panel-sidebar .sidebar { display:flex; }
  .panel-inspector .inspector { display:flex; }
  .inspector { padding:10px 14px; gap:10px; }
  .sheet-controls { justify-content:flex-end; gap:6px; flex-shrink:0; padding:4px 10px; }
  .sheet-controls button { border:0; background:var(--panel-2); color:var(--bone); border-radius:8px; min-width:44px; padding:0 12px; }
  .panel-expanded .sidebar, .panel-expanded .inspector { height:calc(100dvh - 124px - env(safe-area-inset-bottom)); }
  .panel-compact .inspector { height:auto; max-height:235px; }
  .panel-compact .inspector #tagLatin, .panel-compact .inspector #tagId, .panel-compact .inspector #tagNote, .panel-compact .inspector #tagPath, .panel-compact .inspector #wiki, .panel-compact .tag-hole { display:none; }
  .tag { padding:12px; }
  .tag h2 { font-size:1.2rem; }
  .tag-actions { display:flex; gap:8px; }
  .tag-actions button { flex:1; }
  .tabs { flex-shrink:0; }
  .pane { overflow:auto; overscroll-behavior:contain; }
  .layer-list li { min-height:56px; }
  .tree .row { min-height:48px; }
  .tree .label { white-space:normal; text-align:left; }
  .tree .caret, .tree .eye { min-width:44px; flex-shrink:0; }
  .radio-col label { min-height:44px; display:flex; align-items:center; gap:8px; }
  input[type=range] { min-height:44px; }
  .mobile-view { position:absolute; right:10px; top:10px; z-index:5; flex-direction:column; gap:6px; }
  .mobile-view button { width:44px; border:1px solid var(--line); border-radius:10px; background:var(--panel); color:var(--bone); font-size:1.3rem; }
  dialog { max-height:calc(100dvh - 24px); width:calc(100vw - 20px); }
  .dialog-body { padding:16px; overflow-wrap:anywhere; }
  .about-contact { grid-template-columns:1fr; }
}
@media (max-width:950px) and (orientation:landscape) {
 .panel-sidebar .sidebar,.panel-inspector .inspector { left:auto; width: min(48vw,380px); top:56px; bottom:calc(64px + env(safe-area-inset-bottom)); height:auto; max-height:none; border-radius:12px 0 0 12px; }
 .mobile-view { left:10px; right:auto; }
}
@media (max-width:950px) {
 .layer-list .solo { opacity:1; min-width:44px; }
 .brand span { font-size:0; }
 .brand span::after { content:'Anatomy'; font-size:1rem; }
 .sidebar .tabs { display:none; }
 .panel-compact .tag { margin:0; }
 .panel-compact .tag h2 { margin-top:0; }
}
@media (max-width:950px) {
 .sheet-controls { padding:0 6px; gap:4px; min-height:44px; align-items:center; }
 .sheet-controls button { background:transparent; padding:0 8px; }
 #layerAllRow { margin:0 auto 0 4px; min-height:44px; gap:8px; font-size:.9rem; }
 #layerAll { width:20px; height:20px; accent-color:var(--film); }
 .tree .caret { font-size:1.5rem; font-weight:700; color:var(--film); }
 .tree .caret.leaf { visibility:hidden; }
}
@media (max-width:950px) {
 #app { --mobile-top:48px; --mobile-bottom:52px; grid-template-rows:var(--mobile-top) minmax(0,1fr) calc(var(--mobile-bottom) + env(safe-area-inset-bottom)); }
 .topbar { padding:0 8px; gap:2px; }
 .brand span::after { content:'TuTu Anatomy'; font-size:.95rem; }
 .topbar .icon-btn { border:0; background:transparent; padding:0 6px; min-width:44px; height:44px; }
 .mobile-nav { padding-top:0; padding-bottom:env(safe-area-inset-bottom); }
 .mobile-nav button { gap:0; font-size:1.05rem; border-radius:6px; }
 .mobile-nav button span { font-size:.7rem; }
 .sidebar,.inspector { bottom:calc(var(--mobile-bottom) + env(safe-area-inset-bottom)); max-height:calc(100dvh - var(--mobile-top) - var(--mobile-bottom) - env(safe-area-inset-bottom)); }
 .panel-expanded .sidebar,.panel-expanded .inspector { height:calc(100dvh - var(--mobile-top) - var(--mobile-bottom) - env(safe-area-inset-bottom)); }
 .menu-open .tools { top:var(--mobile-top); }
 .search-results { top:var(--mobile-top); }
 .layer-list li { padding:0 8px; cursor:pointer; }
 .layer-list .name { display:flex; align-items:center; align-self:stretch; min-height:56px; gap:6px; cursor:pointer; }
 .layer-list input.toggle { position:relative; }
 .layer-list input.toggle::before { content:''; position:absolute; inset:-14px -6px; }
 #app.distraction-free { grid-template-rows:0 minmax(0,1fr) 0; }
 .distraction-free .topbar,.distraction-free .mobile-nav { display:none; }
 .distraction-free .mobile-view { display:flex; }
}
@media (max-width:950px) and (orientation:landscape) {
 .panel-sidebar .sidebar,.panel-inspector .inspector { top:48px; bottom:calc(52px + env(safe-area-inset-bottom)); }
}
@media (max-width:950px) {
 #mobileZoomIn,#mobileZoomOut { display:none; }
 #mobileSearch,#mobileMenu { display:flex; align-items:center; justify-content:center; font-size:1.7rem; line-height:1; }
 #mobileSearch svg { width:24px; height:24px; flex-shrink:0; }
 .sidebar .sheet-controls .seg { margin:0 auto 0 0; min-width:0; }
 .sidebar .sheet-controls .seg button { padding:0 9px; font-size:.85rem; white-space:nowrap; }
 [data-pane="layers"] > #hiddenNote { margin:4px 16px 8px; font-size:.8rem; }
}
@media (max-width:950px) {
 .sidebar .sheet-controls .seg.full {
   display:inline-flex; flex:0 1 auto; width:auto; margin:0 auto 0 4px;
   padding:3px; border:0; border-radius:9px; background:var(--stage);
 }
 .sidebar .sheet-controls .seg.full button {
   flex:0 0 auto; min-height:30px; height:30px; padding:0 10px;
   border-radius:6px; font-size:.78rem; line-height:1; font-weight:500;
   position:relative;
 }
 .sidebar .sheet-controls .seg.full button::after {
   content:''; position:absolute; inset:-7px 0;
 }
 .sidebar .sheet-controls .seg.full button.on {
   background:var(--panel-2); color:var(--film); box-shadow:0 1px 3px #0003;
 }
}
@media (max-width:950px) {
 #mobileXray { font-size:.72rem; font-weight:600; }
 #mobileXray[aria-pressed=true] { background:var(--film); color:var(--film-ink); border-color:var(--film); }
 .menu-open .tools > #btnXray { display:none; }
 .inspector .tag { background:var(--panel-2); color:var(--bone); border-radius:12px; padding:14px; box-shadow:none; border:1px solid var(--line); }
 .inspector .tag-hole { display:none; }
 .inspector .tag h2 { font-family:var(--sans); font-size:1.1rem; line-height:1.35; }
 .inspector .tag-id,.inspector .tag-latin,.inspector .tag-note,.inspector .tag-cat #tagCount,.inspector .tag #tagEnglish { color:var(--muted); }
 .inspector .tag-path { border-top:1px solid var(--line); }
 .inspector .tag-path button,.inspector .tag-path li:last-child button { color:var(--film); }
 .inspector .tag-actions { gap:8px; margin-top:12px; }
 .inspector .tag-actions button { border:1px solid var(--line); background:var(--stage); color:var(--bone); border-radius:8px; min-height:44px; padding:6px; }
 .inspector .tag-actions #actIsolate[aria-pressed=true] { background:var(--film); color:var(--film-ink); border-color:var(--film); }
 .inspector .wiki { padding:2px 4px 12px; font-size:.9rem; line-height:1.6; }
}
/* Canvas tool rail replaces the mobile footer. */
@media (max-width:950px) {
 #app { --mobile-bottom:0px; grid-template-rows:var(--mobile-top) minmax(0,1fr); grid-template-areas:'top' 'stage'; }
 #app.distraction-free { grid-template-rows:0 minmax(0,1fr); }
 .sidebar,.inspector { bottom:env(safe-area-inset-bottom); }
 .mobile-view { max-height:calc(100% - 20px); overflow-y:auto; scrollbar-width:none; }
 .mobile-view button { flex-shrink:0; }
 .mobile-view button[aria-pressed=true] { background:var(--film); color:var(--film-ink); border-color:var(--film); }
 .panel-sections .sidebar {
   left:auto; right:64px; top:calc(var(--mobile-top) + 6px); bottom:auto;
   width:min(270px, calc(100vw - 76px)); height:auto; max-height:calc(100dvh - 64px);
   border-radius:14px; box-shadow:0 8px 28px #0005; overflow:auto;
 }
 .panel-sections .sidebar .sheet-controls { min-height:40px; padding:0 6px 0 14px; }
 .panel-sections #sectionTitle { display:block; margin-right:auto; font-size:.85rem; color:var(--bone); }
 .panel-sections .sidebar [data-sheet-expand] { display:none; }
 .panel-sections [data-pane="sections"] { flex:none; padding:0 12px 10px; gap:4px; overflow:visible; }
 .panel-sections [data-pane="sections"] > .note { display:none; }
 .panel-sections .radio-col { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:3px; }
 .panel-sections .radio-col label { min-height:40px; padding:0 2px; justify-content:center; gap:0; border:1px solid var(--line); border-radius:8px; font-size:.74rem; cursor:pointer; }
 .panel-sections .radio-col label:has(input:checked) { border-color:var(--film); background:var(--panel-2); color:var(--film); }
 .panel-sections input[type=radio] { position:absolute; opacity:0; width:1px; height:1px; }
 .panel-sections .radio-col label:has(input:focus-visible) { outline:2px solid var(--film); outline-offset:2px; }
 .panel-sections .slider-label { margin:6px 0 0; font-size:.8rem; }
 .panel-sections #planePos { width:100%; margin:0; accent-color:var(--film); }
 .panel-sections .check { min-height:40px; font-size:.8rem; }
 .distraction-free.panel-sections .sidebar { top:6px; }
}
@media (max-width:950px) and (orientation:landscape) {
 .panel-sidebar:not(.panel-sections) .sidebar,.panel-inspector .inspector { bottom:env(safe-area-inset-bottom); }
 .panel-sections .sidebar { left:64px; right:auto; top:58px; max-height:calc(100dvh - 66px); }
 .distraction-free.panel-sections .sidebar { top:8px; max-height:calc(100dvh - 16px); }
}
#sectionTitle { display:none; }
@media (max-width:950px) {
 .panel-sections #sectionTitle { display:block; }
 #mobileXray { padding:0; white-space:nowrap; }
}
@media (max-width:950px) {
 .menu-open .tools > :not([data-mobile-pane="quiz"]):not(#btnReset):not(#btnData):not(#btnAbout) { display:none; }
 .menu-open .tools { width:200px; display:grid; grid-template-columns:1fr; gap:4px; }
 .menu-open .tools > button { width:100%; justify-content:flex-start; text-align:left; }
 #positionPopup { position:absolute; right:64px; top:10px; z-index:35; width:min(250px,calc(100% - 76px)); padding:6px; gap:4px; flex-wrap:wrap; background:var(--panel); border:1px solid var(--line); border-radius:12px; box-shadow:0 8px 28px #0005; }
 #positionPopup[hidden] { display:none; }
 #positionPopup button { flex:1 0 40%; display:flex; align-items:center; justify-content:center; gap:8px; background:var(--panel-2); border:0; border-radius:8px; color:var(--bone); font-size:1.15rem; }
 #positionPopup button span { font-size:.8rem; }
 #positionPopup #resetZoom { flex-basis:100%; }
}
@media (max-width:950px) and (orientation:landscape) {
 #positionPopup { left:64px; right:auto; }
}
@media (max-width:950px) {
 .panel-quiz .inspector { left:10px; right:auto; top:54px; bottom:auto; width:min(310px,calc(100vw - 74px)); height:auto; max-height:calc(100dvh - 68px); border-radius:14px; padding:6px 12px 12px; gap:4px; overflow:auto; }
 .panel-quiz #mobileDetails { pointer-events:none; font-size:.85rem; padding:0; margin-right:auto; }
 .panel-quiz .sheet-controls { padding:0; min-height:36px; }
 .panel-quiz #quiz { padding:0; }
 .panel-quiz #quizSetup h2 { display:none; }
 .panel-quiz #quizSetup > .note { font-size:.75rem; line-height:1.4; margin:0 0 8px; }
 .panel-quiz .radio-col { gap:4px; }
 .panel-quiz .radio-col label { min-height:40px; font-size:.8rem; }
 .panel-quiz #quiz h2 { font-size:.95rem; line-height:1.35; margin:6px 0; }
 .panel-quiz #quiz p { margin:6px 0; }
 .panel-quiz .quiz-options { gap:4px; }
 .panel-quiz .quiz-options button { padding:6px 8px; font-size:.8rem; min-height:40px; }
 .panel-quiz .quiz-row { gap:4px; }
 .panel-quiz .quiz-row button { padding:6px 8px; font-size:.8rem; }
 .panel-quiz .quiz-progress,.panel-quiz .quiz-feedback { font-size:.8rem; }
 .distraction-free.panel-quiz .inspector { top:6px; }
}
@media (max-width:950px) and (orientation:landscape) {
 .panel-quiz .inspector { left:auto; right:10px; top:54px; bottom:auto; }
}
@media (max-width:950px) {
 .panel-quiz .inspector { width:min(280px,calc(100vw - 74px)); padding:0 10px 8px; gap:0; }
 .panel-quiz #mobileDetails { pointer-events:auto; touch-action:none; cursor:grab; user-select:none; flex:1; text-align:left; min-height:40px; }
 .panel-quiz #mobileDetails:active { cursor:grabbing; }
 .panel-quiz #quizSetup { display:grid; grid-template-columns:1fr auto; gap:4px 8px; align-items:center; }
 .panel-quiz #quizSetup > .note,.panel-quiz #quizSetup h2 { display:none; }
 .panel-quiz #quizSetup .radio-col,.panel-quiz #quizStart,.panel-quiz #quizSetupMsg { grid-column:1 / -1; }
 .panel-quiz #quizSetupMsg:empty { display:none; }
 .panel-quiz #quizSetup .radio-col { flex-direction:row; gap:6px; }
 .panel-quiz #quizSetup .radio-col label { flex:1; font-size:.75rem; line-height:1.3; }
 .panel-quiz #quizSetup .slider-label { margin:0; font-size:.8rem; }
 .panel-quiz #qcount { width:70px; min-height:36px; padding:4px 8px; }
 .panel-quiz #quizStart,.panel-quiz #quizAgain { margin:4px 0 0; min-height:40px; padding:6px 10px; }
 .panel-quiz #quiz .quiz-progress { margin:0 0 4px; }
 .panel-quiz #quiz .quiz-feedback:empty { display:none; }
 .panel-quiz .quiz-options { display:grid; grid-template-columns:1fr 1fr; }
 .panel-quiz .quiz-options button { overflow-wrap:anywhere; }
 .panel-quiz #quizDone .missed { max-height:110px; overflow:auto; margin:4px 0; }
}
@media (max-width:950px) {
 [data-pane="layers"] > #hiddenNote { margin-bottom:2px; }
 [data-pane="layers"] > #btnShowHidden { align-self:flex-start; margin:0 16px 6px; min-height:36px; padding:4px 0; text-align:left; color:var(--film); }
}
